@gjsify/example-dom-excalibur-jelly-jumper 0.4.30 → 0.4.31
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/browser.js +2 -2
- package/dist/gjs.js +5 -5
- package/package.json +7 -7
package/dist/gjs.js
CHANGED
|
@@ -2,11 +2,11 @@ if(globalThis.__gjsifyBundleUrl??=import.meta.url,globalThis.process===void 0){l
|
|
|
2
2
|
`)}else if(gt){let W=` `.repeat(this._groupDepth*this._groupIndentation)+_formatArgs(...R);e===`stderr`?printerr(W):print(W)}else{let W=globalThis.console;e===`stderr`?W.error(...R):W.log(...R)}}log(...e){this._write(`stdout`,...e)}info(...e){this._write(`stdout`,...e)}debug(...e){this._write(`stdout`,...e)}warn(...e){this._write(`stderr`,...e)}error(...e){this._write(`stderr`,...e)}dir(e,R){this._write(`stdout`,e)}dirxml(...e){this.log(...e)}assert(e,...R){e||this.error(`Assertion failed:`,...R)}clear(){this._stdout?this._stdout.write(`\x1Bc`):gt?print(`\x1Bc`):globalThis.console.clear()}count(e=`default`){let R=(this._counters.get(e)||0)+1;this._counters.set(e,R),this.log(`${e}: ${R}`)}countReset(e=`default`){this._counters.delete(e)}group(...e){e.length>0&&this.log(...e),this._groupDepth++}groupCollapsed(...e){this.group(...e)}groupEnd(){this._groupDepth>0&&this._groupDepth--}table(e,R){this._stdout?this._write(`stdout`,e):gt?print(JSON.stringify(e,null,2)):globalThis.console.table(e,R)}time(e=`default`){this._timers.set(e,Date.now())}timeEnd(e=`default`){let R=this._timers.get(e);R===void 0?this.warn(`Warning: No such label '${e}' for console.timeEnd()`):(this.log(`${e}: ${Date.now()-R}ms`),this._timers.delete(e))}timeLog(e=`default`,...R){let W=this._timers.get(e);W===void 0?this.warn(`Warning: No such label '${e}' for console.timeLog()`):this.log(`${e}: ${Date.now()-W}ms`,...R)}trace(...e){let R=Error().stack?.split(`
|
|
3
3
|
`).slice(1).join(`
|
|
4
4
|
`)||``;this._write(`stderr`,`Trace:`,...e,`
|
|
5
|
-
`+R)}profile(e){}profileEnd(e){}timeStamp(e){}},_t=new Console,log=(...e)=>_t.log(...e),info=(...e)=>_t.info(...e),debug=(...e)=>_t.debug(...e),warn=(...e)=>_t.warn(...e),error=(...e)=>_t.error(...e),dir=(e,R)=>_t.dir(e,R),dirxml=(...e)=>_t.dirxml(...e),table=(e,R)=>_t.table(e,R),clear=()=>_t.clear(),vt=__name$1((e,...R)=>_t.assert(e,...R),`assert`),trace=(...e)=>_t.trace(...e),time=e=>_t.time(e),timeEnd=e=>_t.timeEnd(e),timeLog=(e,...R)=>_t.timeLog(e,...R),count=e=>_t.count(e),countReset=e=>_t.countReset(e),group=(...e)=>_t.group(...e),groupCollapsed=(...e)=>_t.groupCollapsed(...e),groupEnd=()=>_t.groupEnd(),profile=e=>{},profileEnd=e=>{},timeStamp=e=>{}}),bt,xt=__esmMin(()=>{yt(),bt={log,info,debug,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace,assert:vt,clear,count,countReset,group,groupCollapsed,groupEnd,profile,profileEnd,timeStamp}}),warnNotImplemented,St=__esmMin(()=>{xt(),warnNotImplemented=e=>{let R=e?`Not implemented: ${e}`:`Not implemented`;return bt.warn(R),R}}),Ct,wt=__esmMin(()=>{Ct=__name$1(e=>{Promise.resolve().then(e)},`queueMicrotask`)});function drainOnce(e){let R=Math.min(64,Tt.length);for(let W=0;W<R;W++){let R=Tt.shift();try{R()}catch(R){try{e.log_default_handler(`gjsify-nextTick`,e.LogLevelFlags.LEVEL_WARNING,String(R?.stack||R),null)}catch{}}}Tt.length>0?e.timeout_add(e.PRIORITY_DEFAULT,1,()=>(drainOnce(e),!1)):Et=!1}function tryGLibTimeout(e){let R=globalThis.imports?.gi?.GLib;return R?.timeout_add?(Tt.push(e),Et||(Et=!0,R.timeout_add(R.PRIORITY_DEFAULT,0,()=>(drainOnce(R),!1))),!0):!1}var Tt,Et,nextTick,Ot=__esmMin(()=>{Tt=[],Et=!1,nextTick=(e,...R)=>{let W=R.length>0?()=>e(...R):e;if(!tryGLibTimeout(W)){if(typeof globalThis.process?.nextTick==`function`){globalThis.process.nextTick(e,...R);return}if(typeof queueMicrotask==`function`){queueMicrotask(W);return}Promise.resolve().then(W)}}}),jt,Mt=__esmMin(()=>{$e(),st(),{File:jt}=at});function classOf(e){return Nt.call(e).slice(8,-1)}function throwDataCloneError(e){let R=globalThis.DOMException;if(typeof R==`function`)throw new R(e,`DataCloneError`);let W=Error(e);throw W.name=`DataCloneError`,W}function internalClone(e,R,W){if(e==null)return e;let Y=typeof e;if(Y===`boolean`||Y===`number`||Y===`string`||Y===`bigint`)return e;Y===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),Y===`function`&&throwDataCloneError(`Function cannot be cloned`);let X=e;if(R.has(X))return R.get(X);let ie=classOf(X);if(ie===`Date`)return new Date(X.getTime());if(ie===`RegExp`)return new RegExp(X.source,X.flags);if(ie===`Boolean`||ie===`Number`||ie===`String`)return Object(X.valueOf());if(ie===`BigInt`)return Object(BigInt.prototype.valueOf.call(X));if(X instanceof Error){let e=X,Y=e.constructor?.name,ie=new(Y&&Pt[Y]||Pt[e.name]||Error)(e.message);return ie.name=e.name,`cause`in e&&Object.defineProperty(ie,"cause",{value:internalClone(e.cause,R,W),writable:!0,enumerable:!1,configurable:!0}),ie}if(ie===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let R=X;return new e(R.message,R.name)}}if(ie===`ArrayBuffer`){let e=X;if(W&&W.transferred.has(e)){let Y=W.transferred.get(e);return R.set(X,Y),Y}(e.detached===!0||e.byteLength===0&&e.detached)&&throwDataCloneError(`ArrayBuffer is detached and cannot be cloned`);let Y=e.slice(0);return R.set(X,Y),Y}if(ie===`SharedArrayBuffer`||X&&typeof X==`object`&&X.constructor?.name===`SharedBuffer`)return X;if(ie===`DataView`){let e=X,Y=W?.viewSnapshots.get(X),ie=internalClone(e.buffer,R,W),ae=Y?Y.byteOffset:e.byteOffset,le=Y?Y.byteLength:e.byteLength,_e=new DataView(ie,ae,le);return R.set(X,_e),_e}if(Ft.has(ie)){let e=X,Y=W?.viewSnapshots.get(X),ie=internalClone(e.buffer,R,W),ae=e.constructor,le=new ae(ie,Y?Y.byteOffset:e.byteOffset,Y?Y.length:e.length);return R.set(X,le),le}if(ie===`Map`){let e=new Map;R.set(X,e);for(let[Y,ie]of X)e.set(internalClone(Y,R,W),internalClone(ie,R,W));return e}if(ie===`Set`){let e=new Set;R.set(X,e);for(let Y of X)e.add(internalClone(Y,R,W));return e}{let e=globalThis,R=e.Blob,W=e.File;if(typeof W==`function`&&X instanceof W){let e=X;return new W([X],e.name,{type:e.type,lastModified:e.lastModified})}if(typeof R==`function`&&X instanceof R)return new R([X],{type:X.type})}if(X instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),X instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),X instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&X instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),ie===`Array`){let e=X,Y=[];R.set(X,Y);for(let X=0;X<e.length;X++)X in e&&(Y[X]=internalClone(e[X],R,W));return Y}if(ie===`Object`||typeof X==`object`){let e={};R.set(X,e);for(let Y of Object.keys(X))e[Y]=internalClone(X[Y],R,W);return e}throwDataCloneError(`${ie} cannot be cloned`)}function structuredClone$1(e,R){let W=R?.transfer;if(!W||W.length===0)return internalClone(e,new Map);let Y=new Set;for(let e of W)if(classOf(e)===`ArrayBuffer`){let R=e;R.detached===!0&&throwDataCloneError(`ArrayBuffer in transfer list is detached`),Y.add(R)}let X=new Map;Y.size>0&&snapshotViewsBackedByTransferredBuffers(e,Y,X,new Set);let ie=new Map;for(let e of Y){let R=e;typeof R.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),ie.set(e,R.transfer())}return internalClone(e,new Map,{transferred:ie,viewSnapshots:X})}function snapshotViewsBackedByTransferredBuffers(e,R,W,Y){if(typeof e!=`object`||!e)return;let X=e;if(Y.has(X))return;Y.add(X);let ie=classOf(X);if(ie===`DataView`){let e=X;R.has(e.buffer)&&W.set(X,{byteOffset:e.byteOffset,length:0,byteLength:e.byteLength});return}if(Ft.has(ie)){let e=X;R.has(e.buffer)&&W.set(X,{byteOffset:e.byteOffset,length:e.length,byteLength:e.byteLength});return}if(Array.isArray(X)){for(let e=0;e<X.length;e++)e in X&&snapshotViewsBackedByTransferredBuffers(X[e],R,W,Y);return}if(ie===`Map`){for(let[e,ie]of X)snapshotViewsBackedByTransferredBuffers(e,R,W,Y),snapshotViewsBackedByTransferredBuffers(ie,R,W,Y);return}if(ie===`Set`){for(let e of X)snapshotViewsBackedByTransferredBuffers(e,R,W,Y);return}if(ie===`Object`)for(let e of Object.keys(X))snapshotViewsBackedByTransferredBuffers(X[e],R,W,Y)}var Nt,Pt,Ft,Lt=__esmMin(()=>{({toString:Nt}=Object.prototype),Pt={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},Ft=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]),__name$1(structuredClone$1,`structuredClone`)});function ensureMainLoop(){let e=globalThis.imports;if(!e)return;if(Rt)return zt;let R=e.gi?.GLib;if(R){if(zt=new R.MainLoop(null,!1),Rt=!0,R.main_depth()===0)try{zt.runAsync()}catch{}return zt}}function quitMainLoop(){zt&&=(zt.quit(),Rt=!1,null)}var Rt,zt,Vt=__esmMin(()=>{Rt=!1,zt=null}),Ht=__esmMin(()=>{Ye(),et(),tt(),nt(),ut(),mt(),ht(),St(),wt(),Ot(),Mt(),Lt(),Vt()});Je(),Ht(),registerGlobal(`Blob`,Ke),registerGlobal(`File`,qe);var Ut=Object.defineProperty,__exportAll=(e,R)=>{let W={};for(var Y in e)Ut(W,Y,{get:e[Y],enumerable:!0});return R||Ut(W,Symbol.toStringTag,{value:`Module`}),W};__exportAll({attributes:()=>$t,childNodesList:()=>Kt,elementChildren:()=>qt,isConnected:()=>Jt,localName:()=>Xt,name:()=>An,namespaceURI:()=>Zt,nodeType:()=>Wt,ownerElement:()=>rr,parentNode:()=>Gt,prefix:()=>Qt,propertyEventListeners:()=>on,tagName:()=>Yt,value:()=>tr});const Wt=Symbol(`nodeType`),Gt=Symbol(`parentNode`),Kt=Symbol(`childNodesList`),qt=Symbol(`elementChildren`),Jt=Symbol(`isConnected`),Yt=Symbol(`tagName`),Xt=Symbol(`localName`),Zt=Symbol(`namespaceURI`),Qt=Symbol(`prefix`),$t=Symbol(`attributes`),on=Symbol(`propertyEventListeners`),An=Symbol(`name`),tr=Symbol(`value`),rr=Symbol(`ownerElement`),ir={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11};var NodeList=class{constructor(e){this._items=e}get length(){return this._items.length}item(e){return this._items[e]??null}forEach(e,R){for(let W=0;W<this._items.length;W++)e.call(R,this._items[W],W,this)}entries(){return this._items.entries()}keys(){return this._items.keys()}values(){return this._items.values()}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NodeList`}};const or={IndexSizeError:1,HierarchyRequestError:3,WrongDocumentError:4,InvalidCharacterError:5,NoModificationAllowedError:7,NotFoundError:8,NotSupportedError:9,InUseAttributeError:10,InvalidStateError:11,SyntaxError:12,InvalidModificationError:13,NamespaceError:14,InvalidAccessError:15,TypeMismatchError:17,SecurityError:18,NetworkError:19,AbortError:20,URLMismatchError:21,QuotaExceededError:22,TimeoutError:23,InvalidNodeTypeError:24,DataCloneError:25};var _DOMExceptionPolyfill=class extends Error{code;constructor(e,R){super(e),this.name=R||`Error`,this.code=Object.hasOwn(or,this.name)?or[this.name]:0}};const lr=globalThis.DOMException===void 0?_DOMExceptionPolyfill:globalThis.DOMException;xt();const hr=Symbol(`type`),gr=Symbol(`bubbles`),vr=Symbol(`cancelable`),Sr=Symbol(`composed`),Tr=Symbol(`target`),Er=Symbol(`currentTarget`),kr=Symbol(`eventPhase`),jr=Symbol(`defaultPrevented`),Mr=Symbol(`isTrusted`),Nr=Symbol(`timeStamp`),Fr=Symbol(`stop`),Br=Symbol(`immediateStop`),Vr=Symbol(`dispatching`),Hr=Symbol(`inPassiveListener`);var Event$1=class{static{__name$1(this,`Event`)}[hr];[gr];[vr];[Sr];[Tr]=null;[Er]=null;[kr]=0;[jr]=!1;[Mr]=!1;[Nr];[Fr]=!1;[Br]=!1;[Vr]=!1;[Hr]=!1;get type(){return this[hr]}get bubbles(){return this[gr]}get cancelable(){return this[vr]}get composed(){return this[Sr]}get target(){return this[Tr]}get currentTarget(){return this[Er]}get eventPhase(){return this[kr]}get defaultPrevented(){return this[jr]}get timeStamp(){return this[Nr]}get cancelBubble(){return this[Fr]}set cancelBubble(e){e&&this.stopPropagation()}get returnValue(){return!this[jr]}set returnValue(e){e||this.preventDefault()}get srcElement(){return this[Tr]}static NONE=0;static CAPTURING_PHASE=1;static AT_TARGET=2;static BUBBLING_PHASE=3;get[Symbol.toStringTag](){return`Event`}constructor(e,R){this[hr]=e,this[gr]=R?.bubbles??!1,this[vr]=R?.cancelable??!1,this[Sr]=R?.composed??!1,this[Nr]=Date.now(),Object.defineProperty(this,"isTrusted",{get:()=>this[Mr],enumerable:!0,configurable:!1})}composedPath(){return this[Er]?[this[Er]]:[]}preventDefault(){this[vr]&&!this[Hr]&&(this[jr]=!0)}stopPropagation(){this[Fr]=!0}stopImmediatePropagation(){this[Fr]=!0,this[Br]=!0}},CustomEvent=class extends Event$1{detail;constructor(e,R){super(e,R),this.detail=R?.detail}},MessageEvent=class extends Event$1{data;origin;lastEventId;source;ports;constructor(e,R){super(e,R),this.data=R?.data??null,this.origin=R?.origin??``,this.lastEventId=R?.lastEventId??``,this.source=R?.source??null,this.ports=R?.ports??[]}get[Symbol.toStringTag](){return`MessageEvent`}},ErrorEvent=class extends Event$1{message;filename;lineno;colno;error;constructor(e,R){super(e,R),this.message=R?.message??``,this.filename=R?.filename??``,this.lineno=R?.lineno??0,this.colno=R?.colno??0,this.error=R?.error??null}get[Symbol.toStringTag](){return`ErrorEvent`}},CloseEvent=class extends Event$1{code;reason;wasClean;constructor(e,R){super(e,R),this.code=R?.code??0,this.reason=R?.reason??``,this.wasClean=R?.wasClean??!1}get[Symbol.toStringTag](){return`CloseEvent`}},ProgressEvent$1=class extends Event$1{static{__name$1(this,`ProgressEvent`)}lengthComputable;loaded;total;constructor(e,R){super(e,R),this.lengthComputable=R?.lengthComputable??!1,this.loaded=R?.loaded??0,this.total=R?.total??0}get[Symbol.toStringTag](){return`ProgressEvent`}},EventTarget$1=class{static{__name$1(this,`EventTarget`)}_listeners=new Map;get[Symbol.toStringTag](){return`EventTarget`}addEventListener(e,R,W){if(R===null)return;let Y=typeof W==`boolean`?W:W?.capture??!1,X=typeof W==`object`?W?.once??!1:!1,ie=typeof W==`object`?W?.passive??!1:!1,ae=this._listeners.get(e);ae||(ae=[],this._listeners.set(e,ae));for(let e of ae)if(e.listener===R&&e.capture===Y)return;let le={listener:R,capture:Y,once:X,passive:ie,removed:!1};ae.push(le),typeof W==`object`&&W?.signal&&W.signal.addEventListener(`abort`,()=>{this.removeEventListener(e,R,{capture:Y})},{once:!0})}removeEventListener(e,R,W){if(R===null)return;let Y=typeof W==`boolean`?W:W?.capture??!1,X=this._listeners.get(e);if(!X)return;let ie=X.findIndex(e=>e.listener===R&&e.capture===Y);ie!==-1&&(X[ie].removed=!0,X.splice(ie,1),X.length===0&&this._listeners.delete(e))}dispatchEvent(e){let R=e;if(R[Vr])throw new lr(`The event is already being dispatched.`,`InvalidStateError`);R[Vr]=!0,R[Tr]=this,R[Er]=this,R[kr]=Event$1.AT_TARGET;let W=this._listeners.get(e.type);if(W){let Y=[...W];for(let W of Y)if(!W.removed){if(R[Br]||R[Fr])break;W.once&&this.removeEventListener(e.type,W.listener,{capture:W.capture});try{W.passive&&(R[Hr]=!0),typeof W.listener==`function`?W.listener.call(this,e):typeof W.listener.handleEvent==`function`&&W.listener.handleEvent.call(W.listener,e)}catch(e){bt.error(e)}finally{R[Hr]=!1}}}return R[kr]=Event$1.NONE,R[Er]=null,R[Vr]=!1,!e.defaultPrevented}};for(let[e,R]of[[`NONE`,0],[`CAPTURING_PHASE`,1],[`AT_TARGET`,2],[`BUBBLING_PHASE`,3]])Object.defineProperty(Event$1.prototype,e,{value:R,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Event$1,e,{value:R,writable:!1,enumerable:!0,configurable:!1});var UIEvent=class extends Event$1{detail;view;constructor(e,R){super(e,R),this.detail=R?.detail??0,this.view=null}get[Symbol.toStringTag](){return`UIEvent`}},MouseEvent=class extends UIEvent{altKey;button;buttons;clientX;clientY;ctrlKey;metaKey;movementX;movementY;offsetX;offsetY;screenX;screenY;shiftKey;relatedTarget;get pageX(){return this.clientX}get pageY(){return this.clientY}get x(){return this.clientX}get y(){return this.clientY}constructor(e,R){super(e,R),this.altKey=R?.altKey??!1,this.button=R?.button??0,this.buttons=R?.buttons??0,this.clientX=R?.clientX??0,this.clientY=R?.clientY??0,this.ctrlKey=R?.ctrlKey??!1,this.metaKey=R?.metaKey??!1,this.movementX=R?.movementX??0,this.movementY=R?.movementY??0,this.offsetX=R?.offsetX??0,this.offsetY=R?.offsetY??0,this.screenX=R?.screenX??0,this.screenY=R?.screenY??0,this.shiftKey=R?.shiftKey??!1,this.relatedTarget=R?.relatedTarget??null}getModifierState(e){switch(e){case`Alt`:return this.altKey;case`Control`:return this.ctrlKey;case`Meta`:return this.metaKey;case`Shift`:return this.shiftKey;default:return!1}}get[Symbol.toStringTag](){return`MouseEvent`}},PointerEvent$1=class extends MouseEvent{static{__name$1(this,`PointerEvent`)}pointerId;width;height;pressure;tangentialPressure;tiltX;tiltY;twist;altitudeAngle;azimuthAngle;pointerType;isPrimary;constructor(e,R){super(e,R),this.pointerId=R?.pointerId??0,this.width=R?.width??1,this.height=R?.height??1,this.pressure=R?.pressure??0,this.tangentialPressure=R?.tangentialPressure??0,this.tiltX=R?.tiltX??0,this.tiltY=R?.tiltY??0,this.twist=R?.twist??0,this.altitudeAngle=R?.altitudeAngle??Math.PI/2,this.azimuthAngle=R?.azimuthAngle??0,this.pointerType=R?.pointerType??``,this.isPrimary=R?.isPrimary??!1}getCoalescedEvents(){return[]}getPredictedEvents(){return[]}get[Symbol.toStringTag](){return`PointerEvent`}},KeyboardEvent$1=class extends UIEvent{static{__name$1(this,`KeyboardEvent`)}altKey;code;ctrlKey;isComposing;key;location;metaKey;repeat;shiftKey;keyCode;which;static DOM_KEY_LOCATION_STANDARD=0;static DOM_KEY_LOCATION_LEFT=1;static DOM_KEY_LOCATION_RIGHT=2;static DOM_KEY_LOCATION_NUMPAD=3;constructor(e,R){super(e,R),this.altKey=R?.altKey??!1,this.code=R?.code??``,this.ctrlKey=R?.ctrlKey??!1,this.isComposing=R?.isComposing??!1,this.key=R?.key??``,this.location=R?.location??0,this.metaKey=R?.metaKey??!1,this.repeat=R?.repeat??!1,this.shiftKey=R?.shiftKey??!1,this.keyCode=R?.keyCode??0,this.which=R?.which??0}getModifierState(e){switch(e){case`Alt`:return this.altKey;case`Control`:return this.ctrlKey;case`Meta`:return this.metaKey;case`Shift`:return this.shiftKey;default:return!1}}get[Symbol.toStringTag](){return`KeyboardEvent`}},WheelEvent$1=class extends MouseEvent{static{__name$1(this,`WheelEvent`)}deltaX;deltaY;deltaZ;deltaMode;static DOM_DELTA_PIXEL=0;static DOM_DELTA_LINE=1;static DOM_DELTA_PAGE=2;constructor(e,R){super(e,R),this.deltaX=R?.deltaX??0,this.deltaY=R?.deltaY??0,this.deltaZ=R?.deltaZ??0,this.deltaMode=R?.deltaMode??0}get[Symbol.toStringTag](){return`WheelEvent`}},FocusEvent=class extends UIEvent{relatedTarget;constructor(e,R){super(e,R),this.relatedTarget=R?.relatedTarget??null}get[Symbol.toStringTag](){return`FocusEvent`}};let Ur,Zr,$r,ei,ti;var ni=class Node extends EventTarget$1{constructor(...e){super(...e),this.ELEMENT_NODE=ir.ELEMENT_NODE,this.ATTRIBUTE_NODE=ir.ATTRIBUTE_NODE,this.TEXT_NODE=ir.TEXT_NODE,this.CDATA_SECTION_NODE=ir.CDATA_SECTION_NODE,this.PROCESSING_INSTRUCTION_NODE=ir.PROCESSING_INSTRUCTION_NODE,this.COMMENT_NODE=ir.COMMENT_NODE,this.DOCUMENT_NODE=ir.DOCUMENT_NODE,this.DOCUMENT_TYPE_NODE=ir.DOCUMENT_TYPE_NODE,this.DOCUMENT_FRAGMENT_NODE=ir.DOCUMENT_FRAGMENT_NODE,this[Ur]=ir.ELEMENT_NODE,this[Zr]=null,this[$r]=[],this[ei]=[],this[ti]=!1}static{this.ELEMENT_NODE=ir.ELEMENT_NODE}static{this.ATTRIBUTE_NODE=ir.ATTRIBUTE_NODE}static{this.TEXT_NODE=ir.TEXT_NODE}static{this.CDATA_SECTION_NODE=ir.CDATA_SECTION_NODE}static{this.PROCESSING_INSTRUCTION_NODE=ir.PROCESSING_INSTRUCTION_NODE}static{this.COMMENT_NODE=ir.COMMENT_NODE}static{this.DOCUMENT_NODE=ir.DOCUMENT_NODE}static{this.DOCUMENT_TYPE_NODE=ir.DOCUMENT_TYPE_NODE}static{this.DOCUMENT_FRAGMENT_NODE=ir.DOCUMENT_FRAGMENT_NODE}static{this.DOCUMENT_POSITION_DISCONNECTED=1}static{this.DOCUMENT_POSITION_PRECEDING=2}static{this.DOCUMENT_POSITION_FOLLOWING=4}static{this.DOCUMENT_POSITION_CONTAINS=8}static{this.DOCUMENT_POSITION_CONTAINED_BY=16}static{this.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32}get nodeType(){return this[Wt]}get nodeName(){return``}get parentNode(){return this[Gt]}get parentElement(){let e=this[Gt];return e&&e[Wt]===ir.ELEMENT_NODE?e:null}get childNodes(){return new NodeList(this[Kt])}get firstChild(){return this[Kt][0]??null}get lastChild(){let e=this[Kt];return e[e.length-1]??null}get previousSibling(){let e=this[Gt];if(!e)return null;let R=e[Kt],W=R.indexOf(this);return W>0?R[W-1]:null}get nextSibling(){let e=this[Gt];if(!e)return null;let R=e[Kt],W=R.indexOf(this);return W!==-1&&W<R.length-1?R[W+1]:null}get textContent(){return null}set textContent(e){}get nodeValue(){return null}set nodeValue(e){}get ownerDocument(){let e=this;for(;e[Gt];)e=e[Gt];let R=globalThis.document;return e===R?R:null}get isConnected(){return this[Jt]}hasChildNodes(){return this[Kt].length>0}contains(e){if(e===null)return!1;if(e===this)return!0;let R=e;for(;R;){if(R===this)return!0;R=R[Gt]}return!1}getRootNode(){let e=this;for(;e[Gt];)e=e[Gt];return e}appendChild(e){return e[Gt]&&e[Gt].removeChild(e),e[Gt]=this,this[Kt].push(e),e[Wt]===ir.ELEMENT_NODE&&this[qt].push(e),e}removeChild(e){let R=this[Kt],W=R.indexOf(e);if(W===-1)throw new DOMException(`Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.`,`NotFoundError`);if(R.splice(W,1),e[Gt]=null,e[Wt]===ir.ELEMENT_NODE){let R=this[qt].indexOf(e);R!==-1&&this[qt].splice(R,1)}return e}insertBefore(e,R){if(R===null)return this.appendChild(e);let W=this[Kt],Y=W.indexOf(R);if(Y===-1)throw new DOMException(`Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`,`NotFoundError`);if(e[Gt]&&e[Gt].removeChild(e),e[Gt]=this,W.splice(Y,0,e),e[Wt]===ir.ELEMENT_NODE){let R=this[qt],X=R.length;for(let ie=Y;ie<W.length;ie++)if(W[ie][Wt]===ir.ELEMENT_NODE&&W[ie]!==e){X=R.indexOf(W[ie]);break}R.splice(X,0,e)}return e}replaceChild(e,R){return this.insertBefore(e,R),this.removeChild(R),R}cloneNode(e=!1){let R=new this.constructor;if(R[Wt]=this[Wt],e)for(let e of this[Kt])R.appendChild(e.cloneNode(!0));return R}dispatchEvent(e){let R=super.dispatchEvent(e);if(e.bubbles&&!e.cancelBubble){let R=this[Gt];for(;R&&(Object.getPrototypeOf(Node.prototype).dispatchEvent.call(R,e),!e.cancelBubble);)R=R[Gt]}return R}get[(Ur=Wt,Zr=Gt,$r=Kt,ei=qt,ti=Jt,Symbol.toStringTag)](){return`Node`}};const ii={html:`http://www.w3.org/1999/xhtml`,svg:`http://www.w3.org/2000/svg`,mathML:`http://www.w3.org/1998/Math/MathML`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};var Attr=class{constructor(e,R,W=null,Y=null,X=null){this.specified=!0,this[An]=e,this[tr]=R,this[rr]=X,this.namespaceURI=W,this.prefix=Y;let ie=e.indexOf(`:`);this.localName=ie===-1?e:e.slice(ie+1)}get name(){return this[An]}get value(){return this[tr]}set value(e){this[tr]=e}get ownerElement(){return this[rr]}get[Symbol.toStringTag](){return`Attr`}},NamedNodeMap=class{constructor(e){this._items=[],this._ownerElement=e}get length(){return this._items.length}item(e){return this._items[e]??null}getNamedItem(e){return this._findByName(e)}getNamedItemNS(e,R){let W=e===``?null:e;for(let e of this._items)if(e.namespaceURI===W&&e.localName===R)return e;return null}setNamedItem(e){return this._setAttr(e)}setNamedItemNS(e){return this._setAttr(e)}removeNamedItem(e){let R=this._findByName(e);if(!R)throw new DOMException(`Failed to execute 'removeNamedItem' on 'NamedNodeMap': No item with name '${e}' was found.`,`NotFoundError`);return this._removeAttr(R),R}removeNamedItemNS(e,R){let W=this.getNamedItemNS(e,R);if(!W)throw new DOMException(`Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': No item with namespace '${e}' and localName '${R}' was found.`,`NotFoundError`);return this._removeAttr(W),W}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NamedNodeMap`}_setNamedItem(e,R,W=null,Y=null){let X=W===null?this._findByName(e):this.getNamedItemNS(W,e.includes(`:`)?e.split(`:`)[1]:e);if(X)X.value=R;else{let X=new Attr(e,R,W,Y,this._ownerElement);this._items.push(X)}}_removeNamedItem(e){let R=this._findByName(e);return R?(this._removeAttr(R),!0):!1}_removeNamedItemNS(e,R){let W=this.getNamedItemNS(e,R);return W?(this._removeAttr(W),!0):!1}_findByName(e){let R=this._ownerElement.namespaceURI===ii.html,W=R?e.toLowerCase():e;for(let e of this._items)if((R?e.name.toLowerCase():e.name)===W)return e;return null}_setAttr(e){let R=null;if(R=e.namespaceURI===null?this._findByName(e.name):this.getNamedItemNS(e.namespaceURI,e.localName),R){let W=new Attr(R.name,R.value,R.namespaceURI,R.prefix,R.ownerElement);return R.value=e.value,W}return this._items.push(e),null}_removeAttr(e){let R=this._items.indexOf(e);R!==-1&&this._items.splice(R,1)}};xt();let si,ci,fi,pi,mi,hi;var Element=class extends ni{constructor(){super(),this[si]=``,this[ci]=``,this[fi]=ii.html,this[pi]=null,this[mi]=new NamedNodeMap(this),this[hi]=new Map,this._resizeSubscribers=null,this._allocatedClientWidth=0,this._allocatedClientHeight=0,this._pointerCaptures=new Set,this[Wt]=ir.ELEMENT_NODE}get tagName(){return this[Yt]}get localName(){return this[Xt]}get namespaceURI(){return this[Zt]}get prefix(){return this[Qt]}get nodeName(){return this[Yt]}get attributes(){return this[$t]}get id(){return this.getAttribute(`id`)??``}set id(e){this.setAttribute(`id`,e)}get className(){return this.getAttribute(`class`)??``}set className(e){this.setAttribute(`class`,e)}get children(){return this[qt]}get childElementCount(){return this[qt].length}get firstElementChild(){return this[qt][0]??null}get lastElementChild(){let e=this[qt];return e[e.length-1]??null}get previousElementSibling(){let e=this[Gt];if(!e)return null;let R=e[qt],W=R.indexOf(this);return W>0?R[W-1]:null}get nextElementSibling(){let e=this[Gt];if(!e)return null;let R=e[qt],W=R.indexOf(this);return W!==-1&&W<R.length-1?R[W+1]:null}get textContent(){let e=``;for(let R of this[Kt])R.textContent!==null&&(e+=R.textContent);return e}set textContent(e){let R=this[Kt];for(;R.length>0;)this.removeChild(R[0])}getAttribute(e){let R=this[$t].getNamedItem(e);return R?R.value:null}getAttributeNS(e,R){let W=this[$t].getNamedItemNS(e,R);return W?W.value:null}setAttribute(e,R){this[$t]._setNamedItem(e,String(R))}setAttributeNS(e,R,W){let Y=e===``?null:e,X=R.split(`:`),ie=X.length>1?X[0]:null;this[$t]._setNamedItem(R,String(W),Y,ie)}removeAttribute(e){this[$t]._removeNamedItem(e)}removeAttributeNS(e,R){let W=e===``?null:e;this[$t]._removeNamedItemNS(W,R)}hasAttribute(e){return this[$t].getNamedItem(e)!==null}hasAttributeNS(e,R){return this[$t].getNamedItemNS(e,R)!==null}getAttributeNode(e){return this[$t].getNamedItem(e)}setAttributeNode(e){return this[$t].setNamedItem(e)}removeAttributeNode(e){let R=this[$t].getNamedItem(e.name);if(!R)throw new DOMException(`Failed to execute 'removeAttributeNode' on 'Element': The attribute is not owned by this element.`,`NotFoundError`);return this[$t].removeNamedItem(R.name),R}toggleAttribute(e,R){return R===void 0?this.hasAttribute(e)?(this.removeAttribute(e),!1):(this.setAttribute(e,``),!0):R?(this.setAttribute(e,``),!0):(this.removeAttribute(e),!1)}hasAttributes(){return this[$t].length>0}dispatchEvent(e){let R=super.dispatchEvent(e),W=this[on].get(`on`+e.type);return typeof W==`function`&&W.call(this,e),R}querySelector(e){return null}querySelectorAll(e){return[]}matches(e){return!1}closest(e){return null}getElementsByTagName(e){let R=[],W=e.toUpperCase(),walk=Y=>{for(let X of Y[Kt])if(X[Wt]===ir.ELEMENT_NODE){let Y=X;(e===`*`||Y[Yt]===W)&&R.push(Y),walk(Y)}};return walk(this),R}getElementsByClassName(e){let R=[],W=e.split(/\s+/).filter(Boolean),walk=e=>{for(let Y of e[Kt])if(Y[Wt]===ir.ELEMENT_NODE){let e=Y,X=e.className.split(/\s+/);W.every(e=>X.includes(e))&&R.push(e),walk(e)}};return walk(this),R}cloneNode(e=!1){let R=super.cloneNode(!1);R[Yt]=this[Yt],R[Xt]=this[Xt],R[Zt]=this[Zt],R[Qt]=this[Qt];for(let e of this[$t])R.setAttributeNS(e.namespaceURI,e.name,e.value);if(e)for(let e of this[Kt])R.appendChild(e.cloneNode(!0));return R}_onResize(e){let R=this._resizeSubscribers??=new Set;return R.add(e),()=>{R.delete(e),R.size===0&&(this._resizeSubscribers=null)}}_fireResizeSubscribers(e,R){let W=this._resizeSubscribers;if(!(!W||W.size===0))for(let Y of[...W])try{Y(e,R)}catch(e){bt.error(`ResizeObserver subscriber threw:`,e)}}setPointerCapture(e){this._pointerCaptures.add(e)}releasePointerCapture(e){this._pointerCaptures.delete(e)}hasPointerCapture(e){return this._pointerCaptures.has(e)}get[(si=Yt,ci=Xt,fi=Zt,pi=Qt,mi=$t,hi=on,Symbol.toStringTag)](){return`Element`}},CSSStyleDeclaration=class{constructor(){this._cssText=``}get cssText(){return this._cssText}set cssText(e){this._cssText=e;for(let R of e.split(`;`)){let e=R.indexOf(`:`);if(e===-1)continue;let W=R.slice(0,e).trim(),Y=R.slice(e+1).trim();if(!W)continue;let X=W.replace(/-([a-z])/g,(e,R)=>R.toUpperCase());this[X]=Y}}setProperty(e,R,W){this[e]=R}getPropertyValue(e){let R=this[e];return typeof R==`string`?R:``}removeProperty(e){let R=this[e];return delete this[e],typeof R==`string`?R:``}getPropertyPriority(e){return``}},HTMLElement$1=class extends Element{static{__name$1(this,`HTMLElement`)}constructor(...e){super(...e),this.style=new CSSStyleDeclaration}get dataset(){let e=this;return new Proxy({},{get(R,W){if(typeof W!=`string`)return;let Y=`data-`+W.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.getAttribute(Y)??void 0},set(R,W,Y){if(typeof W!=`string`)return!1;let X=`data-`+W.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.setAttribute(X,String(Y)),!0},deleteProperty(R,W){if(typeof W!=`string`)return!1;let Y=`data-`+W.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.removeAttribute(Y),!0},has(R,W){if(typeof W!=`string`)return!1;let Y=`data-`+W.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.hasAttribute(Y)}})}get title(){return this.getAttribute(`title`)??``}set title(e){this.setAttribute(`title`,e)}get lang(){return this.getAttribute(`lang`)??``}set lang(e){this.setAttribute(`lang`,e)}get dir(){return this.getAttribute(`dir`)??``}set dir(e){this.setAttribute(`dir`,e)}get accessKey(){return this.getAttribute(`accesskey`)??``}set accessKey(e){this.setAttribute(`accesskey`,e)}get accessKeyLabel(){return this.getAttribute(`accesskey`)??``}get hidden(){return this.hasAttribute(`hidden`)}set hidden(e){e?this.setAttribute(`hidden`,``):this.removeAttribute(`hidden`)}get draggable(){return this.getAttribute(`draggable`)===`true`}set draggable(e){this.setAttribute(`draggable`,String(e))}get spellcheck(){let e=this.getAttribute(`spellcheck`);return e===`false`?!1:e!==null}set spellcheck(e){this.setAttribute(`spellcheck`,String(e))}get translate(){return this.getAttribute(`translate`)!==`no`}set translate(e){this.setAttribute(`translate`,e?`yes`:`no`)}get tabIndex(){let e=this.getAttribute(`tabindex`);return e===null?-1:Number(e)}set tabIndex(e){this.setAttribute(`tabindex`,String(e))}get contentEditable(){let e=this.getAttribute(`contenteditable`);return e===``||e===`true`?`true`:e===`false`?`false`:`inherit`}set contentEditable(e){e===`inherit`?this.removeAttribute(`contenteditable`):this.setAttribute(`contenteditable`,e)}get isContentEditable(){return this.contentEditable===`true`}get offsetHeight(){return this._allocatedClientHeight}get offsetWidth(){return this._allocatedClientWidth}get offsetLeft(){return 0}get offsetTop(){return 0}get offsetParent(){return null}get clientHeight(){return this._allocatedClientHeight}get clientWidth(){return this._allocatedClientWidth}get clientLeft(){return 0}get clientTop(){return 0}get scrollHeight(){return this._allocatedClientHeight}get scrollWidth(){return this._allocatedClientWidth}get scrollTop(){return 0}set scrollTop(e){}get scrollLeft(){return 0}set scrollLeft(e){}getBoundingClientRect(){let e=this.clientWidth,R=this.clientHeight;return{x:0,y:0,top:0,left:0,right:e,bottom:R,width:e,height:R,toJSON(){return this}}}click(){this.dispatchEvent(new Event$1(`click`,{bubbles:!0,cancelable:!0}))}blur(){this.dispatchEvent(new Event$1(`blur`))}focus(){this.dispatchEvent(new Event$1(`focus`))}get onclick(){return this[on].get(`onclick`)??null}set onclick(e){this[on].set(`onclick`,e)}get ondblclick(){return this[on].get(`ondblclick`)??null}set ondblclick(e){this[on].set(`ondblclick`,e)}get onload(){return this[on].get(`onload`)??null}set onload(e){this[on].set(`onload`,e)}get onerror(){return this[on].get(`onerror`)??null}set onerror(e){this[on].set(`onerror`,e)}get onabort(){return this[on].get(`onabort`)??null}set onabort(e){this[on].set(`onabort`,e)}get onfocus(){return this[on].get(`onfocus`)??null}set onfocus(e){this[on].set(`onfocus`,e)}get onblur(){return this[on].get(`onblur`)??null}set onblur(e){this[on].set(`onblur`,e)}get onchange(){return this[on].get(`onchange`)??null}set onchange(e){this[on].set(`onchange`,e)}get oninput(){return this[on].get(`oninput`)??null}set oninput(e){this[on].set(`oninput`,e)}get onsubmit(){return this[on].get(`onsubmit`)??null}get onreset(){return this[on].get(`onreset`)??null}set onreset(e){this[on].set(`onreset`,e)}get onscroll(){return this[on].get(`onscroll`)??null}set onscroll(e){this[on].set(`onscroll`,e)}get onresize(){return this[on].get(`onresize`)??null}set onresize(e){this[on].set(`onresize`,e)}get onmousedown(){return this[on].get(`onmousedown`)??null}set onmousedown(e){this[on].set(`onmousedown`,e)}get onmouseup(){return this[on].get(`onmouseup`)??null}set onmouseup(e){this[on].set(`onmouseup`,e)}get onmousemove(){return this[on].get(`onmousemove`)??null}set onmousemove(e){this[on].set(`onmousemove`,e)}get onmouseover(){return this[on].get(`onmouseover`)??null}set onmouseover(e){this[on].set(`onmouseover`,e)}get onmouseout(){return this[on].get(`onmouseout`)??null}set onmouseout(e){this[on].set(`onmouseout`,e)}get onmouseenter(){return this[on].get(`onmouseenter`)??null}set onmouseenter(e){this[on].set(`onmouseenter`,e)}get onmouseleave(){return this[on].get(`onmouseleave`)??null}set onmouseleave(e){this[on].set(`onmouseleave`,e)}get oncontextmenu(){return this[on].get(`oncontextmenu`)??null}set oncontextmenu(e){this[on].set(`oncontextmenu`,e)}get onwheel(){return this[on].get(`onwheel`)??null}set onwheel(e){this[on].set(`onwheel`,e)}get onkeydown(){return this[on].get(`onkeydown`)??null}set onkeydown(e){this[on].set(`onkeydown`,e)}get onkeyup(){return this[on].get(`onkeyup`)??null}set onkeyup(e){this[on].set(`onkeyup`,e)}get ontouchstart(){return this[on].get(`ontouchstart`)??null}set ontouchstart(e){this[on].set(`ontouchstart`,e)}get ontouchend(){return this[on].get(`ontouchend`)??null}set ontouchend(e){this[on].set(`ontouchend`,e)}get ontouchmove(){return this[on].get(`ontouchmove`)??null}set ontouchmove(e){this[on].set(`ontouchmove`,e)}get onpointerdown(){return this[on].get(`onpointerdown`)??null}set onpointerdown(e){this[on].set(`onpointerdown`,e)}get onpointerup(){return this[on].get(`onpointerup`)??null}set onpointerup(e){this[on].set(`onpointerup`,e)}get onpointermove(){return this[on].get(`onpointermove`)??null}set onpointermove(e){this[on].set(`onpointermove`,e)}cloneNode(e=!1){return super.cloneNode(e)}get[Symbol.toStringTag](){return`HTMLElement`}},gi=class HTMLCanvasElement extends HTMLElement$1{constructor(...e){super(...e),this.oncontextlost=null,this.oncontextrestored=null,this.onwebglcontextcreationerror=null,this.onwebglcontextlost=null,this.onwebglcontextrestored=null}static{this._contextFactories=new Map}static registerContextFactory(e,R){HTMLCanvasElement._contextFactories.set(e,R)}get width(){let e=this.getAttribute(`width`);return e===null?300:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get height(){let e=this.getAttribute(`height`);return e===null?150:Number(e)}set height(e){this.setAttribute(`height`,String(e))}getContext(e,R){let W=HTMLCanvasElement._contextFactories.get(e);return W?W(this,R):null}toDataURL(e,R){let W=this.getContext(`2d`);return W&&typeof W._toDataURL==`function`?W._toDataURL(e,R):``}toBlob(e,R,W){let Y=this.toDataURL(R,W);if(!Y){e(null);return}let[X,ie]=Y.split(`,`),ae=X.split(`:`)[1].split(`;`)[0],le=atob(ie),_e=new Uint8Array(le.length);for(let e=0;e<le.length;e++)_e[e]=le.charCodeAt(e);e(new Blob([_e],{type:ae}))}captureStream(e){return{}}},_i=class DOMMatrix{constructor(e){this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1,this.is2D=!0,this.isIdentity=!0,Array.isArray(e)&&(e.length===6?(this.a=this.m11=e[0],this.b=this.m12=e[1],this.c=this.m21=e[2],this.d=this.m22=e[3],this.e=this.m41=e[4],this.f=this.m42=e[5],this.is2D=!0):e.length===16&&(this.m11=e[0],this.m12=e[1],this.m13=e[2],this.m14=e[3],this.m21=e[4],this.m22=e[5],this.m23=e[6],this.m24=e[7],this.m31=e[8],this.m32=e[9],this.m33=e[10],this.m34=e[11],this.m41=e[12],this.m42=e[13],this.m43=e[14],this.m44=e[15],this.a=this.m11,this.b=this.m12,this.c=this.m21,this.d=this.m22,this.e=this.m41,this.f=this.m42,this.is2D=!1),this.isIdentity=this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0)}multiply(e){return new DOMMatrix([this.a*e.a+this.c*e.b,this.b*e.a+this.d*e.b,this.a*e.c+this.c*e.d,this.b*e.c+this.d*e.d,this.a*e.e+this.c*e.f+this.e,this.b*e.e+this.d*e.f+this.f])}multiplySelf(e){let R=this.multiply(e);return this.a=R.a,this.b=R.b,this.c=R.c,this.d=R.d,this.e=R.e,this.f=R.f,this.m11=this.a,this.m12=this.b,this.m21=this.c,this.m22=this.d,this.m41=this.e,this.m42=this.f,this.isIdentity=!1,this}inverse(){let e=this.a*this.d-this.b*this.c;if(e===0)return new DOMMatrix([1,0,0,1,0,0]);let R=1/e;return new DOMMatrix([this.d*R,-this.b*R,-this.c*R,this.a*R,(this.c*this.f-this.d*this.e)*R,(this.b*this.e-this.a*this.f)*R])}translate(e=0,R=0){return this.multiply({a:1,b:0,c:0,d:1,e,f:R})}scale(e=1,R=e){return this.multiply({a:e,b:0,c:0,d:R,e:0,f:0})}};const yi=_i;function defineGlobal(e,R){Object.defineProperty(globalThis,e,{value:R,writable:!0,configurable:!0})}function defineGlobalIfMissing(e,R){globalThis[e]===void 0&&defineGlobal(e,R)}const bi={aliceblue:`#f0f8ff`,antiquewhite:`#faebd7`,aqua:`#00ffff`,aquamarine:`#7fffd4`,azure:`#f0ffff`,beige:`#f5f5dc`,bisque:`#ffe4c4`,black:`#000000`,blanchedalmond:`#ffebcd`,blue:`#0000ff`,blueviolet:`#8a2be2`,brown:`#a52a2a`,burlywood:`#deb887`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,cornflowerblue:`#6495ed`,cornsilk:`#fff8dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,darkkhaki:`#bdb76b`,darkmagenta:`#8b008b`,darkolivegreen:`#556b2f`,darkorange:`#ff8c00`,darkorchid:`#9932cc`,darkred:`#8b0000`,darksalmon:`#e9967a`,darkseagreen:`#8fbc8f`,darkslateblue:`#483d8b`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,darkturquoise:`#00ced1`,darkviolet:`#9400d3`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,dimgray:`#696969`,dimgrey:`#696969`,dodgerblue:`#1e90ff`,firebrick:`#b22222`,floralwhite:`#fffaf0`,forestgreen:`#228b22`,fuchsia:`#ff00ff`,gainsboro:`#dcdcdc`,ghostwhite:`#f8f8ff`,gold:`#ffd700`,goldenrod:`#daa520`,gray:`#808080`,green:`#008000`,greenyellow:`#adff2f`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,indianred:`#cd5c5c`,indigo:`#4b0082`,ivory:`#fffff0`,khaki:`#f0e68c`,lavender:`#e6e6fa`,lavenderblush:`#fff0f5`,lawngreen:`#7cfc00`,lemonchiffon:`#fffacd`,lightblue:`#add8e6`,lightcoral:`#f08080`,lightcyan:`#e0ffff`,lightgoldenrodyellow:`#fafad2`,lightgray:`#d3d3d3`,lightgreen:`#90ee90`,lightgrey:`#d3d3d3`,lightpink:`#ffb6c1`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,lightskyblue:`#87cefa`,lightslategray:`#778899`,lightslategrey:`#778899`,lightsteelblue:`#b0c4de`,lightyellow:`#ffffe0`,lime:`#00ff00`,limegreen:`#32cd32`,linen:`#faf0e6`,magenta:`#ff00ff`,maroon:`#800000`,mediumaquamarine:`#66cdaa`,mediumblue:`#0000cd`,mediumorchid:`#ba55d3`,mediumpurple:`#9370db`,mediumseagreen:`#3cb371`,mediumslateblue:`#7b68ee`,mediumspringgreen:`#00fa9a`,mediumturquoise:`#48d1cc`,mediumvioletred:`#c71585`,midnightblue:`#191970`,mintcream:`#f5fffa`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,navajowhite:`#ffdead`,navy:`#000080`,oldlace:`#fdf5e6`,olive:`#808000`,olivedrab:`#6b8e23`,orange:`#ffa500`,orangered:`#ff4500`,orchid:`#da70d6`,palegoldenrod:`#eee8aa`,palegreen:`#98fb98`,paleturquoise:`#afeeee`,palevioletred:`#db7093`,papayawhip:`#ffefd5`,peachpuff:`#ffdab9`,peru:`#cd853f`,pink:`#ffc0cb`,plum:`#dda0dd`,powderblue:`#b0e0e6`,purple:`#800080`,rebeccapurple:`#663399`,red:`#ff0000`,rosybrown:`#bc8f8f`,royalblue:`#4169e1`,saddlebrown:`#8b4513`,salmon:`#fa8072`,sandybrown:`#f4a460`,seagreen:`#2e8b57`,seashell:`#fff5ee`,sienna:`#a0522d`,silver:`#c0c0c0`,skyblue:`#87ceeb`,slateblue:`#6a5acd`,slategray:`#708090`,slategrey:`#708090`,snow:`#fffafa`,springgreen:`#00ff7f`,steelblue:`#4682b4`,tan:`#d2b48c`,teal:`#008080`,thistle:`#d8bfd8`,tomato:`#ff6347`,turquoise:`#40e0d0`,violet:`#ee82ee`,wheat:`#f5deb3`,white:`#ffffff`,whitesmoke:`#f5f5f5`,yellow:`#ffff00`,yellowgreen:`#9acd32`,transparent:`#00000000`};function parseColor(e){if(!e||typeof e!=`string`)return null;let R=e.trim().toLowerCase(),W=bi[R];if(W)return parseHex(W);if(R.startsWith(`#`))return parseHex(R);let Y=R.match(/^rgba?\(\s*(\d+(?:\.\d+)?%?)\s*[,\s]\s*(\d+(?:\.\d+)?%?)\s*[,\s]\s*(\d+(?:\.\d+)?%?)\s*(?:[,/]\s*(\d+(?:\.\d+)?%?))?\s*\)$/);if(Y)return{r:parseComponent(Y[1],255)/255,g:parseComponent(Y[2],255)/255,b:parseComponent(Y[3],255)/255,a:Y[4]===void 0?1:parseComponent(Y[4],1)};let X=R.match(/^hsla?\(\s*(\d+(?:\.\d+)?)\s*[,\s]\s*(\d+(?:\.\d+)?)(%)?\s*[,\s]\s*(\d+(?:\.\d+)?)(%)?\s*(?:[,/]\s*(\d+(?:\.\d+)?%?))?\s*\)$/);if(X){let e=parseFloat(X[1]),R=parseFloat(X[2]),W=X[3]===`%`,Y=parseFloat(X[4]),ie=X[5]===`%`,ae=X[6]===void 0?1:parseComponent(X[6],1);return e>1&&(e/=360),(W||R>1)&&(R/=100),(ie||Y>1)&&(Y/=100),hslToRGBA(e,R,Y,Math.max(0,Math.min(1,ae)))}return null}function parseHex(e){let R=e.slice(1),W,Y,X,ie=1;if(R.length===3)W=parseInt(R[0]+R[0],16)/255,Y=parseInt(R[1]+R[1],16)/255,X=parseInt(R[2]+R[2],16)/255;else if(R.length===4)W=parseInt(R[0]+R[0],16)/255,Y=parseInt(R[1]+R[1],16)/255,X=parseInt(R[2]+R[2],16)/255,ie=parseInt(R[3]+R[3],16)/255;else if(R.length===6)W=parseInt(R.slice(0,2),16)/255,Y=parseInt(R.slice(2,4),16)/255,X=parseInt(R.slice(4,6),16)/255;else if(R.length===8)W=parseInt(R.slice(0,2),16)/255,Y=parseInt(R.slice(2,4),16)/255,X=parseInt(R.slice(4,6),16)/255,ie=parseInt(R.slice(6,8),16)/255;else return null;return{r:W,g:Y,b:X,a:ie}}function parseComponent(e,R){return e.endsWith(`%`)?parseFloat(e)/100*R:parseFloat(e)}function hue2rgb(e,R,W){return W<0&&(W+=1),W>1&&--W,W<1/6?e+(R-e)*6*W:W<1/2?R:W<2/3?e+(R-e)*(2/3-W)*6:e}function hslToRGBA(e,R,W,Y){let X,ie,ae;if(R===0)X=ie=ae=W;else{let Y=W<.5?W*(1+R):W+R-W*R,le=2*W-Y;X=hue2rgb(le,Y,e+1/3),ie=hue2rgb(le,Y,e),ae=hue2rgb(le,Y,e-1/3)}return{r:X,g:ie,b:ae,a:Y}}const Si={r:0,g:0,b:0,a:1};var CanvasGradient=class{constructor(e,R,Y,X,ie,ae,le){e===`radial`?this._pattern=new W.RadialGradient(R,Y,ae,X,ie,le):this._pattern=new W.LinearGradient(R,Y,X,ie)}addColorStop(e,R){let W=parseColor(R);W&&this._pattern.addColorStopRGBA(e,W.r,W.g,W.b,W.a)}_getCairoPattern(){return this._pattern}};function quadraticToCubic(e,R,W,Y,X,ie){return{cp1x:e+2/3*(W-e),cp1y:R+2/3*(Y-R),cp2x:X+2/3*(W-X),cp2y:ie+2/3*(Y-ie)}}function computeArcTo(e,R,W,Y,X,ie,ae){let le=e-W,_e=R-Y,ye=X-W,be=ie-Y,Ce=Math.sqrt(le*le+_e*_e),Te=Math.sqrt(ye*ye+be*be);if(Ce===0||Te===0)return null;let Oe=le/Ce,Ae=_e/Ce,Me=ye/Te,Pe=be/Te,Re=Oe*Pe-Ae*Me;if(Math.abs(Re)<1e-10)return null;let Be=Oe*Me+Ae*Pe,Ve=Math.acos(Math.max(-1,Math.min(1,Be)))/2,He=ae/Math.tan(Ve),Ue=W+Oe*He,We=Y+Ae*He,Ge=W+Me*He,Ke=Y+Pe*He,qe=ae/Math.sin(Ve),Je=(Oe+Me)/2,Ye=(Ae+Pe)/2,Xe=Math.sqrt(Je*Je+Ye*Ye),Ze=W+Je/Xe*qe,Qe=Y+Ye/Xe*qe;return{tx0:Ue,ty0:We,tx1:Ge,ty1:Ke,cx:Ze,cy:Qe,startAngle:Math.atan2(We-Qe,Ue-Ze),endAngle:Math.atan2(Ke-Qe,Ge-Ze),counterclockwise:Re>0}}function cairoArcTo(e,R,W,Y,X,ie,ae,le){let _e=computeArcTo(R,W,Y,X,ie,ae,le);if(!_e){e.lineTo(Y,X);return}let{tx0:ye,ty0:be,cx:Ce,cy:Te,startAngle:Oe,endAngle:Ae,counterclockwise:Me}=_e;e.lineTo(ye,be),Me?e.arcNegative(Ce,Te,le,Oe,Ae):e.arc(Ce,Te,le,Oe,Ae)}function cairoEllipse(e,R,W,Y,X,ie,ae,le,_e){e.save(),e.translate(R,W),e.rotate(ie),e.scale(Y,X),_e?e.arcNegative(0,0,1,ae,le):e.arc(0,0,1,ae,le),e.restore()}function cairoRoundRect(e,R,W,Y,X,ie){let ae,le,_e,ye;typeof ie==`number`?ae=le=_e=ye=ie:ie.length===1?ae=le=_e=ye=ie[0]:ie.length===2?(ae=_e=ie[0],le=ye=ie[1]):ie.length===3?(ae=ie[0],le=ye=ie[1],_e=ie[2]):(ae=ie[0],le=ie[1],_e=ie[2],ye=ie[3]);let be=Math.min(Y/2,X/2);ae=Math.min(ae,be),le=Math.min(le,be),_e=Math.min(_e,be),ye=Math.min(ye,be);let Ce=Math.PI/2;e.newSubPath(),e.arc(R+ae,W+ae,ae,Math.PI,Math.PI+Ce),e.arc(R+Y-le,W+le,le,-Ce,0),e.arc(R+Y-_e,W+X-_e,_e,0,Ce),e.arc(R+ye,W+X-ye,ye,Ce,Math.PI),e.closePath()}const Ti={"source-over":2,"source-in":3,"source-out":4,"source-atop":5,"destination-over":7,"destination-in":8,"destination-out":9,"destination-atop":10,lighter:12,copy:1,xor:11,multiply:14,screen:15,overlay:16,darken:17,lighten:18,"color-dodge":19,"color-burn":20,"hard-light":21,"soft-light":22,difference:23,exclusion:24,hue:25,saturation:26,color:27,luminosity:28},Ei={butt:0,round:1,square:2},Di={miter:0,round:1,bevel:2};var Oi=class Path2D{constructor(e){this._ops=[],e instanceof Path2D&&(this._ops=[...e._ops])}addPath(e){this._ops.push(...e._ops)}moveTo(e,R){this._ops.push({type:`moveTo`,x:e,y:R})}lineTo(e,R){this._ops.push({type:`lineTo`,x:e,y:R})}closePath(){this._ops.push({type:`closePath`})}bezierCurveTo(e,R,W,Y,X,ie){this._ops.push({type:`bezierCurveTo`,cp1x:e,cp1y:R,cp2x:W,cp2y:Y,x:X,y:ie})}quadraticCurveTo(e,R,W,Y){this._ops.push({type:`quadraticCurveTo`,cpx:e,cpy:R,x:W,y:Y})}arc(e,R,W,Y,X,ie=!1){this._ops.push({type:`arc`,x:e,y:R,radius:W,startAngle:Y,endAngle:X,ccw:ie})}ellipse(e,R,W,Y,X,ie,ae,le=!1){if(W<0||Y<0)throw RangeError(`The radii provided are negative`);this._ops.push({type:`ellipse`,x:e,y:R,rx:W,ry:Y,rotation:X,startAngle:ie,endAngle:ae,ccw:le})}rect(e,R,W,Y){this._ops.push({type:`rect`,x:e,y:R,w:W,h:Y})}roundRect(e,R,W,Y,X=0){this._ops.push({type:`roundRect`,x:e,y:R,w:W,h:Y,radii:X})}_replayOnCairo(e){let R=0,W=0;for(let Y of this._ops)switch(Y.type){case`moveTo`:e.moveTo(Y.x,Y.y),R=Y.x,W=Y.y;break;case`lineTo`:e.lineTo(Y.x,Y.y),R=Y.x,W=Y.y;break;case`closePath`:e.closePath();break;case`bezierCurveTo`:e.curveTo(Y.cp1x,Y.cp1y,Y.cp2x,Y.cp2y,Y.x,Y.y),R=Y.x,W=Y.y;break;case`quadraticCurveTo`:{let{cp1x:X,cp1y:ie,cp2x:ae,cp2y:le}=quadraticToCubic(R,W,Y.cpx,Y.cpy,Y.x,Y.y);e.curveTo(X,ie,ae,le,Y.x,Y.y),R=Y.x,W=Y.y;break}case`arc`:Y.ccw?e.arcNegative(Y.x,Y.y,Y.radius,Y.startAngle,Y.endAngle):e.arc(Y.x,Y.y,Y.radius,Y.startAngle,Y.endAngle);break;case`ellipse`:e.save(),e.translate(Y.x,Y.y),e.rotate(Y.rotation),e.scale(Y.rx,Y.ry),Y.ccw?e.arcNegative(0,0,1,Y.startAngle,Y.endAngle):e.arc(0,0,1,Y.startAngle,Y.endAngle),e.restore();break;case`rect`:e.rectangle(Y.x,Y.y,Y.w,Y.h);break;case`roundRect`:cairoRoundRect(e,Y.x,Y.y,Y.w,Y.h,Y.radii);break}}};function asCairoPattern(e){if(!e)return null;let R=e;return typeof R.setFilter!=`function`||typeof R.setExtend!=`function`?null:R}function isPixbufImageSource(e){return typeof e!=`object`||!e?!1:typeof e.isPixbuf==`function`&&e.isPixbuf()}function isCanvasImageSource(e){return typeof e!=`object`||!e?!1:typeof e.getContext==`function`}var ki=class CanvasPattern{constructor(e,R){let Y=asCairoPattern(new W.SurfacePattern(e));if(!Y)throw TypeError(`CanvasPattern: cairo SurfacePattern is missing setExtend at runtime — incompatible Cairo binding`);switch(this._pattern=Y,R){case`repeat`:case``:case null:Y.setExtend(W.Extend.REPEAT);break;case`repeat-x`:case`repeat-y`:Y.setExtend(W.Extend.REPEAT);break;case`no-repeat`:Y.setExtend(W.Extend.NONE);break}}static create(e,R){if(isPixbufImageSource(e)){let X=e._pixbuf,ie=X.get_width(),ae=X.get_height(),le=new W.ImageSurface(W.Format.ARGB32,ie,ae),_e=new W.Context(le);return Y.cairo_set_source_pixbuf(_e,X,0,0),_e.paint(),_e.$dispose(),new CanvasPattern(le,R)}if(isCanvasImageSource(e)){let Y=e.getContext(`2d`);if(Y&&typeof Y._getSurface==`function`){let e=Y._getSurface(),X=e.getWidth(),ie=e.getHeight(),ae=new W.ImageSurface(W.Format.ARGB32,X,ie),le=new W.Context(ae);return le.setSourceSurface(e,0,0),le.paint(),le.$dispose(),new CanvasPattern(ae,R)}}return null}_getCairoPattern(){return this._pattern}},OurImageData=class{constructor(e,R,W){if(this.colorSpace=`srgb`,typeof e==`number`)this.width=e,this.height=R,this.data=new Uint8ClampedArray(this.width*this.height*4);else if(this.data=e,this.width=R,this.height=W??this.data.length/(4*this.width),this.data.length!==this.width*this.height*4)throw RangeError(`Source data length ${this.data.length} is not a multiple of (4 * width=${this.width})`)}};const Ai={translate(e,R){this._ensureSurface(),this._ctx.translate(e,R)},rotate(e){this._ensureSurface(),this._ctx.rotate(e)},scale(e,R){this._ensureSurface(),this._ctx.scale(e,R)},transform(e,R,W,Y,X,ie){if(this._ensureSurface(),!Number.isFinite(e)||!Number.isFinite(R)||!Number.isFinite(W)||!Number.isFinite(Y)||!Number.isFinite(X)||!Number.isFinite(ie))return;let ae=X,le=ie,_e=Math.hypot(e,R),ye=Math.hypot(W,Y),be=Math.atan2(R,e);this._ctx.translate(ae,le),be!==0&&this._ctx.rotate(be),(_e!==1||ye!==1)&&this._ctx.scale(_e,ye)},setTransform(e,R,W,Y,X,ie){if(this._ensureSurface(),typeof e==`object`&&e){let R=e;this._ctx.identityMatrix(),this.transform(R.a??R.m11??1,R.b??R.m12??0,R.c??R.m21??0,R.d??R.m22??1,R.e??R.m41??0,R.f??R.m42??0)}else typeof e==`number`?(this._ctx.identityMatrix(),this.transform(e,R,W,Y,X,ie)):this._ctx.identityMatrix()},getTransform(){let e=this._ctx.userToDevice(0,0),R=this._ctx.userToDevice(1,0),W=this._ctx.userToDevice(0,1),Y=e[0]??0,X=e[1]??0,ie=(R[0]??0)-Y,ae=(R[1]??0)-X,le=(W[0]??0)-Y,_e=(W[1]??0)-X,ye=globalThis.DOMMatrix;return typeof ye==`function`?new ye([ie,ae,le,_e,Y,X]):{a:ie,b:ae,c:le,d:_e,e:Y,f:X,m11:ie,m12:ae,m13:0,m14:0,m21:le,m22:_e,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:Y,m42:X,m43:0,m44:1,is2D:!0,isIdentity:ie===1&&ae===0&&le===0&&_e===1&&Y===0&&X===0}},resetTransform(){this._ensureSurface(),this._ctx.identityMatrix()}};function installTransformMethods(e){Object.assign(e,Ai)}const Mi={beginPath(){this._ensureSurface(),this._ctx.newPath()},moveTo(e,R){this._ensureSurface(),this._ctx.moveTo(e,R)},lineTo(e,R){this._ensureSurface(),this._ctx.lineTo(e,R)},closePath(){this._ensureSurface(),this._ctx.closePath()},bezierCurveTo(e,R,W,Y,X,ie){this._ensureSurface(),this._ctx.curveTo(e,R,W,Y,X,ie)},quadraticCurveTo(e,R,W,Y){this._ensureSurface();let X,ie;this._ctx.hasCurrentPoint()?[X,ie]=this._ctx.getCurrentPoint():(X=e,ie=R);let{cp1x:ae,cp1y:le,cp2x:_e,cp2y:ye}=quadraticToCubic(X,ie,e,R,W,Y);this._ctx.curveTo(ae,le,_e,ye,W,Y)},arc(e,R,W,Y,X,ie=!1){if(this._ensureSurface(),Math.abs(X-Y)>=2*Math.PI){this._ctx.arc(e,R,W,0,2*Math.PI);return}ie?this._ctx.arcNegative(e,R,W,Y,X):this._ctx.arc(e,R,W,Y,X)},arcTo(e,R,W,Y,X){this._ensureSurface();let ie,ae;this._ctx.hasCurrentPoint()?[ie,ae]=this._ctx.getCurrentPoint():(ie=e,ae=R,this._ctx.moveTo(e,R)),cairoArcTo(this._ctx,ie,ae,e,R,W,Y,X)},ellipse(e,R,W,Y,X,ie,ae,le=!1){if(this._ensureSurface(),W<0||Y<0)throw RangeError(`The radii provided are negative`);cairoEllipse(this._ctx,e,R,W,Y,X,ie,ae,le)},rect(e,R,W,Y){this._ensureSurface(),this._ctx.rectangle(e,R,W,Y)},roundRect(e,R,W,Y,X=0){this._ensureSurface(),cairoRoundRect(this._ctx,e,R,W,Y,X)}};function installPathMethods(e){Object.assign(e,Mi)}function getDrawImageSource(e){if(isPixbufImageSource(e)){let R=e._pixbuf;return{pixbuf:R,imgWidth:R.get_width(),imgHeight:R.get_height()}}if(isCanvasImageSource(e)){let R=e.width??0,W=e.height??0;if(!Number.isFinite(R)||!Number.isFinite(W)||R<=0||W<=0)return null;let X=e.getContext(`2d`);if(X&&typeof X._getSurface==`function`){let e=X._getSurface();e.flush();let ie=Y.pixbuf_get_from_surface(e,0,0,R,W);if(ie)return{pixbuf:ie,imgWidth:R,imgHeight:W}}}return null}const Fi={fill(e,R){this._ensureSurface(),this._applyCompositing(),this._applyFillStyle();let Y;e instanceof Oi?(this._ctx.newPath(),e._replayOnCairo(this._ctx),Y=R):Y=e,this._ctx.setFillRule(Y===`evenodd`?W.FillRule.EVEN_ODD:W.FillRule.WINDING),this._ctx.fillPreserve()},stroke(e){this._ensureSurface(),this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle(),e instanceof Oi&&(this._ctx.newPath(),e._replayOnCairo(this._ctx)),this._ctx.strokePreserve()},fillRect(e,R,W,Y){this._ensureSurface(),this._applyCompositing();let X=this._ctx.copyPath();this._hasShadow()&&this._renderShadow(()=>{this._ctx.newPath(),this._ctx.rectangle(e,R,W,Y),this._ctx.fill()}),this._applyFillStyle(),this._ctx.newPath(),this._ctx.rectangle(e,R,W,Y),this._ctx.fill(),this._ctx.newPath(),this._ctx.appendPath(X)},strokeRect(e,R,W,Y){this._ensureSurface(),this._applyCompositing();let X=this._ctx.copyPath();this._hasShadow()&&this._renderShadow(()=>{this._ctx.newPath(),this._ctx.rectangle(e,R,W,Y),this._ctx.stroke()}),this._applyStrokeStyle(),this._applyLineStyle(),this._ctx.newPath(),this._ctx.rectangle(e,R,W,Y),this._ctx.stroke(),this._ctx.newPath(),this._ctx.appendPath(X)},clearRect(e,R,Y,X){this._ensureSurface();let ie=this._ctx.copyPath();this._ctx.save(),this._ctx.setOperator(W.Operator.CLEAR),this._ctx.newPath(),this._ctx.rectangle(e,R,Y,X),this._ctx.fill(),this._ctx.restore(),this._ctx.newPath(),this._ctx.appendPath(ie)},clip(e,R){this._ensureSurface();let Y;e instanceof Oi?(this._ctx.newPath(),e._replayOnCairo(this._ctx),Y=R):Y=e,this._ctx.setFillRule(Y===`evenodd`?W.FillRule.EVEN_ODD:W.FillRule.WINDING),this._ctx.clip()},isPointInPath(e,R,Y,X){this._ensureSurface();let ie,ae,le;return e instanceof Oi?(this._ctx.newPath(),e._replayOnCairo(this._ctx),ie=R,ae=Y,le=X):(ie=e,ae=R,le=Y),this._ctx.setFillRule(le===`evenodd`?W.FillRule.EVEN_ODD:W.FillRule.WINDING),this._ctx.inFill(ie,ae)},isPointInStroke(e,R,W){return this._ensureSurface(),this._applyLineStyle(),e instanceof Oi?(this._ctx.newPath(),e._replayOnCairo(this._ctx),this._ctx.inStroke(R,W)):this._ctx.inStroke(e,R)},drawImage(e,R,X,ie,ae,le,_e,ye,be){this._ensureSurface(),this._applyCompositing();let Ce,Te,Oe,Ae,Me,Pe,Re,Be,Ve=getDrawImageSource(e);if(!Ve)return;let{pixbuf:He,imgWidth:Ue,imgHeight:We}=Ve;if(ie===void 0?(Ce=0,Te=0,Oe=Ue,Ae=We,Me=R,Pe=X,Re=Ue,Be=We):le===void 0?(Ce=0,Te=0,Oe=Ue,Ae=We,Me=R,Pe=X,Re=ie,Be=ae):(Ce=R,Te=X,Oe=ie,Ae=ae,Me=le,Pe=_e,Re=ye,Be=be),!Number.isFinite(Ce)||!Number.isFinite(Te)||!Number.isFinite(Oe)||!Number.isFinite(Ae)||!Number.isFinite(Me)||!Number.isFinite(Pe)||!Number.isFinite(Re)||!Number.isFinite(Be)||Oe===0||Ae===0||Re===0||Be===0)return;this._ctx.save(),this._ctx.rectangle(Me,Pe,Re,Be),this._ctx.clip(),this._ctx.translate(Me,Pe),this._ctx.scale(Re/Oe,Be/Ae),this._ctx.translate(-Ce,-Te),Y.cairo_set_source_pixbuf(this._ctx,He,0,0);let Ge=asCairoPattern(this._ctx.getSource?.());if(Ge){let e;e=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?W.Filter.BEST:W.Filter.BILINEAR:W.Filter.NEAREST,Ge.setFilter(e)}this._state.globalAlpha<1?this._ctx.paintWithAlpha(this._state.globalAlpha):this._ctx.paint(),this._ctx.restore()}};function installDrawingMethods$1(e){Object.assign(e,Fi)}__name$1(installDrawingMethods$1,`installDrawingMethods`);const Ii={createImageData(e,R){return typeof e==`number`?new OurImageData(Math.abs(e),Math.abs(R)):new OurImageData(e.width,e.height)},getImageData(e,R,W,X){this._ensureSurface(),this._surface.flush();let ie=Y.pixbuf_get_from_surface(this._surface,e,R,W,X);if(!ie)return new OurImageData(W,X);let ae=ie.get_pixels(),le=ie.get_has_alpha(),_e=ie.get_rowstride(),ye=ie.get_n_channels(),be=new Uint8ClampedArray(W*X*4);for(let e=0;e<X;e++)for(let R=0;R<W;R++){let Y=e*_e+R*ye,X=(e*W+R)*4;be[X]=ae[Y],be[X+1]=ae[Y+1],be[X+2]=ae[Y+2],be[X+3]=le?ae[Y+3]:255}return new OurImageData(be,W,X)},putImageData(e,R,ie,ae,le,_e,ye){this._ensureSurface();let be=ae??0,Ce=le??0,Te=_e??e.width,Oe=ye??e.height,Ae=e.data,Me=e.width,Pe=new Uint8Array(Te*Oe*4);for(let e=0;e<Oe;e++)for(let R=0;R<Te;R++){let W=((Ce+e)*Me+(be+R))*4,Y=(e*Te+R)*4;Pe[Y]=Ae[W],Pe[Y+1]=Ae[W+1],Pe[Y+2]=Ae[W+2],Pe[Y+3]=Ae[W+3]}let Re=X.Pixbuf.new_from_bytes(Pe,X.Colorspace.RGB,!0,8,Te,Oe,Te*4);this._ctx.save(),this._ctx.setOperator(W.Operator.SOURCE),Y.cairo_set_source_pixbuf(this._ctx,Re,R+be,ie+Ce),this._ctx.rectangle(R+be,ie+Ce,Te,Oe),this._ctx.fill(),this._ctx.restore()}};function installPixelMethods(e){Object.assign(e,Ii)}function parseFontToDescription(e){let R=e.match(/^\s*(italic|oblique|normal)?\s*(small-caps|normal)?\s*(bold|bolder|lighter|[1-9]00|normal)?\s*(\d+(?:\.\d+)?)(px|pt|em|rem|%)?\s*(?:\/\S+)?\s*(.+)?$/i);if(!R)return ie.font_description_from_string(e);let W=R[1]||``,Y=R[3]||``,X=parseFloat(R[4])||10,ae=(R[5]||`px`).toLowerCase(),le=(R[6]||`sans-serif`).replace(/['"]/g,``).trim();ae===`pt`?X=X*96/72:ae===`em`||ae===`rem`?X*=16:ae===`%`&&(X=X/100*16);let _e=le;W===`italic`?_e+=` Italic`:W===`oblique`&&(_e+=` Oblique`),Y===`bold`||Y===`bolder`||parseInt(Y)>=600?_e+=` Bold`:(Y===`lighter`||parseInt(Y)>0&&parseInt(Y)<=300)&&(_e+=` Light`);let ye=ie.font_description_from_string(_e);return ye.set_absolute_size(X*ie.SCALE),ye}function createTextLayout(e,R){let W=ae.create_layout(e._ctx);W.set_text(R,-1),W.get_context().set_base_dir(ie.Direction.LTR),W.context_changed();let Y=parseFontToDescription(e._state.font);return W.set_font_description(Y),W}function getTextAlignOffset(e,R){let[,W]=R.get_pixel_extents(),Y=W.width;switch(e._state.textAlign){case`center`:return-Y/2;case`right`:case`end`:return-Y;default:return 0}}function getTextBaselineOffset(e,R){let W=R.get_font_description()||parseFontToDescription(e._state.font),Y=R.get_context().get_metrics(W,null),X=Y.get_ascent()/ie.SCALE,ae=Y.get_descent()/ie.SCALE,le=X+ae;switch(e._state.textBaseline){case`top`:return 0;case`hanging`:return-(X*.2);case`middle`:return-(le/2);case`alphabetic`:return-X;case`ideographic`:return-(X+ae*.5);case`bottom`:return-le;default:return-X}}const Li={fillText(e,R,Y,X){this._ensureSurface(),this._applyCompositing();let ie=createTextLayout(this,e),le=getTextAlignOffset(this,ie),_e=getTextBaselineOffset(this,ie);if(this._hasShadow()){let e=parseColor(this._state.shadowColor);if(e){let[X,ye]=this._deviceToUserDistance(this._state.shadowOffsetX,this._state.shadowOffsetY),be=this._state.shadowBlur,Ce;if(be>0){let[R]=this._deviceToUserDistance(be,0),[,W]=this._deviceToUserDistance(0,be);Ce=[[X,ye,e.a],[X+R,ye,e.a*.5],[X-R,ye,e.a*.5],[X,ye+W,e.a*.5],[X,ye-W,e.a*.5]]}else Ce=[[X,ye,e.a]];let Te=this._state.imageSmoothingEnabled?W.Antialias.DEFAULT:W.Antialias.NONE;for(let[W,X,ye]of Ce)this._ctx.save(),this._ctx.setAntialias(Te),this._ctx.setSourceRGBA(e.r,e.g,e.b,ye),this._ctx.moveTo(R+le+W,Y+_e+X),ae.show_layout(this._ctx,ie),this._ctx.restore()}}this._applyFillStyle(),this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?W.Antialias.DEFAULT:W.Antialias.NONE),this._ctx.moveTo(R+le,Y+_e),ae.show_layout(this._ctx,ie),this._ctx.restore()},strokeText(e,R,Y,X){this._ensureSurface(),this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle();let ie=createTextLayout(this,e),le=getTextAlignOffset(this,ie),_e=getTextBaselineOffset(this,ie);this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?W.Antialias.DEFAULT:W.Antialias.NONE),this._ctx.moveTo(R+le,Y+_e),ae.layout_path(this._ctx,ie),this._ctx.stroke(),this._ctx.restore()},measureText(e){this._ensureSurface();let R=createTextLayout(this,e),[W,Y]=R.get_pixel_extents(),X=R.get_baseline()/ie.SCALE,ae=Math.max(0,X-W.y),le=Math.max(0,W.y+W.height-X),_e=R.get_font_description()||parseFontToDescription(this._state.font),ye=R.get_context().get_metrics(_e,null),be=ye.get_ascent()/ie.SCALE,Ce=ye.get_descent()/ie.SCALE;return{width:Y.width,actualBoundingBoxAscent:ae,actualBoundingBoxDescent:le,actualBoundingBoxLeft:Math.max(0,-W.x),actualBoundingBoxRight:W.x+W.width,fontBoundingBoxAscent:be,fontBoundingBoxDescent:Ce,alphabeticBaseline:0,emHeightAscent:be,emHeightDescent:Ce,hangingBaseline:be*.8,ideographicBaseline:-Ce}}};function installTextMethods(e){Object.assign(e,Li)}const zi={createLinearGradient(e,R,W,Y){return new CanvasGradient(`linear`,e,R,W,Y)},createRadialGradient(e,R,W,Y,X,ie){return new CanvasGradient(`radial`,e,R,Y,X,W,ie)},createPattern(e,R){return ki.create(e,R)}};function installFactoryMethods(e){Object.assign(e,zi)}function installAllContextMethods$1(e){installTransformMethods(e),installPathMethods(e),installDrawingMethods$1(e),installPixelMethods(e),installTextMethods(e),installFactoryMethods(e)}__name$1(installAllContextMethods$1,`installAllContextMethods`);function createDefaultState(){return{fillStyle:`#000000`,fillColor:{...Si},strokeStyle:`#000000`,strokeColor:{...Si},lineWidth:1,lineCap:`butt`,lineJoin:`miter`,miterLimit:10,lineDash:[],lineDashOffset:0,globalAlpha:1,globalCompositeOperation:`source-over`,shadowColor:`rgba(0, 0, 0, 0)`,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,font:`10px sans-serif`,textAlign:`start`,textBaseline:`alphabetic`,direction:`ltr`,imageSmoothingEnabled:!0,imageSmoothingQuality:`low`}}function cloneState(e){return{...e,fillColor:{...e.fillColor},strokeColor:{...e.strokeColor},lineDash:[...e.lineDash]}}var CanvasRenderingContext2D=class{constructor(e,R){this._stateStack=[],this.canvas=e,this._surfaceWidth=e.width||300,this._surfaceHeight=e.height||150,this._surface=new W.ImageSurface(W.Format.ARGB32,this._surfaceWidth,this._surfaceHeight),this._ctx=new W.Context(this._surface),this._state=createDefaultState()}_ensureSurface(){let e=this.canvas.width||300,R=this.canvas.height||150;(e!==this._surfaceWidth||R!==this._surfaceHeight)&&(this._ctx.$dispose(),this._surface.finish(),this._surfaceWidth=e,this._surfaceHeight=R,this._surface=new W.ImageSurface(W.Format.ARGB32,e,R),this._ctx=new W.Context(this._surface),this._stateStack=[])}_resetState(){this._state=createDefaultState(),this._stateStack=[]}_applyFillStyle(){let e=this._state.fillStyle;if(typeof e==`string`){let e=this._state.fillColor,R=e.a*this._state.globalAlpha;this._ctx.setSourceRGBA(e.r,e.g,e.b,R)}else e instanceof CanvasGradient?this._ctx.setSource(e._getCairoPattern()):e instanceof ki&&(this._ctx.setSource(e._getCairoPattern()),this._applyPatternFilter())}_applyStrokeStyle(){let e=this._state.strokeStyle;if(typeof e==`string`){let e=this._state.strokeColor,R=e.a*this._state.globalAlpha;this._ctx.setSourceRGBA(e.r,e.g,e.b,R)}else e instanceof CanvasGradient?this._ctx.setSource(e._getCairoPattern()):e instanceof ki&&(this._ctx.setSource(e._getCairoPattern()),this._applyPatternFilter())}_applyPatternFilter(){let e=asCairoPattern(this._ctx.getSource?.());if(!e)return;let R;R=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?W.Filter.BEST:W.Filter.BILINEAR:W.Filter.NEAREST,e.setFilter(R)}_applyLineStyle(){this._ctx.setLineWidth(this._state.lineWidth),this._ctx.setLineCap(Ei[this._state.lineCap]),this._ctx.setLineJoin(Di[this._state.lineJoin]),this._ctx.setMiterLimit(this._state.miterLimit),this._ctx.setDash(this._state.lineDash,this._state.lineDashOffset)}_applyCompositing(){let e=Ti[this._state.globalCompositeOperation];e!==void 0&&this._ctx.setOperator(e)}_getSurface(){return this._surface}_hasShadow(){if(this._state.shadowBlur===0&&this._state.shadowOffsetX===0&&this._state.shadowOffsetY===0)return!1;let e=parseColor(this._state.shadowColor);return e!==null&&e.a>0}_deviceToUserDistance(e,R){let W=this._ctx.userToDevice(0,0),Y=this._ctx.userToDevice(1,0),X=this._ctx.userToDevice(0,1),ie=(Y[0]??0)-(W[0]??0),ae=(Y[1]??0)-(W[1]??0),le=(X[0]??0)-(W[0]??0),_e=(X[1]??0)-(W[1]??0),ye=ie*_e-ae*le;return Math.abs(ye)<1e-10?[e,R]:[(_e*e-le*R)/ye,(-ae*e+ie*R)/ye]}_renderShadow(e){}save(){this._ensureSurface(),this._stateStack.push(cloneState(this._state)),this._ctx.save()}restore(){this._ensureSurface();let e=this._stateStack.pop();e&&(this._state=e,this._ctx.restore())}get fillStyle(){return this._state.fillStyle}set fillStyle(e){if(typeof e==`string`){let R=parseColor(e);R&&(this._state.fillStyle=e,this._state.fillColor=R)}else this._state.fillStyle=e}get strokeStyle(){return this._state.strokeStyle}set strokeStyle(e){if(typeof e==`string`){let R=parseColor(e);R&&(this._state.strokeStyle=e,this._state.strokeColor=R)}else this._state.strokeStyle=e}get lineWidth(){return this._state.lineWidth}set lineWidth(e){e>0&&isFinite(e)&&(this._state.lineWidth=e)}get lineCap(){return this._state.lineCap}set lineCap(e){(e===`butt`||e===`round`||e===`square`)&&(this._state.lineCap=e)}get lineJoin(){return this._state.lineJoin}set lineJoin(e){(e===`miter`||e===`round`||e===`bevel`)&&(this._state.lineJoin=e)}get miterLimit(){return this._state.miterLimit}set miterLimit(e){e>0&&isFinite(e)&&(this._state.miterLimit=e)}get globalAlpha(){return this._state.globalAlpha}set globalAlpha(e){e>=0&&e<=1&&isFinite(e)&&(this._state.globalAlpha=e)}get globalCompositeOperation(){return this._state.globalCompositeOperation}set globalCompositeOperation(e){Ti[e]!==void 0&&(this._state.globalCompositeOperation=e)}get imageSmoothingEnabled(){return this._state.imageSmoothingEnabled}set imageSmoothingEnabled(e){this._state.imageSmoothingEnabled=!!e}get imageSmoothingQuality(){return this._state.imageSmoothingQuality}set imageSmoothingQuality(e){(e===`low`||e===`medium`||e===`high`)&&(this._state.imageSmoothingQuality=e)}setLineDash(e){e.some(e=>e<0||!isFinite(e))||(this._state.lineDash=[...e])}getLineDash(){return[...this._state.lineDash]}get lineDashOffset(){return this._state.lineDashOffset}set lineDashOffset(e){isFinite(e)&&(this._state.lineDashOffset=e)}get shadowColor(){return this._state.shadowColor}set shadowColor(e){this._state.shadowColor=e}get shadowBlur(){return this._state.shadowBlur}set shadowBlur(e){e>=0&&isFinite(e)&&(this._state.shadowBlur=e)}get shadowOffsetX(){return this._state.shadowOffsetX}set shadowOffsetX(e){isFinite(e)&&(this._state.shadowOffsetX=e)}get shadowOffsetY(){return this._state.shadowOffsetY}set shadowOffsetY(e){isFinite(e)&&(this._state.shadowOffsetY=e)}get font(){return this._state.font}set font(e){this._state.font=e}get textAlign(){return this._state.textAlign}set textAlign(e){this._state.textAlign=e}get textBaseline(){return this._state.textBaseline}set textBaseline(e){this._state.textBaseline=e}get direction(){return this._state.direction}set direction(e){this._state.direction=e}_toDataURL(e,R){this._surface.flush();let W=imports.gi.Gio,Y=imports.gi.GLib,[,X]=Y.file_open_tmp(`canvas-XXXXXX.png`);try{this._surface.writeToPNG(X);let[,e]=W.File.new_for_path(X).load_contents(null);return`data:image/png;base64,${Y.base64_encode(e)}`}finally{try{Y.unlink(X)}catch{}}}_dispose(){this._ctx.$dispose(),this._surface.finish()}};installAllContextMethods$1(CanvasRenderingContext2D.prototype),defineGlobal(`HTMLCanvasElement`,gi),defineGlobal(`CanvasRenderingContext2D`,CanvasRenderingContext2D),defineGlobal(`DOMMatrix`,_i),defineGlobal(`DOMMatrixReadOnly`,yi);const Vi=Symbol.for(`gjsify_canvas2d_context`);gi.registerContextFactory(`2d`,(e,R)=>{let W=e,Y=W[Vi];if(Y)return Y;let X=new CanvasRenderingContext2D(e,R);return W[Vi]=X,X});var CharacterData=class extends ni{constructor(e=``){super(),this[Wt]=ir.TEXT_NODE,this._data=e}get data(){return this._data}set data(e){this._data=e}get textContent(){return this._data}set textContent(e){this._data=e}get nodeValue(){return this._data}set nodeValue(e){this._data=e}get length(){return this._data.length}appendData(e){this._data+=e}deleteData(e,R){this._data=this._data.substring(0,e)+this._data.substring(e+R)}insertData(e,R){this._data=this._data.substring(0,e)+R+this._data.substring(e)}replaceData(e,R,W){this._data=this._data.substring(0,e)+W+this._data.substring(e+R)}substringData(e,R){return this._data.substring(e,e+R)}cloneNode(e=!1){return new this.constructor(this._data)}get[Symbol.toStringTag](){return`CharacterData`}},Hi=class Comment extends CharacterData{constructor(e=``){super(e),this[Wt]=ir.COMMENT_NODE}get nodeName(){return`#comment`}cloneNode(e=!1){return new Comment(this.data)}get[Symbol.toStringTag](){return`Comment`}},Ui=class Text extends CharacterData{constructor(e=``){super(e),this[Wt]=ir.TEXT_NODE}get nodeName(){return`#text`}get wholeText(){let e=this.data,R=this.previousSibling;for(;R&&R instanceof Text;)e=R.data+e,R=R.previousSibling;let W=this.nextSibling;for(;W&&W instanceof Text;)e+=W.data,W=W.nextSibling;return e}splitText(e){let R=this.data.substring(e);this.data=this.data.substring(0,e);let W=new Text(R);return this.parentNode&&this.parentNode.insertBefore(W,this.nextSibling),W}cloneNode(e=!1){return new Text(this.data)}get[Symbol.toStringTag](){return`Text`}},Wi=class DocumentFragment extends ni{constructor(){super(),this[Wt]=ir.DOCUMENT_FRAGMENT_NODE}get nodeName(){return`#document-fragment`}get children(){return this[qt]}get childElementCount(){return this[qt].length}get firstElementChild(){return this[qt][0]??null}get lastElementChild(){let e=this[qt];return e[e.length-1]??null}get textContent(){let e=``;for(let R of this.childNodes)R.textContent!==null&&(e+=R.textContent);return e}set textContent(e){for(;this.firstChild;)this.removeChild(this.firstChild);e&&this.appendChild(new Ui(e))}append(...e){for(let R of e)typeof R==`string`?this.appendChild(new Ui(R)):this.appendChild(R)}prepend(...e){let R=this.firstChild;for(let W of e)typeof W==`string`?this.insertBefore(new Ui(W),R):this.insertBefore(W,R)}replaceChildren(...e){for(;this.firstChild;)this.removeChild(this.firstChild);this.append(...e)}getElementById(e){for(let R of this.children){if(R.id===e)return R;let W=this._findById(R,e);if(W)return W}return null}_findById(e,R){for(let W of e.children){if(W.id===R)return W;let e=this._findById(W,R);if(e)return e}return null}cloneNode(e=!1){let R=new DocumentFragment;if(e)for(let e of this.childNodes)R.appendChild(e.cloneNode(!0));return R}get[Symbol.toStringTag](){return`DocumentFragment`}},Gi=le;xt(),$e(),st();var HTMLImageElement=class extends HTMLElement$1{constructor(){super(),this._complete=!1,this._naturalHeight=0,this._naturalWidth=0,this[Yt]=`IMG`,this[Xt]=`img`,this[Zt]=ii.html}get complete(){return this._complete}get naturalHeight(){return this._naturalHeight}get naturalWidth(){return this._naturalWidth}get currentSrc(){return this.src}get x(){return 0}get y(){return 0}get alt(){return this.getAttribute(`alt`)??``}set alt(e){this.setAttribute(`alt`,e)}get crossOrigin(){return this.getAttribute(`crossorigin`)}set crossOrigin(e){e===null?this.removeAttribute(`crossorigin`):this.setAttribute(`crossorigin`,e)}get decoding(){return this.getAttribute(`decoding`)??`auto`}set decoding(e){this.setAttribute(`decoding`,e)}get loading(){let e=this.getAttribute(`loading`);return e===`lazy`||e===`eager`?e:`auto`}set loading(e){this.setAttribute(`loading`,e)}get referrerPolicy(){return this.getAttribute(`referrerpolicy`)??``}set referrerPolicy(e){this.setAttribute(`referrerpolicy`,e)}get sizes(){return this.getAttribute(`sizes`)??``}set sizes(e){this.setAttribute(`sizes`,e)}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,e);let R=globalThis.__GJSIFY_DEBUG_IMG===!0;if(e.startsWith(`data:`)){let W=e.indexOf(`,`);if(W===-1){this._complete=!0,this.dispatchEvent(new Event$1(`error`));return}let Y=e.slice(5,W),X=e.slice(W+1),ie=Y.includes(`;base64`);try{let e;e=ie?Qe.base64_decode(X):new TextEncoder().encode(decodeURIComponent(X));let W=Qe.Bytes.new(e),Y=at.MemoryInputStream.new_from_bytes(W);this._pixbuf=Gi.Pixbuf.new_from_stream(Y,null),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,R&&bt.log(`[img] ok data: (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event$1(`load`))}catch(e){R&&bt.warn(`[img] error data:: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new Event$1(`error`))}return}let W;if(e.startsWith(`file://`))W=Qe.filename_from_uri(e)[0];else if(e.startsWith(`http://`)||e.startsWith(`https://`)){this._complete=!0,this.dispatchEvent(new Event$1(`error`));return}else{let R=Qe.path_get_dirname(_e.programInvocationName);W=Qe.build_filenamev([R,e])}try{R&&bt.log(`[img] load ${W}`),this._pixbuf=Gi.Pixbuf.new_from_file(W),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,R&&bt.log(`[img] ok ${W} (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event$1(`load`))}catch(e){R&&bt.warn(`[img] error ${W}: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new Event$1(`error`))}}get srcset(){return this.getAttribute(`srcset`)??``}set srcset(e){this.setAttribute(`srcset`,e)}get useMap(){return this.getAttribute(`usemap`)??``}set useMap(e){this.setAttribute(`usemap`,e)}get height(){if(this._pixbuf)return this._pixbuf.get_height();let e=this.getAttribute(`height`);return e===null?0:Number(e)}set height(e){this.setAttribute(`height`,String(e))}get width(){if(this._pixbuf)return this._pixbuf.get_width();let e=this.getAttribute(`width`);return e===null?0:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get isMap(){return this.hasAttribute(`ismap`)}set isMap(e){e?this.setAttribute(`ismap`,``):this.removeAttribute(`ismap`)}decode(){return Promise.resolve()}cloneNode(e=!1){return super.cloneNode(e)}getImageData(){if(!this._pixbuf)return null;let e=this._pixbuf.get_has_alpha()?this._pixbuf:this._pixbuf.add_alpha(!1,0,0,0)??this._pixbuf;return{colorSpace:`srgb`,data:new Uint8ClampedArray(e.get_pixels()),height:e.get_height(),width:e.get_width()}}isPixbuf(){return!!this._pixbuf}get[Symbol.toStringTag](){return`HTMLImageElement`}},HTMLMediaElement=class extends HTMLElement$1{constructor(...e){super(...e),this._src=``,this._srcObject=null,this.currentTime=0,this.duration=NaN,this.paused=!0,this.ended=!1,this.volume=1,this.muted=!1,this.defaultMuted=!1,this.loop=!1,this.autoplay=!1,this.preload=``,this.playbackRate=1,this.defaultPlaybackRate=1,this.readyState=0,this.networkState=0}get buffered(){return{length:0,start:()=>0,end:()=>0}}get seekable(){return{length:0,start:()=>0,end:()=>0}}get played(){return{length:0,start:()=>0,end:()=>0}}get src(){return this._src}set src(e){this._src=e,this._srcObject=null,this.dispatchEvent(new Event$1(`srcchange`))}get srcObject(){return this._srcObject}set srcObject(e){this._srcObject=e,this._src=``,this.dispatchEvent(new Event$1(`srcobjectchange`))}play(){return this.paused=!1,this.ended=!1,this.dispatchEvent(new Event$1(`play`)),Promise.resolve()}pause(){this.paused=!0,this.dispatchEvent(new Event$1(`pause`))}load(){this.readyState=0,this.networkState=2,this.dispatchEvent(new Event$1(`loadstart`))}canPlayType(e){return``}static{this.HAVE_NOTHING=0}static{this.HAVE_METADATA=1}static{this.HAVE_CURRENT_DATA=2}static{this.HAVE_FUTURE_DATA=3}static{this.HAVE_ENOUGH_DATA=4}static{this.NETWORK_EMPTY=0}static{this.NETWORK_IDLE=1}static{this.NETWORK_LOADING=2}static{this.NETWORK_NO_SOURCE=3}get[Symbol.toStringTag](){return`HTMLMediaElement`}};const Ki=1e9;function secondsToGstTime(e){return BigInt(Math.round(e*Ki))}function gstTimeToSeconds(e){return Number(e)/Ki}var HTMLVideoElement=class extends HTMLMediaElement{constructor(){super(),this._pipeline=null,this._videoWidth=0,this._videoHeight=0,this.poster=``,this[Yt]=`VIDEO`,this[Xt]=`video`,this[Zt]=ii.html;let e=this;Object.defineProperty(this,"paused",{get(){if(!e._pipeline)return!0;let[,R]=e._pipeline.get_state(0n);return R!==4},configurable:!0,enumerable:!0}),Object.defineProperty(this,"currentTime",{get(){if(!e._pipeline)return 0;let[R,W]=e._pipeline.query_position(3);return R?gstTimeToSeconds(W):0},set(R){e._pipeline?.seek(1,3,5,1,secondsToGstTime(R),0,-1n)},configurable:!0,enumerable:!0}),Object.defineProperty(this,"duration",{get(){if(!e._pipeline)return NaN;let[R,W]=e._pipeline.query_duration(3);return R&&Number(W)>0?gstTimeToSeconds(W):NaN},configurable:!0,enumerable:!0}),Object.defineProperty(this,"volume",{get(){return e._playbin()?.volume??1},set(R){let W=e._playbin();W&&(W.volume=Math.max(0,Math.min(1,R)))},configurable:!0,enumerable:!0}),Object.defineProperty(this,"muted",{get(){return e._playbin()?.mute??!1},set(R){let W=e._playbin();W&&(W.mute=R)},configurable:!0,enumerable:!0})}async play(){this._pipeline?.set_state(4),this.dispatchEvent(new Event$1(`play`)),this.dispatchEvent(new Event$1(`playing`))}pause(){this._pipeline?.set_state(3),this.dispatchEvent(new Event$1(`pause`))}get videoWidth(){return this._videoWidth}set videoWidth(e){this._videoWidth=e}get videoHeight(){return this._videoHeight}set videoHeight(e){this._videoHeight=e}get[Symbol.toStringTag](){return`HTMLVideoElement`}_playbin(){return this._pipeline?.get_by_name(`playbin`)??null}};const qi=new class Document extends ni{static{this._elementFactories=new Map}constructor(){super(),this.body=new HTMLElement$1,this.head=new HTMLElement$1,this.documentElement=new HTMLElement$1,this.appendChild(this.documentElement),this.documentElement.appendChild(this.body)}static registerElementFactory(e,R){Document._elementFactories.set(e.toLowerCase(),R)}createElementNS(e,R){let W=R.toLowerCase();switch(W){case`img`:return new HTMLImageElement;case`video`:return new HTMLVideoElement;case`canvas`:return new gi;default:{let e=Document._elementFactories.get(W);return e?e():new HTMLElement$1}}}createElement(e){return this.createElementNS(`http://www.w3.org/1999/xhtml`,e)}createTextNode(e){return new Ui(e)}createComment(e){return new Hi(e)}createDocumentFragment(){return new Wi}createEvent(e){return new Event$1(e)}getElementById(e){return this._findById(this.body,e)}_findById(e,R){if(e.id===R)return e;for(let W of e.children){let e=this._findById(W,R);if(e)return e}return null}get[Symbol.toStringTag](){return`Document`}};var DOMTokenList=class{constructor(e,R){this._ownerElement=e,this._attributeName=R}_getTokens(){let e=this._ownerElement.getAttribute(this._attributeName);return e?e.split(/\s+/).filter(e=>e.length>0):[]}_setTokens(e){let R=e.join(` `);R?this._ownerElement.setAttribute(this._attributeName,R):this._ownerElement.removeAttribute(this._attributeName)}get length(){return this._getTokens().length}get value(){return this._ownerElement.getAttribute(this._attributeName)??``}set value(e){e?this._ownerElement.setAttribute(this._attributeName,e):this._ownerElement.removeAttribute(this._attributeName)}item(e){let R=this._getTokens();return e>=0&&e<R.length?R[e]:null}contains(e){return this._getTokens().includes(e)}add(...e){let R=this._getTokens();for(let W of e)W&&!R.includes(W)&&R.push(W);this._setTokens(R)}remove(...e){let R=this._getTokens().filter(R=>!e.includes(R));this._setTokens(R)}toggle(e,R){let W=this.contains(e);return R===void 0?W?(this.remove(e),!1):(this.add(e),!0):R?(this.add(e),!0):(this.remove(e),!1)}replace(e,R){let W=this._getTokens(),Y=W.indexOf(e);return Y===-1?!1:(W[Y]=R,this._setTokens(W),!0)}supports(e){return!0}forEach(e){let R=this._getTokens();for(let W=0;W<R.length;W++)e(R[W],W,this)}keys(){return this._getTokens().keys()}values(){return this._getTokens().values()}entries(){return this._getTokens().entries()}[Symbol.iterator](){return this._getTokens().values()}toString(){return this.value}get[Symbol.toStringTag](){return`DOMTokenList`}};xt(),defineGlobal(`Text`,Ui),defineGlobal(`Comment`,Hi),defineGlobal(`DocumentFragment`,Wi),defineGlobal(`DOMTokenList`,DOMTokenList),defineGlobal(`document`,qi),defineGlobalIfMissing(`self`,globalThis);var Window$1=class{static{__name$1(this,`Window`)}};defineGlobalIfMissing(`Window`,Window$1),defineGlobalIfMissing(`window`,globalThis),defineGlobalIfMissing(`focus`,()=>{}),defineGlobalIfMissing(`blur`,()=>{});{let e=globalThis;if(typeof e.addEventListener!=`function`){let R=new EventTarget$1;e.__gjsify_globalEventTarget=R,e.addEventListener=(e,W,Y)=>R.addEventListener(e,W,Y),e.removeEventListener=(e,W,Y)=>R.removeEventListener(e,W,Y),e.dispatchEvent=e=>R.dispatchEvent(e)}}defineGlobalIfMissing(`devicePixelRatio`,1),defineGlobalIfMissing(`scrollX`,0),defineGlobalIfMissing(`scrollY`,0),defineGlobalIfMissing(`pageXOffset`,0),defineGlobalIfMissing(`pageYOffset`,0),defineGlobalIfMissing(`alert`,(...e)=>bt.error(`alert:`,...e)),globalThis.top===void 0&&Object.defineProperty(globalThis,"top",{get:()=>globalThis,configurable:!0});var FontFace$1=class{static{__name$1(this,`FontFace`)}constructor(e,R,W){this.status=`unloaded`,this.display=`auto`,this.style=`normal`,this.weight=`normal`,this.stretch=`normal`,this.unicodeRange=`U+0-10FFFF`,this.variant=`normal`,this.featureSettings=`normal`,this.family=e,this.source=typeof R==`string`?R:`[binary]`,this.loaded=Promise.resolve(this)}_extractFilePath(){let e=this.source.match(/url\s*\(\s*["']?(file:\/\/\/[^"')]+)["']?\s*\)/i);return e?e[1].replace(/^file:\/\//,``):null}async load(){this.status=`loading`;let e=this._extractFilePath();if(e)try{let{default:R}=await import(`gi://PangoCairo?version=1.0`);R.font_map_get_default().add_font_file(e)}catch{}return this.status=`loaded`,this}},FontFaceSet=class{constructor(){this.status=`loaded`,this.ready=Promise.resolve(this),this._faces=new Set}addEventListener(e,R){}removeEventListener(e,R){}dispatchEvent(e){return!0}add(e){return this._faces.add(e),this}delete(e){return this._faces.delete(e)}clear(){this._faces.clear()}has(e){return this._faces.has(e)}check(e,R){return!1}load(e,R){return Promise.resolve([])}forEach(e){this._faces.forEach(R=>e(R,R,this))}values(){return this._faces.values()}keys(){return this._faces.values()}entries(){return Array.from(this._faces).map(e=>[e,e])[Symbol.iterator]()}[Symbol.iterator](){return this._faces[Symbol.iterator]()}get size(){return this._faces.size}};const Ji=globalThis;defineGlobalIfMissing(`FontFace`,FontFace$1),Ji.FontFace===void 0&&(Ji.FontFace=FontFace$1);const Xi=Ji.document;Xi&&Xi.fonts===void 0&&Object.defineProperty(Xi,"fonts",{value:new FontFaceSet,configurable:!0,writable:!0});var Image$1=class extends HTMLImageElement{static{__name$1(this,`Image`)}constructor(e=null,R=null){super(),e!==null&&(this.width=e),R!==null&&(this.height=R)}};defineGlobal(`HTMLImageElement`,HTMLImageElement),defineGlobal(`Image`,Image$1),defineGlobalIfMissing(`location`,{href:`file://`,origin:`file://`,protocol:`file:`,host:``,hostname:``,port:``,pathname:`/`,search:``,hash:``,assign(e){},replace(e){},reload(){},toString(){return this.href},ancestorOrigins:{length:0,item:()=>null,contains:()=>!1,[Symbol.iterator]:function*(){}}});var MediaQueryList=class extends EventTarget$1{constructor(e){super(),this.onchange=null,this.media=e,this.matches=!1}addListener(e){}removeListener(e){}};function matchMedia(e){return new MediaQueryList(e)}defineGlobalIfMissing(`matchMedia`,matchMedia),globalThis.navigator===void 0&&(globalThis.navigator={});var MutationObserver=class{constructor(e){}observe(e,R){}disconnect(){}takeRecords(){return[]}};xt();const $i=new Set;let na=!1;function scheduleFlush(){na||(na=!0,queueMicrotask(()=>{na=!1;let e=Array.from($i);$i.clear();for(let R of e)R._deliver()}))}var ResizeObserver$1=class{static{__name$1(this,`ResizeObserver`)}constructor(e){this._observed=new Map,this._pending=new Map,this._callback=e}observe(e,R){if(this._observed.has(e))return;let W=e._onResize((R,W)=>{this._enqueue(e,R,W)});this._observed.set(e,W),queueMicrotask(()=>{if(!this._observed.has(e))return;let R=readClientRect(e);this._enqueue(e,R.width,R.height)})}unobserve(e){let R=this._observed.get(e);R&&(R(),this._observed.delete(e),this._pending.delete(e))}disconnect(){for(let e of this._observed.values())e();this._observed.clear(),this._pending.clear(),$i.delete(this)}_deliver(){if(this._pending.size===0)return;let e=Array.from(this._pending.values());this._pending.clear();try{this._callback(e,this)}catch(e){bt.error(`ResizeObserver callback threw:`,e)}}_enqueue(e,R,W){let Y={inlineSize:R,blockSize:W};this._pending.set(e,{target:e,contentRect:{x:0,y:0,width:R,height:W,top:0,right:R,bottom:W,left:0},borderBoxSize:[Y],contentBoxSize:[Y],devicePixelContentBoxSize:[Y]}),$i.add(this),scheduleFlush()}};function readClientRect(e){let R=e.getBoundingClientRect;if(typeof R==`function`){let W=R.call(e);return{width:W.width??0,height:W.height??0}}return{width:0,height:0}}var IntersectionObserver=class{constructor(e,R){this.root=R?.root??null,this.rootMargin=R?.rootMargin??`0px`,this.thresholds=Array.isArray(R?.threshold)?R.threshold:[R?.threshold??0]}observe(e){}unobserve(e){}disconnect(){}takeRecords(){return[]}};defineGlobal(`MutationObserver`,MutationObserver),defineGlobal(`ResizeObserver`,ResizeObserver$1),defineGlobal(`IntersectionObserver`,IntersectionObserver);var DOMNode=class{nodeType;nodeName;nodeValue;parentNode=null;childNodes=[];constructor(e,R,W=null){this.nodeType=e,this.nodeName=R,this.nodeValue=W}get textContent(){return this.nodeType===3||this.nodeType===4?this.nodeValue??``:this.childNodes.map(e=>e.textContent??``).join(``)}},DOMElement=class extends DOMNode{tagName;localName;_attrs=new Map;constructor(e){super(1,e.toUpperCase()),this.tagName=e.toLowerCase(),this.localName=this.tagName}get children(){return this.childNodes.filter(e=>e.nodeType===1)}getAttribute(e){return this._attrs.has(e)?this._attrs.get(e)??null:null}setAttribute(e,R){this._attrs.set(e,R)}hasAttribute(e){return this._attrs.has(e)}get attributes(){return Array.from(this._attrs.entries()).map(([e,R])=>({name:e,value:R}))}get innerHTML(){return this.childNodes.map(e=>e.nodeType===1?e.outerHTML:e.nodeType===3?e.nodeValue??``:e.nodeType===4?`<![CDATA[`+(e.nodeValue??``)+`]]>`:``).join(``)}get outerHTML(){let e=Array.from(this._attrs.entries()).map(([e,R])=>` `+e+`="`+R.replace(/"/g,`"`)+`"`).join(``);return this.childNodes.length===0?`<`+this.tagName+e+`/>`:`<`+this.tagName+e+`>`+this.innerHTML+`</`+this.tagName+`>`}querySelector(e){let R=e.trim().split(/\s*>\s*/);if(R.length>1)return this._queryChildChain(R);let W=e.trim().split(/\s+/);return W.length>1?this._queryDescendantChain(W):this._find(e.trim().toLowerCase())??null}querySelectorAll(e){let R=e.trim().toLowerCase(),W=[];return this._findAll(R,W),W}_find(e){for(let R of this.children){if(R.tagName===e)return R;let W=R._find(e);if(W)return W}}_findAll(e,R){for(let W of this.children)W.tagName===e&&R.push(W),W._findAll(e,R)}_queryChildChain(e){let[R,...W]=e,Y=this.children.filter(e=>e.tagName===R.trim().toLowerCase());if(W.length===0)return Y[0]??null;for(let e of Y){let R=e._queryChildChain(W);if(R)return R}return null}_queryDescendantChain(e){let[R,...W]=e,Y=[];if(this._findAll(R.trim().toLowerCase(),Y),W.length===0)return Y[0]??null;for(let e of Y){let R=e._queryDescendantChain(W);if(R)return R}return null}},DOMDocument=class extends DOMElement{documentElement=null;constructor(){super(`#document`),this.nodeType=9,this.nodeName=`#document`}querySelector(e){if(this.documentElement){let R=e.trim().toLowerCase();return this.documentElement.tagName===R?this.documentElement:this.documentElement.querySelector(e)}return super.querySelector(e)}querySelectorAll(e){let R=e.trim().toLowerCase(),W=[];return this.documentElement&&(this.documentElement.tagName===R&&W.push(this.documentElement),this.documentElement._findAll(R,W)),W}};const aa=/\s+([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+))/g;function parseAttributes(e,R){let W;for(aa.lastIndex=0;(W=aa.exec(e))!==null;)R.setAttribute(W[1],W[2]??W[3]??W[4]??``)}function parseXml(e){let R=new DOMDocument,W=[R],Y=0,X=e.length;for(;Y<X;){let ie=e.indexOf(`<`,Y);if(ie===-1){let R=e.slice(Y);if(R.trim()){let e=new DOMNode(3,`#text`,R),Y=W[W.length-1];e.parentNode=Y,Y.childNodes.push(e)}break}if(ie>Y){let R=e.slice(Y,ie);if(R.trim()){let e=new DOMNode(3,`#text`,R),Y=W[W.length-1];e.parentNode=Y,Y.childNodes.push(e)}}if(e.startsWith(`<![CDATA[`,ie)){let R=e.indexOf(`]]>`,ie);if(R===-1)break;let X=new DOMNode(4,`#cdata-section`,e.slice(ie+9,R)),ae=W[W.length-1];X.parentNode=ae,ae.childNodes.push(X),Y=R+3;continue}if(e.startsWith(`<!--`,ie)){let R=e.indexOf(`-->`,ie);Y=R===-1?X:R+3;continue}if(e.startsWith(`<?`,ie)||e.startsWith(`<!`,ie)){let R=e.indexOf(`>`,ie);Y=R===-1?X:R+1;continue}let ae=findTagEnd(e,ie+1);if(ae===-1)break;let le=e.slice(ie+1,ae);if(le.startsWith(`/`)){W.length>1&&W.pop(),Y=ae+1;continue}let _e=le.endsWith(`/`),ye=_e?le.slice(0,-1):le,be=ye.search(/\s/),Ce=(be===-1?ye:ye.slice(0,be)).trim();if(!Ce){Y=ae+1;continue}let Te=new DOMElement(Ce);be!==-1&&parseAttributes(ye.slice(be),Te);let Oe=W[W.length-1];Te.parentNode=Oe,Oe.childNodes.push(Te),Oe===R&&!R.documentElement&&(R.documentElement=Te),_e||W.push(Te),Y=ae+1}return R}function findTagEnd(e,R){let W=!1,Y=!1;for(let X=R;X<e.length;X++){let R=e[X];if(R===`"`&&!W){Y=!Y;continue}if(R===`'`&&!Y){W=!W;continue}if(R===`>`&&!W&&!Y)return X}return-1}var DOMParser$1=class{static{__name$1(this,`DOMParser`)}parseFromString(e,R){return parseXml(e)}};const sa=globalThis;sa.DOMParser===void 0&&(sa.DOMParser=DOMParser$1);var GamepadEvent=class extends Event$1{gamepad;constructor(e,R){super(e,R),this.gamepad=R.gamepad}get[Symbol.toStringTag](){return`GamepadEvent`}};const ca={LEFT_X:0,LEFT_Y:1,RIGHT_X:2,RIGHT_Y:3,LEFT_TRIGGER:4,RIGHT_TRIGGER:5},da={LEFT_STICK_X:0,LEFT_STICK_Y:1,RIGHT_STICK_X:2,RIGHT_STICK_Y:3},pa=new Map([[ca.LEFT_X,da.LEFT_STICK_X],[ca.LEFT_Y,da.LEFT_STICK_Y],[ca.RIGHT_X,da.RIGHT_STICK_X],[ca.RIGHT_Y,da.RIGHT_STICK_Y]]),_a=.5,ya={BTN_SOUTH:304,BTN_EAST:305,BTN_C:306,BTN_NORTH:307,BTN_WEST:308,BTN_Z:309,BTN_TL:310,BTN_TR:311,BTN_TL2:312,BTN_TR2:313,BTN_SELECT:314,BTN_START:315,BTN_MODE:316,BTN_THUMBL:317,BTN_THUMBR:318,BTN_DPAD_UP:544,BTN_DPAD_DOWN:545,BTN_DPAD_LEFT:546,BTN_DPAD_RIGHT:547},ba={FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,LEFT_BUMPER:4,RIGHT_BUMPER:5,LEFT_TRIGGER:6,RIGHT_TRIGGER:7,SELECT:8,START:9,LEFT_STICK:10,RIGHT_STICK:11,DPAD_UP:12,DPAD_DOWN:13,DPAD_LEFT:14,DPAD_RIGHT:15,HOME:16},xa=new Map([[ya.BTN_SOUTH,ba.FACE_1],[ya.BTN_EAST,ba.FACE_2],[ya.BTN_WEST,ba.FACE_3],[ya.BTN_NORTH,ba.FACE_4],[ya.BTN_TL,ba.LEFT_BUMPER],[ya.BTN_TR,ba.RIGHT_BUMPER],[ya.BTN_TL2,ba.LEFT_TRIGGER],[ya.BTN_TR2,ba.RIGHT_TRIGGER],[ya.BTN_SELECT,ba.SELECT],[ya.BTN_START,ba.START],[ya.BTN_THUMBL,ba.LEFT_STICK],[ya.BTN_THUMBR,ba.RIGHT_STICK],[ya.BTN_DPAD_UP,ba.DPAD_UP],[ya.BTN_DPAD_DOWN,ba.DPAD_DOWN],[ya.BTN_DPAD_LEFT,ba.DPAD_LEFT],[ya.BTN_DPAD_RIGHT,ba.DPAD_RIGHT],[ya.BTN_MODE,ba.HOME]]);var GamepadButton=class{pressed;touched;value;constructor(e=!1,R=!1,W=0){this.pressed=e,this.touched=R,this.value=W}get[Symbol.toStringTag](){return`GamepadButton`}},Gamepad$1=class{static{__name$1(this,`Gamepad`)}id;index;connected;timestamp;mapping;axes;buttons;vibrationActuator;constructor(e){this.id=e.id,this.index=e.index,this.connected=e.connected,this.timestamp=e.timestamp,this.mapping=e.mapping,this.axes=Object.freeze([...e.axes]),this.buttons=Object.freeze(e.buttons),this.vibrationActuator=e.vibrationActuator??null}get[Symbol.toStringTag](){return`Gamepad`}},ManetteHapticActuator=class{effects;_device;constructor(e){this._device=e,this.effects=e.has_rumble()?[`dual-rumble`]:[]}playEffect(e,R){if(e!==`dual-rumble`||!this._device.has_rumble())return Promise.resolve(`complete`);let W=R?.duration??200,Y=Math.round((R?.strongMagnitude??1)*65535),X=Math.round((R?.weakMagnitude??1)*65535);return this._device.rumble(Y,X,Math.min(W,32767)),Promise.resolve(`complete`)}reset(){return this._device.has_rumble()&&this._device.rumble(0,0,0),Promise.resolve(`complete`)}},GamepadManager=class{_monitor=null;_slots=Array.from({length:4}).fill(null);_monitorSignalIds=[];_ManetteModule=null;_initPromise=null;_initialized=!1;_ensureInit(){this._initialized||(this._initPromise||=this._init())}async _init(){try{let e=await import(`gi://Manette`);this._ManetteModule=e.default}catch{this._initialized=!0;return}let e=new this._ManetteModule.Monitor;this._monitor=e;let R=e.iterate(),W=R.next();for(;W[0];){let e=W[1];e&&this._onDeviceConnected(e),W=R.next()}this._monitorSignalIds.push(e.connect(`device-connected`,(e,R)=>{this._onDeviceConnected(R)}),e.connect(`device-disconnected`,(e,R)=>{this._onDeviceDisconnected(R)})),this._initialized=!0}_onDeviceConnected(e){let R=-1;for(let e=0;e<4;e++)if(this._slots[e]===null){R=e;break}if(R===-1)return;let W={device:e,index:R,connected:!0,timestamp:performance.now(),buttons:new Float64Array(17),buttonsPressed:Array.from({length:17}).fill(!1),axes:new Float64Array(4),hapticActuator:new ManetteHapticActuator(e),signalIds:[]};W.signalIds.push(e.connect(`button-press-event`,(e,R)=>{this._onButtonPress(W,R)}),e.connect(`button-release-event`,(e,R)=>{this._onButtonRelease(W,R)}),e.connect(`absolute-axis-event`,(e,R)=>{this._onAxisChange(W,R)}),e.connect(`hat-axis-event`,(e,R)=>{this._onHatChange(W,R)}),e.connect(`disconnected`,()=>{this._onDeviceDisconnected(e)})),this._slots[R]=W;let Y=this._createSnapshot(W);Y&&globalThis.dispatchEvent?.(new GamepadEvent(`gamepadconnected`,{gamepad:Y}))}_onDeviceDisconnected(e){let R=this._findStateByDevice(e);if(!R)return;for(let W of R.signalIds)e.disconnect(W);R.connected=!1;let W=this._createSnapshot(R);this._slots[R.index]=null,W&&globalThis.dispatchEvent?.(new GamepadEvent(`gamepaddisconnected`,{gamepad:W}))}_onButtonPress(e,R){let[W,Y]=R.get_button();if(!W)return;let X=xa.get(Y);X!==void 0&&(e.buttons[X]=1,e.buttonsPressed[X]=!0,e.timestamp=performance.now())}_onButtonRelease(e,R){let[W,Y]=R.get_button();if(!W)return;let X=xa.get(Y);X!==void 0&&(e.buttons[X]=0,e.buttonsPressed[X]=!1,e.timestamp=performance.now())}_onAxisChange(e,R){let[W,Y,X]=R.get_absolute();if(!W)return;let ie=pa.get(Y);if(ie!==void 0)e.axes[ie]=X;else if(Y===ca.LEFT_TRIGGER){let R=(X+1)/2;e.buttons[ba.LEFT_TRIGGER]=R,e.buttonsPressed[ba.LEFT_TRIGGER]=R>_a}else if(Y===ca.RIGHT_TRIGGER){let R=(X+1)/2;e.buttons[ba.RIGHT_TRIGGER]=R,e.buttonsPressed[ba.RIGHT_TRIGGER]=R>_a}e.timestamp=performance.now()}_onHatChange(e,R){let[W,Y,X]=R.get_hat();W&&(Y===0?(e.buttonsPressed[ba.DPAD_LEFT]=X<0,e.buttons[ba.DPAD_LEFT]=+(X<0),e.buttonsPressed[ba.DPAD_RIGHT]=X>0,e.buttons[ba.DPAD_RIGHT]=+(X>0)):Y===1&&(e.buttonsPressed[ba.DPAD_UP]=X<0,e.buttons[ba.DPAD_UP]=+(X<0),e.buttonsPressed[ba.DPAD_DOWN]=X>0,e.buttons[ba.DPAD_DOWN]=+(X>0)),e.timestamp=performance.now())}_findStateByDevice(e){for(let R of this._slots)if(R&&R.device===e)return R;return null}_createSnapshot(e){let R=[];for(let W=0;W<17;W++)R.push(new GamepadButton(e.buttonsPressed[W],e.buttonsPressed[W]||e.buttons[W]>0,e.buttons[W]));return new Gamepad$1({id:e.device.get_name()??`Gamepad (${e.device.get_guid()})`,index:e.index,connected:e.connected,timestamp:e.timestamp,mapping:`standard`,axes:Array.from(e.axes),buttons:R,vibrationActuator:e.hapticActuator})}getGamepads(){this._ensureInit();let e=[];for(let R=0;R<4;R++){let W=this._slots[R];e.push(W?this._createSnapshot(W):null)}return e}dispose(){for(let e of this._slots)if(e)for(let R of e.signalIds)e.device.disconnect(R);if(this._slots.fill(null),this._monitor){for(let e of this._monitorSignalIds)this._monitor.disconnect(e);this._monitorSignalIds=[],this._monitor=null}this._initialized=!1,this._initPromise=null}};const Ea=new GamepadManager,Da=globalThis;Da.navigator===void 0&&(Da.navigator={}),Da.navigator.getGamepads=()=>Ea.getGamepads(),Da.GamepadEvent===void 0&&(Da.GamepadEvent=GamepadEvent);function btoaPolyfill(e){if(typeof globalThis.btoa==`function`)return globalThis.btoa(e);let R=``,W=0;for(;W+2<e.length;W+=3){let Y=e.charCodeAt(W)<<16|e.charCodeAt(W+1)<<8|e.charCodeAt(W+2);R+=Oa[Y>>18&63]+Oa[Y>>12&63]+Oa[Y>>6&63]+Oa[Y&63]}if(W+1===e.length){let Y=e.charCodeAt(W)<<16;R+=Oa[Y>>18&63]+Oa[Y>>12&63]+`==`}else if(W+2===e.length){let Y=e.charCodeAt(W)<<16|e.charCodeAt(W+1)<<8;R+=Oa[Y>>18&63]+Oa[Y>>12&63]+Oa[Y>>6&63]+`=`}return R}function base64Decode(e){let R=e.replace(/[=\s]/g,``),W=new Uint8Array(R.length*3>>2),Y=0,X=0,ie=0;for(let e=0;e<R.length;e++)Y=Y<<6|Aa[R.charCodeAt(e)],X+=6,X>=8&&(X-=8,W[ie++]=Y>>X&255);return W.subarray(0,ie)}var Oa,Aa,Pa=__esmMin(()=>{Oa=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Aa=new Uint8Array(256);for(let e=0;e<64;e++)Aa[Oa.charCodeAt(e)]=e});function normalizeEncoding(e){if(!e||e===`utf8`||e===`utf-8`)return`utf8`;switch((``+e).toLowerCase().replace(/-/g,``)){case`utf8`:return`utf8`;case`ascii`:return`ascii`;case`latin1`:case`binary`:return`latin1`;case`base64`:return`base64`;case`base64url`:return`base64url`;case`hex`:return`hex`;case`ucs2`:case`utf16le`:return`utf16le`;default:return`utf8`}}function checkEncoding(e){let R=(``+e).toLowerCase().replace(/-/g,``);if(!La.includes(R))throw TypeError(`Unknown encoding: ${e}`)}var La,Ra=__esmMin(()=>{La=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`]});function encodeString(e,R){switch(R){case`utf8`:return Ba.encode(e);case`ascii`:{let R=new Uint8Array(e.length);for(let W=0;W<e.length;W++)R[W]=e.charCodeAt(W)&127;return R}case`latin1`:{let R=new Uint8Array(e.length);for(let W=0;W<e.length;W++)R[W]=e.charCodeAt(W)&255;return R}case`base64`:return base64Decode(e.replace(/-/g,`+`).replace(/_/g,`/`));case`base64url`:return encodeString(e.replace(/-/g,`+`).replace(/_/g,`/`),`base64`);case`hex`:{let R=e.length>>>1,W=new Uint8Array(R);for(let Y=0;Y<R;Y++){let R=parseInt(e[Y*2],16),X=parseInt(e[Y*2+1],16);if(Number.isNaN(R)||Number.isNaN(X))break;W[Y]=R<<4|X}return W}case`utf16le`:{let R=new Uint8Array(e.length*2);for(let W=0;W<e.length;W++){let Y=e.charCodeAt(W);R[W*2]=Y&255,R[W*2+1]=Y>>8&255}return R}default:return Ba.encode(e)}}function decodeString(e,R,W,Y){let X=W!==void 0||Y!==void 0?e.subarray(W??0,Y??e.length):e;switch(R){case`utf8`:return Va.decode(X);case`ascii`:{let e=``;for(let R=0;R<X.length;R++)e+=String.fromCharCode(X[R]&127);return e}case`latin1`:{let e=``;for(let R=0;R<X.length;R++)e+=String.fromCharCode(X[R]);return e}case`base64`:{let e=``;for(let R=0;R<X.length;R++)e+=String.fromCharCode(X[R]);return btoaPolyfill(e)}case`base64url`:return decodeString(X,`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);case`hex`:{let e=``;for(let R=0;R<X.length;R++)e+=X[R].toString(16).padStart(2,`0`);return e}case`utf16le`:{let e=``;for(let R=0;R+1<X.length;R+=2)e+=String.fromCharCode(X[R]|X[R+1]<<8);return e}default:return Va.decode(X)}}function checkOffset(e,R,W){if(e+R>W)throw RangeError(`Attempt to access memory outside buffer bounds`)}var Ba,Va,Ga=__esmMin(()=>{Pa(),Ba=new TextEncoder,Va=new TextDecoder}),Ka,qa,Ja=__esmMin(()=>{Ga(),Ra(),Ka=typeof SharedArrayBuffer<`u`,qa=class Buffer extends Uint8Array{static _isBuffer=!0;static alloc(e,R,W){if(typeof e!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof e}`);if(e<0)throw RangeError(`The value "${e}" is invalid for option "size"`);let Y=new Buffer(e);return R!==void 0&&R!==0&&Y.fill(R,0,e,W),Y}static allocUnsafe(e){if(typeof e!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof e}`);return new Buffer(e)}static allocUnsafeSlow(e){return Buffer.allocUnsafe(e)}static from(e,R,W){if(typeof e==`string`){let W=normalizeEncoding(R);if(R&&typeof R==`string`){let e=(``+R).toLowerCase().replace(/-/g,``);[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`,``].includes(e)||checkEncoding(R)}let Y=encodeString(e,W);return new Buffer(Y.buffer,Y.byteOffset,Y.byteLength)}if(ArrayBuffer.isView(e)){let R=new Buffer(e.buffer,e.byteOffset,e.byteLength),W=new Buffer(R.length);return W.set(R),W}if(e instanceof ArrayBuffer){let Y=R||0;return new Buffer(e,Y,W===void 0?e.byteLength-Y:W)}if(Ka&&e instanceof SharedArrayBuffer){let Y=R||0,X=W===void 0?e.byteLength-Y:W;return new Buffer(new Uint8Array(e,Y,X))}if(typeof e==`object`&&e&&typeof e.viewBytes==`function`&&typeof e.byteLength==`number`&&e.constructor?.name===`SharedBuffer`){let Y=e,X=R||0,ie=W===void 0?Y.byteLength-X:W,ae=Y.viewBytes(X,ie);return new Buffer(ae.buffer,ae.byteOffset,ae.byteLength)}if(Array.isArray(e)){let R=new Buffer(e.length);for(let W=0;W<e.length;W++)R[W]=e[W]&255;return R}throw TypeError(`The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array`)}static isBuffer(e){return e instanceof Buffer}static isEncoding(e){if(typeof e!=`string`)return!1;let R=e.toLowerCase().replace(/-/g,``);return[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`].includes(R)}static byteLength(e,R){if(typeof e!=`string`){if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Ka&&e instanceof SharedArrayBuffer)return e.byteLength;throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer`)}switch(normalizeEncoding(R)){case`utf8`:return new TextEncoder().encode(e).byteLength;case`ascii`:case`latin1`:return e.length;case`base64`:case`base64url`:{let R=e.length;for(;R>0&&(e[R-1]===`=`||e[R-1]===` `);)R--;return R*3>>>2}case`hex`:return e.length>>>1;case`utf16le`:return e.length*2;default:return new TextEncoder().encode(e).byteLength}}static compare(e,R){if(!(e instanceof Uint8Array)||!(R instanceof Uint8Array))throw TypeError(`Arguments must be Buffers or Uint8Arrays`);let W=Math.min(e.length,R.length);for(let Y=0;Y<W;Y++){if(e[Y]<R[Y])return-1;if(e[Y]>R[Y])return 1}return e.length<R.length?-1:+(e.length>R.length)}static concat(e,R){if(e.length===0)return Buffer.alloc(0);if(R===void 0){R=0;for(let W=0;W<e.length;W++)R+=e[W].length}let W=Buffer.alloc(R),Y=0;for(let X=0;X<e.length;X++){let ie=e[X],ae=Math.min(ie.length,R-Y);ae<=0||(W.set(ie.subarray(0,ae),Y),Y+=ae)}return W}static poolSize=8192;toString(e,R,W){let Y=normalizeEncoding(e);return decodeString(this,Y,R,W)}toJSON(){return{type:`Buffer`,data:Array.from(this)}}equals(e){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);if(this.length!==e.length)return!1;for(let R=0;R<this.length;R++)if(this[R]!==e[R])return!1;return!0}compare(e,R,W,Y,X){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);let ie=Y!==void 0||X!==void 0?this.subarray(Y??0,X??this.length):this,ae=R!==void 0||W!==void 0?e.subarray(R??0,W??e.length):e;return Buffer.compare(ie,ae)}copy(e,R=0,W=0,Y){let X=Y??this.length,ie=Math.min(X-W,e.length-R);return ie<=0?0:(e.set(this.subarray(W,W+ie),R),ie)}slice(e,R){let W=e??0,Y=R??this.length,X=super.subarray(W,Y);return new Buffer(X.buffer,X.byteOffset,X.byteLength)}subarray(e,R){let W=super.subarray(e,R);return new Buffer(W.buffer,W.byteOffset,W.byteLength)}write(e,R,W,Y){R??=0;let X=encodeString(e,normalizeEncoding(Y||(typeof W==`string`?W:void 0))),ie=W!==void 0&&typeof W==`number`?Math.min(W,this.length-R):this.length-R,ae=Math.min(X.length,ie);return this.set(X.subarray(0,ae),R),ae}fill(e,R,W,Y){let X=R??0,ie=W??this.length;if(typeof e==`number`)super.fill(e&255,X,ie);else if(typeof e==`string`){let R=encodeString(e,normalizeEncoding(Y));if(R.length===0)super.fill(0,X,ie);else if(R.length===1)super.fill(R[0],X,ie);else for(let e=X;e<ie;e++)this[e]=R[(e-X)%R.length]}else if(e instanceof Uint8Array)if(e.length===0)super.fill(0,X,ie);else for(let R=X;R<ie;R++)this[R]=e[(R-X)%e.length];return this}indexOf(e,R,W){if(typeof e==`number`)return super.indexOf(e&255,R);let Y=typeof e==`string`?encodeString(e,normalizeEncoding(W)):e,X=R??0;outer:for(let e=X;e<=this.length-Y.length;e++){for(let R=0;R<Y.length;R++)if(this[e+R]!==Y[R])continue outer;return e}return-1}lastIndexOf(e,R,W){if(typeof e==`number`)return R===void 0?super.lastIndexOf(e&255):super.lastIndexOf(e&255,R);let Y=typeof e==`string`?encodeString(e,normalizeEncoding(W)):e,X=R===void 0?this.length-Y.length:Math.min(R,this.length-Y.length);outer:for(let e=X;e>=0;e--){for(let R=0;R<Y.length;R++)if(this[e+R]!==Y[R])continue outer;return e}return-1}includes(e,R,W){return this.indexOf(e,R,W)!==-1}readUInt8(e=0){return checkOffset(e,1,this.length),this[e]}readUInt16BE(e=0){return checkOffset(e,2,this.length),this[e]<<8|this[e+1]}readUInt16LE(e=0){return checkOffset(e,2,this.length),this[e]|this[e+1]<<8}readUInt32BE(e=0){return checkOffset(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])}readUInt32LE(e=0){return checkOffset(e,4,this.length),this[e+3]*16777216+(this[e+2]<<16|this[e+1]<<8|this[e])>>>0}readInt8(e=0){return checkOffset(e,1,this.length),this[e]|(this[e]&128?4294967040:0)}readInt16BE(e=0){checkOffset(e,2,this.length);let R=this[e]<<8|this[e+1];return R&32768?R|4294901760:R}readInt16LE(e=0){checkOffset(e,2,this.length);let R=this[e]|this[e+1]<<8;return R&32768?R|4294901760:R}readInt32BE(e=0){return checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]}readInt32LE(e=0){return checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24}readFloatBE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!1)}readFloatLE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!0)}readDoubleBE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!1)}readDoubleLE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!0)}readBigInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!1)}readBigInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!0)}readBigUInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!1)}readBigUInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!0)}readUIntBE(e,R){checkOffset(e,R,this.length);let W=0;for(let Y=0;Y<R;Y++)W=W*256+this[e+Y];return W}readUIntLE(e,R){checkOffset(e,R,this.length);let W=0,Y=1;for(let X=0;X<R;X++)W+=this[e+X]*Y,Y*=256;return W}readIntBE(e,R){checkOffset(e,R,this.length);let W=0;for(let Y=0;Y<R;Y++)W=W*256+this[e+Y];return W>=2**(8*R-1)&&(W-=2**(8*R)),W}readIntLE(e,R){checkOffset(e,R,this.length);let W=0,Y=1;for(let X=0;X<R;X++)W+=this[e+X]*Y,Y*=256;return W>=2**(8*R-1)&&(W-=2**(8*R)),W}writeUInt8(e,R=0){return checkOffset(R,1,this.length),this[R]=e&255,R+1}writeUInt16BE(e,R=0){return checkOffset(R,2,this.length),this[R]=e>>>8&255,this[R+1]=e&255,R+2}writeUInt16LE(e,R=0){return checkOffset(R,2,this.length),this[R]=e&255,this[R+1]=e>>>8&255,R+2}writeUInt32BE(e,R=0){return checkOffset(R,4,this.length),this[R]=e>>>24&255,this[R+1]=e>>>16&255,this[R+2]=e>>>8&255,this[R+3]=e&255,R+4}writeUInt32LE(e,R=0){return checkOffset(R,4,this.length),this[R]=e&255,this[R+1]=e>>>8&255,this[R+2]=e>>>16&255,this[R+3]=e>>>24&255,R+4}writeInt8(e,R=0){return checkOffset(R,1,this.length),e<0&&(e=255+e+1),this[R]=e&255,R+1}writeInt16BE(e,R=0){return checkOffset(R,2,this.length),this[R]=e>>>8&255,this[R+1]=e&255,R+2}writeInt16LE(e,R=0){return checkOffset(R,2,this.length),this[R]=e&255,this[R+1]=e>>>8&255,R+2}writeInt32BE(e,R=0){return checkOffset(R,4,this.length),this[R]=e>>>24&255,this[R+1]=e>>>16&255,this[R+2]=e>>>8&255,this[R+3]=e&255,R+4}writeInt32LE(e,R=0){return checkOffset(R,4,this.length),this[R]=e&255,this[R+1]=e>>>8&255,this[R+2]=e>>>16&255,this[R+3]=e>>>24&255,R+4}writeFloatBE(e,R=0){return checkOffset(R,4,this.length),new DataView(this.buffer,this.byteOffset+R,4).setFloat32(0,e,!1),R+4}writeFloatLE(e,R=0){return checkOffset(R,4,this.length),new DataView(this.buffer,this.byteOffset+R,4).setFloat32(0,e,!0),R+4}writeDoubleBE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setFloat64(0,e,!1),R+8}writeDoubleLE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setFloat64(0,e,!0),R+8}writeBigInt64BE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setBigInt64(0,e,!1),R+8}writeBigInt64LE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setBigInt64(0,e,!0),R+8}writeBigUInt64BE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setBigUint64(0,e,!1),R+8}writeBigUInt64LE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setBigUint64(0,e,!0),R+8}swap16(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let R=0;R<e;R+=2){let e=this[R];this[R]=this[R+1],this[R+1]=e}return this}swap32(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let R=0;R<e;R+=4){let e=this[R],W=this[R+1];this[R]=this[R+3],this[R+1]=this[R+2],this[R+2]=W,this[R+3]=e}return this}swap64(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let R=0;R<e;R+=8){let e=this[R],W=this[R+1],Y=this[R+2],X=this[R+3];this[R]=this[R+7],this[R+1]=this[R+6],this[R+2]=this[R+5],this[R+3]=this[R+4],this[R+4]=X,this[R+5]=Y,this[R+6]=W,this[R+7]=e}return this}}}),Ya=__esmMin(()=>{Je(),Ja(),globalThis.atob,globalThis.btoa});Ya(),`Buffer`in globalThis||Object.defineProperty(globalThis,"Buffer",{value:qa,enumerable:!1,writable:!0,configurable:!0}),$e(),typeof globalThis.btoa!=`function`&&Object.defineProperty(globalThis,"btoa",{value:function btoa(e){let R=new Uint8Array(e.length);for(let W=0;W<e.length;W++)R[W]=e.charCodeAt(W)&255;return Qe.base64_encode(R)},enumerable:!0,writable:!0,configurable:!0}),typeof globalThis.atob!=`function`&&Object.defineProperty(globalThis,"atob",{value:function atob(e){let R=Qe.base64_decode(e),W=``;for(let e=0;e<R.length;e++)W+=String.fromCharCode(R[e]);return W},enumerable:!0,writable:!0,configurable:!0}),Ht(),typeof queueMicrotask!=`function`&&Object.defineProperty(globalThis,"queueMicrotask",{value:Ct,enumerable:!0,writable:!0,configurable:!0});function getGjsGlobal(){return globalThis}function getGioNamespace(){let e=getGjsGlobal().imports?.gi;if(!e)return null;let R=null;try{R=e.GioUnix??null}catch{}if(!R)try{R=e.Gio??null}catch{}return R}function getMonotonicTime(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_monotonic_time)return BigInt(e.get_monotonic_time())*1000n}catch{}return typeof performance?.now==`function`?BigInt(Math.round(performance.now()*1e6)):BigInt(Date.now())*1000000n}const go=getMonotonicTime();function hrtime(e){let R=getMonotonicTime()-go,W=Number(R/1000000000n),Y=Number(R%1000000000n);if(e){let R=W-e[0],X=Y-e[1];return X<0&&(R--,X+=1e9),[R,X]}return[W,Y]}function hrtimeBigint(){return getMonotonicTime()-go}function detectGjsVersion(){try{let e=getGjsGlobal().imports?.system;if(e?.version!==void 0){let R=Number(e.version);return`${Math.floor(R/1e4)}.${Math.floor(R%1e4/100)}.${R%100}`}}catch{}}function detectNodeVersion(){if(typeof globalThis.process?.versions?.node==`string`)return globalThis.process.versions.node}function detectVersionInfo(){if(detectNodeVersion())return{version:globalThis.process.version,versions:{...globalThis.process.versions},title:globalThis.process?.title||`node`};let e=detectGjsVersion(),R={node:`20.0.0`};return e&&(R.gjs=e),{version:`v20.0.0`,versions:R,title:`gjs`}}function detectPpid(){if(typeof globalThis.process?.ppid==`number`)return globalThis.process.ppid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,R]=e.file_get_contents(`/proc/self/status`);if(R){let e=new TextDecoder().decode(R).match(/PPid:\s+(\d+)/);if(e)return parseInt(e[1],10)}}}catch{}return 0}function detectPlatform(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e&&e.get_os_info(`ID`))return`linux`}catch{}return getGjsGlobal().imports?.system===void 0&&typeof globalThis.process?.platform==`string`?globalThis.process.platform:`linux`}function detectArch(){return typeof globalThis.process?.arch==`string`?globalThis.process.arch:`x64`}function getPid(){if(typeof globalThis.process?.pid==`number`)return globalThis.process.pid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,R]=e.file_get_contents(`/proc/self/stat`);if(R){let e=new TextDecoder().decode(R),W=parseInt(e,10);if(!isNaN(W))return W}}}catch{}return 0}function getEnvProxy(){if(typeof globalThis.process?.env==`object`)return globalThis.process.env;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return new Proxy({},{get(R,W){if(typeof W==`string`)return e.getenv(W)??void 0},set(R,W,Y){return typeof W==`string`?(e.setenv(W,String(Y),!0),!0):!1},deleteProperty(R,W){return typeof W==`string`?(e.unsetenv(W),!0):!1},has(R,W){return typeof W==`string`?e.getenv(W)!==null:!1},ownKeys(R){return e.listenv()},getOwnPropertyDescriptor(R,W){if(typeof W!=`string`)return;let Y=e.getenv(W);if(Y!==null)return{configurable:!0,enumerable:!0,writable:!0,value:Y}}})}catch{}return{}}function getArgv(){if(globalThis.process?.argv!==void 0)return globalThis.process.argv;try{let e=getGjsGlobal().imports?.system;if(e?.programArgs)return[`gjs`,e.programInvocationName||``,...e.programArgs]}catch{}return[`gjs`]}function getExecPath(){if(typeof globalThis.process?.execPath==`string`)return globalThis.process.execPath;try{let e=getGjsGlobal().imports?.system;if(e?.programInvocationName)return e.programInvocationName}catch{}return`/usr/bin/gjs`}function getCwd(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_current_dir)return e.get_current_dir()}catch{}return`/`}function chdir(e){let R=getGjsGlobal().imports?.gi?.GLib;try{if(R?.chdir){if(!R.file_test(e,16)){let R=Error(`ENOENT: no such file or directory, chdir '${e}'`);throw R.code=`ENOENT`,R.syscall=`chdir`,R.path=e,R}R.chdir(e);return}}catch(e){if(e&&typeof e==`object`&&e.code===`ENOENT`)throw e}if(!R){let R=globalThis.process;if(R&&typeof R.chdir==`function`){R.chdir(e);return}}throw Error(`process.chdir() is not supported in this environment`)}Ht();function exitProcess(e){let R=getGjsGlobal().imports,W=R?.gi?.GLib,Y=R?.system,X=W?.idle_add,ie=W?.SOURCE_REMOVE,ae=W?.PRIORITY_DEFAULT;if(Y?.exit&&X&&typeof ae==`number`&&typeof ie==`boolean`)return ensureMainLoop(),X(ae,()=>(quitMainLoop(),Y.exit(e),ie)),new Promise(()=>{});try{Y?.exit&&Y.exit(e)}catch{}let le=globalThis.process;throw le&&typeof le.exit==`function`&&le.exit(e),Error(`process.exit(${e})`)}function isGjs(){return getGjsGlobal().imports?.gi?.GLib!==void 0}function killPid(e,R){try{let W=getGjsGlobal().imports?.gi?.GLib;if(W){let Y=typeof R==`number`?String(R):R||`SIGTERM`,X=Y.startsWith(`SIG`)?`-${Y.slice(3)}`:`-${Y}`;return W.spawn_command_line_sync(`kill ${X} ${e}`),!0}}catch{}if(!isGjs()){let W=globalThis.process;if(W&&typeof W.kill==`function`)return W.kill(e,R)}throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,R]=e.file_get_contents(`/proc/self/status`);if(R){let e=new TextDecoder().decode(R).match(/VmRSS:\s+(\d+)/),W=e?parseInt(e[1],10)*1024:0;return{rss:W,heapTotal:W,heapUsed:W,external:0,arrayBuffers:0}}}}catch{}if(!isGjs()){let e=globalThis.process;if(e&&typeof e.memoryUsage==`function`)return e.memoryUsage()}return{rss:0,heapTotal:0,heapUsed:0,external:0,arrayBuffers:0}}function cpuUsage(e){if(!isGjs()){let R=globalThis.process;if(R&&typeof R.cpuUsage==`function`)return R.cpuUsage(e)}return{user:0,system:0}}let Vo=null;const Ko=globalThis.imports?.gi;if(Ko)try{Vo=Ko.GjsifyTerminal}catch{}const es=Vo;function onceWrapper(){let{target:e,type:R,listener:W}=this;return this.wrapperFn&&e.removeListener(R,this.wrapperFn),W.apply(e,Array.from(arguments))}function _onceWrap(e,R,W){let Y={target:e,type:R,listener:W,wrapperFn:void 0},X=onceWrapper.bind(Y);return Y.wrapperFn=X,X.listener=W,X}function arrayClone(e){switch(e.length){case 0:return[];case 1:return[e[0]];case 2:return[e[0],e[1]];case 3:return[e[0],e[1],e[2]];default:return e.slice()}}function checkListener(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}function validateNumber(e,R){if(typeof e!=`number`||e!==e)throw TypeError(`The "${R}" argument must be of type number. Received type ${typeof e}`)}function spliceOne(e,R){for(;R+1<e.length;R++)e[R]=e[R+1];e.pop()}function unwrapListeners(e){let R=Array.from({length:e.length});for(let W=0;W<R.length;++W)R[W]=e[W].listener??e[W];return R}function createAbortError$1(e){let R=Error(`The operation was aborted`);return R.name=`AbortError`,R.code=`ABORT_ERR`,e?.reason&&(R.cause=e.reason),R}var rs,as,os,ss=__esmMin(()=>{xt(),rs=Symbol(`kCapture`),as=Symbol.for(`nodejs.rejection`),os=class EventEmitter{static defaultMaxListeners=10;static errorMonitor=Symbol(`events.errorMonitor`);static captureRejectionSymbol=as;static _captureRejections=!1;static get captureRejections(){return EventEmitter._captureRejections}static set captureRejections(e){if(typeof e!=`boolean`)throw TypeError(`The "captureRejections" argument must be of type boolean.`);EventEmitter._captureRejections=e}_events;_eventsCount;_maxListeners;[rs];constructor(e){this._events=Object.create(null),this._eventsCount=0,this._maxListeners=void 0,this[rs]=e?.captureRejections??EventEmitter._captureRejections}setMaxListeners(e){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e);return this._maxListeners=e,this}getMaxListeners(){return this._maxListeners??EventEmitter.defaultMaxListeners}emit(e,...R){let W=this._events,Y=e===`error`;if(W!==void 0)Y&&W[EventEmitter.errorMonitor]!==void 0&&this.emit(EventEmitter.errorMonitor,...R),Y&&=W.error===void 0;else if(!Y)return!1;if(Y){let e;if(e=R.length>0?R[0]:Error(`Unhandled error.`),e instanceof Error)throw e;let W=Error(`Unhandled error. (`+e+`)`);throw W.context=e,W}let X=W[e];if(X===void 0)return!1;if(typeof X==`function`){let W=X.apply(this,R);W!=null&&this[rs]&&this._addCatch(W,e,R)}else{let W=arrayClone(X),Y=W.length;for(let X=0;X<Y;++X){let Y=W[X].apply(this,R);Y!=null&&this[rs]&&this._addCatch(Y,e,R)}}return!0}_addCatch(e,R,W){typeof e?.then==`function`&&e.then(void 0,e=>{let Y=this[as];if(typeof Y==`function`)Y.call(this,e,R,...W);else{let R=this[rs];try{this[rs]=!1,this.emit(`error`,e)}finally{this[rs]=R}}})}addListener(e,R){return this._addListener(e,R,!1)}on(e,R){return this._addListener(e,R,!1)}prependListener(e,R){return this._addListener(e,R,!0)}_addListener(e,R,W){checkListener(R);let Y=this._events;Y===void 0?(Y=this._events=Object.create(null),this._eventsCount=0):Y.newListener!==void 0&&(this.emit(`newListener`,e,R.listener??R),Y=this._events);let X=Y[e];X===void 0?(Y[e]=R,++this._eventsCount):typeof X==`function`?Y[e]=W?[R,X]:[X,R]:W?X.unshift(R):X.push(R);let ie=this.getMaxListeners();if(ie>0){let R=typeof Y[e]==`function`?1:Y[e].length;if(R>ie&&!Y[e].warned){typeof Y[e]!=`function`&&(Y[e].warned=!0);let W=Error(`Possible EventEmitter memory leak detected. ${R} ${String(e)} listeners added to [${this.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);W.name=`MaxListenersExceededWarning`,bt.warn(W.message)}}return this}once(e,R){return checkListener(R),this.on(e,_onceWrap(this,e,R)),this}prependOnceListener(e,R){return checkListener(R),this.prependListener(e,_onceWrap(this,e,R)),this}removeListener(e,R){checkListener(R);let W=this._events;if(W===void 0)return this;let Y=W[e];if(Y===void 0)return this;if(Y===R||Y.listener===R)--this._eventsCount===0?this._events=Object.create(null):(delete W[e],W.removeListener&&this.emit(`removeListener`,e,Y.listener??R));else if(typeof Y!=`function`){let X=-1;for(let e=Y.length-1;e>=0;e--)if(Y[e]===R||Y[e].listener===R){X=e;break}if(X<0)return this;X===0?Y.shift():spliceOne(Y,X),Y.length===1&&(W[e]=Y[0]),W.removeListener!==void 0&&this.emit(`removeListener`,e,R.listener??R)}return this}off(e,R){return this.removeListener(e,R)}removeAllListeners(e){let R=this._events;if(R===void 0)return this;if(R.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):R[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete R[e]),this;if(arguments.length===0){let e=Object.keys(R);for(let R=0;R<e.length;++R){let W=e[R];W!==`removeListener`&&this.removeAllListeners(W)}return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}let W=R[e];if(typeof W==`function`)this.removeListener(e,W);else if(W!==void 0)for(let R=W.length-1;R>=0;R--)this.removeListener(e,W[R]);return this}listeners(e){let R=this._events;if(R===void 0)return[];let W=R[e];return W===void 0?[]:typeof W==`function`?[W.listener??W]:unwrapListeners(W)}rawListeners(e){let R=this._events;if(R===void 0)return[];let W=R[e];return W===void 0?[]:typeof W==`function`?[W]:arrayClone(W)}listenerCount(e){let R=this._events;if(R===void 0)return 0;let W=R[e];return W===void 0?0:typeof W==`function`?1:W.length}eventNames(){return(this._eventsCount??0)>0?Reflect.ownKeys(this._events):[]}static once(e,R,W){return new Promise((Y,X)=>{let ie=W?.signal;if(ie?.aborted){X(createAbortError$1(ie));return}if(typeof e.addEventListener==`function`){let W=e,handler=(...e)=>{ie&&ie.removeEventListener(`abort`,abortHandler),Y(e)},errorHandler=e=>{ie&&ie.removeEventListener(`abort`,abortHandler),W.removeEventListener(`error`,errorHandler),X(e)},abortHandler=()=>{W.removeEventListener(R,handler),W.removeEventListener(`error`,errorHandler),X(createAbortError$1(ie))};W.addEventListener(R,handler,{once:!0}),R!==`error`&&W.addEventListener(`error`,errorHandler,{once:!0}),ie&&ie.addEventListener(`abort`,abortHandler,{once:!0});return}let ae=e,eventHandler=(...e)=>{ie&&ie.removeEventListener(`abort`,abortHandler),errorHandler!==void 0&&ae.removeListener(`error`,errorHandler),Y(e)},errorHandler;R!==`error`&&(errorHandler=e=>{ae.removeListener(R,eventHandler),ie&&ie.removeEventListener(`abort`,abortHandler),X(e)},ae.once(`error`,errorHandler)),ae.once(R,eventHandler);let abortHandler=()=>{ae.removeListener(R,eventHandler),errorHandler&&ae.removeListener(`error`,errorHandler),X(createAbortError$1(ie))};ie&&ie.addEventListener(`abort`,abortHandler,{once:!0})})}static on(e,R,W){let Y=W?.signal;if(Y?.aborted)throw createAbortError$1(Y);let X=W?.highWaterMark??2**53-1,ie=W?.lowWaterMark??1;validateNumber(X,`highWaterMark`),validateNumber(ie,`lowWaterMark`);let ae=[],le=[],_e=null,ye=!1,be=!1,eventHandler=(...R)=>{if(le.length>0){let{resolve:e}=le.shift();e({value:R,done:!1})}else ae.push(R),ae.length>=X&&!be&&(be=!0,typeof e.pause==`function`&&e.pause())},errorHandler=e=>{if(_e=e,le.length>0){let{reject:R}=le.shift();R(e)}Ce.return()},abortHandler=()=>{errorHandler(createAbortError$1(Y))};e.on(R,eventHandler),R!==`error`&&e.on(`error`,errorHandler),Y&&Y.addEventListener(`abort`,abortHandler,{once:!0});let cleanup=()=>{e.removeListener(R,eventHandler),e.removeListener(`error`,errorHandler),Y&&Y.removeEventListener(`abort`,abortHandler),ye=!0;for(let{resolve:e}of le)e({value:void 0,done:!0});le.length=0,ae.length=0},Ce={next(){if(ae.length>0){let R=ae.shift();return be&&ae.length<ie&&(be=!1,typeof e.resume==`function`&&e.resume()),Promise.resolve({value:R,done:!1})}if(_e){let e=Promise.reject(_e);return _e=null,e}return ye?Promise.resolve({value:void 0,done:!0}):new Promise((e,R)=>{le.push({resolve:e,reject:R})})},return(){return cleanup(),Promise.resolve({value:void 0,done:!0})},throw(e){return ye||(_e=e,cleanup()),Promise.reject(e)},[Symbol.asyncIterator](){return this}};return Ce}static listenerCount(e,R){return e.listenerCount(R)}static getEventListeners(e,R){return typeof e.listeners==`function`?e.listeners(R):[]}static setMaxListeners(e,...R){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range.`);if(R.length===0)EventEmitter.defaultMaxListeners=e;else for(let W of R)typeof W.setMaxListeners==`function`&&W.setMaxListeners(e)}static getMaxListeners(e){return typeof e.getMaxListeners==`function`?e.getMaxListeners():EventEmitter.defaultMaxListeners}static addAbortListener(e,R){e.aborted&&Promise.resolve().then(()=>R());let handler=()=>R();return e.addEventListener(`abort`,handler,{once:!0}),{[Symbol.dispose](){e.removeEventListener(`abort`,handler)}}}},os.EventEmitter=os;for(let e of[`setMaxListeners`,`getMaxListeners`,`emit`,`addListener`,`on`,`prependListener`,`once`,`prependOnceListener`,`removeListener`,`off`,`removeAllListeners`,`listeners`,`rawListeners`,`listenerCount`,`eventNames`]){let R=os.prototype[e];typeof R==`function`&&Object.defineProperty(os.prototype,e,{enumerable:!0,configurable:!0,writable:!0,value:R})}Object.defineProperty(os.prototype,"_events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(os.prototype,"_eventsCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(os.prototype,"_maxListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),__name$1(createAbortError$1,`createAbortError`)}),cs,ls=__esmMin(()=>{ss(),Ht(),cs=makeCallable(os),cs.EventEmitter=cs,cs.captureRejectionSymbol,cs.errorMonitor,cs.defaultMaxListeners,cs.setMaxListeners,cs.getMaxListeners,cs.once,cs.on,cs.getEventListeners,cs.listenerCount,cs.addAbortListener});xt(),ls(),Ht();const us=new TextEncoder;var ProcessWriteStream=class extends cs{fd;writable=!0;_outGio=null;constructor(e){super(),this.fd=e;let R=getGioNamespace();if(R){let e=R.UnixOutputStream??R.OutputStream;if(e)try{this._outGio=e.new(this.fd,!1)}catch{}}}write(e){if(this._outGio)try{let R=typeof e==`string`?us.encode(e):e;return this._outGio.write_all(R,null),!0}catch{}return this.fd===2?bt.error(e):bt.log(e),!0}get isTTY(){if(es)return es.Terminal.is_tty(this.fd);try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return!!e.log_writer_supports_color(this.fd)}catch{}return!1}get columns(){if(es){let[e,,R]=es.Terminal.get_size(this.fd);if(e&&R>0)return R}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let R=parseInt(e.getenv(`COLUMNS`)??`0`,10);if(R>0)return R}}catch{}return 80}end(){}destroy(){}get rows(){if(es){let[e,R]=es.Terminal.get_size(this.fd);if(e&&R>0)return R}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let R=parseInt(e.getenv(`LINES`)??`0`,10);if(R>0)return R}}catch{}return 24}},ProcessReadStream=class extends cs{fd;isRaw=!1;_gio=null;_stdinGio=null;_reading=!1;_flowing=!1;_sttyCleanupRegistered=!1;_mainLoopHeld=!1;_pendingRead=!1;constructor(e){super(),this.fd=e,this._gio=getGioNamespace()}get isTTY(){return es?es.Terminal.is_tty(this.fd):!1}setRawMode(e){return es&&es.Terminal.set_raw_mode(this.fd,e)?(this.isRaw=e,this):(this._setRawModeViaStty(e),this.isRaw=e,this)}_setRawModeViaStty(e){try{let R=globalThis.imports?.gi,W=R?.Gio??R?.Gio;if(!W)return;let Y=W.SubprocessFlags?.STDIN_INHERIT??2,X=e?[`stty`,`-icanon`,`-echo`,`-icrnl`,`min`,`1`,`time`,`0`]:[`stty`,`icanon`,`echo`,`icrnl`];if(new W.SubprocessLauncher({flags:Y}).spawnv(X).wait(null),e&&!this._sttyCleanupRegistered){this._sttyCleanupRegistered=!0;let e=globalThis.process;e?.once&&typeof e.once==`function`&&e.once(`exit`,()=>this._setRawModeViaStty(!1))}}catch{}}setEncoding(e){return this}resume(){return this._flowing=!0,this._gio&&this.fd===0&&!this._reading&&this._startReading(),this}pause(){if(this._flowing=!1,this._reading=!1,this._mainLoopHeld){this._mainLoopHeld=!1;let e=globalThis.imports?.gi,R=e?.GLib??e?.GLib;R?.idle_add?R.idle_add(300,()=>(this._mainLoopHeld||quitMainLoop(),!1)):quitMainLoop()}return this}read(){return null}_startReading(){if(!this._gio||this._reading)return;if(this._pendingRead){this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop());return}if(this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop()),!this._stdinGio){let e=this._gio.UnixInputStream??this._gio.InputStream;if(!e){this._reading=!1;return}try{this._stdinGio=e.new(this.fd,!1)}catch{this._reading=!1;return}}let loop=()=>{if(!this._reading){this._pendingRead=!1;return}this._pendingRead=!0,this._stdinGio.read_bytes_async(4096,0,null,(e,R)=>{this._pendingRead=!1;try{let W=e.read_bytes_finish(R)?.get_data?.()??null;if(W&&W.byteLength>0)this.emit(`data`,Buffer.from(W));else if(W!==null&&W.byteLength===0){this._reading=!1,this.emit(`end`);return}}catch{this._reading=!1;return}this._reading&&loop()})};loop()}};xt(),ls();const ds=Date.now();var Process=class extends cs{platform;arch;env;argv;argv0;execPath;pid;ppid;version;versions;title;execArgv;config;exitCode;constructor(){super(),this.platform=detectPlatform(),this.arch=detectArch(),this.env=getEnvProxy(),this.argv=getArgv(),this.argv0=this.argv[0]||`gjs`,this.execPath=getExecPath(),this.execArgv=globalThis.process?.execArgv??[],this.config=globalThis.process?.config??{target_defaults:{},variables:{}},this.pid=getPid(),this.ppid=detectPpid();let e=detectVersionInfo();this.version=e.version,this.versions=e.versions,this.title=e.title}cwd(){return getCwd()}chdir(e){chdir(e)}kill(e,R){return killPid(e,R)}exit(e){return this.exitCode=e??this.exitCode??0,this.emit(`exit`,this.exitCode),exitProcess(this.exitCode)}nextTick(e,...R){typeof queueMicrotask==`function`?queueMicrotask(()=>e(...R)):Promise.resolve().then(()=>e(...R))}hrtime(e){return hrtime(e)}uptime(){return(Date.now()-ds)/1e3}memoryUsage(){return memoryUsage()}cpuUsage(e){return cpuUsage(e)}stdout=new ProcessWriteStream(1);stderr=new ProcessWriteStream(2);stdin=new ProcessReadStream(0);abort(){this.exit(1)}umask(e){return 18}emitWarning(e,R){bt.warn(typeof e==`string`?`(${R||`Warning`}): ${e}`:e.message)}};Process.prototype.hrtime.bigint=function(){return hrtimeBigint()};const fs=new Process;if(es)try{let e=new es.ResizeWatcher;e.connect(`resized`,(e,R,W)=>{fs.stdout.emit(`resize`),fs.stderr.emit(`resize`)}),e.start()}catch{}fs.platform,fs.arch,fs.env,fs.argv,fs.argv0,fs.execPath,fs.pid,fs.ppid,fs.version,fs.versions,fs.cwd.bind(fs),fs.chdir.bind(fs),fs.exit.bind(fs),fs.nextTick.bind(fs),Object.assign(fs.hrtime.bind(fs),{bigint:hrtimeBigint}),fs.uptime.bind(fs),fs.memoryUsage.bind(fs),fs.cpuUsage.bind(fs),fs.kill.bind(fs),fs.abort.bind(fs),fs.umask.bind(fs),fs.emitWarning.bind(fs),fs.execArgv,fs.config,fs.stdout,fs.stderr,fs.stdin,Ht(),typeof Promise.withResolvers!=`function`&&(Promise.withResolvers=function(){let e,R;return{promise:new Promise((W,Y)=>{e=W,R=Y}),resolve:e,reject:R}}),initErrorV8Methods(Error),`global`in globalThis||Object.defineProperty(globalThis,"global",{value:globalThis,writable:!1,enumerable:!1,configurable:!0}),Object.defineProperty(globalThis,"process",{value:fs,enumerable:!1,writable:!0,configurable:!0}),Ht(),typeof globalThis.structuredClone!=`function`&&Object.defineProperty(globalThis,"structuredClone",{value:structuredClone$1,enumerable:!0,writable:!0,configurable:!0});function getGLib(){return globalThis.imports?.gi?.GLib}const ps=getGLib()!==void 0;var GjsifyTimeout=class{_id=null;_refed=!0;_callback;_delay;_args;_repeat;constructor(e,R,W,Y){this._callback=e,this._delay=R,this._args=W,this._repeat=Y,this._schedule()}_schedule(){let e=getGLib();if(!e)return;let R=e.timeout_add.bind(e);this._id=R(e.PRIORITY_DEFAULT,this._delay,()=>{try{this._callback.apply(globalThis,this._args)}catch(e){setTimeout(()=>{throw e},0)}return this._repeat?e.SOURCE_CONTINUE:(this._id=null,e.SOURCE_REMOVE)})}ref(){return this._refed=!0,this}unref(){return this._refed=!1,this}hasRef(){return this._refed}refresh(){return this._cancel(),this._schedule(),this}_cancel(){if(this._id!==null){try{getGLib()?.Source.remove(this._id)}catch{}this._id=null}}[Symbol.toPrimitive](){return this._id}[Symbol.dispose](){this._cancel()}};function removeById(e){if(e instanceof GjsifyTimeout)e._cancel();else if(typeof e==`number`)try{getGLib()?.Source.remove(e)}catch{}}if(ps){let setT=(e,R=0,...W)=>new GjsifyTimeout(e,Math.max(0,R|0),W,!1),setI=(e,R=0,...W)=>new GjsifyTimeout(e,Math.max(0,R|0),W,!0),e=globalThis;e.setTimeout=setT,e.clearTimeout=removeById,e.setInterval=setI,e.clearInterval=removeById}function setImmediate(e,...R){return setTimeout(e,0,...R)}function clearImmediate(e){clearTimeout(e)}`setImmediate`in globalThis||Object.defineProperty(globalThis,"setImmediate",{value:setImmediate,enumerable:!0,writable:!0,configurable:!0}),`clearImmediate`in globalThis||Object.defineProperty(globalThis,"clearImmediate",{value:clearImmediate,enumerable:!0,writable:!0,configurable:!0}),$e();const ms=Qe.UriFlags.HAS_PASSWORD|Qe.UriFlags.ENCODED|Qe.UriFlags.SCHEME_NORMALIZE;var hs=class URLSearchParams{_entries=[];constructor(e){if(e)if(typeof e==`string`){let R=e.startsWith(`?`)?e.slice(1):e;if(R)for(let e of R.split(`&`)){let R=e.indexOf(`=`);R===-1?this._entries.push([decodeComponent(e),``]):this._entries.push([decodeComponent(e.slice(0,R)),decodeComponent(e.slice(R+1))])}}else if(Array.isArray(e))for(let[R,W]of e)this._entries.push([String(R),String(W)]);else if(e instanceof URLSearchParams)this._entries=e._entries.map(([e,R])=>[e,R]);else for(let R of Object.keys(e))this._entries.push([R,String(e[R])])}get(e){for(let[R,W]of this._entries)if(R===e)return W;return null}getAll(e){return this._entries.filter(([R])=>R===e).map(([,e])=>e)}set(e,R){let W=!1;if(this._entries=this._entries.filter(([R])=>R===e?W?!1:(W=!0,!0):!0),W){for(let W=0;W<this._entries.length;W++)if(this._entries[W][0]===e){this._entries[W][1]=R;break}}else this._entries.push([e,R])}has(e){return this._entries.some(([R])=>R===e)}delete(e){this._entries=this._entries.filter(([R])=>R!==e)}append(e,R){this._entries.push([e,R])}sort(){this._entries.sort((e,R)=>e[0]<R[0]?-1:+(e[0]>R[0]))}toString(){return this._entries.map(([e,R])=>encodeComponent(e)+`=`+encodeComponent(R)).join(`&`)}forEach(e){for(let[R,W]of this._entries)e(W,R,this)}*entries(){yield*this._entries}*keys(){for(let[e]of this._entries)yield e}*values(){for(let[,e]of this._entries)yield e}[Symbol.iterator](){return this.entries()}get size(){return this._entries.length}};function decodeComponent(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}}function encodeComponent(e){return encodeURIComponent(e).replace(/%20/g,`+`)}var gs=class URL{#e;#t;constructor(e,R){let W=e instanceof URL?e.href:String(e);try{if(R!==void 0){let e=R instanceof URL?R.href:String(R),Y=Qe.Uri.parse(e,ms);this.#e=Y.parse_relative(W,ms)}else this.#e=Qe.Uri.parse(W,ms)}catch{throw TypeError(`Invalid URL: ${W}`)}if(!this.#e)throw TypeError(`Invalid URL: ${W}`);this.#t=new hs(this.#e.get_query()||``)}get protocol(){return this.#e.get_scheme()+`:`}get hostname(){return(this.#e.get_host()||``).toLowerCase()}get port(){let e=this.#e.get_port();if(e===-1)return``;let R=this.#e.get_scheme();return(R===`http`||R===`ws`)&&e===80||(R===`https`||R===`wss`)&&e===443||R===`ftp`&&e===21?``:String(e)}get host(){let e=this.hostname,R=this.port;return R?`${e}:${R}`:e}get pathname(){return this.#e.get_path()||`/`}get search(){let e=this.#e.get_query();return e?`?`+e:``}get hash(){let e=this.#e.get_fragment();return e?`#`+e:``}get origin(){let e=this.protocol;return e===`http:`||e===`https:`||e===`ftp:`?`${e}//${this.host}`:`null`}get username(){return this.#e.get_user()||``}get password(){return this.#e.get_password()||``}get href(){let e=this.protocol,R=this.#e.get_scheme();(R===`http`||R===`https`||R===`ftp`||R===`file`||R===`ws`||R===`wss`||this.hostname)&&(e+=`//`);let W=this.username,Y=this.password;W&&(e+=W,Y&&(e+=`:`+Y),e+=`@`),e+=this.hostname,this.port&&(e+=`:`+this.port);let X=this.pathname;return e+=X,e+=this.search,e+=this.hash,e}get searchParams(){return this.#t}toString(){return this.href}toJSON(){return this.href}static _objectURLPaths=new Map;static _objectURLCounter=0;static createObjectURL(e){let R=e?._tmpPath;if(typeof R==`string`&&R.length>0){let e=`file://${R}`;return URL._objectURLPaths.set(e,R),e}return`file:///dev/null`}static revokeObjectURL(e){let R=URL._objectURLPaths.get(e);if(R){try{Qe.unlink(R)}catch{}URL._objectURLPaths.delete(e)}}};typeof globalThis.URL!=`function`&&Object.defineProperty(globalThis,"URL",{value:gs,enumerable:!1,writable:!0,configurable:!0}),typeof globalThis.URLSearchParams!=`function`&&Object.defineProperty(globalThis,"URLSearchParams",{value:hs,enumerable:!1,writable:!0,configurable:!0});let _s;if(globalThis.performance)_s=globalThis.performance;else{let e,_now;try{let R=globalThis.imports?.gi?.GLib;if(!R)throw Error(`GJS imports.gi.GLib not available`);e=R.get_monotonic_time(),_now=()=>(R.get_monotonic_time()-e)/1e3}catch{let R=Date.now();e=0,_now=()=>Date.now()-R}let R=[],W=Date.now()-_now();_s={timeOrigin:W,now:_now,mark(e){let W={name:e,entryType:`mark`,startTime:_now(),duration:0};return R.push(W),W},measure(e,W,Y){let X=0,ie=_now();if(W){let e=R.find(e=>e.entryType===`mark`&&e.name===W);e&&(X=e.startTime)}if(Y){let e=R.find(e=>e.entryType===`mark`&&e.name===Y);e&&(ie=e.startTime)}let ae={name:e,entryType:`measure`,startTime:X,duration:ie-X};return R.push(ae),ae},getEntries(){return[...R]},getEntriesByName(e){return R.filter(R=>R.name===e)},getEntriesByType(e){return R.filter(R=>R.entryType===e)},clearMarks(e){for(let W=R.length-1;W>=0;W--)R[W].entryType===`mark`&&(!e||R[W].name===e)&&R.splice(W,1)},clearMeasures(e){for(let W=R.length-1;W>=0;W--)R[W].entryType===`measure`&&(!e||R[W].name===e)&&R.splice(W,1)},clearResourceTimings(){},setResourceTimingBufferSize(){},toJSON(){return{timeOrigin:W}}}}var PerformanceObserverStub=class{_callback;constructor(e){this._callback=e}observe(e){}disconnect(){}takeRecords(){return[]}};const ys=globalThis,bs=ys.PerformanceObserver||PerformanceObserverStub;ys.PerformanceEntry,ys.PerformanceObserverEntryList,ys.PerformanceMark,ys.PerformanceMeasure;const Cs=globalThis;globalThis.performance===void 0&&(Cs.performance=_s),typeof Cs.PerformanceObserver!=`function`&&(Cs.PerformanceObserver=bs);var AudioNode=class{_outputs=new Set;_inputs=new Set;numberOfInputs;numberOfOutputs;channelCount;constructor(e=1,R=1){this.numberOfInputs=e,this.numberOfOutputs=R,this.channelCount=2}connect(e){return this._outputs.add(e),e._inputs.add(this),e}disconnect(e){if(e)this._outputs.delete(e),e._inputs.delete(this);else{for(let e of this._outputs)e._inputs.delete(this);this._outputs.clear()}}};let Ts=!1;function ensureGstInit(){Ts||=(ye.init(null),!0)}var AudioParam=class{defaultValue;minValue;maxValue;_onChange=null;_value;_rampTimerId=null;constructor(e=0,R=-34028235e31,W=34028235e31){this.defaultValue=e,this.minValue=R,this.maxValue=W,this._value=e}get value(){return this._value}set value(e){this._cancelRamp(),this._value=Math.max(this.minValue,Math.min(this.maxValue,e)),this._onChange?.(this._value)}setValueAtTime(e,R){return this.value=e,this}linearRampToValueAtTime(e,R){return this.value=e,this}exponentialRampToValueAtTime(e,R){return this.value=e,this}setTargetAtTime(R,W,Y){if(this._cancelRamp(),Y<=0)return this.value=R,this;let X=Math.max(10,Math.round(Y*100));return this._rampTimerId=e.timeout_add(e.PRIORITY_DEFAULT,X,()=>{let W=R-this._value;if(Math.abs(W)<.001)return this._value=R,this._onChange?.(this._value),this._rampTimerId=null,e.SOURCE_REMOVE;let ie=1-Math.exp(-X/(Y*1e3));return this._value+=W*ie,this._onChange?.(this._value),e.SOURCE_CONTINUE}),this}setValueCurveAtTime(e,R,W){return this}cancelScheduledValues(e){return this._cancelRamp(),this}cancelAndHoldAtTime(e){return this._cancelRamp(),this}_cancelRamp(){this._rampTimerId!==null&&(e.source_remove(this._rampTimerId),this._rampTimerId=null)}},GainNode=class extends AudioNode{gain;_activePlayers=new Set;constructor(){super(1,1),this.gain=new AudioParam(1,0,10),this.gain._onChange=e=>{for(let R of this._activePlayers)R.setVolume(e)}}},GstPlayer=class{_pipeline=null;_volumeElement=null;_busWatchId=null;_ended=!1;_loop;_onEnded;_audioBuffer;constructor(e){ensureGstInit(),this._loop=e.loop,this._onEnded=e.onEnded,this._audioBuffer=e.audioBuffer;let{audioBuffer:R,volume:W,offset:Y,duration:X,playbackRate:ie}=e,ae=R.sampleRate,le=R.numberOfChannels,_e=this._interleave(R,Y,X);if(_e.length===0){this._fireEnded();return}let be=`appsrc name=src caps="${`audio/x-raw,format=F32LE,rate=${ae},channels=${le},layout=interleaved`}" format=3 ! audioconvert ! volume name=vol ! autoaudiosink`;this._pipeline=ye.parse_launch(be),this._volumeElement=this._pipeline.get_by_name(`vol`);let Ce=this._pipeline.get_by_name(`src`);this._volumeElement.set_property(`volume`,Math.max(0,Math.min(W,10)));let Te=this._pipeline.get_bus();this._busWatchId=Te.add_watch(0,(e,R)=>(R.type===ye.MessageType.EOS?this._loop&&!this._ended?this._restartPlayback(Ce,_e):this._fireEnded():R.type===ye.MessageType.ERROR&&this._fireEnded(),!0));let Oe=ye.Buffer.new_wrapped(_e),Ae=_e.length/(4*le);Oe.pts=0,Oe.duration=Math.floor(Ae/ae*Number(ye.SECOND)),Ce.push_buffer(Oe),Ce.end_of_stream(),ie!==1&&(this._pipeline.set_state(ye.State.PAUSED),this._pipeline.seek(ie,ye.Format.TIME,ye.SeekFlags.FLUSH|ye.SeekFlags.ACCURATE,ye.SeekType.SET,0,ye.SeekType.NONE,-1)),this._pipeline.set_state(ye.State.PLAYING)}setVolume(e){this._volumeElement&&!this._ended&&this._volumeElement.set_property(`volume`,Math.max(0,Math.min(e,10)))}setLoop(e){this._loop=e}stop(){this._ended||this._fireEnded()}get ended(){return this._ended}_restartPlayback(e,R){this._pipeline&&this._pipeline.seek_simple(ye.Format.TIME,ye.SeekFlags.FLUSH,0)}_fireEnded(){this._ended||(this._ended=!0,this._cleanup(),this._onEnded())}_cleanup(){let R=this._pipeline;this._pipeline=null,this._volumeElement=null,this._busWatchId=null,R&&e.idle_add(e.PRIORITY_LOW,()=>(R.set_state(ye.State.NULL),e.SOURCE_REMOVE))}_interleave(e,R,W){let Y=e.numberOfChannels,X=Math.min(Math.floor(R*e.sampleRate),e.length),ie=e.length-X,ae=W===void 0?ie:Math.min(Math.floor(W*e.sampleRate),ie);if(ae<=0)return new Uint8Array;let le=new Float32Array(ae*Y);for(let R=0;R<ae;R++)for(let W=0;W<Y;W++)le[R*Y+W]=e._channelData[W][X+R];return new Uint8Array(le.buffer)}},AudioBufferSourceNode=class extends AudioNode{buffer=null;loop=!1;loopStart=0;loopEnd=0;playbackRate;onended=null;_player=null;_started=!1;constructor(){super(0,1),this.playbackRate=new AudioParam(1,.0625,16)}start(e=0,R=0,W){if(this._started)throw new DOMException(`AudioBufferSourceNode can only be started once`,`InvalidStateError`);if(this._started=!0,!this.buffer)return;let Y=this._findGainNode(),X=Y?Y.gain.value:1;this._player=new GstPlayer({audioBuffer:this.buffer,volume:X,loop:this.loop,offset:R,duration:W,playbackRate:this.playbackRate.value,onEnded:()=>{Y&&Y._activePlayers.delete(this._player),this._player=null,this.onended?.()}}),Y&&this._player&&Y._activePlayers.add(this._player)}stop(e=0){this._player&&this._player.stop()}_findGainNode(){for(let e of this._outputs){if(e instanceof GainNode)return e;for(let R of e._outputs)if(R instanceof GainNode)return R}return null}},AudioBuffer=class{sampleRate;length;duration;numberOfChannels;_channelData;constructor(e){this.sampleRate=e.sampleRate,this.length=e.length,this.numberOfChannels=e.numberOfChannels,this.duration=this.length/this.sampleRate,this._channelData=[];for(let e=0;e<this.numberOfChannels;e++)this._channelData.push(new Float32Array(this.length))}getChannelData(e){if(e<0||e>=this.numberOfChannels)throw RangeError(`channel index ${e} out of range [0, ${this.numberOfChannels})`);return this._channelData[e]}copyFromChannel(e,R,W=0){let Y=this.getChannelData(R),X=Math.min(e.length,Y.length-W);e.set(Y.subarray(W,W+X))}copyToChannel(e,R,W=0){let Y=this.getChannelData(R),X=Math.min(e.length,Y.length-W);Y.set(e.subarray(0,X),W)}},AudioDestinationNode=class extends AudioNode{maxChannelCount=2;constructor(){super(1,0)}};function decodeAudioDataSync(e){if(ensureGstInit(),!(e instanceof ArrayBuffer)||e.byteLength===0)throw new DOMException(`Unable to decode audio data`,`EncodingError`);let R=ye.parse_launch(`appsrc name=src ! decodebin ! audioconvert ! audioresample ! capsfilter caps=audio/x-raw,format=F32LE,layout=interleaved ! appsink name=sink sync=false`),W=R.get_by_name(`src`),Y=R.get_by_name(`sink`);R.set_state(ye.State.PLAYING);let X=new Uint8Array(e);W.push_buffer(ye.Buffer.new_wrapped(X)),W.end_of_stream();let ie=[],ae=0,le=0;for(;;){let e=Y.try_pull_sample(2*Number(ye.SECOND));if(!e)break;if(ae===0){let R=e.get_caps();if(R){let e=R.get_structure(0);[,ae]=e.get_int(`rate`),[,le]=e.get_int(`channels`)}}let R=e.get_buffer();if(!R)continue;let[W,X]=R.map(ye.MapFlags.READ);W&&(ie.push(new Uint8Array(X.data)),R.unmap(X))}if(R.set_state(ye.State.NULL),ae===0||le===0)throw new DOMException(`Unable to decode audio data`,`EncodingError`);let _e=0;for(let e of ie)_e+=e.length;let be=_e/(4*le),Ce=new AudioBuffer({numberOfChannels:le,length:be,sampleRate:ae}),Te=0;for(let e of ie){let R=new Float32Array(e.buffer,e.byteOffset,e.length/4),W=R.length/le;for(let e=0;e<W;e++)for(let W=0;W<le;W++)Ce._channelData[W][Te+e]=R[e*le+W];Te+=W}return Ce}var AudioContext$1=class{static{__name$1(this,`AudioContext`)}state=`suspended`;sampleRate=44100;destination;listener={};_startTime;constructor(){ensureGstInit(),this._startTime=e.get_monotonic_time(),this.destination=new AudioDestinationNode}get currentTime(){return(e.get_monotonic_time()-this._startTime)/1e6}createGain(){return new GainNode}createBufferSource(){return new AudioBufferSourceNode}createBuffer(e,R,W){return new AudioBuffer({numberOfChannels:e,length:R,sampleRate:W})}decodeAudioData(e,R,W){try{let W=decodeAudioDataSync(e);return R?.(W),Promise.resolve(W)}catch(e){let R=e instanceof DOMException?e:new DOMException(`Unable to decode audio data`,`EncodingError`);return W?.(R),Promise.reject(R)}}async resume(){this.state=`running`}async suspend(){this.state=`suspended`}async close(){this.state=`closed`}createAnalyser(){return{connect:()=>{},disconnect:()=>{},fftSize:2048,frequencyBinCount:1024,getByteFrequencyData:()=>{},getFloatFrequencyData:()=>{}}}createDynamicsCompressor(){return new AudioNode}createBiquadFilter(){return new AudioNode}createConvolver(){return new AudioNode}createPanner(){return new AudioNode}createStereoPanner(){return new AudioNode}addEventListener(e,R){}removeEventListener(e,R){}};const Es=new Set([`audio/mpeg`,`audio/mp3`,`audio/wav`,`audio/x-wav`,`audio/ogg`,`audio/webm`,`audio/flac`,`audio/x-flac`,`audio/aac`,`audio/mp4`]);var HTMLAudioElement=class{src=``;volume=1;loop=!1;paused=!0;currentTime=0;duration=0;readyState=0;_pipeline=null;canPlayType(e){let R=e.split(`;`)[0].trim().toLowerCase();return Es.has(R)?`maybe`:``}play(){return!this.src||(ensureGstInit(),this._cleanup(),this._pipeline=ye.ElementFactory.make(`playbin`,`player`),!this._pipeline)?Promise.resolve():(this._pipeline.set_property(`uri`,this.src),this._pipeline.set_property(`volume`,this.volume),this._pipeline.set_state(ye.State.PLAYING),this.paused=!1,Promise.resolve())}pause(){this._pipeline&&(this._pipeline.set_state(ye.State.PAUSED),this.paused=!0)}load(){this._cleanup()}addEventListener(e,R){}removeEventListener(e,R){}_cleanup(){this._pipeline&&=(this._pipeline.set_state(ye.State.NULL),null)}};const As=globalThis;As.AudioContext===void 0&&(As.AudioContext=AudioContext$1),As.webkitAudioContext===void 0&&(As.webkitAudioContext=AudioContext$1),As.Audio===void 0&&(As.Audio=HTMLAudioElement),As.HTMLAudioElement===void 0&&(As.HTMLAudioElement=HTMLAudioElement);const js=Symbol(`abort`),Ms=Symbol(`internal`);var Ns=class AbortSignal extends EventTarget$1{#e=!1;reason=void 0;onabort=null;constructor(e){if(super(),e!==Ms)throw TypeError(`Illegal constructor.`)}get aborted(){if(!(this instanceof AbortSignal))throw TypeError(`'get aborted' called on an object that is not a valid instance of AbortSignal.`);return this.#e}get[Symbol.toStringTag](){return`AbortSignal`}throwIfAborted(){if(this.#e)throw this.reason}[js](e){if(this.#e)return;this.#e=!0,this.reason=e??new lr(`The operation was aborted.`,`AbortError`);let R=new Event$1(`abort`);typeof this.onabort==`function`&&this.onabort.call(this,R),this.dispatchEvent(R)}static abort(e){let R=new AbortSignal(Ms);return R[js](e),R}static timeout(e){let R=new AbortSignal(Ms);return setTimeout(()=>{R[js](new lr(`The operation timed out.`,`TimeoutError`))},e),R}static any(e){let R=new AbortSignal(Ms);for(let W of e)if(W.aborted)return R[js](W.reason),R;let onAbort=()=>{if(!R.aborted){let W=e.find(e=>e.aborted);R[js](W?.reason)}};for(let R of e)R.addEventListener(`abort`,onAbort,{once:!0});return R}},Is=class AbortController{signal;constructor(){this.signal=new Ns(Ms)}abort(e){if(!(this instanceof AbortController))throw TypeError(`'abort' called on an object that is not a valid instance of AbortController.`);this.signal[js](e)}};const zs=globalThis;globalThis.AbortController===void 0&&(zs.AbortController=Is),globalThis.AbortSignal===void 0&&(zs.AbortSignal=Ns);const Bs=Symbol(`kState`),Hs=Symbol(`kType`);function isBrandCheck(e){return R=>typeof R==`object`&&!!R&&R[Bs]!==void 0&&R[Hs]===e}function dequeueValue(e){let R=e[Bs].queue.shift();if(R===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:W,size:Y}=R;return e[Bs].queueTotalSize=Math.max(0,e[Bs].queueTotalSize-Y),W}function resetQueue(e){e[Bs].queue=[],e[Bs].queueTotalSize=0}function peekQueueValue(e){return e[Bs].queue[0].value}function enqueueValueWithSize(e,R,W){if(W=+W,typeof W!=`number`||W<0||Number.isNaN(W)||W===1/0)throw RangeError(`Invalid size: ${W}`);e[Bs].queue.push({value:R,size:W}),e[Bs].queueTotalSize+=W}function extractHighWaterMark(e,R){if(e===void 0)return R;if(e=+e,typeof e!=`number`||Number.isNaN(e)||e<0)throw RangeError(`Invalid highWaterMark: ${e}`);return e}function extractSizeAlgorithm(e){if(e===void 0)return()=>1;if(typeof e!=`function`)throw TypeError(`strategy.size must be a function`);return e}function transferArrayBuffer(e){return typeof ArrayBuffer.prototype.transfer==`function`?e.transfer():e.slice(0)}function isDetachedBuffer(e){if(typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||e.byteLength!==0)return!1;try{return e.slice(0,0),!1}catch{return!0}}function typedArrayConstructorByTag(e){switch(e){case`Int8Array`:return Int8Array;case`Uint8Array`:return Uint8Array;case`Uint8ClampedArray`:return Uint8ClampedArray;case`Int16Array`:return Int16Array;case`Uint16Array`:return Uint16Array;case`Int32Array`:return Int32Array;case`Uint32Array`:return Uint32Array;case`Float32Array`:return Float32Array;case`Float64Array`:return Float64Array;case`BigInt64Array`:return typeof BigInt64Array<`u`?BigInt64Array:void 0;case`BigUint64Array`:return typeof BigUint64Array<`u`?BigUint64Array:void 0;default:return}}function elementSizeByTag(e){switch(e){case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:return 1;case`Int16Array`:case`Uint16Array`:return 2;case`Int32Array`:case`Uint32Array`:case`Float32Array`:return 4;case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:return 8;default:return 1}}function setPromiseHandled(e){e.then(()=>{},()=>{})}function createPromiseCallback(e,R,W){if(typeof R!=`function`)throw TypeError(`${e} must be a function`);return async(...e)=>R.call(W,...e)}async function nonOpFlush(){}function nonOpStart(){}async function nonOpPull(){}async function nonOpCancel(){}async function nonOpWrite(){}const Us={__proto__:Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),next:void 0,return:void 0};function createAsyncFromSyncIterator(e){let R={[Symbol.iterator]:()=>e.iterator},W=(async function*(){return yield*R})();return{iterator:W,nextMethod:W.next,done:!1}}function getIterator(e,R=`sync`,W){if(W===void 0)if(R===`async`){if(W=e[Symbol.asyncIterator],W==null){let R=e[Symbol.iterator];if(R===void 0)throw TypeError(`Object is not iterable`);return createAsyncFromSyncIterator(getIterator(e,`sync`,R))}}else W=e[Symbol.iterator];if(W===void 0)throw TypeError(`Object is not iterable`);let Y=W.call(e);if(typeof Y!=`object`||!Y)throw TypeError(`The iterator method must return an object`);return{iterator:Y,nextMethod:Y.next,done:!1}}function iteratorNext(e,R){let W;if(W=R===void 0?e.nextMethod.call(e.iterator):e.nextMethod.call(e.iterator,R),typeof W!=`object`||!W)throw TypeError(`The iterator.next() method must return an object`);return W}const Ws=typeof globalThis.AbortController==`function`?globalThis.AbortController:class AbortControllerShim{signal={aborted:!1,reason:void 0,addEventListener(){},removeEventListener(){}};abort(e){this.signal.aborted=!0,this.signal.reason=e}},Xs=Symbol(`kAbort`),Zs=Symbol(`kCloseSentinel`),$s=Symbol(`kError`),ec=Symbol(`kSkipThrow`);var WritableStream=class{[Hs]=`WritableStream`;[Bs];constructor(e={},R={}){if(e!=null&&typeof e!=`object`)throw TypeError(`sink must be an object`);if(R!=null&&typeof R!=`object`)throw TypeError(`strategy must be an object`);let W=e?.type;if(W!==void 0)throw RangeError(`Invalid type: ${W}`);this[Bs]=createWritableStreamState();let Y=extractSizeAlgorithm(R?.size),X=extractHighWaterMark(R?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,e,X,Y)}get locked(){if(!tc(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(e){return tc(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){return tc(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamCloseQueuedOrInFlight(this)?Promise.reject(TypeError(`Failure closing WritableStream`)):writableStreamClose(this):Promise.reject(TypeError(`Invalid this`))}getWriter(){if(!tc(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[Hs]=`WritableStreamDefaultWriter`;[Bs];constructor(e){if(!tc(e))throw TypeError(`Expected a WritableStream`);this[Bs]={stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0},ready:{promise:void 0,resolve:void 0,reject:void 0}},setupWritableStreamDefaultWriter(this,e)}get closed(){return nc(this)?this[Bs].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!nc(this))throw TypeError(`Invalid this`);if(this[Bs].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return nc(this)?this[Bs].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(e){return nc(this)?this[Bs].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){if(!nc(this))return Promise.reject(TypeError(`Invalid this`));let{stream:e}=this[Bs];return e===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamCloseQueuedOrInFlight(e)?Promise.reject(TypeError(`Failure to close WritableStream`)):writableStreamDefaultWriterClose(this)}releaseLock(){if(!nc(this))throw TypeError(`Invalid this`);let{stream:e}=this[Bs];e!==void 0&&writableStreamDefaultWriterRelease(this)}write(e){return nc(this)?this[Bs].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterWrite(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`WritableStreamDefaultWriter`}},WritableStreamDefaultController=class{[Hs]=`WritableStreamDefaultController`;[Bs];constructor(e){if(e!==ec)throw TypeError(`Illegal constructor`)}[Xs](e){let R=this[Bs].abortAlgorithm(e);return writableStreamDefaultControllerClearAlgorithms(this),R}[$s](){resetQueue(this)}get signal(){if(!sc(this))throw TypeError(`Invalid this`);return this[Bs].abortController.signal}error(e){if(!sc(this))throw TypeError(`Invalid this`);this[Bs].stream[Bs].state===`writable`&&writableStreamDefaultControllerError(this,e)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const tc=isBrandCheck(`WritableStream`),nc=isBrandCheck(`WritableStreamDefaultWriter`),sc=isBrandCheck(`WritableStreamDefaultController`);function createEmptyPromiseRecord(){return{promise:void 0,resolve:void 0,reject:void 0}}function createWritableStreamState(){return{close:Promise.withResolvers(),closeRequest:createEmptyPromiseRecord(),inFlightWriteRequest:createEmptyPromiseRecord(),inFlightCloseRequest:createEmptyPromiseRecord(),pendingAbortRequest:{abort:createEmptyPromiseRecord(),reason:void 0,wasAlreadyErroring:!1},backpressure:!1,controller:void 0,state:`writable`,storedError:void 0,writeRequests:[],writer:void 0}}function isWritableStreamLocked(e){return e[Bs].writer!==void 0}function setupWritableStreamDefaultWriter(e,R){if(isWritableStreamLocked(R))throw TypeError(`WritableStream is locked`);switch(e[Bs].stream=R,R[Bs].writer=e,R[Bs].state){case`writable`:!writableStreamCloseQueuedOrInFlight(R)&&R[Bs].backpressure?e[Bs].ready=Promise.withResolvers():e[Bs].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Bs].close=Promise.withResolvers();break;case`erroring`:e[Bs].ready={promise:Promise.reject(R[Bs].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].ready.promise),e[Bs].close=Promise.withResolvers();break;case`closed`:e[Bs].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Bs].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:e[Bs].ready={promise:Promise.reject(R[Bs].storedError),resolve:void 0,reject:void 0},e[Bs].close={promise:Promise.reject(R[Bs].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].ready.promise),setPromiseHandled(e[Bs].close.promise)}}function writableStreamAbort(e,R){let{state:W,controller:Y}=e[Bs];if(W===`closed`||W===`errored`)return Promise.resolve();if(Y[Bs].abortController.abort(R),e[Bs].pendingAbortRequest.abort.promise!==void 0)return e[Bs].pendingAbortRequest.abort.promise;let X=!1;W===`erroring`&&(X=!0,R=void 0);let ie=Promise.withResolvers();return e[Bs].pendingAbortRequest={abort:ie,reason:R,wasAlreadyErroring:X},X||writableStreamStartErroring(e,R),ie.promise}function writableStreamClose(e){let{state:R,writer:W,backpressure:Y,controller:X}=e[Bs];if(R===`closed`||R===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));e[Bs].closeRequest=Promise.withResolvers();let{promise:ie}=e[Bs].closeRequest;return W!==void 0&&Y&&R===`writable`&&W[Bs].ready.resolve?.(),writableStreamDefaultControllerClose(X),ie}function writableStreamUpdateBackpressure(e,R){let{writer:W}=e[Bs];W!==void 0&&e[Bs].backpressure!==R&&(R?W[Bs].ready=Promise.withResolvers():W[Bs].ready.resolve?.()),e[Bs].backpressure=R}function writableStreamStartErroring(e,R){let{controller:W,writer:Y}=e[Bs];e[Bs].state=`erroring`,e[Bs].storedError=R,Y!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(Y,R),!writableStreamHasOperationMarkedInFlight(e)&&W[Bs].started&&writableStreamFinishErroring(e)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){e[Bs].closeRequest.promise!==void 0&&(e[Bs].closeRequest.reject?.(e[Bs].storedError),e[Bs].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(e[Bs].close.promise),e[Bs].close.reject?.(e[Bs].storedError);let{writer:R}=e[Bs];R!==void 0&&(setPromiseHandled(R[Bs].close.promise),R[Bs].close.reject?.(e[Bs].storedError))}function writableStreamMarkFirstWriteRequestInFlight(e){let R=e[Bs].writeRequests.shift();e[Bs].inFlightWriteRequest=R}function writableStreamMarkCloseRequestInFlight(e){e[Bs].inFlightCloseRequest=e[Bs].closeRequest,e[Bs].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(e){return e[Bs].inFlightWriteRequest.promise!==void 0||e[Bs].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(e,R){e[Bs].inFlightWriteRequest.reject?.(R),e[Bs].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(e,R)}function writableStreamFinishInFlightWrite(e){e[Bs].inFlightWriteRequest.resolve?.(),e[Bs].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(e,R){e[Bs].inFlightCloseRequest.reject?.(R),e[Bs].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Bs].pendingAbortRequest.abort.promise!==void 0&&(e[Bs].pendingAbortRequest.abort.reject?.(R),e[Bs].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(e,R)}function writableStreamFinishInFlightClose(e){e[Bs].inFlightCloseRequest.resolve?.(),e[Bs].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Bs].state===`erroring`&&(e[Bs].storedError=void 0,e[Bs].pendingAbortRequest.abort.promise!==void 0&&(e[Bs].pendingAbortRequest.abort.resolve?.(),e[Bs].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),e[Bs].state=`closed`,e[Bs].writer!==void 0&&e[Bs].writer[Bs].close.resolve?.(),e[Bs].close.resolve?.()}function writableStreamFinishErroring(e){e[Bs].state=`errored`,e[Bs].controller[$s]();let R=e[Bs].storedError;for(let W of e[Bs].writeRequests)W.reject?.(R);if(e[Bs].writeRequests=[],e[Bs].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}let W=e[Bs].pendingAbortRequest;if(e[Bs].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1},W.wasAlreadyErroring){W.abort.reject?.(R),writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}e[Bs].controller[Xs](W.reason).then(()=>{W.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)},R=>{W.abort.reject?.(R),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)})}function writableStreamDealWithRejection(e,R){if(e[Bs].state===`writable`){writableStreamStartErroring(e,R);return}writableStreamFinishErroring(e)}function writableStreamCloseQueuedOrInFlight(e){return e[Bs].closeRequest.promise!==void 0||e[Bs].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(e){let{promise:R,resolve:W,reject:Y}=Promise.withResolvers();return e[Bs].writeRequests.push({promise:R,resolve:W,reject:Y}),R}function writableStreamDefaultWriterWrite(e,R){let{stream:W}=e[Bs],{controller:Y}=W[Bs],X=writableStreamDefaultControllerGetChunkSize(Y,R);if(W!==e[Bs].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:ie}=W[Bs];if(ie===`errored`)return Promise.reject(W[Bs].storedError);if(writableStreamCloseQueuedOrInFlight(W)||ie===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(ie===`erroring`)return Promise.reject(W[Bs].storedError);let ae=writableStreamAddWriteRequest(W);return writableStreamDefaultControllerWrite(Y,R,X),ae}function writableStreamDefaultWriterRelease(e){let{stream:R}=e[Bs],W=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(e,W),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,W),R[Bs].writer=void 0,e[Bs].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(e){let{stream:R}=e[Bs];switch(R[Bs].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(R[Bs].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,R){e[Bs].ready.reject?(e[Bs].ready.reject(R),e[Bs].ready.resolve=void 0,e[Bs].ready.reject=void 0):e[Bs].ready={promise:Promise.reject(R),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,R){e[Bs].close.reject?(e[Bs].close.reject(R),e[Bs].close.resolve=void 0,e[Bs].close.reject=void 0):e[Bs].close={promise:Promise.reject(R),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(e){let{stream:R}=e[Bs],{state:W}=R[Bs];return writableStreamCloseQueuedOrInFlight(R)||W===`closed`?Promise.resolve():W===`errored`?Promise.reject(R[Bs].storedError):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterClose(e){return writableStreamClose(e[Bs].stream)}function writableStreamDefaultWriterAbort(e,R){return writableStreamAbort(e[Bs].stream,R)}function writableStreamDefaultControllerWrite(e,R,W){try{enqueueValueWithSize(e,R,W)}catch(R){writableStreamDefaultControllerErrorIfNeeded(e,R);return}let{stream:Y}=e[Bs];!writableStreamCloseQueuedOrInFlight(Y)&&Y[Bs].state===`writable`&&writableStreamUpdateBackpressure(Y,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerProcessWrite(e,R){let{stream:W,writeAlgorithm:Y}=e[Bs];writableStreamMarkFirstWriteRequestInFlight(W),Y(R,e).then(()=>{writableStreamFinishInFlightWrite(W);let{state:R}=W[Bs];dequeueValue(e),!writableStreamCloseQueuedOrInFlight(W)&&R===`writable`&&writableStreamUpdateBackpressure(W,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)},R=>{W[Bs].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(W,R)})}function writableStreamDefaultControllerProcessClose(e){let{closeAlgorithm:R,stream:W}=e[Bs];writableStreamMarkCloseRequestInFlight(W),dequeueValue(e);let Y=R();writableStreamDefaultControllerClearAlgorithms(e),Y.then(()=>writableStreamFinishInFlightClose(W),e=>writableStreamFinishInFlightCloseWithError(W,e))}function writableStreamDefaultControllerGetDesiredSize(e){return e[Bs].highWaterMark-e[Bs].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(e,R){let{sizeAlgorithm:W}=e[Bs];if(W===void 0)return 1;try{return W(R)}catch(R){return writableStreamDefaultControllerErrorIfNeeded(e,R),1}}function writableStreamDefaultControllerErrorIfNeeded(e,R){e[Bs].stream[Bs].state===`writable`&&writableStreamDefaultControllerError(e,R)}function writableStreamDefaultControllerError(e,R){writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(e[Bs].stream,R)}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,Zs,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerClearAlgorithms(e){e[Bs].writeAlgorithm=void 0,e[Bs].closeAlgorithm=void 0,e[Bs].abortAlgorithm=void 0,e[Bs].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){let{queue:R,started:W,stream:Y}=e[Bs];if(!W||Y[Bs].inFlightWriteRequest.promise!==void 0)return;if(Y[Bs].state===`erroring`){writableStreamFinishErroring(Y);return}if(!R.length)return;let X=peekQueueValue(e);X===Zs?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,X)}function setupWritableStreamDefaultControllerFromSink(e,R,W,Y){let X=new WritableStreamDefaultController(ec),ie=R?.start,ae=R?.write,le=R?.close,_e=R?.abort;setupWritableStreamDefaultController(e,X,ie?ie.bind(R,X):nonOpStart,ae?createPromiseCallback(`sink.write`,ae,R):nonOpWrite,le?createPromiseCallback(`sink.close`,le,R):nonOpCancel,_e?createPromiseCallback(`sink.abort`,_e,R):nonOpCancel,W,Y)}function setupWritableStreamDefaultController(e,R,W,Y,X,ie,ae,le){R[Bs]={abortAlgorithm:ie,closeAlgorithm:X,highWaterMark:ae,queue:[],queueTotalSize:0,abortController:new Ws,sizeAlgorithm:le,started:!1,stream:e,writeAlgorithm:Y},e[Bs].controller=R,writableStreamUpdateBackpressure(e,writableStreamDefaultControllerGetBackpressure(R));let _e=W();new Promise(e=>e(_e)).then(()=>{R[Bs].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(R)},W=>{R[Bs].started=!0,writableStreamDealWithRejection(e,W)})}function createWritableStream(e,R,W,Y,X=1,ie=()=>1){let ae=Object.create(WritableStream.prototype);return ae[Hs]=`WritableStream`,ae[Bs]=createWritableStreamState(),setupWritableStreamDefaultController(ae,new WritableStreamDefaultController(ec),e,R,W,Y,X,ie),ae}Ht();const uc=Symbol(`kCancel`),hc=Symbol(`kClose`),Ac=Symbol(`kChunk`),Ic=Symbol(`kError`),Hc=Symbol(`kPull`),el=Symbol(`kRelease`),nl=Symbol(`kSkipThrow`);let sl,fl;function lazyReadableReleasedError(){return sl||(sl=TypeError(`Reader released`),sl)}function lazyReadableReleasingError(){return fl||(fl=TypeError(`Releasing reader`),fl)}function createAbortError(){if(typeof globalThis.DOMException==`function`)return new DOMException(`The operation was aborted`,`AbortError`);let e=Error(`The operation was aborted`);return e.name=`AbortError`,e}function createReadableStreamState(){return{disturbed:!1,reader:void 0,state:`readable`,storedError:void 0,controller:void 0,closedPromise:Promise.withResolvers()}}var ReadableStream$1=class{static{__name$1(this,`ReadableStream`)}[Hs]=`ReadableStream`;[Bs];constructor(e={},R={}){if(e!=null&&typeof e!=`object`)throw TypeError(`source must be an object`);if(R!=null&&typeof R!=`object`)throw TypeError(`strategy must be an object`);this[Bs]=createReadableStreamState();let W=R?.size,Y=R?.highWaterMark,X=e?.type;if(X!==void 0){if(`${X}`==`bytes`){if(W!==void 0)throw RangeError(`strategy.size must not be set for a byte stream`);setupReadableByteStreamControllerFromSource(this,e,extractHighWaterMark(Y,0));return}throw RangeError(`Invalid type: ${X}`)}setupReadableStreamDefaultControllerFromSource(this,e,extractHighWaterMark(Y,1),extractSizeAlgorithm(W))}get locked(){if(!ml(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(e){return readableStreamFromIterable(e)}cancel(e=void 0){return ml(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,e):Promise.reject(TypeError(`Invalid this`))}getReader(e={}){if(!ml(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let R=e?.mode;if(R===void 0)return new ReadableStreamDefaultReader(this);if(`${R}`==`byob`)return new ReadableStreamBYOBReader(this);throw RangeError(`Invalid mode: ${R}`)}pipeThrough(e,R={}){if(!ml(this))throw TypeError(`Invalid this`);let W=e?.readable;if(!ml(W))throw TypeError(`transform.readable must be a ReadableStream`);let Y=e?.writable;if(!tc(Y))throw TypeError(`transform.writable must be a WritableStream`);if(R!=null&&typeof R!=`object`)throw TypeError(`options must be an object`);let X=R?.preventAbort,ie=R?.preventCancel,ae=R?.preventClose,le=R?.signal;if(le!==void 0&&!(le instanceof Object&&`aborted`in le))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(Y))throw TypeError(`The WritableStream is locked`);return setPromiseHandled(readableStreamPipeTo(this,Y,!!ae,!!X,!!ie,le)),W}pipeTo(e,R={}){try{if(!ml(this))throw TypeError(`Invalid this`);if(!tc(e))throw TypeError(`destination must be a WritableStream`);if(R!=null&&typeof R!=`object`)throw TypeError(`options must be an object`);let W=R?.preventAbort,Y=R?.preventCancel,X=R?.preventClose,ie=R?.signal;if(ie!==void 0&&!(ie instanceof Object&&`aborted`in ie))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(e))throw TypeError(`The WritableStream is locked`);return readableStreamPipeTo(this,e,!!X,!!W,!!Y,ie)}catch(e){return Promise.reject(e)}}tee(){if(!ml(this))throw TypeError(`Invalid this`);let e=this[Bs].controller;return yl(e)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(e={}){if(!ml(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let R=!!e?.preventCancel,W=new ReadableStreamDefaultReader(this),Y={done:!1,current:void 0},X=!1;function nextSteps(){if(Y.done)return Promise.resolve({done:!0,value:void 0});if(W[Bs].stream===void 0)return Promise.reject(TypeError(`The reader is not bound to a ReadableStream`));let{promise:e,resolve:R,reject:X}=Promise.withResolvers();return readableStreamDefaultReaderRead(W,{[Ac](e){Y.current=void 0,R({value:e,done:!1})},[hc](){Y.current=void 0,Y.done=!0,readableStreamReaderGenericRelease(W),R({done:!0,value:void 0})},[Ic](e){Y.current=void 0,Y.done=!0,readableStreamReaderGenericRelease(W),X(e)}}),e}async function returnSteps(e){if(Y.done)return{done:!0,value:e};if(Y.done=!0,W[Bs].stream===void 0)throw TypeError(`The reader is not bound to a ReadableStream`);if(!R){let R=readableStreamReaderGenericCancel(W,e);return readableStreamReaderGenericRelease(W),await R,{done:!0,value:e}}return readableStreamReaderGenericRelease(W),{done:!0,value:e}}return Object.setPrototypeOf({next(){return X||=(Y.current=Promise.resolve(),!0),Y.current=Y.current===void 0?nextSteps():Y.current.then(nextSteps,nextSteps),Y.current},return(e){return X=!0,Y.current=Y.current===void 0?returnSteps(e):Y.current.then(()=>returnSteps(e),()=>returnSteps(e)),Y.current},[Symbol.asyncIterator](){return this}},Us)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[Bs];constructor(){this[Bs]=Promise.withResolvers()}[Ac](e){this[Bs].resolve?.({value:e,done:!1})}[hc](){this[Bs].resolve?.({value:void 0,done:!0})}[Ic](e){this[Bs].reject?.(e)}get promise(){return this[Bs].promise}},ReadableStreamDefaultReader=class{[Hs]=`ReadableStreamDefaultReader`;[Bs];constructor(e){if(!ml(e))throw TypeError(`Expected a ReadableStream`);this[Bs]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,e)}read(){if(!vl(this))return Promise.reject(TypeError(`Invalid this`));if(this[Bs].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let e=this[Bs].stream,R=e[Bs].controller;if(e[Bs].state===`readable`&&_l(R)&&R[Bs].queue.length>0){e[Bs].disturbed=!0;let W=dequeueValue(R);return R[Bs].closeRequested&&!R[Bs].queue.length?(readableStreamDefaultControllerClearAlgorithms(R),readableStreamClose(e)):readableStreamDefaultControllerCallPullIfNeeded(R),Promise.resolve({value:W,done:!1})}let W=new DefaultReadRequest;return readableStreamDefaultReaderRead(this,W),W.promise}releaseLock(){if(!vl(this))throw TypeError(`Invalid this`);this[Bs].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return vl(this)?this[Bs].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return vl(this)?this[Bs].stream===void 0?Promise.reject(TypeError(`The reader is not attached to a stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamDefaultReader`}},ReadableStreamDefaultController=class{[Hs]=`ReadableStreamDefaultController`;[Bs];constructor(e){if(e!==nl)throw TypeError(`Illegal constructor`)}get desiredSize(){return readableStreamDefaultControllerGetDesiredSize(this)}close(){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerClose(this)}enqueue(e=void 0){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerEnqueue(this,e)}error(e=void 0){readableStreamDefaultControllerError(this,e)}[uc](e){return readableStreamDefaultControllerCancelSteps(this,e)}[Hc](e){readableStreamDefaultControllerPullSteps(this,e)}[el](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const ml=isBrandCheck(`ReadableStream`),_l=isBrandCheck(`ReadableStreamDefaultController`),vl=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(e){return e[Bs].reader!==void 0}function readableStreamCancel(e,R){switch(e[Bs].disturbed=!0,e[Bs].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(e[Bs].storedError)}readableStreamClose(e);let W=e[Bs].reader;if(W!==void 0&&readableStreamHasBYOBReader(e)){let e=W[Bs].readIntoRequests;W[Bs].readIntoRequests=[];for(let R=0;R<e.length;R++)e[R][hc](void 0)}return e[Bs].controller[uc](R).then(()=>{})}function readableStreamClose(e){e[Bs].state=`closed`,e[Bs].closedPromise.resolve();let{reader:R}=e[Bs];if(R!==void 0&&(R[Bs].close.resolve?.(),readableStreamHasDefaultReader(e))){for(let e=0;e<R[Bs].readRequests.length;e++)R[Bs].readRequests[e][hc]();R[Bs].readRequests=[]}}function readableStreamError(e,R){e[Bs].state=`errored`,e[Bs].storedError=R,setPromiseHandled(e[Bs].closedPromise.promise),e[Bs].closedPromise.reject(R);let{reader:W}=e[Bs];if(W!==void 0){if(setPromiseHandled(W[Bs].close.promise),W[Bs].close.reject?.(R),readableStreamHasDefaultReader(e)){for(let e=0;e<W[Bs].readRequests.length;e++)W[Bs].readRequests[e][Ic](R);W[Bs].readRequests=[]}else if(readableStreamHasBYOBReader(e)){for(let e=0;e<W[Bs].readIntoRequests.length;e++)W[Bs].readIntoRequests[e][Ic](R);W[Bs].readIntoRequests=[]}}}function readableStreamHasDefaultReader(e){let{reader:R}=e[Bs];return R===void 0?!1:R[Bs]!==void 0&&R[Hs]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(e){return e[Bs].reader[Bs].readRequests.length}function readableStreamFulfillReadRequest(e,R,W){let{reader:Y}=e[Bs],X=Y[Bs].readRequests.shift();W?X[hc]():X[Ac](R)}function readableStreamAddReadRequest(e,R){e[Bs].reader[Bs].readRequests.push(R)}function readableStreamReaderGenericCancel(e,R){let{stream:W}=e[Bs];return readableStreamCancel(W,R)}function readableStreamReaderGenericInitialize(e,R){switch(e[Bs].stream=R,R[Bs].reader=e,R[Bs].state){case`readable`:e[Bs].close=Promise.withResolvers();break;case`closed`:e[Bs].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:e[Bs].close={promise:Promise.reject(R[Bs].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].close.promise);break}}function readableStreamReaderGenericRelease(e){let{stream:R}=e[Bs],W=lazyReadableReleasedError();R[Bs].state===`readable`?e[Bs].close.reject?.(W):e[Bs].close={promise:Promise.reject(W),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].close.promise),R[Bs].controller[el](),R[Bs].reader=void 0,e[Bs].stream=void 0}function readableStreamDefaultReaderRelease(e){readableStreamReaderGenericRelease(e),readableStreamDefaultReaderErrorReadRequests(e,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(e,R){for(let W=0;W<e[Bs].readRequests.length;++W)e[Bs].readRequests[W][Ic](R);e[Bs].readRequests=[]}function readableStreamDefaultReaderRead(e,R){let{stream:W}=e[Bs];switch(W[Bs].disturbed=!0,W[Bs].state){case`closed`:R[hc]();break;case`errored`:R[Ic](W[Bs].storedError);break;case`readable`:W[Bs].controller[Hc](R);break}}function setupReadableStreamDefaultReader(e,R){if(isReadableStreamLocked(R))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(e,R),e[Bs].readRequests=[]}function readableStreamDefaultControllerClose(e){readableStreamDefaultControllerCanCloseOrEnqueue(e)&&(e[Bs].closeRequested=!0,e[Bs].queue.length||(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(e[Bs].stream)))}function readableStreamDefaultControllerEnqueue(e,R){if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return;let{stream:W}=e[Bs];if(isReadableStreamLocked(W)&&readableStreamGetNumReadRequests(W))readableStreamFulfillReadRequest(W,R,!1);else try{enqueueValueWithSize(e,R,e[Bs].sizeAlgorithm(R))}catch(R){throw readableStreamDefaultControllerError(e,R),R}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){let{stream:R}=e[Bs];return!e[Bs].closeRequested&&R[Bs].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(e){let{stream:R,highWaterMark:W,queueTotalSize:Y}=e[Bs];switch(R[Bs].state){case`errored`:return null;case`closed`:return 0;default:return W-Y}}function readableStreamDefaultControllerHasBackpressure(e){return!readableStreamDefaultControllerShouldCallPull(e)}function readableStreamDefaultControllerShouldCallPull(e){let{stream:R}=e[Bs];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e)||!e[Bs].started)return!1;if(isReadableStreamLocked(R)&&readableStreamGetNumReadRequests(R))return!0;let W=readableStreamDefaultControllerGetDesiredSize(e);return W!==null&&W>0}function readableStreamDefaultControllerCallPullIfNeeded(e){if(readableStreamDefaultControllerShouldCallPull(e)){if(e[Bs].pulling){e[Bs].pullAgain=!0;return}e[Bs].pulling=!0,e[Bs].pullAlgorithm(e).then(()=>{e[Bs].pulling=!1,e[Bs].pullAgain&&(e[Bs].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(e))},R=>readableStreamDefaultControllerError(e,R))}}function readableStreamDefaultControllerClearAlgorithms(e){e[Bs].pullAlgorithm=void 0,e[Bs].cancelAlgorithm=void 0,e[Bs].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(e,R){let{stream:W}=e[Bs];W[Bs].state===`readable`&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(W,R))}function readableStreamDefaultControllerCancelSteps(e,R){resetQueue(e);let W=e[Bs].cancelAlgorithm?.(R)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(e),W}function readableStreamDefaultControllerPullSteps(e,R){let{stream:W,queue:Y}=e[Bs];if(Y.length){let X=dequeueValue(e);e[Bs].closeRequested&&!Y.length?(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(W)):readableStreamDefaultControllerCallPullIfNeeded(e),R[Ac](X);return}readableStreamAddReadRequest(W,R),readableStreamDefaultControllerCallPullIfNeeded(e)}function setupReadableStreamDefaultController(e,R,W,Y,X,ie,ae){R[Bs]={cancelAlgorithm:X,closeRequested:!1,highWaterMark:ie,pullAgain:!1,pullAlgorithm:Y,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:ae,stream:e},e[Bs].controller=R;let le=W();new Promise(e=>e(le)).then(()=>{R[Bs].started=!0,readableStreamDefaultControllerCallPullIfNeeded(R)},e=>readableStreamDefaultControllerError(R,e))}function setupReadableStreamDefaultControllerFromSource(e,R,W,Y){let X=new ReadableStreamDefaultController(nl),ie=R?.start,ae=R?.pull,le=R?.cancel;setupReadableStreamDefaultController(e,X,ie?ie.bind(R,X):nonOpStart,ae?createPromiseCallback(`source.pull`,ae,R):nonOpPull,le?createPromiseCallback(`source.cancel`,le,R):nonOpCancel,W,Y)}function createReadableStream(e,R,W,Y=1,X=()=>1){let ie=Object.create(ReadableStream$1.prototype);return ie[Hs]=`ReadableStream`,ie[Bs]=createReadableStreamState(),setupReadableStreamDefaultController(ie,new ReadableStreamDefaultController(nl),e,R,W,Y,X),ie}function readableStreamFromIterable(e){let R,W=getIterator(e,`async`),Y=nonOpStart;async function pullAlgorithm(){let e=iteratorNext(W);return Promise.resolve(e).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.next() method must fulfill with an object`);e.done?readableStreamDefaultControllerClose(R[Bs].controller):readableStreamDefaultControllerEnqueue(R[Bs].controller,e.value)})}async function cancelAlgorithm(e){let R=W.iterator,Y=R.return;if(Y===void 0)return Promise.resolve();let X=Y.call(R,e);return Promise.resolve(X).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.return() method must fulfill with an object`)})}return R=createReadableStream(Y,pullAlgorithm,cancelAlgorithm,0),R}function readableStreamPipeTo(e,R,W,Y,X,ie){let ae,le;try{ae=new ReadableStreamDefaultReader(e),le=new WritableStreamDefaultWriter(R)}catch(e){return Promise.reject(e)}e[Bs].disturbed=!0;let _e=!1,{promise:ye,resolve:be,reject:Ce}=Promise.withResolvers(),Te={currentWrite:Promise.resolve()},Oe;function finalize(e,R){writableStreamDefaultWriterRelease(le),readableStreamReaderGenericRelease(ae),ie!==void 0&&Oe&&(ie.removeEventListener(`abort`,Oe),Oe=void 0),e?Ce(R):be()}async function waitForCurrentWrite(){let e=Te.currentWrite;await e,e!==Te.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(e,W,Y){if(_e)return;if(_e=!0,R[Bs].state===`writable`&&!writableStreamCloseQueuedOrInFlight(R)){waitForCurrentWrite().then(complete,e=>finalize(!0,e));return}complete();function complete(){e().then(()=>finalize(!!W,Y),e=>finalize(!0,e))}}function shutdown(e,W){if(!_e){if(_e=!0,R[Bs].state===`writable`&&!writableStreamCloseQueuedOrInFlight(R)){waitForCurrentWrite().then(()=>finalize(!!e,W),e=>finalize(!0,e));return}finalize(!!e,W)}}function abortAlgorithm(){let W;W=ie.reason&&ie.reason.name===`AbortError`?createAbortError():ie.reason;let ae=[];Y||ae.push(()=>R[Bs].state===`writable`?writableStreamAbort(R,W):Promise.resolve()),X||ae.push(()=>e[Bs].state===`readable`?readableStreamCancel(e,W):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(ae.map(e=>e())).then(()=>void 0),!0,W)}function watchErrored(e,R,W){e[Bs].state===`errored`?W(e[Bs].storedError):R.then(void 0,W)}function watchClosed(e,R,W){e[Bs].state===`closed`?W():R.then(W,()=>{})}class PipeToReadRequest{[Ac](e){Ct(()=>{Te.currentWrite=writableStreamDefaultWriterWrite(le,e),setPromiseHandled(Te.currentWrite),Ae.resolve(!1)})}[hc](){Ae.resolve(!0)}[Ic](e){Ae.reject(e)}}let Ae={resolve:null,reject:null};async function step(){if(_e||R[Bs].backpressure&&(await le[Bs].ready.promise,_e))return!0;let W=e[Bs].controller;if(e[Bs].state===`readable`&&_l(W)&&W[Bs].queue.length>0){for(;W[Bs].queue.length>0;){if(_e)return!0;let Y=dequeueValue(W);if(W[Bs].closeRequested&&!W[Bs].queue.length&&(readableStreamDefaultControllerClearAlgorithms(W),readableStreamClose(e)),Te.currentWrite=writableStreamDefaultWriterWrite(le,Y),setPromiseHandled(Te.currentWrite),R[Bs].backpressure||R[Bs].state!==`writable`||writableStreamCloseQueuedOrInFlight(R))break}return readableStreamDefaultControllerCallPullIfNeeded(W),e[Bs].state===`closed`}let{promise:Y,resolve:X,reject:ie}=Promise.withResolvers();return Ae={resolve:X,reject:ie},readableStreamDefaultReaderRead(ae,new PipeToReadRequest),Y}async function run(){for(;!await step(););}if(ie!==void 0){if(ie.aborted)return abortAlgorithm(),ye;Oe=abortAlgorithm,ie.addEventListener(`abort`,Oe,{once:!0})}if(setPromiseHandled(run()),watchErrored(e,ae[Bs].close.promise,e=>{if(!Y)return shutdownWithAnAction(()=>writableStreamAbort(R,e),!0,e);shutdown(!0,e)}),watchErrored(R,le[Bs].close.promise,R=>{if(!X)return shutdownWithAnAction(()=>readableStreamCancel(e,R),!0,R);shutdown(!0,R)}),watchClosed(e,ae[Bs].close.promise,()=>{if(!W)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(le));shutdown()}),writableStreamCloseQueuedOrInFlight(R)||R[Bs].state===`closed`){let R=TypeError(`Destination WritableStream is closed`);X?shutdown(!0,R):shutdownWithAnAction(()=>readableStreamCancel(e,R),!0,R)}return ye}function readableStreamDefaultTee(e,R){let W=new ReadableStreamDefaultReader(e),Y=!1,X=!1,ie=!1,ae,le,_e,ye,be=Promise.withResolvers();async function pullAlgorithm(){Y||(Y=!0,readableStreamDefaultReaderRead(W,{[Ac](e){Ct(()=>{Y=!1;let W=e,ae=e;if(!ie&&R)try{ae=structuredClone(ae)}catch{}X||readableStreamDefaultControllerEnqueue(_e[Bs].controller,W),ie||readableStreamDefaultControllerEnqueue(ye[Bs].controller,ae)})},[hc](){Ct(()=>{Y=!1,X||readableStreamDefaultControllerClose(_e[Bs].controller),ie||readableStreamDefaultControllerClose(ye[Bs].controller),(!X||!ie)&&be.resolve(void 0)})},[Ic](){Y=!1}}))}function cancel1Algorithm(R){if(X=!0,ae=R,ie){let R=[ae,le];be.resolve(readableStreamCancel(e,R))}return be.promise}function cancel2Algorithm(R){if(ie=!0,le=R,X){let R=[ae,le];be.resolve(readableStreamCancel(e,R))}return be.promise}return _e=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),ye=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),W[Bs].close.promise.then(void 0,e=>{readableStreamDefaultControllerError(_e[Bs].controller,e),readableStreamDefaultControllerError(ye[Bs].controller,e),(!X||!ie)&&be.resolve(void 0)}),[_e,ye]}var BYOBReadIntoRequest=class{[Bs];constructor(){this[Bs]=Promise.withResolvers()}[Ac](e){this[Bs].resolve?.({value:e,done:!1})}[hc](e){this[Bs].resolve?.({value:e,done:!0})}[Ic](e){this[Bs].reject?.(e)}get promise(){return this[Bs].promise}},ReadableStreamBYOBReader=class{[Hs]=`ReadableStreamBYOBReader`;[Bs];constructor(e){if(!ml(e))throw TypeError(`Expected a ReadableStream`);this[Bs]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,e)}read(e,R={}){if(!bl(this))return Promise.reject(TypeError(`Invalid this`));if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))return Promise.reject(TypeError(`view must be an ArrayBufferView`));let W=e.buffer,Y=e.byteLength;if(Y===0)return Promise.reject(TypeError(`view must have non-zero byteLength`));if(W.byteLength===0)return isDetachedBuffer(W)?Promise.reject(TypeError(`view's buffer has been detached`)):Promise.reject(TypeError(`view's buffer must have non-zero byteLength`));let X=R?.min??1;if(typeof X!=`number`||X<1||!Number.isInteger(X)||Number.isNaN(X))return Promise.reject(TypeError(`options.min must be a positive integer`));let ie=e[Symbol.toStringTag];if(ie!==void 0&&ie!==`DataView`){if(X>e.length)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`))}else if(X>Y)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`));if(this[Bs].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let ae=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,e,X,ae),ae.promise}releaseLock(){if(!bl(this))throw TypeError(`Invalid this`);this[Bs].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return bl(this)?this[Bs].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return bl(this)?this[Bs].stream===void 0?Promise.reject(TypeError(`Reader has no associated stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamBYOBReader`}},ReadableStreamBYOBRequest=class{[Hs]=`ReadableStreamBYOBRequest`;[Bs];constructor(e){if(e!==nl)throw TypeError(`Illegal constructor`)}get view(){if(!xl(this))throw TypeError(`Invalid this`);return this[Bs].view}respond(e){if(!xl(this))throw TypeError(`Invalid this`);if(this[Bs].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(e=+e,!Number.isInteger(e)||e<0||!Number.isFinite(e))throw RangeError(`bytesWritten must be a non-negative integer`);let R=this[Bs].view;if(isDetachedBuffer(R.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[Bs].controller,e)}respondWithNewView(e){if(!xl(this))throw TypeError(`Invalid this`);if(this[Bs].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`view must be an ArrayBufferView`);if(isDetachedBuffer(e.buffer))throw TypeError(`The given view's buffer has been detached`);readableByteStreamControllerRespondWithNewView(this[Bs].controller,e)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[Hs]=`ReadableByteStreamController`;[Bs];constructor(e){if(e!==nl)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!yl(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!yl(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!yl(this))throw TypeError(`Invalid this`);if(this[Bs].closeRequested)throw TypeError(`Close already requested`);if(this[Bs].stream[Bs].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(e){if(!yl(this))throw TypeError(`Invalid this`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`chunk must be an ArrayBufferView`);if(e.byteLength===0)throw TypeError(`chunk length must be non-zero`);if(e.buffer.byteLength===0)throw TypeError(`chunk's buffer length must be non-zero`);if(this[Bs].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[Bs].stream[Bs].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,e)}error(e=void 0){if(!yl(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,e)}[uc](e){return readableByteStreamControllerCancelSteps(this,e)}[Hc](e){readableByteStreamControllerPullSteps(this,e)}[el](){if(this[Bs].pendingPullIntos.length>0){let e=this[Bs].pendingPullIntos[0];e.readerType=`none`,this[Bs].pendingPullIntos=[e]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const yl=isBrandCheck(`ReadableByteStreamController`),bl=isBrandCheck(`ReadableStreamBYOBReader`),xl=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(e){let{reader:R}=e[Bs];return R===void 0?!1:R[Bs]!==void 0&&R[Hs]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(e){return e[Bs].reader[Bs].readIntoRequests.length}function readableStreamAddReadIntoRequest(e,R){e[Bs].reader[Bs].readIntoRequests.push(R)}function readableStreamFulfillReadIntoRequest(e,R,W){let{reader:Y}=e[Bs],X=Y[Bs].readIntoRequests.shift();W?X[hc](R):X[Ac](R)}function setupReadableStreamBYOBReader(e,R){if(isReadableStreamLocked(R))throw TypeError(`ReadableStream is locked`);if(!yl(R[Bs].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(e,R),e[Bs].readIntoRequests=[]}function readableStreamBYOBReaderRead(e,R,W,Y){let{stream:X}=e[Bs];X[Bs].disturbed=!0,X[Bs].state===`errored`?Y[Ic](X[Bs].storedError):readableByteStreamControllerPullInto(X[Bs].controller,R,W,Y)}function readableStreamBYOBReaderRelease(e){readableStreamReaderGenericRelease(e);let R=TypeError(`Reader was released`);for(let W=0;W<e[Bs].readIntoRequests.length;W++)e[Bs].readIntoRequests[W][Ic](R);e[Bs].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(e){e[Bs].pullAlgorithm=void 0,e[Bs].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[Bs].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(e){let R=e[Bs].byobRequest;R!=null&&(R[Bs].controller=void 0,R[Bs].view=null,e[Bs].byobRequest=null)}function readableByteStreamControllerError(e,R){let{stream:W}=e[Bs];W[Bs].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(W,R))}function readableByteStreamControllerGetDesiredSize(e){let R=e[Bs].stream[Bs].state;return R===`errored`?null:R===`closed`?0:e[Bs].highWaterMark-e[Bs].queueTotalSize}function readableByteStreamControllerShouldCallPull(e){let{stream:R}=e[Bs];if(R[Bs].state!==`readable`||e[Bs].closeRequested||!e[Bs].started)return!1;if(readableStreamHasDefaultReader(R)&&readableStreamGetNumReadRequests(R)>0||readableStreamHasBYOBReader(R)&&readableStreamGetNumReadIntoRequests(R)>0)return!0;let W=readableByteStreamControllerGetDesiredSize(e);return W!==null&&W>0}function readableByteStreamControllerCallPullIfNeeded(e){if(readableByteStreamControllerShouldCallPull(e)){if(e[Bs].pulling){e[Bs].pullAgain=!0;return}e[Bs].pulling=!0,e[Bs].pullAlgorithm(e).then(()=>{e[Bs].pulling=!1,e[Bs].pullAgain&&(e[Bs].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(e))},R=>readableByteStreamControllerError(e,R))}}function readableByteStreamControllerHandleQueueDrain(e){e[Bs].queueTotalSize===0&&e[Bs].closeRequested?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[Bs].stream)):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,R,W,Y){e[Bs].queue.push({buffer:R,byteOffset:W,byteLength:Y}),e[Bs].queueTotalSize+=Y}function readableByteStreamControllerEnqueueClonedChunkToQueue(e,R,W,Y){let X;try{X=R.slice(W,W+Y)}catch(R){readableByteStreamControllerError(e,R);return}readableByteStreamControllerEnqueueChunkToQueue(e,X,0,Y)}function readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,R){R.bytesFilled>0&&readableByteStreamControllerEnqueueClonedChunkToQueue(e,R.buffer,R.byteOffset,R.bytesFilled),readableByteStreamControllerShiftPendingPullInto(e)}function readableByteStreamControllerShiftPendingPullInto(e){return e[Bs].pendingPullIntos.shift()}function readableByteStreamControllerFillHeadPullIntoDescriptor(e,R,W){W.bytesFilled+=R}function readableByteStreamControllerConvertPullIntoDescriptor(e){let R=e.bytesFilled,W=e.elementSize,Y=transferArrayBuffer(e.buffer);return e.buffer=Y,new e.viewConstructor(Y,e.byteOffset,R/W)}function readableByteStreamControllerCommitPullIntoDescriptor(e,R){let W=!1;e[Bs].state===`closed`&&(W=!0);let Y=readableByteStreamControllerConvertPullIntoDescriptor(R);R.readerType===`default`?readableStreamFulfillReadRequest(e,Y,W):readableStreamFulfillReadIntoRequest(e,Y,W)}function readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,R){let W=Math.min(e[Bs].queueTotalSize,R.byteLength-R.bytesFilled),Y=R.bytesFilled+W,X=W,ie=!1,ae=Y-Y%R.elementSize;ae>=R.minimumFill&&(X=ae-R.bytesFilled,ie=!0);let le=e[Bs].queue;for(;X>0;){let W=le[0],Y=Math.min(X,W.byteLength),ie=R.byteOffset+R.bytesFilled,ae=new Uint8Array(R.buffer,ie,Y),_e=new Uint8Array(W.buffer,W.byteOffset,Y);ae.set(_e),W.byteLength===Y?le.shift():(W.byteOffset+=Y,W.byteLength-=Y),e[Bs].queueTotalSize-=Y,readableByteStreamControllerFillHeadPullIntoDescriptor(e,Y,R),X-=Y}return ie}function readableByteStreamControllerFillReadRequestFromQueue(e,R){let W=e[Bs].queue.shift();e[Bs].queueTotalSize-=W.byteLength,readableByteStreamControllerHandleQueueDrain(e);let Y=new Uint8Array(W.buffer,W.byteOffset,W.byteLength);R[Ac](Y)}function readableByteStreamControllerProcessReadRequestsUsingQueue(e){let R=e[Bs].stream[Bs].reader;for(;R[Bs].readRequests.length!==0;){if(e[Bs].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(e,R[Bs].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){for(;e[Bs].pendingPullIntos.length!==0;){if(e[Bs].queueTotalSize===0)return;let R=e[Bs].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,R)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[Bs].stream,R))}}function readableByteStreamControllerGetBYOBRequest(e){if(e[Bs].byobRequest===null&&e[Bs].pendingPullIntos.length!==0){let R=e[Bs].pendingPullIntos[0],W=new Uint8Array(R.buffer,R.byteOffset+R.bytesFilled,R.byteLength-R.bytesFilled),Y=new ReadableStreamBYOBRequest(nl);Y[Bs]={controller:e,view:W},e[Bs].byobRequest=Y}return e[Bs].byobRequest}function readableByteStreamControllerEnqueue(e,R){let{stream:W}=e[Bs];if(e[Bs].closeRequested||W[Bs].state!==`readable`)return;let Y=R.buffer,X=R.byteLength,ie=R.byteOffset;if(isDetachedBuffer(Y))throw TypeError(`chunk's buffer is detached`);let ae=transferArrayBuffer(Y);if(e[Bs].pendingPullIntos.length!==0){let R=e[Bs].pendingPullIntos[0];if(isDetachedBuffer(R.buffer))throw TypeError(`BYOB request's buffer has been detached`);readableByteStreamControllerInvalidateBYOBRequest(e),R.buffer=transferArrayBuffer(R.buffer),R.readerType===`none`&&readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,R)}readableStreamHasDefaultReader(W)?(readableByteStreamControllerProcessReadRequestsUsingQueue(e),readableStreamGetNumReadRequests(W)===0?readableByteStreamControllerEnqueueChunkToQueue(e,ae,ie,X):(e[Bs].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(e),readableStreamFulfillReadRequest(W,new Uint8Array(ae,ie,X),!1))):readableStreamHasBYOBReader(W)?(readableByteStreamControllerEnqueueChunkToQueue(e,ae,ie,X),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,ae,ie,X),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerClose(e){let{stream:R}=e[Bs];if(!(e[Bs].closeRequested||R[Bs].state!==`readable`)){if(e[Bs].queueTotalSize>0){e[Bs].closeRequested=!0;return}if(e[Bs].pendingPullIntos.length!==0){let R=e[Bs].pendingPullIntos[0];if(R.bytesFilled%R.elementSize!==0){let R=TypeError(`Insufficient bytes to fill elements in the given buffer`);throw readableByteStreamControllerError(e,R),R}}readableByteStreamControllerClearAlgorithms(e),readableStreamClose(R)}}function readableByteStreamControllerPullInto(e,R,W,Y){let X=e[Bs].stream,ie=R[Symbol.toStringTag],ae,le;if(ie===void 0||ie===`DataView`)ae=DataView,le=1;else{let e=typedArrayConstructorByTag(ie);if(!e){Y[Ic](TypeError(`Unsupported typed array: ${ie}`));return}ae=e,le=elementSizeByTag(ie)}let _e=R.buffer,ye=R.byteLength,be=R.byteOffset,Ce=W*le,Te;try{Te=transferArrayBuffer(_e)}catch(e){Y[Ic](e);return}let Oe={buffer:Te,bufferByteLength:Te.byteLength,byteOffset:be,byteLength:ye,bytesFilled:0,minimumFill:Ce,elementSize:le,viewConstructor:ae,readerType:`byob`};if(e[Bs].pendingPullIntos.length!==0){e[Bs].pendingPullIntos.push(Oe),readableStreamAddReadIntoRequest(X,Y);return}if(X[Bs].state===`closed`){let e=new ae(Oe.buffer,Oe.byteOffset,0);Y[hc](e);return}if(e[Bs].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,Oe)){let R=readableByteStreamControllerConvertPullIntoDescriptor(Oe);readableByteStreamControllerHandleQueueDrain(e),Y[Ac](R);return}if(e[Bs].closeRequested){let R=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(e,R),Y[Ic](R);return}}e[Bs].pendingPullIntos.push(Oe),readableStreamAddReadIntoRequest(X,Y),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespond(e,R){let W=e[Bs].pendingPullIntos[0];if(e[Bs].stream[Bs].state===`closed`){if(R!==0)throw TypeError(`bytesWritten must be 0 when calling respond() on a closed stream`)}else{if(R===0)throw TypeError(`bytesWritten must be greater than 0 when calling respond() on a readable stream`);if(W.bytesFilled+R>W.byteLength)throw RangeError(`bytesWritten out of range`)}W.buffer=transferArrayBuffer(W.buffer),readableByteStreamControllerRespondInternal(e,R)}function readableByteStreamControllerRespondWithNewView(e,R){let W=e[Bs].pendingPullIntos[0],Y=e[Bs].stream[Bs].state,X=R.byteLength,ie=R.byteOffset,ae=R.buffer;if(Y===`closed`){if(X!==0)throw TypeError(`view's length must be 0 when calling respondWithNewView() on a closed stream`)}else if(X===0)throw TypeError(`view's length must be greater than 0 when calling respondWithNewView() on a readable stream`);if(W.byteOffset+W.bytesFilled!==ie)throw RangeError(`The region specified by view does not match byobRequest`);if(W.bufferByteLength!==ae.byteLength)throw RangeError(`The buffer of view has different capacity than byobRequest`);if(W.bytesFilled+X>W.byteLength)throw RangeError(`The region specified by view is larger than byobRequest`);W.buffer=transferArrayBuffer(ae),readableByteStreamControllerRespondInternal(e,X)}function readableByteStreamControllerRespondInternal(e,R){let W=e[Bs].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(e),e[Bs].stream[Bs].state===`closed`?readableByteStreamControllerRespondInClosedState(e,W):readableByteStreamControllerRespondInReadableState(e,R,W),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondInClosedState(e,R){R.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(e);let W=e[Bs].stream;if(readableStreamHasBYOBReader(W))for(;readableStreamGetNumReadIntoRequests(W)>0;)readableByteStreamControllerCommitPullIntoDescriptor(W,readableByteStreamControllerShiftPendingPullInto(e))}function readableByteStreamControllerRespondInReadableState(e,R,W){if(readableByteStreamControllerFillHeadPullIntoDescriptor(e,R,W),W.readerType===`none`){readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,W),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e);return}if(W.bytesFilled<W.minimumFill)return;readableByteStreamControllerShiftPendingPullInto(e);let Y=W.bytesFilled%W.elementSize;if(Y>0){let R=W.byteOffset+W.bytesFilled;readableByteStreamControllerEnqueueClonedChunkToQueue(e,W.buffer,R-Y,Y)}W.bytesFilled-=Y,readableByteStreamControllerCommitPullIntoDescriptor(e[Bs].stream,W),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerCancelSteps(e,R){readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e);let W=e[Bs].cancelAlgorithm?.(R)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(e),W}function readableByteStreamControllerPullSteps(e,R){let W=e[Bs].stream;if(e[Bs].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(e,R);return}let Y=e[Bs].autoAllocateChunkSize;if(Y!==void 0){let W;try{W=new ArrayBuffer(Y)}catch(e){R[Ic](e);return}let X={buffer:W,bufferByteLength:Y,byteOffset:0,byteLength:Y,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};e[Bs].pendingPullIntos.push(X)}readableStreamAddReadRequest(W,R),readableByteStreamControllerCallPullIfNeeded(e)}function setupReadableByteStreamController(e,R,W,Y,X,ie,ae){R[Bs]={cancelAlgorithm:X,closeRequested:!1,highWaterMark:ie,pullAgain:!1,pullAlgorithm:Y,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:e,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:ae},e[Bs].controller=R;let le=W();new Promise(e=>e(le)).then(()=>{R[Bs].started=!0,readableByteStreamControllerCallPullIfNeeded(R)},e=>readableByteStreamControllerError(R,e))}function setupReadableByteStreamControllerFromSource(e,R,W){let Y=new ReadableByteStreamController(nl),X=R?.start,ie=R?.pull,ae=R?.cancel,le=R?.autoAllocateChunkSize;if(le!==void 0&&(le===0||!Number.isInteger(le)||le<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(e,Y,X?X.bind(R,Y):nonOpStart,ie?createPromiseCallback(`source.pull`,ie,R):nonOpPull,ae?createPromiseCallback(`source.cancel`,ae,R):nonOpCancel,W,le)}function readableByteStreamTee(e){let R=new ReadableStreamDefaultReader(e),W=!1,Y=!1,X=!1,ie,ae,le=Promise.withResolvers(),_e,ye,be,Ce;function pullAlgorithm(){return W?Promise.resolve():(W=!0,R.read().then(e=>{if(W=!1,e.done){Y||be.close(),X||Ce.close();return}let R=e.value,ie=new Uint8Array(R.buffer.slice(R.byteOffset,R.byteOffset+R.byteLength));Y||be.enqueue(ie),X||Ce.enqueue(new Uint8Array(ie))},()=>{}),Promise.resolve())}return _e=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(R){if(Y=!0,ie=R,X){let R=readableStreamCancel(e,[ie,ae]);return le.resolve(),R}return le.promise}}),ye=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(R){if(X=!0,ae=R,Y){let R=readableStreamCancel(e,[ie,ae]);return le.resolve(),R}return le.promise}}),be=_e[Bs].controller,Ce=ye[Bs].controller,R.closed.catch(e=>{be.error(e),Ce.error(e),(!Y||!X)&&le.resolve()}),[_e,ye]}const Sl=Symbol(`kSkipThrow`);var TransformStream=class{[Hs]=`TransformStream`;[Bs];constructor(e={},R={},W={}){if(e!=null&&typeof e!=`object`)throw TypeError(`transformer must be an object`);if(R!=null&&typeof R!=`object`)throw TypeError(`writableStrategy must be an object`);if(W!=null&&typeof W!=`object`)throw TypeError(`readableStrategy must be an object`);let Y=e?.readableType,X=e?.writableType,ie=e?.start;if(Y!==void 0)throw RangeError(`Invalid readableType: ${Y}`);if(X!==void 0)throw RangeError(`Invalid writableType: ${X}`);let ae=extractHighWaterMark(W?.highWaterMark,0),le=extractSizeAlgorithm(W?.size),_e=extractHighWaterMark(R?.highWaterMark,1),ye=extractSizeAlgorithm(R?.size),be=Promise.withResolvers();initializeTransformStream(this,be,_e,ye,ae,le),setupTransformStreamDefaultControllerFromTransformer(this,e),ie===void 0?be.resolve():be.resolve(ie.call(e,this[Bs].controller))}get readable(){if(!Cl(this))throw TypeError(`Invalid this`);return this[Bs].readable}get writable(){if(!Cl(this))throw TypeError(`Invalid this`);return this[Bs].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[Hs]=`TransformStreamDefaultController`;[Bs];constructor(e){if(e!==Sl)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!wl(this))throw TypeError(`Invalid this`);let{stream:e}=this[Bs],{readable:R}=e[Bs],W=R[Bs].controller;return readableStreamDefaultControllerGetDesiredSize(W)}enqueue(e){if(!wl(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!wl(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,e)}terminate(){if(!wl(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const Cl=isBrandCheck(`TransformStream`),wl=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(e,R){transformStreamDefaultControllerEnqueue(R,e)}function initializeTransformStream(e,R,W,Y,X,ie){let startAlgorithm=()=>R.promise,ae=createWritableStream(startAlgorithm,R=>transformStreamDefaultSinkWriteAlgorithm(e,R),()=>transformStreamDefaultSinkCloseAlgorithm(e),R=>transformStreamDefaultSinkAbortAlgorithm(e,R),W,Y);e[Bs]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(e),R=>transformStreamDefaultSourceCancelAlgorithm(e,R),X,ie),writable:ae,controller:void 0,backpressure:void 0,backpressureChange:{promise:void 0,resolve:void 0,reject:void 0}},transformStreamSetBackpressure(e,!0)}function transformStreamError(e,R){let{readable:W}=e[Bs];readableStreamDefaultControllerError(W[Bs].controller,R),transformStreamErrorWritableAndUnblockWrite(e,R)}function transformStreamErrorWritableAndUnblockWrite(e,R){let{controller:W,writable:Y}=e[Bs];transformStreamDefaultControllerClearAlgorithms(W),writableStreamDefaultControllerErrorIfNeeded(Y[Bs].controller,R),transformStreamUnblockWrite(e)}function transformStreamUnblockWrite(e){e[Bs].backpressure&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,R){e[Bs].backpressureChange.promise!==void 0&&e[Bs].backpressureChange.resolve?.(),e[Bs].backpressureChange=Promise.withResolvers(),e[Bs].backpressure=R}function setupTransformStreamDefaultController(e,R,W,Y,X){R[Bs]={stream:e,transformAlgorithm:W,flushAlgorithm:Y,cancelAlgorithm:X,finishPromise:void 0},e[Bs].controller=R}function setupTransformStreamDefaultControllerFromTransformer(e,R){let W=new TransformStreamDefaultController(Sl),Y=R?.transform,X=R?.flush,ie=R?.cancel;setupTransformStreamDefaultController(e,W,Y?createPromiseCallback(`transformer.transform`,Y,R):defaultTransformAlgorithm,X?createPromiseCallback(`transformer.flush`,X,R):nonOpFlush,ie?createPromiseCallback(`transformer.cancel`,ie,R):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(e){e[Bs].transformAlgorithm=void 0,e[Bs].flushAlgorithm=void 0,e[Bs].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(e,R){let{stream:W}=e[Bs],{readable:Y}=W[Bs],X=Y[Bs].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(X))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(X,R)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(W,e),Y[Bs].storedError}readableStreamDefaultControllerHasBackpressure(X)!==W[Bs].backpressure&&transformStreamSetBackpressure(W,!0)}function transformStreamDefaultControllerError(e,R){transformStreamError(e[Bs].stream,R)}async function transformStreamDefaultControllerPerformTransform(e,R){try{let W=e[Bs].transformAlgorithm;if(W===void 0)return;await W(R,e)}catch(R){throw transformStreamError(e[Bs].stream,R),R}}function transformStreamDefaultControllerTerminate(e){let{stream:R}=e[Bs],{readable:W}=R[Bs];readableStreamDefaultControllerClose(W[Bs].controller),transformStreamErrorWritableAndUnblockWrite(R,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(e,R){let{controller:W}=e[Bs];return e[Bs].backpressure?e[Bs].backpressureChange.promise.then(()=>{let{writable:Y}=e[Bs];if(Y[Bs].state===`erroring`)throw Y[Bs].storedError;return transformStreamDefaultControllerPerformTransform(W,R)}):transformStreamDefaultControllerPerformTransform(W,R)}async function transformStreamDefaultSinkAbortAlgorithm(e,R){let{controller:W,readable:Y}=e[Bs];if(W[Bs].finishPromise!==void 0)return W[Bs].finishPromise;let{promise:X,resolve:ie,reject:ae}=Promise.withResolvers();W[Bs].finishPromise=X;let le=W[Bs].cancelAlgorithm(R);return transformStreamDefaultControllerClearAlgorithms(W),le.then(()=>{Y[Bs].state===`errored`?ae(Y[Bs].storedError):(readableStreamDefaultControllerError(Y[Bs].controller,R),ie())},e=>{readableStreamDefaultControllerError(Y[Bs].controller,e),ae(e)}),W[Bs].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(e){let{readable:R,controller:W}=e[Bs];if(W[Bs].finishPromise!==void 0)return W[Bs].finishPromise;let{promise:Y,resolve:X,reject:ie}=Promise.withResolvers();W[Bs].finishPromise=Y;let ae=W[Bs].flushAlgorithm(W);return transformStreamDefaultControllerClearAlgorithms(W),ae.then(()=>{R[Bs].state===`errored`?ie(R[Bs].storedError):(readableStreamDefaultControllerClose(R[Bs].controller),X())},e=>{readableStreamDefaultControllerError(R[Bs].controller,e),ie(e)}),W[Bs].finishPromise}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[Bs].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(e,R){let{controller:W,writable:Y}=e[Bs];if(W[Bs].finishPromise!==void 0)return W[Bs].finishPromise;let{promise:X,resolve:ie,reject:ae}=Promise.withResolvers();W[Bs].finishPromise=X;let le=W[Bs].cancelAlgorithm(R);return transformStreamDefaultControllerClearAlgorithms(W),le.then(()=>{Y[Bs].state===`errored`?ae(Y[Bs].storedError):(writableStreamDefaultControllerErrorIfNeeded(Y[Bs].controller,R),transformStreamUnblockWrite(e),ie())},R=>{writableStreamDefaultControllerErrorIfNeeded(Y[Bs].controller,R),transformStreamUnblockWrite(e),ae(R)}),W[Bs].finishPromise}const Tl=Object.defineProperty(e=>e.byteLength,"name",{value:`size`}),El=Object.defineProperty(()=>1,"name",{value:`size`});var ByteLengthQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return Tl}get[Symbol.toStringTag](){return`ByteLengthQueuingStrategy`}},CountQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return El}get[Symbol.toStringTag](){return`CountQueuingStrategy`}},TextEncoderStream=class{#e=null;#t=new TextEncoder;#n;constructor(){this.#n=new TransformStream({transform:(e,R)=>{if(e=String(e),e===``)return;this.#e!==null&&(e=this.#e+e);let W=e.charCodeAt(e.length-1);55296<=W&&W<=56319?(this.#e=e.slice(-1),e=e.slice(0,-1)):this.#e=null,e&&R.enqueue(this.#t.encode(e))},flush:e=>{this.#e!==null&&e.enqueue(new Uint8Array([239,191,189]))}})}get encoding(){return`utf-8`}get readable(){return this.#n.readable}get writable(){return this.#n.writable}};function hasStreamingSupport(){try{return new TextDecoder().decode(new Uint8Array([195]),{stream:!0}),!0}catch{return!1}}const Al=hasStreamingSupport();function incompleteUtf8Tail(e){let R=e.length;if(R===0)return 0;for(let W=1;W<=Math.min(3,R);W++){let Y=e[R-W];if(!(Y&128))return 0;if((Y&192)!=128){let e;if((Y&224)==192)e=2;else if((Y&240)==224)e=3;else if((Y&248)==240)e=4;else return 0;return W<e?W:0}}return 0}var TextDecoderStream=class{#e;#t;constructor(e,R){if(this.#e=new TextDecoder(e,R),Al)this.#t=new TransformStream({transform:(e,R)=>{let W=toUint8Array$2(e),Y=this.#e.decode(W,{stream:!0});Y&&R.enqueue(Y)},flush:e=>{let R=this.#e.decode();R&&e.enqueue(R)},cancel:()=>{this.#e.decode()}});else{let e=new Uint8Array;this.#t=new TransformStream({transform:(R,W)=>{let Y=toUint8Array$2(R),X;e.length>0?(X=new Uint8Array(e.length+Y.length),X.set(e,0),X.set(Y,e.length)):X=Y;let ie=incompleteUtf8Tail(X),ae;if(ie>0?(ae=X.slice(0,X.length-ie),e=X.slice(X.length-ie)):(ae=X,e=new Uint8Array),ae.length>0){let e=this.#e.decode(ae);e&&W.enqueue(e)}},flush:R=>{if(e.length>0){let W=this.#e.decode(e);W&&R.enqueue(W),e=new Uint8Array}},cancel:()=>{e=new Uint8Array}})}}get encoding(){return this.#e.encoding}get fatal(){return this.#e.fatal}get ignoreBOM(){return this.#e.ignoreBOM}get readable(){return this.#t.readable}get writable(){return this.#t.writable}};function toUint8Array$2(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`chunk must be a BufferSource`)}__name$1(toUint8Array$2,`toUint8Array`);function isNativeStreamUsable$3(e,R){try{return typeof e==`function`?typeof e.prototype?.[R]==`function`:!1}catch{return!1}}__name$1(isNativeStreamUsable$3,`isNativeStreamUsable`);const jl=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,Ml=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,Nl=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,Fl=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,Ll=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,Rl=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,zl=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;var Bl=__esmMin(()=>{Ht()});function _setPipeImpl(e){Vl=e}var Vl,Stream_,Gl=__esmMin(()=>{ls(),Stream_=class extends cs{constructor(e){super(e)}pipe(e,R){return Vl(this,e,R)}}});function getDefaultHighWaterMark(e){return e?Jl:ql}function setDefaultHighWaterMark(e,R){if(typeof R!=`number`||R<0||Number.isNaN(R))throw TypeError(`Invalid highWaterMark: ${R}`);e?Jl=R:ql=R}function validateHighWaterMark(e,R){if(R!==void 0&&(typeof R!=`number`||Number.isNaN(R))){let W=TypeError(`The value of "${e}" is invalid. Received ${R}`);throw W.code=`ERR_INVALID_ARG_VALUE`,W}}var ql,Jl,Yl=__esmMin(()=>{ql=16384,Jl=16});function chunkLength(e){if(e==null)return 1;let R=e.length;return typeof R==`number`?R:1}function sliceChunk(e,R,W){if(typeof e==`string`)return W===void 0?e.slice(R):e.slice(R,W);let Y=e.slice;return typeof Y==`function`?Y.call(e,R,W):e}var Xl,Zl=__esmMin(()=>{Gl(),Yl(),Ht(),Xl=class Readable_ extends Stream_{readable=!0;readableFlowing=null;readableLength=0;readableHighWaterMark;readableEncoding;readableObjectMode;readableEnded=!1;readableAborted=!1;destroyed=!1;_pipeDests=[];_buffer=[];_readableState={ended:!1,endEmitted:!1,reading:!1,constructed:!0,highWaterMark:0,objectMode:!1,pipes:[]};_err;_readablePending=!1;_readImpl;_destroyImpl;_constructImpl;constructor(e){super(e),this.readableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.readableEncoding=e?.encoding??null,this.readableObjectMode=e?.objectMode??!1,this._readableState.highWaterMark=this.readableHighWaterMark,this._readableState.objectMode=this.readableObjectMode,e?.read&&(this._readImpl=e.read),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Readable_.prototype._construct)&&(this._readableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._readableState.constructed=!0,e?this.destroy(e):this.readableFlowing===!0&&this._flow()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_read(e){this._readImpl&&this._readImpl.call(this,e)}read(e){if(!this._readableState.constructed)return null;if(this._buffer.length===0){if(this._readableState.ended)return null;this._readableState.reading=!0,this._read(e??this.readableHighWaterMark),this._readableState.reading=!1}if(this._buffer.length===0||e===0)return null;if(this.readableObjectMode){if(e===void 0){let e=this._buffer.shift();return--this.readableLength,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),e}if(e>this.readableLength)return null;let R=this._buffer.shift();return--this.readableLength,R}if(e!=null)return e>this.readableLength?null:this._readBytes(e);let R=this._buffer.splice(0);if(this.readableLength=0,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),R.length===1)return R[0];if(R.length===0)return null;if(typeof R[0]==`string`)return R.join(``);let W=globalThis.Buffer;return W?.concat?W.concat(R):R}_readBytes(e){let R=0,W=[];for(;R<e&&this._buffer.length>0;){let Y=this._buffer[0],X=chunkLength(Y);if(R+X<=e)W.push(this._buffer.shift()),R+=X,this.readableLength-=X;else{let X=e-R;W.push(sliceChunk(Y,0,X)),this._buffer[0]=sliceChunk(Y,X),this.readableLength-=X,R+=X}}if(W.length===1)return W[0];let Y=globalThis.Buffer;return Y?.concat?Y.concat(W):W}push(e,R){if(e===null)return this._readableState.ended=!0,this.readableEnded=!0,this._buffer.length===0&&!this._readableState.endEmitted&&nextTick(()=>this._emitEnd()),this._scheduleReadable(),!1;if(!this.readableObjectMode&&!(typeof e==`string`||ArrayBuffer.isView(e))){let R=Object.assign(TypeError(`Invalid non-string/buffer chunk type: ${typeof e}`),{code:`ERR_INVALID_ARG_TYPE`});return nextTick(()=>this.emit(`error`,R)),!1}return this._buffer.push(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e),this.readableFlowing&&!this._flowing&&nextTick(()=>this._flow()),this.readableFlowing!==!0&&this._scheduleReadable(),this.readableLength<this.readableHighWaterMark}_emitEnd(){this._readableState.endEmitted||(this._readableState.endEmitted=!0,this.emit(`end`),nextTick(()=>this._autoClose()))}_autoClose(){this.emit(`close`)}_scheduleReadable(){this._readablePending||this.listenerCount(`readable`)===0||(this._readablePending=!0,nextTick(()=>{this._readablePending=!1,this.destroyed||this.emit(`readable`)}))}on(e,R){return super.on(e,R),e===`data`&&this.readableFlowing!==!1&&this.resume(),e===`readable`&&(this._buffer.length>0||this._readableState.ended)&&this._scheduleReadable(),this}unshift(e){this._buffer.unshift(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e)}setEncoding(e){return this.readableEncoding=e,this}pause(){return this.readableFlowing=!1,this.emit(`pause`),this}resume(){return this.readableFlowing!==!0&&(this.readableFlowing=!0,this.emit(`resume`),this._readableState.constructed&&this._flow()),this}_flowing=!1;_flow(){if(!(this.readableFlowing!==!0||this._flowing||this.destroyed)&&this._readableState.constructed){this._flowing=!0;try{for(;this._buffer.length>0&&this.readableFlowing&&!this.destroyed;){let e=this._buffer.shift();if(this.readableLength-=this.readableObjectMode?1:chunkLength(e),this.readableEncoding&&typeof e!=`string`){let R=globalThis.Buffer;R?.isBuffer&&R.isBuffer(e)?e=e.toString(this.readableEncoding):e instanceof Uint8Array&&(e=new TextDecoder(this.readableEncoding).decode(e))}this.emit(`data`,e)}if(this.destroyed)return;if(this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted){nextTick(()=>this._emitEnd());return}!this._readableState.ended&&!this._readableState.reading&&!this.destroyed&&(this._readableState.reading=!0,this._read(this.readableHighWaterMark),this._readableState.reading=!1)}finally{this._flowing=!1}this._buffer.length>0&&this.readableFlowing&&!this.destroyed&&nextTick(()=>this._flow())}}isPaused(){return this.readableFlowing===!1}unpipe(e){if(e){let R=this._pipeDests.findIndex(R=>R.dest===e);if(R!==-1){this._pipeDests[R].cleanup(),this._pipeDests.splice(R,1);let W=this._readableState.pipes.indexOf(e);W!==-1&&this._readableState.pipes.splice(W,1),e.emit(`unpipe`,this),this._pipeDests.length===0&&(this.readableFlowing=!1)}}else{for(let e of this._pipeDests)e.cleanup(),e.dest.emit(`unpipe`,this);this._pipeDests=[],this._readableState.pipes=[],this.readableFlowing=!1}return this}_destroy(e,R){this._destroyImpl?this._destroyImpl.call(this,e,R):R(e??void 0)}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.readable=!1,this.readableAborted=!this.readableEnded,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return Object.prototype.hasOwnProperty.call(this,`_destroy`)?this._destroy(e??null,cb):this._destroyImpl?this._destroyImpl.call(this,e??null,cb):cb(e),this}static toWeb(e){return new ReadableStream({start(R){e.on(`data`,e=>{typeof e==`string`?R.enqueue(new TextEncoder().encode(e)):e instanceof Uint8Array?R.enqueue(e):e&&typeof e.length==`number`&&R.enqueue(new Uint8Array(e))}),e.on(`end`,()=>{R.close()}),e.on(`error`,e=>{R.error(e)})},cancel(){e.destroy()}})}static fromWeb(e,R){let W=e.getReader();return new Readable_({...R,read(){W.read().then(({done:e,value:R})=>{e?this.push(null):this.push(R)},e=>{this.destroy(e)})},destroy(e,R){W.cancel(e?.message).then(()=>R(null),R)}})}[Symbol.asyncIterator](){let e=this,R=[],W=!1,Y=null,X=null,ie=null;return e.on(`data`,e=>{if(X){let R=X;X=null,ie=null,R({value:e,done:!1})}else R.push(e)}),e.on(`end`,()=>{if(W=!0,X){let e=X;X=null,ie=null,e({value:void 0,done:!0})}}),e.on(`error`,e=>{if(Y=e,W=!0,ie){let R=ie;X=null,ie=null,R(e)}}),{next(){return Y?Promise.reject(Y):R.length>0?Promise.resolve({value:R.shift(),done:!1}):W?Promise.resolve({value:void 0,done:!0}):new Promise((e,R)=>{X=e,ie=R})},return(){return e.destroy(),Promise.resolve({value:void 0,done:!0})},[Symbol.asyncIterator](){return this}}}static from(e,R){let W=new Readable_({objectMode:!0,...R,read(){}});return typeof e==`string`||ArrayBuffer.isView(e)?(W.push(e),W.push(null),W):((async()=>{try{for await(let R of e)W.push(R)||await new Promise(e=>W.once(`drain`,e));W.push(null)}catch(e){W.destroy(e)}})(),W)}}});function chunkLen$1(e){if(e==null)return 1;let R=e.length;return typeof R==`number`?R:1}var Duplex_,Ql=__esmMin(()=>{Yl(),Zl(),Ht(),Duplex_=class extends Xl{writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;allowHalfOpen;_decodeStrings;_writableState={highWaterMark:0,objectMode:!1};_duplexCorkedBuffer=[];_duplexWriting=!1;_duplexWriteQueue=[];_writeImpl;_finalImpl;_defaultEncoding=`utf8`;_pendingWrites=0;_pendingEndCb=null;constructor(e){super(e),validateHighWaterMark(`writableHighWaterMark`,e?.writableHighWaterMark),validateHighWaterMark(`readableHighWaterMark`,e?.readableHighWaterMark),this.writableObjectMode=e?.writableObjectMode??e?.objectMode??!1,this.writableHighWaterMark=e?.highWaterMark??e?.writableHighWaterMark??getDefaultHighWaterMark(this.writableObjectMode),this._writableState.highWaterMark=this.writableHighWaterMark,this._writableState.objectMode=this.writableObjectMode,e?.highWaterMark===void 0&&e?.readableHighWaterMark!==void 0&&(this.readableHighWaterMark=e.readableHighWaterMark,this._readableState.highWaterMark=e.readableHighWaterMark),e?.readableObjectMode!==void 0&&(this.readableObjectMode=e.readableObjectMode,this._readableState.objectMode=e.readableObjectMode,e?.readableHighWaterMark===void 0&&e?.highWaterMark===void 0&&(this.readableHighWaterMark=getDefaultHighWaterMark(e.readableObjectMode),this._readableState.highWaterMark=this.readableHighWaterMark)),this.allowHalfOpen=e?.allowHalfOpen!==!1,this._decodeStrings=e?.decodeStrings!==!1,e?.write&&(this._writeImpl=e.write),e?.final&&(this._finalImpl=e.final),this.allowHalfOpen||this.once(`end`,()=>{this.writableEnded||nextTick(()=>this.end())})}_write(e,R,W){this._writeImpl?this._writeImpl.call(this,e,R,W):W()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}destroy(e){return this.destroyed?this:(this.writable=!1,super.destroy(e))}write(e,R,W){let Y,X;if(typeof R==`function`?(Y=R,X=this._defaultEncoding):(X=R??this._defaultEncoding,Y=W??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let R=globalThis.Buffer;R&&(e=R.from(e,X),X=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let R=globalThis.Buffer;(R&&R.isBuffer(e)||e instanceof Uint8Array)&&(X=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{Y(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen$1(e),this.writableCorked>0)return this._duplexCorkedBuffer.push({chunk:e,encoding:X,callback:Y}),this.writableLength<this.writableHighWaterMark;let ie=this.writableLength<this.writableHighWaterMark;return ie||(this.writableNeedDrain=!0),this._duplexDoWrite(e,X,Y),ie}_duplexDoWrite(e,R,W){if(this._duplexWriting){this._duplexWriteQueue.push({chunk:e,encoding:R,callback:W});return}this._duplexWriting=!0,this._duplexStartWrite(e,R,W)}_duplexStartWrite(e,R,W){this._pendingWrites++,this._write(e,R,R=>{this._pendingWrites--,this.writableLength-=this.writableObjectMode?1:chunkLen$1(e),nextTick(R?()=>{if(W(R),this._duplexWriting=!1,this.emit(`error`,R),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexWriting=!0,this._duplexStartWrite(e.chunk,e.encoding,e.callback)}}:()=>{if(W(),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexStartWrite(e.chunk,e.encoding,e.callback);return}if(this._duplexWriting=!1,this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._pendingWrites===0&&this._pendingEndCb){let e=this._pendingEndCb;this._pendingEndCb=null,e()}})})}end(e,R,W){typeof e==`function`&&(W=e,e=void 0),typeof R==`function`&&(W=R,R=void 0),e!=null&&this.write(e,R),this.writableEnded=!0;let doFinal=()=>{this._final(e=>{this.writableFinished=!0,this._doPrefinishHooks(()=>{nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),nextTick(()=>this.emit(`close`)),W&&W()})})})};return this._pendingWrites>0||this._duplexWriting||this._duplexWriteQueue.length>0?this._pendingEndCb=doFinal:doFinal(),this}_doPrefinishHooks(e){e()}cork(){this.writableCorked++}uncork(){if(this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._duplexCorkedBuffer.length>0)){let e=this._duplexCorkedBuffer.splice(0);for(let{chunk:R,encoding:W,callback:Y}of e)this._write(R,W,e=>{this.writableLength-=this.writableObjectMode?1:chunkLen$1(R),e?(Y(e),this.emit(`error`,e)):Y()});this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,nextTick(()=>this.emit(`drain`)))}}setDefaultEncoding(e){return this._defaultEncoding=e,this}},__name$1(chunkLen$1,`chunkLen`)});function pipe(e,R,W){let Y=e,X=W?.end!==!1,ie=!1,ondrain=()=>{ie=!1,R.removeListener(`drain`,ondrain);let e=Y;typeof e.resume==`function`&&e.resume()},ondata=e=>{if(R.writable){let W=Y;R.write(e)===!1&&typeof W.pause==`function`&&(W.pause(),ie||(ie=!0,R.on(`drain`,ondrain)))}};Y.on(`data`,ondata);let ae=!1,onend=()=>{ae||(ae=!0,X&&R.end())},onclose=()=>{if(!ae&&(ae=!0,X&&!(Y instanceof Xl))){let e=R;typeof e.destroy==`function`&&e.destroy()}};X&&(Y.on(`end`,onend),Y.on(`close`,onclose));let cleanup=()=>{Y.removeListener(`data`,ondata),ie&&R.removeListener(`drain`,ondrain),Y.removeListener(`end`,onend),Y.removeListener(`close`,onclose),Y.removeListener(`end`,cleanup),Y.removeListener(`close`,cleanup),R.removeListener(`close`,cleanup)};return Y.on(`end`,cleanup),Y.on(`close`,cleanup),R.on(`close`,cleanup),Y instanceof Xl&&(Y._pipeDests.push({dest:R,cleanup}),Y._readableState.pipes.push(R)),R.emit(`pipe`,Y),R}var eu=__esmMin(()=>{Gl(),Zl(),_setPipeImpl(pipe)});function chunkLen(e){if(e==null)return 1;let R=e.length;return typeof R==`number`?R:1}var tu,nu=__esmMin(()=>{Gl(),Yl(),Ht(),tu=class Writable_ extends Stream_{static[Symbol.hasInstance](e){let R=this;return R.prototype!==void 0&&Object.prototype.isPrototypeOf.call(R.prototype,e)?!0:R.prototype!==Writable_.prototype||e==null?!1:typeof e.writableHighWaterMark==`number`}writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;destroyed=!1;_err;_writableState={ended:!1,finished:!1,constructed:!0,writing:!1};_corkedBuffer=[];_writeBuffer=[];_pendingConstruct=[];_ending=!1;_endCallback;_pendingEnd=null;_writeImpl;_writev;_finalImpl;_destroyImpl;_constructImpl;_decodeStrings;_defaultEncoding=`utf8`;constructor(e){super(e),this.writableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.writableObjectMode=e?.objectMode??!1,this._decodeStrings=e?.decodeStrings!==!1,e?.write&&(this._writeImpl=e.write),e?.writev&&(this._writev=e.writev),e?.final&&(this._finalImpl=e.final),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Writable_.prototype._construct)&&(this._writableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._writableState.constructed=!0,e?this.destroy(e):this._maybeFlush()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_write(e,R,W){this._writeImpl?this._writeImpl.call(this,e,R,W):W()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}_destroy(e,R){this._destroyImpl?this._destroyImpl.call(this,e,R):R(e)}_maybeFlush(){let e=this._pendingConstruct.splice(0);if(e.length>0){let[R,...W]=e;this._writeBuffer.push(...W),this._doWrite(R.chunk,R.encoding,R.callback)}if(this._pendingEnd){let{chunk:e,encoding:R,callback:W}=this._pendingEnd;this._pendingEnd=null,this._doEnd(e,R,W)}}_doWrite(e,R,W){this._writableState.writing=!0;let Y=!0;this._write(e,R,R=>{if(this.writableLength-=this.writableObjectMode?1:chunkLen(e),Y){nextTick(()=>{if(R){W(R),this.emit(`error`,R);return}W(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}),R||this._drainWriteBuffer();return}nextTick(R?()=>{W(R),this.emit(`error`,R),this._drainWriteBuffer()}:()=>{W(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._drainWriteBuffer()})}),Y=!1}_drainWriteBuffer(){if(this._writeBuffer.length>0){let e=this._writeBuffer.shift();this._doWrite(e.chunk,e.encoding,e.callback)}else this._writableState.writing=!1,this._maybeFinish()}_maybeFinish(){!this._ending||this._writableState.finished||this._writableState.writing||this._writeBuffer.length>0||(this._ending=!1,this._final(e=>{this.writableFinished=!0,this._writableState.finished=!0,nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),nextTick(()=>this.emit(`close`)),this._endCallback&&this._endCallback()})}))}write(e,R,W){let Y,X;if(typeof R==`function`?(Y=R,X=this._defaultEncoding):(X=R??this._defaultEncoding,Y=W??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let R=globalThis.Buffer;R&&(e=R.from(e,X),X=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let R=globalThis.Buffer;(R&&R.isBuffer(e)||e instanceof Uint8Array)&&(X=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{Y(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen(e),this.writableCorked>0)return this._corkedBuffer.push({chunk:e,encoding:X,callback:Y}),this.writableLength<this.writableHighWaterMark;if(!this._writableState.constructed)return this._pendingConstruct.push({chunk:e,encoding:X,callback:Y}),this.writableLength<this.writableHighWaterMark;let ie=this.writableLength<this.writableHighWaterMark;return ie||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:e,encoding:X,callback:Y}):this._doWrite(e,X,Y),ie}_doEnd(e,R,W){e!=null&&this.write(e,R),this.writableEnded=!0,this._writableState.ended=!0,this._ending=!0,this._endCallback=W,this._maybeFinish()}end(e,R,W){return typeof e==`function`&&(W=e,e=void 0),typeof R==`function`&&(W=R,R=void 0),this.writableEnded?(W&&nextTick(W),this):this._writableState.constructed?(this._doEnd(e,R,W),this):(this._pendingEnd={chunk:e,encoding:R,callback:W},this)}cork(){this.writableCorked++}uncork(){this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._corkedBuffer.length>0&&this._flushCorkedBuffer())}_flushCorkedBuffer(){if(this._writev&&this._corkedBuffer.length>1){let e=this._corkedBuffer.splice(0),R=e.map(e=>({chunk:e.chunk,encoding:e.encoding}));this._writev.call(this,R,R=>{for(let R of e)this.writableLength-=this.writableObjectMode?1:chunkLen(R.chunk);if(R){for(let W of e)W.callback(R);this.emit(`error`,R)}else{for(let R of e)R.callback();this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}})}else{let e=this._corkedBuffer.splice(0);if(e.length>0){let[R,...W]=e;this._writeBuffer.push(...W),this._doWrite(R.chunk,R.encoding,R.callback)}}}setDefaultEncoding(e){return this._defaultEncoding=e,this}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.writable=!1,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return this._destroy(e??null,cb),this}}}),ru,iu=__esmMin(()=>{Ql(),Ht(),ru=class Transform_ extends Duplex_{constructor(e){super({...e,write:void 0,final:void 0});let R=this;e?.transform&&(R._transform=e.transform),e?.flush&&(R._flush=e.flush),e?.final&&(R._final=e.final)}_transform(e,R,W){throw Object.assign(Error(`The _transform() method is not implemented`),{code:`ERR_METHOD_NOT_IMPLEMENTED`})}_flush(e){e()}_write(e,R,W){let Y=!1;try{this._transform(e,R,(e,R)=>{if(Y){let e=Object.assign(Error(`Callback called multiple times`),{code:`ERR_MULTIPLE_CALLBACK`});nextTick(()=>this.emit(`error`,e));return}if(Y=!0,e){W(e);return}R!=null&&this.push(R),W()})}catch(e){if(e?.code===`ERR_METHOD_NOT_IMPLEMENTED`)throw e;W(e)}}_final(e){this._flush((R,W)=>{if(R){e(R);return}W!=null&&this.push(W),this.push(null),e()})}_doPrefinishHooks(e){let R=Transform_.prototype._final;this._final===R?e():R.call(this,e)}}}),PassThrough_,au=__esmMin(()=>{iu(),PassThrough_=class extends ru{constructor(e){super({...e,transform(e,R,W){W(null,e)}})}}});function pipeline(...e){let R=e,W=typeof R[R.length-1]==`function`?R.pop():void 0,Y=R;if(Y.length<2)throw Error(`pipeline requires at least 2 streams`);let X=null;function onError(e){if(!X){X=e;for(let e of Y)typeof e.destroy==`function`&&e.destroy();W&&W(e)}}let ie=Y[0];for(let e=1;e<Y.length;e++){let R=Y[e];ie.pipe(R),ie.on(`error`,onError),ie=R}let ae=Y[Y.length-1];return ae.on(`error`,onError),ae.on(`finish`,()=>{W&&!X&&W(null)}),ae}var ou=__esmMin(()=>{});function finished(e,R,W){let Y;Y=typeof R==`function`?R:W;let X=!1;function done(e){X||(X=!0,Y(e))}let onFinish=()=>done(),onEnd=()=>done(),onError=e=>done(e),onClose=()=>{let R=e,W=e;!R.writableFinished&&!W.readableEnded&&done(Error(`premature close`))};e.on(`finish`,onFinish),e.on(`end`,onEnd),e.on(`error`,onError),e.on(`close`,onClose);let ie=e,ae=typeof e.write==`function`,le=typeof e.read==`function`,_e=ie.writableFinished===!0,ye=ie.readableEnded===!0;if(ie.destroyed===!0){let e=ie._err;Ct(e?()=>done(e):ae&&_e||le&&ye?()=>done():()=>done(Error(`premature close`)))}else (ae&&!le&&_e||!ae&&le&&ye||ae&&le&&_e&&ye)&&Ct(()=>done());return function cleanup(){e.removeListener(`finish`,onFinish),e.removeListener(`end`,onEnd),e.removeListener(`error`,onError),e.removeListener(`close`,onClose)}}function addAbortSignal(e,R){if(!(e instanceof AbortSignal))throw TypeError(`The first argument must be an AbortSignal`);if(!(R instanceof Stream_))throw TypeError(`The second argument must be a Stream`);let W=R;if(e.aborted)W.destroy(Error(`The operation was aborted`));else{let onAbort=()=>{W.destroy(Error(`The operation was aborted`))};e.addEventListener(`abort`,onAbort,{once:!0}),R.once(`close`,()=>{e.removeEventListener(`abort`,onAbort)})}return R}function isReadable(e){if(e==null)return!1;let R=e;return typeof R.readable!=`boolean`||typeof R.read!=`function`||R.destroyed===!0||R.readableEnded===!0?!1:R.readable===!0}function isWritable(e){if(e==null)return!1;let R=e;return typeof R.writable!=`boolean`||typeof R.write!=`function`||R.destroyed===!0||R.writableEnded===!0?!1:R.writable===!0}function isDestroyed(e){return e==null?!1:e.destroyed===!0}function isDisturbed(e){if(e==null)return!1;let R=e;return R.readableDidRead===!0||R.readableFlowing!==null&&R.readableFlowing!==void 0}function isErrored(e){if(e==null)return!1;let R=e;return R.destroyed===!0&&typeof R.readable==`boolean`&&R.readable===!1||R.destroyed===!0&&typeof R.writable==`boolean`&&R.writable===!1}var su=__esmMin(()=>{Gl(),Ht()}),cu,lu,uu,du,fu,pu,mu,hu=__esmMin(()=>{Bl(),Gl(),Yl(),Zl(),Ql(),eu(),nu(),iu(),au(),ou(),su(),cu=makeCallable(Stream_),lu=makeCallable(Xl),uu=makeCallable(tu),du=makeCallable(Duplex_),fu=makeCallable(ru),pu=makeCallable(PassThrough_),mu=Object.assign(cu,{Stream:cu,Readable:lu,Writable:uu,Duplex:du,Transform:fu,PassThrough:pu,pipeline,finished,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark})});function getGioCompressorFormat(e){switch(e){case`gzip`:return at.ZlibCompressorFormat.GZIP;case`deflate`:return at.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return at.ZlibCompressorFormat.RAW}}function toUint8Array$1(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function createGzip(e){return new ZlibTransform(`gzip`,`compress`,e)}function createGunzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createDeflate(e){return new ZlibTransform(`deflate`,`compress`,e)}function createInflate(e){return new ZlibTransform(`deflate`,`decompress`,e)}function createDeflateRaw(e){return new ZlibTransform(`deflate-raw`,`compress`,e)}function createInflateRaw(e){return new ZlibTransform(`deflate-raw`,`decompress`,e)}function createUnzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createBrotliCompress(e){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(e){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}var ZlibTransform,gu=__esmMin(()=>{st(),$e(),hu(),__name$1(toUint8Array$1,`toUint8Array`),ZlibTransform=class extends fu{_format;_mode;_chunks=[];constructor(e,R,W){super(W),this._format=e,this._mode=R}_transform(e,R,W){this._chunks.push(toUint8Array$1(e)),W()}_flush(e){let R=this._chunks.reduce((e,R)=>e+R.length,0),W=new Uint8Array(R),Y=0;for(let e of this._chunks)W.set(e,Y),Y+=e.length;this._chunks=[];try{let R=this._mode===`compress`?this._compress(W):this._decompress(W);this.push(Buffer.from(R)),e()}catch(R){e(R instanceof Error?R:Error(String(R)))}}_compress(e){let R=new at.ZlibCompressor({format:getGioCompressorFormat(this._format)}),W=new at.ConverterOutputStream({base_stream:at.MemoryOutputStream.new_resizable(),converter:R});W.write_bytes(new Qe.Bytes(e),null),W.close(null);let Y=W.get_base_stream().steal_as_bytes();return new Uint8Array(Y.get_data()??[])}_decompress(e){let R=new at.ZlibDecompressor({format:getGioCompressorFormat(this._format)}),W=at.MemoryInputStream.new_from_bytes(new Qe.Bytes(e)),Y=new at.ConverterInputStream({base_stream:W,converter:R}),X=[];for(;;){let e=Y.read_bytes(4096,null);if(e.get_size()===0)break;X.push(new Uint8Array(e.get_data()))}Y.close(null);let ie=X.reduce((e,R)=>e+R.length,0),ae=new Uint8Array(ie),le=0;for(let e of X)ae.set(e,le),le+=e.length;return ae}}}),_u=__exportAll$1({ZlibTransform:()=>ZlibTransform,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>bu,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,default:()=>xu,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip,gunzipSync:()=>gunzipSync,gzip:()=>gzip,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync});function getGioFormat(e){switch(e){case`gzip`:return at.ZlibCompressorFormat.GZIP;case`deflate`:return at.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return at.ZlibCompressorFormat.RAW}}function compressWithGio(e,R){let W=new at.ZlibCompressor({format:getGioFormat(R)}),Y=new at.ConverterOutputStream({base_stream:at.MemoryOutputStream.new_resizable(),converter:W});Y.write_bytes(new Qe.Bytes(e),null),Y.close(null);let X=Y.get_base_stream().steal_as_bytes();return new Uint8Array(X.get_data()??[])}function decompressStreamWithGio(e,R){let W=new at.ZlibDecompressor({format:getGioFormat(R)}),Y=at.MemoryInputStream.new_from_bytes(new Qe.Bytes(e)),X=new at.ConverterInputStream({base_stream:Y,converter:W}),ie=[];for(;;){let e=X.read_bytes(4096,null);if(e.get_size()===0)break;ie.push(new Uint8Array(e.get_data()))}X.close(null);let ae=ie.reduce((e,R)=>e+R.length,0),le=new Uint8Array(ae),_e=0;for(let e of ie)le.set(e,_e),_e+=e.length;return le}function findGzipMemberEnd(e){let R=new at.ZlibDecompressor({format:at.ZlibCompressorFormat.GZIP}),W=new Uint8Array(65536),Y=0,X=!1;for(;!X;){let ie=e.subarray(Y);try{let[e,ae]=R.convert(ie,W,at.ConverterFlags.NONE);Y+=ae,e===at.ConverterResult.FINISHED&&(X=!0)}catch{X=!0}}return Y}function decompressWithGio(e,R){if(R!==`gzip`)return decompressStreamWithGio(e,R);let W=[],Y=0;for(;Y<e.length&&!(e.length-Y<2||e[Y]!==31||e[Y+1]!==139);){let R=e.subarray(Y),X=findGzipMemberEnd(R);if(X<=0)break;let ie=decompressStreamWithGio(R.subarray(0,X),`gzip`);W.push(ie),Y+=X}if(W.length===0)return decompressStreamWithGio(e,`gzip`);let X=W.reduce((e,R)=>e+R.length,0),ie=new Uint8Array(X),ae=0;for(let e of W)ie.set(e,ae),ae+=e.length;return ie}async function compressWithWeb(e,R){let W=new CompressionStream(R),Y=W.writable.getWriter();Y.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Y.close();let X=[],ie=W.readable.getReader();for(;;){let{done:e,value:R}=await ie.read();if(e)break;X.push(R)}let ae=X.reduce((e,R)=>e+R.length,0),le=new Uint8Array(ae),_e=0;for(let e of X)le.set(e,_e),_e+=e.length;return le}async function decompressWithWeb(e,R){let W=new DecompressionStream(R),Y=W.writable.getWriter();Y.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Y.close();let X=[],ie=W.readable.getReader();for(;;){let{done:e,value:R}=await ie.read();if(e)break;X.push(R)}let ae=X.reduce((e,R)=>e+R.length,0),le=new Uint8Array(ae),_e=0;for(let e of X)le.set(e,_e),_e+=e.length;return le}async function compress(e,R){return vu?compressWithWeb(e,R):compressWithGio(e,R)}async function decompress(e,R){return vu?decompressWithWeb(e,R):decompressWithGio(e,R)}function toUint8Array(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function gzip(e,R,W){let Y=typeof R==`function`?R:W;compress(toUint8Array(e),`gzip`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gunzip(e,R,W){let Y=typeof R==`function`?R:W;decompress(toUint8Array(e),`gzip`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflate(e,R,W){let Y=typeof R==`function`?R:W;compress(toUint8Array(e),`deflate`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflate(e,R,W){let Y=typeof R==`function`?R:W;decompress(toUint8Array(e),`deflate`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflateRaw(e,R,W){let Y=typeof R==`function`?R:W;compress(toUint8Array(e),`deflate-raw`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflateRaw(e,R,W){let Y=typeof R==`function`?R:W;decompress(toUint8Array(e),`deflate-raw`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gzipSync(e,R){return compressWithGio(toUint8Array(e),`gzip`)}function gunzipSync(e,R){return decompressWithGio(toUint8Array(e),`gzip`)}function deflateSync(e,R){return compressWithGio(toUint8Array(e),`deflate`)}function inflateSync(e,R){return decompressWithGio(toUint8Array(e),`deflate`)}function deflateRawSync(e,R){return compressWithGio(toUint8Array(e),`deflate-raw`)}function inflateRawSync(e,R){return decompressWithGio(toUint8Array(e),`deflate-raw`)}function brotliCompress(e,R,W){(typeof R==`function`?R:W)(Error(`brotliCompress: Brotli is not supported in this environment`),yu)}function brotliDecompress(e,R,W){(typeof R==`function`?R:W)(Error(`brotliDecompress: Brotli is not supported in this environment`),yu)}function brotliCompressSync(e,R){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(e,R){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}var vu,yu,bu,xu,Su=__esmMin(()=>{gu(),st(),$e(),vu=globalThis.CompressionStream!==void 0,yu=new Uint8Array,bu={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_DEFLATED:8},xu={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,constants:bu}});const Cu=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(e){if(!Cu.has(e))throw TypeError(`Unsupported compression format: '${e}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return e}const wu=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let Tu=!1,Eu,Du,Ou,ku,Au,ju;async function loadZlib(){if(Tu)return;let e=await Promise.resolve().then(()=>(Su(),_u));Eu=e.gzipSync,Du=e.gunzipSync,Ou=e.deflateSync,ku=e.inflateSync,Au=e.deflateRawSync,ju=e.inflateRawSync,Tu=!0}function getCompressFn(e){switch(e){case`gzip`:return e=>Eu(e);case`deflate`:return e=>Ou(e);case`deflate-raw`:return e=>Au(e)}}function getDecompressFn(e){switch(e){case`gzip`:return e=>Du(e);case`deflate`:return e=>ku(e);case`deflate-raw`:return e=>ju(e)}}let Mu,Nu;if(wu)Mu=globalThis.CompressionStream,Nu=globalThis.DecompressionStream;else{let e=loadZlib();Mu=class CompressionStream{readable;writable;constructor(R){let W=validateFormat(R),Y=new Nl({async transform(R,Y){try{await e,Y.enqueue(getCompressFn(W)(R))}catch(e){Y.error(e)}}});this.readable=Y.readable,this.writable=Y.writable}},Nu=class DecompressionStream{readable;writable;constructor(R){let W=validateFormat(R),Y=new Nl({async transform(R,Y){try{await e,Y.enqueue(getDecompressFn(W)(R))}catch(e){Y.error(e)}}});this.readable=Y.readable,this.writable=Y.writable}}}const Pu=globalThis;globalThis.CompressionStream===void 0&&(Pu.CompressionStream=Mu),globalThis.DecompressionStream===void 0&&(Pu.DecompressionStream=Nu);const Fu={CustomEvent,MessageEvent,ErrorEvent,CloseEvent,ProgressEvent:ProgressEvent$1};for(let[e,R]of Object.entries(Fu))globalThis[e]===void 0&&Object.defineProperty(globalThis,e,{value:R,writable:!0,configurable:!0});const Iu=globalThis;Iu.Event===void 0&&Object.defineProperty(globalThis,"Event",{value:Event$1,writable:!0,configurable:!0}),Iu.EventTarget===void 0&&Object.defineProperty(globalThis,"EventTarget",{value:EventTarget$1,writable:!0,configurable:!0});const Lu={UIEvent,MouseEvent,PointerEvent:PointerEvent$1,KeyboardEvent:KeyboardEvent$1,WheelEvent:WheelEvent$1,FocusEvent};for(let[e,R]of Object.entries(Lu))globalThis[e]===void 0&&Object.defineProperty(globalThis,e,{value:R,writable:!0,configurable:!0});const Ru=globalThis;globalThis.DOMException===void 0&&(Ru.DOMException=lr);var zu,__name,Bu=__esmMin(()=>{zu=Object.defineProperty,__name=(e,R)=>zu(e,`name`,{value:R,configurable:!0})}),Vu=be;function validateHeaderName(e){if(typeof e!=`string`||!/^[\^`\-\w!#$%&'*+.|~]+$/.test(e)){let R=TypeError(`Header name must be a valid HTTP token ["${e}"]`);throw Object.defineProperty(R,"code",{value:`ERR_INVALID_HTTP_TOKEN`}),R}}function validateHeaderValue(e,R){if(R===void 0){let R=TypeError(`Header "${e}" value must not be undefined`);throw Object.defineProperty(R,"code",{value:`ERR_HTTP_INVALID_HEADER_VALUE`}),R}if(typeof R==`string`&&/[^\t -~-ÿ]/.test(R)){let R=TypeError(`Invalid character in header content ["${e}"]`);throw Object.defineProperty(R,"code",{value:`ERR_INVALID_CHAR`}),R}}const Hu=Symbol(`Headers.headers`);function isBoxedPrimitive(e){return e instanceof String||e instanceof Number||e instanceof Boolean||typeof Symbol<`u`&&e instanceof Symbol||typeof BigInt<`u`&&e instanceof BigInt}var Uu=class Headers{[Hu];constructor(e){if(this[Hu]=new Map,e!=null){if(e instanceof Headers){for(let[R,W]of e[Hu])this[Hu].set(R,[...W]);return}if(typeof e==`object`&&!isBoxedPrimitive(e)){let R=e[Symbol.iterator];if(R==null)for(let[R,W]of Object.entries(e))validateHeaderName(R),validateHeaderValue(R,String(W)),this.append(R,String(W));else{if(typeof R!=`function`)throw TypeError(`Header pairs must be iterable`);for(let R of e){if(typeof R!=`object`||isBoxedPrimitive(R))throw TypeError(`Each header pair must be an iterable object`);let e=[...R];if(e.length!==2)throw TypeError(`Each header pair must be a name/value tuple`);validateHeaderName(e[0]),validateHeaderValue(e[0],String(e[1])),this.append(e[0],String(e[1]))}}}else throw TypeError(`Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)'`)}}append(e,R){validateHeaderName(e),validateHeaderValue(e,R);let W=String(e).toLowerCase(),Y=String(R),X=this[Hu].get(W);X?X.push(Y):this[Hu].set(W,[Y])}set(e,R){validateHeaderName(e),validateHeaderValue(e,R);let W=String(e).toLowerCase();this[Hu].set(W,[String(R)])}delete(e){this[Hu].delete(String(e).toLowerCase())}has(e){return this[Hu].has(String(e).toLowerCase())}get(e){let R=this[Hu].get(String(e).toLowerCase());if(!R||R.length===0)return null;let W=R.join(`, `);return/^content-encoding$/i.test(e)&&(W=W.toLowerCase()),W}getAll(e){return this[Hu].get(String(e).toLowerCase())??[]}getSetCookie(){return this[Hu].get(`set-cookie`)??[]}forEach(e,R){for(let W of this.keys())Reflect.apply(e,R,[this.get(W),W,this])}*keys(){let e=[...this[Hu].keys()].sort(),R=new Set;for(let W of e)R.has(W)||(R.add(W),yield W)}*values(){for(let e of this.keys())yield this.get(e)}*entries(){for(let e of this.keys())yield[e,this.get(e)]}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return`Headers`}toString(){return Object.prototype.toString.call(this)}raw(){let e={};for(let R of this.keys())e[R]=this.getAll(R);return e}_appendToSoupMessage(e,R=Vu.MessageHeadersType.REQUEST){let W=e?e.get_request_headers():new Vu.MessageHeaders(R);for(let[e,R]of this.entries())W.append(e,R);return W}static _newFromSoupMessage(e,R=Vu.MessageHeadersType.RESPONSE){let W=new Headers,Y;return Y=R===Vu.MessageHeadersType.RESPONSE?e.get_response_headers():e.get_request_headers(),Y.foreach((e,R)=>{W.append(e,R)}),W}[Symbol.for(`nodejs.util.inspect.custom`)](){let e={};for(let R of this.keys()){let W=this.getAll(R);R===`host`?e[R]=W[0]:e[R]=W.length>1?W:W[0]}return e}};Object.defineProperties(Uu.prototype,[`get`,`entries`,`forEach`,`values`].reduce((e,R)=>(e[R]={enumerable:!0},e),{}));var Wu=__esmMin(()=>{Ya()});Wu();var FetchBaseError=class extends Error{type;constructor(e,R){super(e),typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,this.constructor),this.type=R}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}},FetchError=class extends FetchBaseError{code;errno;erroredSysCall;constructor(e,R,W){super(e,R),W&&(this.code=this.errno=W.code,this.erroredSysCall=W.syscall)}};const Gu=Symbol.toStringTag,isURLSearchParameters=e=>typeof e==`object`&&typeof e.append==`function`&&typeof e.delete==`function`&&typeof e.get==`function`&&typeof e.getAll==`function`&&typeof e.has==`function`&&typeof e.set==`function`&&typeof e.sort==`function`&&e[Gu]===`URLSearchParams`,isBlob=e=>{if(!e||typeof e!=`object`)return!1;let R=e;return typeof R.arrayBuffer==`function`&&typeof R.type==`string`&&typeof R.stream==`function`&&typeof R.constructor==`function`&&/^(Blob|File)$/.test(R[Gu])},isAbortSignal=e=>{if(typeof e!=`object`||!e)return!1;let R=e;return R[Gu]===`AbortSignal`||R[Gu]===`EventTarget`},isDomainOrSubdomain=(e,R)=>{let W=new gs(R).hostname,Y=new gs(e).hostname;return W===Y||W.endsWith(`.${Y}`)},isSameProtocol=(e,R)=>new gs(R).protocol===new gs(e).protocol;var Ku,qu,File$1,Ju=__esmMin(()=>{Ku=Symbol(`File.name`),qu=Symbol(`File.lastModified`),File$1=class extends Blob{static{__name$1(this,`File`)}[Ku];[qu];webkitRelativePath=``;constructor(e,R,W){super(e,W),this[Ku]=String(R),this[qu]=W?.lastModified??Date.now()}get name(){return this[Ku]}get lastModified(){return this[qu]}get[Symbol.toStringTag](){return`File`}}});function generateBoundary(){let e=`----formdata-`;for(let R=0;R<24;R++)e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*62));return e}function escape(e){return e.replace(/\n/g,`%0A`).replace(/\r/g,`%0D`).replace(/"/g,`%22`)}function formDataToBlob(e,R){R??=generateBoundary();let W=[],Y=`--${R}\r\nContent-Disposition: form-data; name="`;for(let[R,X]of e.entries())if(typeof X==`string`)W.push(`${Y}${escape(R)}"\r\n\r\n${X.replace(/\r(?!\n)|(?<!\r)\n/g,`\r
|
|
5
|
+
`+R)}profile(e){}profileEnd(e){}timeStamp(e){}},_t=new Console,log=(...e)=>_t.log(...e),info=(...e)=>_t.info(...e),debug=(...e)=>_t.debug(...e),warn=(...e)=>_t.warn(...e),error=(...e)=>_t.error(...e),dir=(e,R)=>_t.dir(e,R),dirxml=(...e)=>_t.dirxml(...e),table=(e,R)=>_t.table(e,R),clear=()=>_t.clear(),vt=__name$1((e,...R)=>_t.assert(e,...R),`assert`),trace=(...e)=>_t.trace(...e),time=e=>_t.time(e),timeEnd=e=>_t.timeEnd(e),timeLog=(e,...R)=>_t.timeLog(e,...R),count=e=>_t.count(e),countReset=e=>_t.countReset(e),group=(...e)=>_t.group(...e),groupCollapsed=(...e)=>_t.groupCollapsed(...e),groupEnd=()=>_t.groupEnd(),profile=e=>{},profileEnd=e=>{},timeStamp=e=>{}}),bt,xt=__esmMin(()=>{yt(),bt={log,info,debug,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace,assert:vt,clear,count,countReset,group,groupCollapsed,groupEnd,profile,profileEnd,timeStamp}}),warnNotImplemented,St=__esmMin(()=>{xt(),warnNotImplemented=e=>{let R=e?`Not implemented: ${e}`:`Not implemented`;return bt.warn(R),R}}),Ct,wt=__esmMin(()=>{Ct=__name$1(e=>{Promise.resolve().then(e)},`queueMicrotask`)});function drainOnce(e){let R=Math.min(64,Tt.length);for(let W=0;W<R;W++){let R=Tt.shift();try{R()}catch(R){try{e.log_default_handler(`gjsify-nextTick`,e.LogLevelFlags.LEVEL_WARNING,String(R?.stack||R),null)}catch{}}}Tt.length>0?e.timeout_add(e.PRIORITY_DEFAULT,1,()=>(drainOnce(e),!1)):Et=!1}function tryGLibTimeout(e){let R=globalThis.imports?.gi?.GLib;return R?.timeout_add?(Tt.push(e),Et||(Et=!0,R.timeout_add(R.PRIORITY_DEFAULT,0,()=>(drainOnce(R),!1))),!0):!1}var Tt,Et,nextTick,Ot=__esmMin(()=>{Tt=[],Et=!1,nextTick=(e,...R)=>{let W=R.length>0?()=>e(...R):e;if(!tryGLibTimeout(W)){if(typeof globalThis.process?.nextTick==`function`){globalThis.process.nextTick(e,...R);return}if(typeof queueMicrotask==`function`){queueMicrotask(W);return}Promise.resolve().then(W)}}}),jt,Mt=__esmMin(()=>{$e(),st(),{File:jt}=at});function classOf(e){return Nt.call(e).slice(8,-1)}function throwDataCloneError(e){let R=globalThis.DOMException;if(typeof R==`function`)throw new R(e,`DataCloneError`);let W=Error(e);throw W.name=`DataCloneError`,W}function internalClone(e,R,W){if(e==null)return e;let Y=typeof e;if(Y===`boolean`||Y===`number`||Y===`string`||Y===`bigint`)return e;Y===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),Y===`function`&&throwDataCloneError(`Function cannot be cloned`);let X=e;if(R.has(X))return R.get(X);let ie=classOf(X);if(ie===`Date`)return new Date(X.getTime());if(ie===`RegExp`)return new RegExp(X.source,X.flags);if(ie===`Boolean`||ie===`Number`||ie===`String`)return Object(X.valueOf());if(ie===`BigInt`)return Object(BigInt.prototype.valueOf.call(X));if(X instanceof Error){let e=X,Y=e.constructor?.name,ie=new(Y&&Pt[Y]||Pt[e.name]||Error)(e.message);return ie.name=e.name,`cause`in e&&Object.defineProperty(ie,"cause",{value:internalClone(e.cause,R,W),writable:!0,enumerable:!1,configurable:!0}),ie}if(ie===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let R=X;return new e(R.message,R.name)}}if(ie===`ArrayBuffer`){let e=X;if(W&&W.transferred.has(e)){let Y=W.transferred.get(e);return R.set(X,Y),Y}(e.detached===!0||e.byteLength===0&&e.detached)&&throwDataCloneError(`ArrayBuffer is detached and cannot be cloned`);let Y=e.slice(0);return R.set(X,Y),Y}if(ie===`SharedArrayBuffer`||X&&typeof X==`object`&&X.constructor?.name===`SharedBuffer`)return X;if(ie===`DataView`){let e=X,Y=W?.viewSnapshots.get(X),ie=internalClone(e.buffer,R,W),ae=Y?Y.byteOffset:e.byteOffset,le=Y?Y.byteLength:e.byteLength,_e=new DataView(ie,ae,le);return R.set(X,_e),_e}if(Ft.has(ie)){let e=X,Y=W?.viewSnapshots.get(X),ie=internalClone(e.buffer,R,W),ae=e.constructor,le=new ae(ie,Y?Y.byteOffset:e.byteOffset,Y?Y.length:e.length);return R.set(X,le),le}if(ie===`Map`){let e=new Map;R.set(X,e);for(let[Y,ie]of X)e.set(internalClone(Y,R,W),internalClone(ie,R,W));return e}if(ie===`Set`){let e=new Set;R.set(X,e);for(let Y of X)e.add(internalClone(Y,R,W));return e}{let e=globalThis,R=e.Blob,W=e.File;if(typeof W==`function`&&X instanceof W){let e=X;return new W([X],e.name,{type:e.type,lastModified:e.lastModified})}if(typeof R==`function`&&X instanceof R)return new R([X],{type:X.type})}if(X instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),X instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),X instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&X instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),ie===`Array`){let e=X,Y=[];R.set(X,Y);for(let X=0;X<e.length;X++)X in e&&(Y[X]=internalClone(e[X],R,W));return Y}if(ie===`Object`||typeof X==`object`){let e={};R.set(X,e);for(let Y of Object.keys(X))e[Y]=internalClone(X[Y],R,W);return e}throwDataCloneError(`${ie} cannot be cloned`)}function structuredClone$1(e,R){let W=R?.transfer;if(!W||W.length===0)return internalClone(e,new Map);let Y=new Set;for(let e of W)if(classOf(e)===`ArrayBuffer`){let R=e;R.detached===!0&&throwDataCloneError(`ArrayBuffer in transfer list is detached`),Y.add(R)}let X=new Map;Y.size>0&&snapshotViewsBackedByTransferredBuffers(e,Y,X,new Set);let ie=new Map;for(let e of Y){let R=e;typeof R.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),ie.set(e,R.transfer())}return internalClone(e,new Map,{transferred:ie,viewSnapshots:X})}function snapshotViewsBackedByTransferredBuffers(e,R,W,Y){if(typeof e!=`object`||!e)return;let X=e;if(Y.has(X))return;Y.add(X);let ie=classOf(X);if(ie===`DataView`){let e=X;R.has(e.buffer)&&W.set(X,{byteOffset:e.byteOffset,length:0,byteLength:e.byteLength});return}if(Ft.has(ie)){let e=X;R.has(e.buffer)&&W.set(X,{byteOffset:e.byteOffset,length:e.length,byteLength:e.byteLength});return}if(Array.isArray(X)){for(let e=0;e<X.length;e++)e in X&&snapshotViewsBackedByTransferredBuffers(X[e],R,W,Y);return}if(ie===`Map`){for(let[e,ie]of X)snapshotViewsBackedByTransferredBuffers(e,R,W,Y),snapshotViewsBackedByTransferredBuffers(ie,R,W,Y);return}if(ie===`Set`){for(let e of X)snapshotViewsBackedByTransferredBuffers(e,R,W,Y);return}if(ie===`Object`)for(let e of Object.keys(X))snapshotViewsBackedByTransferredBuffers(X[e],R,W,Y)}var Nt,Pt,Ft,Lt=__esmMin(()=>{({toString:Nt}=Object.prototype),Pt={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},Ft=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]),__name$1(structuredClone$1,`structuredClone`)});function ensureMainLoop(){let e=globalThis.imports;if(!e)return;if(Rt)return zt;let R=e.gi?.GLib;if(R){if(zt=new R.MainLoop(null,!1),Rt=!0,R.main_depth()===0)try{zt.runAsync()}catch{}return zt}}function quitMainLoop(){zt&&=(zt.quit(),Rt=!1,null)}var Rt,zt,Vt=__esmMin(()=>{Rt=!1,zt=null}),Ht=__esmMin(()=>{Ye(),et(),tt(),nt(),ut(),mt(),ht(),St(),wt(),Ot(),Mt(),Lt(),Vt()});Je(),Ht(),registerGlobal(`Blob`,Ke),registerGlobal(`File`,qe);var Ut=Object.defineProperty,__exportAll=(e,R)=>{let W={};for(var Y in e)Ut(W,Y,{get:e[Y],enumerable:!0});return R||Ut(W,Symbol.toStringTag,{value:`Module`}),W};__exportAll({attributes:()=>$t,childNodesList:()=>Kt,elementChildren:()=>qt,isConnected:()=>Jt,localName:()=>Xt,name:()=>An,namespaceURI:()=>Zt,nodeType:()=>Wt,ownerElement:()=>rr,parentNode:()=>Gt,prefix:()=>Qt,propertyEventListeners:()=>on,tagName:()=>Yt,value:()=>tr});const Wt=Symbol(`nodeType`),Gt=Symbol(`parentNode`),Kt=Symbol(`childNodesList`),qt=Symbol(`elementChildren`),Jt=Symbol(`isConnected`),Yt=Symbol(`tagName`),Xt=Symbol(`localName`),Zt=Symbol(`namespaceURI`),Qt=Symbol(`prefix`),$t=Symbol(`attributes`),on=Symbol(`propertyEventListeners`),An=Symbol(`name`),tr=Symbol(`value`),rr=Symbol(`ownerElement`),ir={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11};var NodeList=class{constructor(e){this._items=e}get length(){return this._items.length}item(e){return this._items[e]??null}forEach(e,R){for(let W=0;W<this._items.length;W++)e.call(R,this._items[W],W,this)}entries(){return this._items.entries()}keys(){return this._items.keys()}values(){return this._items.values()}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NodeList`}};const or={IndexSizeError:1,HierarchyRequestError:3,WrongDocumentError:4,InvalidCharacterError:5,NoModificationAllowedError:7,NotFoundError:8,NotSupportedError:9,InUseAttributeError:10,InvalidStateError:11,SyntaxError:12,InvalidModificationError:13,NamespaceError:14,InvalidAccessError:15,TypeMismatchError:17,SecurityError:18,NetworkError:19,AbortError:20,URLMismatchError:21,QuotaExceededError:22,TimeoutError:23,InvalidNodeTypeError:24,DataCloneError:25};var _DOMExceptionPolyfill=class extends Error{code;constructor(e,R){super(e),this.name=R||`Error`,this.code=Object.hasOwn(or,this.name)?or[this.name]:0}};const lr=globalThis.DOMException===void 0?_DOMExceptionPolyfill:globalThis.DOMException;xt();const hr=Symbol(`type`),gr=Symbol(`bubbles`),vr=Symbol(`cancelable`),Sr=Symbol(`composed`),Tr=Symbol(`target`),Er=Symbol(`currentTarget`),kr=Symbol(`eventPhase`),jr=Symbol(`defaultPrevented`),Mr=Symbol(`isTrusted`),Nr=Symbol(`timeStamp`),Fr=Symbol(`stop`),Br=Symbol(`immediateStop`),Vr=Symbol(`dispatching`),Hr=Symbol(`inPassiveListener`);var Event$1=class{static{__name$1(this,`Event`)}[hr];[gr];[vr];[Sr];[Tr]=null;[Er]=null;[kr]=0;[jr]=!1;[Mr]=!1;[Nr];[Fr]=!1;[Br]=!1;[Vr]=!1;[Hr]=!1;get type(){return this[hr]}get bubbles(){return this[gr]}get cancelable(){return this[vr]}get composed(){return this[Sr]}get target(){return this[Tr]}get currentTarget(){return this[Er]}get eventPhase(){return this[kr]}get defaultPrevented(){return this[jr]}get timeStamp(){return this[Nr]}get cancelBubble(){return this[Fr]}set cancelBubble(e){e&&this.stopPropagation()}get returnValue(){return!this[jr]}set returnValue(e){e||this.preventDefault()}get srcElement(){return this[Tr]}static NONE=0;static CAPTURING_PHASE=1;static AT_TARGET=2;static BUBBLING_PHASE=3;get[Symbol.toStringTag](){return`Event`}constructor(e,R){this[hr]=e,this[gr]=R?.bubbles??!1,this[vr]=R?.cancelable??!1,this[Sr]=R?.composed??!1,this[Nr]=Date.now(),Object.defineProperty(this,"isTrusted",{get:()=>this[Mr],enumerable:!0,configurable:!1})}composedPath(){return this[Er]?[this[Er]]:[]}preventDefault(){this[vr]&&!this[Hr]&&(this[jr]=!0)}stopPropagation(){this[Fr]=!0}stopImmediatePropagation(){this[Fr]=!0,this[Br]=!0}},CustomEvent=class extends Event$1{detail;constructor(e,R){super(e,R),this.detail=R?.detail}},MessageEvent=class extends Event$1{data;origin;lastEventId;source;ports;constructor(e,R){super(e,R),this.data=R?.data??null,this.origin=R?.origin??``,this.lastEventId=R?.lastEventId??``,this.source=R?.source??null,this.ports=R?.ports??[]}get[Symbol.toStringTag](){return`MessageEvent`}},ErrorEvent=class extends Event$1{message;filename;lineno;colno;error;constructor(e,R){super(e,R),this.message=R?.message??``,this.filename=R?.filename??``,this.lineno=R?.lineno??0,this.colno=R?.colno??0,this.error=R?.error??null}get[Symbol.toStringTag](){return`ErrorEvent`}},CloseEvent=class extends Event$1{code;reason;wasClean;constructor(e,R){super(e,R),this.code=R?.code??0,this.reason=R?.reason??``,this.wasClean=R?.wasClean??!1}get[Symbol.toStringTag](){return`CloseEvent`}},ProgressEvent$1=class extends Event$1{static{__name$1(this,`ProgressEvent`)}lengthComputable;loaded;total;constructor(e,R){super(e,R),this.lengthComputable=R?.lengthComputable??!1,this.loaded=R?.loaded??0,this.total=R?.total??0}get[Symbol.toStringTag](){return`ProgressEvent`}},EventTarget$1=class{static{__name$1(this,`EventTarget`)}_listeners=new Map;get[Symbol.toStringTag](){return`EventTarget`}addEventListener(e,R,W){if(R===null)return;let Y=typeof W==`boolean`?W:W?.capture??!1,X=typeof W==`object`?W?.once??!1:!1,ie=typeof W==`object`?W?.passive??!1:!1,ae=this._listeners.get(e);ae||(ae=[],this._listeners.set(e,ae));for(let e of ae)if(e.listener===R&&e.capture===Y)return;let le={listener:R,capture:Y,once:X,passive:ie,removed:!1};ae.push(le),typeof W==`object`&&W?.signal&&W.signal.addEventListener(`abort`,()=>{this.removeEventListener(e,R,{capture:Y})},{once:!0})}removeEventListener(e,R,W){if(R===null)return;let Y=typeof W==`boolean`?W:W?.capture??!1,X=this._listeners.get(e);if(!X)return;let ie=X.findIndex(e=>e.listener===R&&e.capture===Y);ie!==-1&&(X[ie].removed=!0,X.splice(ie,1),X.length===0&&this._listeners.delete(e))}dispatchEvent(e){let R=e;if(R[Vr])throw new lr(`The event is already being dispatched.`,`InvalidStateError`);R[Vr]=!0,R[Tr]=this,R[Er]=this,R[kr]=Event$1.AT_TARGET;let W=this._listeners.get(e.type);if(W){let Y=[...W];for(let W of Y)if(!W.removed){if(R[Br]||R[Fr])break;W.once&&this.removeEventListener(e.type,W.listener,{capture:W.capture});try{W.passive&&(R[Hr]=!0),typeof W.listener==`function`?W.listener.call(this,e):typeof W.listener.handleEvent==`function`&&W.listener.handleEvent.call(W.listener,e)}catch(e){bt.error(e)}finally{R[Hr]=!1}}}return R[kr]=Event$1.NONE,R[Er]=null,R[Vr]=!1,!e.defaultPrevented}};for(let[e,R]of[[`NONE`,0],[`CAPTURING_PHASE`,1],[`AT_TARGET`,2],[`BUBBLING_PHASE`,3]])Object.defineProperty(Event$1.prototype,e,{value:R,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Event$1,e,{value:R,writable:!1,enumerable:!0,configurable:!1});var UIEvent=class extends Event$1{detail;view;constructor(e,R){super(e,R),this.detail=R?.detail??0,this.view=null}get[Symbol.toStringTag](){return`UIEvent`}},MouseEvent=class extends UIEvent{altKey;button;buttons;clientX;clientY;ctrlKey;metaKey;movementX;movementY;offsetX;offsetY;screenX;screenY;shiftKey;relatedTarget;get pageX(){return this.clientX}get pageY(){return this.clientY}get x(){return this.clientX}get y(){return this.clientY}constructor(e,R){super(e,R),this.altKey=R?.altKey??!1,this.button=R?.button??0,this.buttons=R?.buttons??0,this.clientX=R?.clientX??0,this.clientY=R?.clientY??0,this.ctrlKey=R?.ctrlKey??!1,this.metaKey=R?.metaKey??!1,this.movementX=R?.movementX??0,this.movementY=R?.movementY??0,this.offsetX=R?.offsetX??0,this.offsetY=R?.offsetY??0,this.screenX=R?.screenX??0,this.screenY=R?.screenY??0,this.shiftKey=R?.shiftKey??!1,this.relatedTarget=R?.relatedTarget??null}getModifierState(e){switch(e){case`Alt`:return this.altKey;case`Control`:return this.ctrlKey;case`Meta`:return this.metaKey;case`Shift`:return this.shiftKey;default:return!1}}get[Symbol.toStringTag](){return`MouseEvent`}},PointerEvent$1=class extends MouseEvent{static{__name$1(this,`PointerEvent`)}pointerId;width;height;pressure;tangentialPressure;tiltX;tiltY;twist;altitudeAngle;azimuthAngle;pointerType;isPrimary;constructor(e,R){super(e,R),this.pointerId=R?.pointerId??0,this.width=R?.width??1,this.height=R?.height??1,this.pressure=R?.pressure??0,this.tangentialPressure=R?.tangentialPressure??0,this.tiltX=R?.tiltX??0,this.tiltY=R?.tiltY??0,this.twist=R?.twist??0,this.altitudeAngle=R?.altitudeAngle??Math.PI/2,this.azimuthAngle=R?.azimuthAngle??0,this.pointerType=R?.pointerType??``,this.isPrimary=R?.isPrimary??!1}getCoalescedEvents(){return[]}getPredictedEvents(){return[]}get[Symbol.toStringTag](){return`PointerEvent`}},KeyboardEvent$1=class extends UIEvent{static{__name$1(this,`KeyboardEvent`)}altKey;code;ctrlKey;isComposing;key;location;metaKey;repeat;shiftKey;keyCode;which;static DOM_KEY_LOCATION_STANDARD=0;static DOM_KEY_LOCATION_LEFT=1;static DOM_KEY_LOCATION_RIGHT=2;static DOM_KEY_LOCATION_NUMPAD=3;constructor(e,R){super(e,R),this.altKey=R?.altKey??!1,this.code=R?.code??``,this.ctrlKey=R?.ctrlKey??!1,this.isComposing=R?.isComposing??!1,this.key=R?.key??``,this.location=R?.location??0,this.metaKey=R?.metaKey??!1,this.repeat=R?.repeat??!1,this.shiftKey=R?.shiftKey??!1,this.keyCode=R?.keyCode??0,this.which=R?.which??0}getModifierState(e){switch(e){case`Alt`:return this.altKey;case`Control`:return this.ctrlKey;case`Meta`:return this.metaKey;case`Shift`:return this.shiftKey;default:return!1}}get[Symbol.toStringTag](){return`KeyboardEvent`}},WheelEvent$1=class extends MouseEvent{static{__name$1(this,`WheelEvent`)}deltaX;deltaY;deltaZ;deltaMode;static DOM_DELTA_PIXEL=0;static DOM_DELTA_LINE=1;static DOM_DELTA_PAGE=2;constructor(e,R){super(e,R),this.deltaX=R?.deltaX??0,this.deltaY=R?.deltaY??0,this.deltaZ=R?.deltaZ??0,this.deltaMode=R?.deltaMode??0}get[Symbol.toStringTag](){return`WheelEvent`}},FocusEvent=class extends UIEvent{relatedTarget;constructor(e,R){super(e,R),this.relatedTarget=R?.relatedTarget??null}get[Symbol.toStringTag](){return`FocusEvent`}};let Ur,Zr,$r,ei,ti;var ni=class Node extends EventTarget$1{constructor(...e){super(...e),this.ELEMENT_NODE=ir.ELEMENT_NODE,this.ATTRIBUTE_NODE=ir.ATTRIBUTE_NODE,this.TEXT_NODE=ir.TEXT_NODE,this.CDATA_SECTION_NODE=ir.CDATA_SECTION_NODE,this.PROCESSING_INSTRUCTION_NODE=ir.PROCESSING_INSTRUCTION_NODE,this.COMMENT_NODE=ir.COMMENT_NODE,this.DOCUMENT_NODE=ir.DOCUMENT_NODE,this.DOCUMENT_TYPE_NODE=ir.DOCUMENT_TYPE_NODE,this.DOCUMENT_FRAGMENT_NODE=ir.DOCUMENT_FRAGMENT_NODE,this[Ur]=ir.ELEMENT_NODE,this[Zr]=null,this[$r]=[],this[ei]=[],this[ti]=!1}static{this.ELEMENT_NODE=ir.ELEMENT_NODE}static{this.ATTRIBUTE_NODE=ir.ATTRIBUTE_NODE}static{this.TEXT_NODE=ir.TEXT_NODE}static{this.CDATA_SECTION_NODE=ir.CDATA_SECTION_NODE}static{this.PROCESSING_INSTRUCTION_NODE=ir.PROCESSING_INSTRUCTION_NODE}static{this.COMMENT_NODE=ir.COMMENT_NODE}static{this.DOCUMENT_NODE=ir.DOCUMENT_NODE}static{this.DOCUMENT_TYPE_NODE=ir.DOCUMENT_TYPE_NODE}static{this.DOCUMENT_FRAGMENT_NODE=ir.DOCUMENT_FRAGMENT_NODE}static{this.DOCUMENT_POSITION_DISCONNECTED=1}static{this.DOCUMENT_POSITION_PRECEDING=2}static{this.DOCUMENT_POSITION_FOLLOWING=4}static{this.DOCUMENT_POSITION_CONTAINS=8}static{this.DOCUMENT_POSITION_CONTAINED_BY=16}static{this.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32}get nodeType(){return this[Wt]}get nodeName(){return``}get parentNode(){return this[Gt]}get parentElement(){let e=this[Gt];return e&&e[Wt]===ir.ELEMENT_NODE?e:null}get childNodes(){return new NodeList(this[Kt])}get firstChild(){return this[Kt][0]??null}get lastChild(){let e=this[Kt];return e[e.length-1]??null}get previousSibling(){let e=this[Gt];if(!e)return null;let R=e[Kt],W=R.indexOf(this);return W>0?R[W-1]:null}get nextSibling(){let e=this[Gt];if(!e)return null;let R=e[Kt],W=R.indexOf(this);return W!==-1&&W<R.length-1?R[W+1]:null}get textContent(){return null}set textContent(e){}get nodeValue(){return null}set nodeValue(e){}get ownerDocument(){let e=this;for(;e[Gt];)e=e[Gt];let R=globalThis.document;return e===R?R:null}get isConnected(){return this[Jt]}hasChildNodes(){return this[Kt].length>0}contains(e){if(e===null)return!1;if(e===this)return!0;let R=e;for(;R;){if(R===this)return!0;R=R[Gt]}return!1}getRootNode(){let e=this;for(;e[Gt];)e=e[Gt];return e}appendChild(e){return e[Gt]&&e[Gt].removeChild(e),e[Gt]=this,this[Kt].push(e),e[Wt]===ir.ELEMENT_NODE&&this[qt].push(e),e}removeChild(e){let R=this[Kt],W=R.indexOf(e);if(W===-1)throw new DOMException(`Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.`,`NotFoundError`);if(R.splice(W,1),e[Gt]=null,e[Wt]===ir.ELEMENT_NODE){let R=this[qt].indexOf(e);R!==-1&&this[qt].splice(R,1)}return e}insertBefore(e,R){if(R===null)return this.appendChild(e);let W=this[Kt],Y=W.indexOf(R);if(Y===-1)throw new DOMException(`Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`,`NotFoundError`);if(e[Gt]&&e[Gt].removeChild(e),e[Gt]=this,W.splice(Y,0,e),e[Wt]===ir.ELEMENT_NODE){let R=this[qt],X=R.length;for(let ie=Y;ie<W.length;ie++)if(W[ie][Wt]===ir.ELEMENT_NODE&&W[ie]!==e){X=R.indexOf(W[ie]);break}R.splice(X,0,e)}return e}replaceChild(e,R){return this.insertBefore(e,R),this.removeChild(R),R}cloneNode(e=!1){let R=new this.constructor;if(R[Wt]=this[Wt],e)for(let e of this[Kt])R.appendChild(e.cloneNode(!0));return R}dispatchEvent(e){let R=super.dispatchEvent(e);if(e.bubbles&&!e.cancelBubble){let R=this[Gt];for(;R&&(Object.getPrototypeOf(Node.prototype).dispatchEvent.call(R,e),!e.cancelBubble);)R=R[Gt]}return R}get[(Ur=Wt,Zr=Gt,$r=Kt,ei=qt,ti=Jt,Symbol.toStringTag)](){return`Node`}};const ii={html:`http://www.w3.org/1999/xhtml`,svg:`http://www.w3.org/2000/svg`,mathML:`http://www.w3.org/1998/Math/MathML`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};var Attr=class{constructor(e,R,W=null,Y=null,X=null){this.specified=!0,this[An]=e,this[tr]=R,this[rr]=X,this.namespaceURI=W,this.prefix=Y;let ie=e.indexOf(`:`);this.localName=ie===-1?e:e.slice(ie+1)}get name(){return this[An]}get value(){return this[tr]}set value(e){this[tr]=e}get ownerElement(){return this[rr]}get[Symbol.toStringTag](){return`Attr`}},NamedNodeMap=class{constructor(e){this._items=[],this._ownerElement=e}get length(){return this._items.length}item(e){return this._items[e]??null}getNamedItem(e){return this._findByName(e)}getNamedItemNS(e,R){let W=e===``?null:e;for(let e of this._items)if(e.namespaceURI===W&&e.localName===R)return e;return null}setNamedItem(e){return this._setAttr(e)}setNamedItemNS(e){return this._setAttr(e)}removeNamedItem(e){let R=this._findByName(e);if(!R)throw new DOMException(`Failed to execute 'removeNamedItem' on 'NamedNodeMap': No item with name '${e}' was found.`,`NotFoundError`);return this._removeAttr(R),R}removeNamedItemNS(e,R){let W=this.getNamedItemNS(e,R);if(!W)throw new DOMException(`Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': No item with namespace '${e}' and localName '${R}' was found.`,`NotFoundError`);return this._removeAttr(W),W}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NamedNodeMap`}_setNamedItem(e,R,W=null,Y=null){let X=W===null?this._findByName(e):this.getNamedItemNS(W,e.includes(`:`)?e.split(`:`)[1]:e);if(X)X.value=R;else{let X=new Attr(e,R,W,Y,this._ownerElement);this._items.push(X)}}_removeNamedItem(e){let R=this._findByName(e);return R?(this._removeAttr(R),!0):!1}_removeNamedItemNS(e,R){let W=this.getNamedItemNS(e,R);return W?(this._removeAttr(W),!0):!1}_findByName(e){let R=this._ownerElement.namespaceURI===ii.html,W=R?e.toLowerCase():e;for(let e of this._items)if((R?e.name.toLowerCase():e.name)===W)return e;return null}_setAttr(e){let R=null;if(R=e.namespaceURI===null?this._findByName(e.name):this.getNamedItemNS(e.namespaceURI,e.localName),R){let W=new Attr(R.name,R.value,R.namespaceURI,R.prefix,R.ownerElement);return R.value=e.value,W}return this._items.push(e),null}_removeAttr(e){let R=this._items.indexOf(e);R!==-1&&this._items.splice(R,1)}};xt();let si,ci,fi,pi,mi,hi;var Element=class extends ni{constructor(){super(),this[si]=``,this[ci]=``,this[fi]=ii.html,this[pi]=null,this[mi]=new NamedNodeMap(this),this[hi]=new Map,this._resizeSubscribers=null,this._allocatedClientWidth=0,this._allocatedClientHeight=0,this._pointerCaptures=new Set,this[Wt]=ir.ELEMENT_NODE}get tagName(){return this[Yt]}get localName(){return this[Xt]}get namespaceURI(){return this[Zt]}get prefix(){return this[Qt]}get nodeName(){return this[Yt]}get attributes(){return this[$t]}get id(){return this.getAttribute(`id`)??``}set id(e){this.setAttribute(`id`,e)}get className(){return this.getAttribute(`class`)??``}set className(e){this.setAttribute(`class`,e)}get children(){return this[qt]}get childElementCount(){return this[qt].length}get firstElementChild(){return this[qt][0]??null}get lastElementChild(){let e=this[qt];return e[e.length-1]??null}get previousElementSibling(){let e=this[Gt];if(!e)return null;let R=e[qt],W=R.indexOf(this);return W>0?R[W-1]:null}get nextElementSibling(){let e=this[Gt];if(!e)return null;let R=e[qt],W=R.indexOf(this);return W!==-1&&W<R.length-1?R[W+1]:null}get textContent(){let e=``;for(let R of this[Kt])R.textContent!==null&&(e+=R.textContent);return e}set textContent(e){let R=this[Kt];for(;R.length>0;)this.removeChild(R[0])}getAttribute(e){let R=this[$t].getNamedItem(e);return R?R.value:null}getAttributeNS(e,R){let W=this[$t].getNamedItemNS(e,R);return W?W.value:null}setAttribute(e,R){this[$t]._setNamedItem(e,String(R))}setAttributeNS(e,R,W){let Y=e===``?null:e,X=R.split(`:`),ie=X.length>1?X[0]:null;this[$t]._setNamedItem(R,String(W),Y,ie)}removeAttribute(e){this[$t]._removeNamedItem(e)}removeAttributeNS(e,R){let W=e===``?null:e;this[$t]._removeNamedItemNS(W,R)}hasAttribute(e){return this[$t].getNamedItem(e)!==null}hasAttributeNS(e,R){return this[$t].getNamedItemNS(e,R)!==null}getAttributeNode(e){return this[$t].getNamedItem(e)}setAttributeNode(e){return this[$t].setNamedItem(e)}removeAttributeNode(e){let R=this[$t].getNamedItem(e.name);if(!R)throw new DOMException(`Failed to execute 'removeAttributeNode' on 'Element': The attribute is not owned by this element.`,`NotFoundError`);return this[$t].removeNamedItem(R.name),R}toggleAttribute(e,R){return R===void 0?this.hasAttribute(e)?(this.removeAttribute(e),!1):(this.setAttribute(e,``),!0):R?(this.setAttribute(e,``),!0):(this.removeAttribute(e),!1)}hasAttributes(){return this[$t].length>0}dispatchEvent(e){let R=super.dispatchEvent(e),W=this[on].get(`on`+e.type);return typeof W==`function`&&W.call(this,e),R}querySelector(e){return null}querySelectorAll(e){return[]}matches(e){return!1}closest(e){return null}getElementsByTagName(e){let R=[],W=e.toUpperCase(),walk=Y=>{for(let X of Y[Kt])if(X[Wt]===ir.ELEMENT_NODE){let Y=X;(e===`*`||Y[Yt]===W)&&R.push(Y),walk(Y)}};return walk(this),R}getElementsByClassName(e){let R=[],W=e.split(/\s+/).filter(Boolean),walk=e=>{for(let Y of e[Kt])if(Y[Wt]===ir.ELEMENT_NODE){let e=Y,X=e.className.split(/\s+/);W.every(e=>X.includes(e))&&R.push(e),walk(e)}};return walk(this),R}cloneNode(e=!1){let R=super.cloneNode(!1);R[Yt]=this[Yt],R[Xt]=this[Xt],R[Zt]=this[Zt],R[Qt]=this[Qt];for(let e of this[$t])R.setAttributeNS(e.namespaceURI,e.name,e.value);if(e)for(let e of this[Kt])R.appendChild(e.cloneNode(!0));return R}_onResize(e){let R=this._resizeSubscribers??=new Set;return R.add(e),()=>{R.delete(e),R.size===0&&(this._resizeSubscribers=null)}}_fireResizeSubscribers(e,R){let W=this._resizeSubscribers;if(!(!W||W.size===0))for(let Y of[...W])try{Y(e,R)}catch(e){bt.error(`ResizeObserver subscriber threw:`,e)}}setPointerCapture(e){this._pointerCaptures.add(e)}releasePointerCapture(e){this._pointerCaptures.delete(e)}hasPointerCapture(e){return this._pointerCaptures.has(e)}get[(si=Yt,ci=Xt,fi=Zt,pi=Qt,mi=$t,hi=on,Symbol.toStringTag)](){return`Element`}},CSSStyleDeclaration=class{constructor(){this._cssText=``}get cssText(){return this._cssText}set cssText(e){this._cssText=e;for(let R of e.split(`;`)){let e=R.indexOf(`:`);if(e===-1)continue;let W=R.slice(0,e).trim(),Y=R.slice(e+1).trim();if(!W)continue;let X=W.replace(/-([a-z])/g,(e,R)=>R.toUpperCase());this[X]=Y}}setProperty(e,R,W){this[e]=R}getPropertyValue(e){let R=this[e];return typeof R==`string`?R:``}removeProperty(e){let R=this[e];return delete this[e],typeof R==`string`?R:``}getPropertyPriority(e){return``}},HTMLElement$1=class extends Element{static{__name$1(this,`HTMLElement`)}constructor(...e){super(...e),this.style=new CSSStyleDeclaration}get dataset(){let e=this;return new Proxy({},{get(R,W){if(typeof W!=`string`)return;let Y=`data-`+W.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.getAttribute(Y)??void 0},set(R,W,Y){if(typeof W!=`string`)return!1;let X=`data-`+W.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.setAttribute(X,String(Y)),!0},deleteProperty(R,W){if(typeof W!=`string`)return!1;let Y=`data-`+W.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.removeAttribute(Y),!0},has(R,W){if(typeof W!=`string`)return!1;let Y=`data-`+W.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.hasAttribute(Y)}})}get title(){return this.getAttribute(`title`)??``}set title(e){this.setAttribute(`title`,e)}get lang(){return this.getAttribute(`lang`)??``}set lang(e){this.setAttribute(`lang`,e)}get dir(){return this.getAttribute(`dir`)??``}set dir(e){this.setAttribute(`dir`,e)}get accessKey(){return this.getAttribute(`accesskey`)??``}set accessKey(e){this.setAttribute(`accesskey`,e)}get accessKeyLabel(){return this.getAttribute(`accesskey`)??``}get hidden(){return this.hasAttribute(`hidden`)}set hidden(e){e?this.setAttribute(`hidden`,``):this.removeAttribute(`hidden`)}get draggable(){return this.getAttribute(`draggable`)===`true`}set draggable(e){this.setAttribute(`draggable`,String(e))}get spellcheck(){let e=this.getAttribute(`spellcheck`);return e===`false`?!1:e!==null}set spellcheck(e){this.setAttribute(`spellcheck`,String(e))}get translate(){return this.getAttribute(`translate`)!==`no`}set translate(e){this.setAttribute(`translate`,e?`yes`:`no`)}get tabIndex(){let e=this.getAttribute(`tabindex`);return e===null?-1:Number(e)}set tabIndex(e){this.setAttribute(`tabindex`,String(e))}get contentEditable(){let e=this.getAttribute(`contenteditable`);return e===``||e===`true`?`true`:e===`false`?`false`:`inherit`}set contentEditable(e){e===`inherit`?this.removeAttribute(`contenteditable`):this.setAttribute(`contenteditable`,e)}get isContentEditable(){return this.contentEditable===`true`}get offsetHeight(){return this._allocatedClientHeight}get offsetWidth(){return this._allocatedClientWidth}get offsetLeft(){return 0}get offsetTop(){return 0}get offsetParent(){return null}get clientHeight(){return this._allocatedClientHeight}get clientWidth(){return this._allocatedClientWidth}get clientLeft(){return 0}get clientTop(){return 0}get scrollHeight(){return this._allocatedClientHeight}get scrollWidth(){return this._allocatedClientWidth}get scrollTop(){return 0}set scrollTop(e){}get scrollLeft(){return 0}set scrollLeft(e){}getBoundingClientRect(){let e=this.clientWidth,R=this.clientHeight;return{x:0,y:0,top:0,left:0,right:e,bottom:R,width:e,height:R,toJSON(){return this}}}click(){this.dispatchEvent(new Event$1(`click`,{bubbles:!0,cancelable:!0}))}blur(){this.dispatchEvent(new Event$1(`blur`))}focus(){this.dispatchEvent(new Event$1(`focus`))}get onclick(){return this[on].get(`onclick`)??null}set onclick(e){this[on].set(`onclick`,e)}get ondblclick(){return this[on].get(`ondblclick`)??null}set ondblclick(e){this[on].set(`ondblclick`,e)}get onload(){return this[on].get(`onload`)??null}set onload(e){this[on].set(`onload`,e)}get onerror(){return this[on].get(`onerror`)??null}set onerror(e){this[on].set(`onerror`,e)}get onabort(){return this[on].get(`onabort`)??null}set onabort(e){this[on].set(`onabort`,e)}get onfocus(){return this[on].get(`onfocus`)??null}set onfocus(e){this[on].set(`onfocus`,e)}get onblur(){return this[on].get(`onblur`)??null}set onblur(e){this[on].set(`onblur`,e)}get onchange(){return this[on].get(`onchange`)??null}set onchange(e){this[on].set(`onchange`,e)}get oninput(){return this[on].get(`oninput`)??null}set oninput(e){this[on].set(`oninput`,e)}get onsubmit(){return this[on].get(`onsubmit`)??null}get onreset(){return this[on].get(`onreset`)??null}set onreset(e){this[on].set(`onreset`,e)}get onscroll(){return this[on].get(`onscroll`)??null}set onscroll(e){this[on].set(`onscroll`,e)}get onresize(){return this[on].get(`onresize`)??null}set onresize(e){this[on].set(`onresize`,e)}get onmousedown(){return this[on].get(`onmousedown`)??null}set onmousedown(e){this[on].set(`onmousedown`,e)}get onmouseup(){return this[on].get(`onmouseup`)??null}set onmouseup(e){this[on].set(`onmouseup`,e)}get onmousemove(){return this[on].get(`onmousemove`)??null}set onmousemove(e){this[on].set(`onmousemove`,e)}get onmouseover(){return this[on].get(`onmouseover`)??null}set onmouseover(e){this[on].set(`onmouseover`,e)}get onmouseout(){return this[on].get(`onmouseout`)??null}set onmouseout(e){this[on].set(`onmouseout`,e)}get onmouseenter(){return this[on].get(`onmouseenter`)??null}set onmouseenter(e){this[on].set(`onmouseenter`,e)}get onmouseleave(){return this[on].get(`onmouseleave`)??null}set onmouseleave(e){this[on].set(`onmouseleave`,e)}get oncontextmenu(){return this[on].get(`oncontextmenu`)??null}set oncontextmenu(e){this[on].set(`oncontextmenu`,e)}get onwheel(){return this[on].get(`onwheel`)??null}set onwheel(e){this[on].set(`onwheel`,e)}get onkeydown(){return this[on].get(`onkeydown`)??null}set onkeydown(e){this[on].set(`onkeydown`,e)}get onkeyup(){return this[on].get(`onkeyup`)??null}set onkeyup(e){this[on].set(`onkeyup`,e)}get ontouchstart(){return this[on].get(`ontouchstart`)??null}set ontouchstart(e){this[on].set(`ontouchstart`,e)}get ontouchend(){return this[on].get(`ontouchend`)??null}set ontouchend(e){this[on].set(`ontouchend`,e)}get ontouchmove(){return this[on].get(`ontouchmove`)??null}set ontouchmove(e){this[on].set(`ontouchmove`,e)}get onpointerdown(){return this[on].get(`onpointerdown`)??null}set onpointerdown(e){this[on].set(`onpointerdown`,e)}get onpointerup(){return this[on].get(`onpointerup`)??null}set onpointerup(e){this[on].set(`onpointerup`,e)}get onpointermove(){return this[on].get(`onpointermove`)??null}set onpointermove(e){this[on].set(`onpointermove`,e)}cloneNode(e=!1){return super.cloneNode(e)}get[Symbol.toStringTag](){return`HTMLElement`}},gi=class HTMLCanvasElement extends HTMLElement$1{constructor(...e){super(...e),this.oncontextlost=null,this.oncontextrestored=null,this.onwebglcontextcreationerror=null,this.onwebglcontextlost=null,this.onwebglcontextrestored=null}static{this._contextFactories=new Map}static registerContextFactory(e,R){HTMLCanvasElement._contextFactories.set(e,R)}get width(){let e=this.getAttribute(`width`);return e===null?300:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get height(){let e=this.getAttribute(`height`);return e===null?150:Number(e)}set height(e){this.setAttribute(`height`,String(e))}getContext(e,R){let W=HTMLCanvasElement._contextFactories.get(e);return W?W(this,R):null}toDataURL(e,R){let W=this.getContext(`2d`);return W&&typeof W._toDataURL==`function`?W._toDataURL(e,R):``}toBlob(e,R,W){let Y=this.toDataURL(R,W);if(!Y){e(null);return}let[X,ie]=Y.split(`,`),ae=X.split(`:`)[1].split(`;`)[0],le=atob(ie),_e=new Uint8Array(le.length);for(let e=0;e<le.length;e++)_e[e]=le.charCodeAt(e);e(new Blob([_e],{type:ae}))}captureStream(e){return{}}},_i=class DOMMatrix{constructor(e){this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1,this.is2D=!0,this.isIdentity=!0,Array.isArray(e)&&(e.length===6?(this.a=this.m11=e[0],this.b=this.m12=e[1],this.c=this.m21=e[2],this.d=this.m22=e[3],this.e=this.m41=e[4],this.f=this.m42=e[5],this.is2D=!0):e.length===16&&(this.m11=e[0],this.m12=e[1],this.m13=e[2],this.m14=e[3],this.m21=e[4],this.m22=e[5],this.m23=e[6],this.m24=e[7],this.m31=e[8],this.m32=e[9],this.m33=e[10],this.m34=e[11],this.m41=e[12],this.m42=e[13],this.m43=e[14],this.m44=e[15],this.a=this.m11,this.b=this.m12,this.c=this.m21,this.d=this.m22,this.e=this.m41,this.f=this.m42,this.is2D=!1),this.isIdentity=this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0)}multiply(e){return new DOMMatrix([this.a*e.a+this.c*e.b,this.b*e.a+this.d*e.b,this.a*e.c+this.c*e.d,this.b*e.c+this.d*e.d,this.a*e.e+this.c*e.f+this.e,this.b*e.e+this.d*e.f+this.f])}multiplySelf(e){let R=this.multiply(e);return this.a=R.a,this.b=R.b,this.c=R.c,this.d=R.d,this.e=R.e,this.f=R.f,this.m11=this.a,this.m12=this.b,this.m21=this.c,this.m22=this.d,this.m41=this.e,this.m42=this.f,this.isIdentity=!1,this}inverse(){let e=this.a*this.d-this.b*this.c;if(e===0)return new DOMMatrix([1,0,0,1,0,0]);let R=1/e;return new DOMMatrix([this.d*R,-this.b*R,-this.c*R,this.a*R,(this.c*this.f-this.d*this.e)*R,(this.b*this.e-this.a*this.f)*R])}translate(e=0,R=0){return this.multiply({a:1,b:0,c:0,d:1,e,f:R})}scale(e=1,R=e){return this.multiply({a:e,b:0,c:0,d:R,e:0,f:0})}};const yi=_i;function defineGlobal(e,R){Object.defineProperty(globalThis,e,{value:R,writable:!0,configurable:!0})}function defineGlobalIfMissing(e,R){globalThis[e]===void 0&&defineGlobal(e,R)}const bi={aliceblue:`#f0f8ff`,antiquewhite:`#faebd7`,aqua:`#00ffff`,aquamarine:`#7fffd4`,azure:`#f0ffff`,beige:`#f5f5dc`,bisque:`#ffe4c4`,black:`#000000`,blanchedalmond:`#ffebcd`,blue:`#0000ff`,blueviolet:`#8a2be2`,brown:`#a52a2a`,burlywood:`#deb887`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,cornflowerblue:`#6495ed`,cornsilk:`#fff8dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,darkkhaki:`#bdb76b`,darkmagenta:`#8b008b`,darkolivegreen:`#556b2f`,darkorange:`#ff8c00`,darkorchid:`#9932cc`,darkred:`#8b0000`,darksalmon:`#e9967a`,darkseagreen:`#8fbc8f`,darkslateblue:`#483d8b`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,darkturquoise:`#00ced1`,darkviolet:`#9400d3`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,dimgray:`#696969`,dimgrey:`#696969`,dodgerblue:`#1e90ff`,firebrick:`#b22222`,floralwhite:`#fffaf0`,forestgreen:`#228b22`,fuchsia:`#ff00ff`,gainsboro:`#dcdcdc`,ghostwhite:`#f8f8ff`,gold:`#ffd700`,goldenrod:`#daa520`,gray:`#808080`,green:`#008000`,greenyellow:`#adff2f`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,indianred:`#cd5c5c`,indigo:`#4b0082`,ivory:`#fffff0`,khaki:`#f0e68c`,lavender:`#e6e6fa`,lavenderblush:`#fff0f5`,lawngreen:`#7cfc00`,lemonchiffon:`#fffacd`,lightblue:`#add8e6`,lightcoral:`#f08080`,lightcyan:`#e0ffff`,lightgoldenrodyellow:`#fafad2`,lightgray:`#d3d3d3`,lightgreen:`#90ee90`,lightgrey:`#d3d3d3`,lightpink:`#ffb6c1`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,lightskyblue:`#87cefa`,lightslategray:`#778899`,lightslategrey:`#778899`,lightsteelblue:`#b0c4de`,lightyellow:`#ffffe0`,lime:`#00ff00`,limegreen:`#32cd32`,linen:`#faf0e6`,magenta:`#ff00ff`,maroon:`#800000`,mediumaquamarine:`#66cdaa`,mediumblue:`#0000cd`,mediumorchid:`#ba55d3`,mediumpurple:`#9370db`,mediumseagreen:`#3cb371`,mediumslateblue:`#7b68ee`,mediumspringgreen:`#00fa9a`,mediumturquoise:`#48d1cc`,mediumvioletred:`#c71585`,midnightblue:`#191970`,mintcream:`#f5fffa`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,navajowhite:`#ffdead`,navy:`#000080`,oldlace:`#fdf5e6`,olive:`#808000`,olivedrab:`#6b8e23`,orange:`#ffa500`,orangered:`#ff4500`,orchid:`#da70d6`,palegoldenrod:`#eee8aa`,palegreen:`#98fb98`,paleturquoise:`#afeeee`,palevioletred:`#db7093`,papayawhip:`#ffefd5`,peachpuff:`#ffdab9`,peru:`#cd853f`,pink:`#ffc0cb`,plum:`#dda0dd`,powderblue:`#b0e0e6`,purple:`#800080`,rebeccapurple:`#663399`,red:`#ff0000`,rosybrown:`#bc8f8f`,royalblue:`#4169e1`,saddlebrown:`#8b4513`,salmon:`#fa8072`,sandybrown:`#f4a460`,seagreen:`#2e8b57`,seashell:`#fff5ee`,sienna:`#a0522d`,silver:`#c0c0c0`,skyblue:`#87ceeb`,slateblue:`#6a5acd`,slategray:`#708090`,slategrey:`#708090`,snow:`#fffafa`,springgreen:`#00ff7f`,steelblue:`#4682b4`,tan:`#d2b48c`,teal:`#008080`,thistle:`#d8bfd8`,tomato:`#ff6347`,turquoise:`#40e0d0`,violet:`#ee82ee`,wheat:`#f5deb3`,white:`#ffffff`,whitesmoke:`#f5f5f5`,yellow:`#ffff00`,yellowgreen:`#9acd32`,transparent:`#00000000`};function parseColor(e){if(!e||typeof e!=`string`)return null;let R=e.trim().toLowerCase(),W=bi[R];if(W)return parseHex(W);if(R.startsWith(`#`))return parseHex(R);let Y=R.match(/^rgba?\(\s*(\d+(?:\.\d+)?%?)\s*[,\s]\s*(\d+(?:\.\d+)?%?)\s*[,\s]\s*(\d+(?:\.\d+)?%?)\s*(?:[,/]\s*(\d+(?:\.\d+)?%?))?\s*\)$/);if(Y)return{r:parseComponent(Y[1],255)/255,g:parseComponent(Y[2],255)/255,b:parseComponent(Y[3],255)/255,a:Y[4]===void 0?1:parseComponent(Y[4],1)};let X=R.match(/^hsla?\(\s*(\d+(?:\.\d+)?)\s*[,\s]\s*(\d+(?:\.\d+)?)(%)?\s*[,\s]\s*(\d+(?:\.\d+)?)(%)?\s*(?:[,/]\s*(\d+(?:\.\d+)?%?))?\s*\)$/);if(X){let e=parseFloat(X[1]),R=parseFloat(X[2]),W=X[3]===`%`,Y=parseFloat(X[4]),ie=X[5]===`%`,ae=X[6]===void 0?1:parseComponent(X[6],1);return e>1&&(e/=360),(W||R>1)&&(R/=100),(ie||Y>1)&&(Y/=100),hslToRGBA(e,R,Y,Math.max(0,Math.min(1,ae)))}return null}function parseHex(e){let R=e.slice(1),W,Y,X,ie=1;if(R.length===3)W=parseInt(R[0]+R[0],16)/255,Y=parseInt(R[1]+R[1],16)/255,X=parseInt(R[2]+R[2],16)/255;else if(R.length===4)W=parseInt(R[0]+R[0],16)/255,Y=parseInt(R[1]+R[1],16)/255,X=parseInt(R[2]+R[2],16)/255,ie=parseInt(R[3]+R[3],16)/255;else if(R.length===6)W=parseInt(R.slice(0,2),16)/255,Y=parseInt(R.slice(2,4),16)/255,X=parseInt(R.slice(4,6),16)/255;else if(R.length===8)W=parseInt(R.slice(0,2),16)/255,Y=parseInt(R.slice(2,4),16)/255,X=parseInt(R.slice(4,6),16)/255,ie=parseInt(R.slice(6,8),16)/255;else return null;return{r:W,g:Y,b:X,a:ie}}function parseComponent(e,R){return e.endsWith(`%`)?parseFloat(e)/100*R:parseFloat(e)}function hue2rgb(e,R,W){return W<0&&(W+=1),W>1&&--W,W<1/6?e+(R-e)*6*W:W<1/2?R:W<2/3?e+(R-e)*(2/3-W)*6:e}function hslToRGBA(e,R,W,Y){let X,ie,ae;if(R===0)X=ie=ae=W;else{let Y=W<.5?W*(1+R):W+R-W*R,le=2*W-Y;X=hue2rgb(le,Y,e+1/3),ie=hue2rgb(le,Y,e),ae=hue2rgb(le,Y,e-1/3)}return{r:X,g:ie,b:ae,a:Y}}const Si={r:0,g:0,b:0,a:1};var CanvasGradient=class{constructor(e,R,Y,X,ie,ae,le){e===`radial`?this._pattern=new W.RadialGradient(R,Y,ae,X,ie,le):this._pattern=new W.LinearGradient(R,Y,X,ie)}addColorStop(e,R){let W=parseColor(R);W&&this._pattern.addColorStopRGBA(e,W.r,W.g,W.b,W.a)}_getCairoPattern(){return this._pattern}};function quadraticToCubic(e,R,W,Y,X,ie){return{cp1x:e+2/3*(W-e),cp1y:R+2/3*(Y-R),cp2x:X+2/3*(W-X),cp2y:ie+2/3*(Y-ie)}}function computeArcTo(e,R,W,Y,X,ie,ae){let le=e-W,_e=R-Y,ye=X-W,be=ie-Y,Ce=Math.sqrt(le*le+_e*_e),Te=Math.sqrt(ye*ye+be*be);if(Ce===0||Te===0)return null;let Oe=le/Ce,Ae=_e/Ce,Me=ye/Te,Pe=be/Te,Re=Oe*Pe-Ae*Me;if(Math.abs(Re)<1e-10)return null;let Be=Oe*Me+Ae*Pe,Ve=Math.acos(Math.max(-1,Math.min(1,Be)))/2,He=ae/Math.tan(Ve),Ue=W+Oe*He,We=Y+Ae*He,Ge=W+Me*He,Ke=Y+Pe*He,qe=ae/Math.sin(Ve),Je=(Oe+Me)/2,Ye=(Ae+Pe)/2,Xe=Math.sqrt(Je*Je+Ye*Ye),Ze=W+Je/Xe*qe,Qe=Y+Ye/Xe*qe;return{tx0:Ue,ty0:We,tx1:Ge,ty1:Ke,cx:Ze,cy:Qe,startAngle:Math.atan2(We-Qe,Ue-Ze),endAngle:Math.atan2(Ke-Qe,Ge-Ze),counterclockwise:Re>0}}function cairoArcTo(e,R,W,Y,X,ie,ae,le){let _e=computeArcTo(R,W,Y,X,ie,ae,le);if(!_e){e.lineTo(Y,X);return}let{tx0:ye,ty0:be,cx:Ce,cy:Te,startAngle:Oe,endAngle:Ae,counterclockwise:Me}=_e;e.lineTo(ye,be),Me?e.arcNegative(Ce,Te,le,Oe,Ae):e.arc(Ce,Te,le,Oe,Ae)}function cairoEllipse(e,R,W,Y,X,ie,ae,le,_e){e.save(),e.translate(R,W),e.rotate(ie),e.scale(Y,X),_e?e.arcNegative(0,0,1,ae,le):e.arc(0,0,1,ae,le),e.restore()}function cairoRoundRect(e,R,W,Y,X,ie){let ae,le,_e,ye;typeof ie==`number`?ae=le=_e=ye=ie:ie.length===1?ae=le=_e=ye=ie[0]:ie.length===2?(ae=_e=ie[0],le=ye=ie[1]):ie.length===3?(ae=ie[0],le=ye=ie[1],_e=ie[2]):(ae=ie[0],le=ie[1],_e=ie[2],ye=ie[3]);let be=Math.min(Y/2,X/2);ae=Math.min(ae,be),le=Math.min(le,be),_e=Math.min(_e,be),ye=Math.min(ye,be);let Ce=Math.PI/2;e.newSubPath(),e.arc(R+ae,W+ae,ae,Math.PI,Math.PI+Ce),e.arc(R+Y-le,W+le,le,-Ce,0),e.arc(R+Y-_e,W+X-_e,_e,0,Ce),e.arc(R+ye,W+X-ye,ye,Ce,Math.PI),e.closePath()}const Ti={"source-over":2,"source-in":3,"source-out":4,"source-atop":5,"destination-over":7,"destination-in":8,"destination-out":9,"destination-atop":10,lighter:12,copy:1,xor:11,multiply:14,screen:15,overlay:16,darken:17,lighten:18,"color-dodge":19,"color-burn":20,"hard-light":21,"soft-light":22,difference:23,exclusion:24,hue:25,saturation:26,color:27,luminosity:28},Ei={butt:0,round:1,square:2},Di={miter:0,round:1,bevel:2};var Oi=class Path2D{constructor(e){this._ops=[],e instanceof Path2D&&(this._ops=[...e._ops])}addPath(e){this._ops.push(...e._ops)}moveTo(e,R){this._ops.push({type:`moveTo`,x:e,y:R})}lineTo(e,R){this._ops.push({type:`lineTo`,x:e,y:R})}closePath(){this._ops.push({type:`closePath`})}bezierCurveTo(e,R,W,Y,X,ie){this._ops.push({type:`bezierCurveTo`,cp1x:e,cp1y:R,cp2x:W,cp2y:Y,x:X,y:ie})}quadraticCurveTo(e,R,W,Y){this._ops.push({type:`quadraticCurveTo`,cpx:e,cpy:R,x:W,y:Y})}arc(e,R,W,Y,X,ie=!1){this._ops.push({type:`arc`,x:e,y:R,radius:W,startAngle:Y,endAngle:X,ccw:ie})}ellipse(e,R,W,Y,X,ie,ae,le=!1){if(W<0||Y<0)throw RangeError(`The radii provided are negative`);this._ops.push({type:`ellipse`,x:e,y:R,rx:W,ry:Y,rotation:X,startAngle:ie,endAngle:ae,ccw:le})}rect(e,R,W,Y){this._ops.push({type:`rect`,x:e,y:R,w:W,h:Y})}roundRect(e,R,W,Y,X=0){this._ops.push({type:`roundRect`,x:e,y:R,w:W,h:Y,radii:X})}_replayOnCairo(e){let R=0,W=0;for(let Y of this._ops)switch(Y.type){case`moveTo`:e.moveTo(Y.x,Y.y),R=Y.x,W=Y.y;break;case`lineTo`:e.lineTo(Y.x,Y.y),R=Y.x,W=Y.y;break;case`closePath`:e.closePath();break;case`bezierCurveTo`:e.curveTo(Y.cp1x,Y.cp1y,Y.cp2x,Y.cp2y,Y.x,Y.y),R=Y.x,W=Y.y;break;case`quadraticCurveTo`:{let{cp1x:X,cp1y:ie,cp2x:ae,cp2y:le}=quadraticToCubic(R,W,Y.cpx,Y.cpy,Y.x,Y.y);e.curveTo(X,ie,ae,le,Y.x,Y.y),R=Y.x,W=Y.y;break}case`arc`:Y.ccw?e.arcNegative(Y.x,Y.y,Y.radius,Y.startAngle,Y.endAngle):e.arc(Y.x,Y.y,Y.radius,Y.startAngle,Y.endAngle);break;case`ellipse`:e.save(),e.translate(Y.x,Y.y),e.rotate(Y.rotation),e.scale(Y.rx,Y.ry),Y.ccw?e.arcNegative(0,0,1,Y.startAngle,Y.endAngle):e.arc(0,0,1,Y.startAngle,Y.endAngle),e.restore();break;case`rect`:e.rectangle(Y.x,Y.y,Y.w,Y.h);break;case`roundRect`:cairoRoundRect(e,Y.x,Y.y,Y.w,Y.h,Y.radii);break}}};function asCairoPattern(e){if(!e)return null;let R=e;return typeof R.setFilter!=`function`||typeof R.setExtend!=`function`?null:R}function isPixbufImageSource(e){return typeof e!=`object`||!e?!1:typeof e.isPixbuf==`function`&&e.isPixbuf()}function isCanvasImageSource(e){return typeof e!=`object`||!e?!1:typeof e.getContext==`function`}var ki=class CanvasPattern{constructor(e,R){let Y=asCairoPattern(new W.SurfacePattern(e));if(!Y)throw TypeError(`CanvasPattern: cairo SurfacePattern is missing setExtend at runtime — incompatible Cairo binding`);switch(this._pattern=Y,R){case`repeat`:case``:case null:Y.setExtend(W.Extend.REPEAT);break;case`repeat-x`:case`repeat-y`:Y.setExtend(W.Extend.REPEAT);break;case`no-repeat`:Y.setExtend(W.Extend.NONE);break}}static create(e,R){if(isPixbufImageSource(e)){let X=e._pixbuf,ie=X.get_width(),ae=X.get_height(),le=new W.ImageSurface(W.Format.ARGB32,ie,ae),_e=new W.Context(le);return Y.cairo_set_source_pixbuf(_e,X,0,0),_e.paint(),_e.$dispose(),new CanvasPattern(le,R)}if(isCanvasImageSource(e)){let Y=e.getContext(`2d`);if(Y&&typeof Y._getSurface==`function`){let e=Y._getSurface(),X=e.getWidth(),ie=e.getHeight(),ae=new W.ImageSurface(W.Format.ARGB32,X,ie),le=new W.Context(ae);return le.setSourceSurface(e,0,0),le.paint(),le.$dispose(),new CanvasPattern(ae,R)}}return null}_getCairoPattern(){return this._pattern}},OurImageData=class{constructor(e,R,W){if(this.colorSpace=`srgb`,typeof e==`number`)this.width=e,this.height=R,this.data=new Uint8ClampedArray(this.width*this.height*4);else if(this.data=e,this.width=R,this.height=W??this.data.length/(4*this.width),this.data.length!==this.width*this.height*4)throw RangeError(`Source data length ${this.data.length} is not a multiple of (4 * width=${this.width})`)}};const Ai={translate(e,R){this._ensureSurface(),this._ctx.translate(e,R)},rotate(e){this._ensureSurface(),this._ctx.rotate(e)},scale(e,R){this._ensureSurface(),this._ctx.scale(e,R)},transform(e,R,W,Y,X,ie){if(this._ensureSurface(),!Number.isFinite(e)||!Number.isFinite(R)||!Number.isFinite(W)||!Number.isFinite(Y)||!Number.isFinite(X)||!Number.isFinite(ie))return;let ae=X,le=ie,_e=Math.hypot(e,R),ye=Math.hypot(W,Y),be=Math.atan2(R,e);this._ctx.translate(ae,le),be!==0&&this._ctx.rotate(be),(_e!==1||ye!==1)&&this._ctx.scale(_e,ye)},setTransform(e,R,W,Y,X,ie){if(this._ensureSurface(),typeof e==`object`&&e){let R=e;this._ctx.identityMatrix(),this.transform(R.a??R.m11??1,R.b??R.m12??0,R.c??R.m21??0,R.d??R.m22??1,R.e??R.m41??0,R.f??R.m42??0)}else typeof e==`number`?(this._ctx.identityMatrix(),this.transform(e,R,W,Y,X,ie)):this._ctx.identityMatrix()},getTransform(){let e=this._ctx.userToDevice(0,0),R=this._ctx.userToDevice(1,0),W=this._ctx.userToDevice(0,1),Y=e[0]??0,X=e[1]??0,ie=(R[0]??0)-Y,ae=(R[1]??0)-X,le=(W[0]??0)-Y,_e=(W[1]??0)-X,ye=globalThis.DOMMatrix;return typeof ye==`function`?new ye([ie,ae,le,_e,Y,X]):{a:ie,b:ae,c:le,d:_e,e:Y,f:X,m11:ie,m12:ae,m13:0,m14:0,m21:le,m22:_e,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:Y,m42:X,m43:0,m44:1,is2D:!0,isIdentity:ie===1&&ae===0&&le===0&&_e===1&&Y===0&&X===0}},resetTransform(){this._ensureSurface(),this._ctx.identityMatrix()}};function installTransformMethods(e){Object.assign(e,Ai)}const Mi={beginPath(){this._ensureSurface(),this._ctx.newPath()},moveTo(e,R){this._ensureSurface(),this._ctx.moveTo(e,R)},lineTo(e,R){this._ensureSurface(),this._ctx.lineTo(e,R)},closePath(){this._ensureSurface(),this._ctx.closePath()},bezierCurveTo(e,R,W,Y,X,ie){this._ensureSurface(),this._ctx.curveTo(e,R,W,Y,X,ie)},quadraticCurveTo(e,R,W,Y){this._ensureSurface();let X,ie;this._ctx.hasCurrentPoint()?[X,ie]=this._ctx.getCurrentPoint():(X=e,ie=R);let{cp1x:ae,cp1y:le,cp2x:_e,cp2y:ye}=quadraticToCubic(X,ie,e,R,W,Y);this._ctx.curveTo(ae,le,_e,ye,W,Y)},arc(e,R,W,Y,X,ie=!1){if(this._ensureSurface(),Math.abs(X-Y)>=2*Math.PI){this._ctx.arc(e,R,W,0,2*Math.PI);return}ie?this._ctx.arcNegative(e,R,W,Y,X):this._ctx.arc(e,R,W,Y,X)},arcTo(e,R,W,Y,X){this._ensureSurface();let ie,ae;this._ctx.hasCurrentPoint()?[ie,ae]=this._ctx.getCurrentPoint():(ie=e,ae=R,this._ctx.moveTo(e,R)),cairoArcTo(this._ctx,ie,ae,e,R,W,Y,X)},ellipse(e,R,W,Y,X,ie,ae,le=!1){if(this._ensureSurface(),W<0||Y<0)throw RangeError(`The radii provided are negative`);cairoEllipse(this._ctx,e,R,W,Y,X,ie,ae,le)},rect(e,R,W,Y){this._ensureSurface(),this._ctx.rectangle(e,R,W,Y)},roundRect(e,R,W,Y,X=0){this._ensureSurface(),cairoRoundRect(this._ctx,e,R,W,Y,X)}};function installPathMethods(e){Object.assign(e,Mi)}function getDrawImageSource(e){if(isPixbufImageSource(e)){let R=e._pixbuf;return{pixbuf:R,imgWidth:R.get_width(),imgHeight:R.get_height()}}if(isCanvasImageSource(e)){let R=e.width??0,W=e.height??0;if(!Number.isFinite(R)||!Number.isFinite(W)||R<=0||W<=0)return null;let X=e.getContext(`2d`);if(X&&typeof X._getSurface==`function`){let e=X._getSurface();e.flush();let ie=Y.pixbuf_get_from_surface(e,0,0,R,W);if(ie)return{pixbuf:ie,imgWidth:R,imgHeight:W}}}return null}const Fi={fill(e,R){this._ensureSurface(),this._applyCompositing(),this._applyFillStyle();let Y;e instanceof Oi?(this._ctx.newPath(),e._replayOnCairo(this._ctx),Y=R):Y=e,this._ctx.setFillRule(Y===`evenodd`?W.FillRule.EVEN_ODD:W.FillRule.WINDING),this._ctx.fillPreserve()},stroke(e){this._ensureSurface(),this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle(),e instanceof Oi&&(this._ctx.newPath(),e._replayOnCairo(this._ctx)),this._ctx.strokePreserve()},fillRect(e,R,W,Y){this._ensureSurface(),this._applyCompositing();let X=this._ctx.copyPath();this._hasShadow()&&this._renderShadow(()=>{this._ctx.newPath(),this._ctx.rectangle(e,R,W,Y),this._ctx.fill()}),this._applyFillStyle(),this._ctx.newPath(),this._ctx.rectangle(e,R,W,Y),this._ctx.fill(),this._ctx.newPath(),this._ctx.appendPath(X)},strokeRect(e,R,W,Y){this._ensureSurface(),this._applyCompositing();let X=this._ctx.copyPath();this._hasShadow()&&this._renderShadow(()=>{this._ctx.newPath(),this._ctx.rectangle(e,R,W,Y),this._ctx.stroke()}),this._applyStrokeStyle(),this._applyLineStyle(),this._ctx.newPath(),this._ctx.rectangle(e,R,W,Y),this._ctx.stroke(),this._ctx.newPath(),this._ctx.appendPath(X)},clearRect(e,R,Y,X){this._ensureSurface();let ie=this._ctx.copyPath();this._ctx.save(),this._ctx.setOperator(W.Operator.CLEAR),this._ctx.newPath(),this._ctx.rectangle(e,R,Y,X),this._ctx.fill(),this._ctx.restore(),this._ctx.newPath(),this._ctx.appendPath(ie)},clip(e,R){this._ensureSurface();let Y;e instanceof Oi?(this._ctx.newPath(),e._replayOnCairo(this._ctx),Y=R):Y=e,this._ctx.setFillRule(Y===`evenodd`?W.FillRule.EVEN_ODD:W.FillRule.WINDING),this._ctx.clip()},isPointInPath(e,R,Y,X){this._ensureSurface();let ie,ae,le;return e instanceof Oi?(this._ctx.newPath(),e._replayOnCairo(this._ctx),ie=R,ae=Y,le=X):(ie=e,ae=R,le=Y),this._ctx.setFillRule(le===`evenodd`?W.FillRule.EVEN_ODD:W.FillRule.WINDING),this._ctx.inFill(ie,ae)},isPointInStroke(e,R,W){return this._ensureSurface(),this._applyLineStyle(),e instanceof Oi?(this._ctx.newPath(),e._replayOnCairo(this._ctx),this._ctx.inStroke(R,W)):this._ctx.inStroke(e,R)},drawImage(e,R,X,ie,ae,le,_e,ye,be){this._ensureSurface(),this._applyCompositing();let Ce,Te,Oe,Ae,Me,Pe,Re,Be,Ve=getDrawImageSource(e);if(!Ve)return;let{pixbuf:He,imgWidth:Ue,imgHeight:We}=Ve;if(ie===void 0?(Ce=0,Te=0,Oe=Ue,Ae=We,Me=R,Pe=X,Re=Ue,Be=We):le===void 0?(Ce=0,Te=0,Oe=Ue,Ae=We,Me=R,Pe=X,Re=ie,Be=ae):(Ce=R,Te=X,Oe=ie,Ae=ae,Me=le,Pe=_e,Re=ye,Be=be),!Number.isFinite(Ce)||!Number.isFinite(Te)||!Number.isFinite(Oe)||!Number.isFinite(Ae)||!Number.isFinite(Me)||!Number.isFinite(Pe)||!Number.isFinite(Re)||!Number.isFinite(Be)||Oe===0||Ae===0||Re===0||Be===0)return;this._ctx.save(),this._ctx.rectangle(Me,Pe,Re,Be),this._ctx.clip(),this._ctx.translate(Me,Pe),this._ctx.scale(Re/Oe,Be/Ae),this._ctx.translate(-Ce,-Te),Y.cairo_set_source_pixbuf(this._ctx,He,0,0);let Ge=asCairoPattern(this._ctx.getSource?.());if(Ge){let e;e=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?W.Filter.BEST:W.Filter.BILINEAR:W.Filter.NEAREST,Ge.setFilter(e)}this._state.globalAlpha<1?this._ctx.paintWithAlpha(this._state.globalAlpha):this._ctx.paint(),this._ctx.restore()}};function installDrawingMethods$1(e){Object.assign(e,Fi)}__name$1(installDrawingMethods$1,`installDrawingMethods`);const Ii={createImageData(e,R){return typeof e==`number`?new OurImageData(Math.abs(e),Math.abs(R)):new OurImageData(e.width,e.height)},getImageData(e,R,W,X){this._ensureSurface(),this._surface.flush();let ie=Y.pixbuf_get_from_surface(this._surface,e,R,W,X);if(!ie)return new OurImageData(W,X);let ae=ie.get_pixels(),le=ie.get_has_alpha(),_e=ie.get_rowstride(),ye=ie.get_n_channels(),be=new Uint8ClampedArray(W*X*4);for(let e=0;e<X;e++)for(let R=0;R<W;R++){let Y=e*_e+R*ye,X=(e*W+R)*4;be[X]=ae[Y],be[X+1]=ae[Y+1],be[X+2]=ae[Y+2],be[X+3]=le?ae[Y+3]:255}return new OurImageData(be,W,X)},putImageData(e,R,ie,ae,le,_e,ye){this._ensureSurface();let be=ae??0,Ce=le??0,Te=_e??e.width,Oe=ye??e.height,Ae=e.data,Me=e.width,Pe=new Uint8Array(Te*Oe*4);for(let e=0;e<Oe;e++)for(let R=0;R<Te;R++){let W=((Ce+e)*Me+(be+R))*4,Y=(e*Te+R)*4;Pe[Y]=Ae[W],Pe[Y+1]=Ae[W+1],Pe[Y+2]=Ae[W+2],Pe[Y+3]=Ae[W+3]}let Re=X.Pixbuf.new_from_bytes(Pe,X.Colorspace.RGB,!0,8,Te,Oe,Te*4);this._ctx.save(),this._ctx.setOperator(W.Operator.SOURCE),Y.cairo_set_source_pixbuf(this._ctx,Re,R+be,ie+Ce),this._ctx.rectangle(R+be,ie+Ce,Te,Oe),this._ctx.fill(),this._ctx.restore()}};function installPixelMethods(e){Object.assign(e,Ii)}function parseFontToDescription(e){let R=e.match(/^\s*(italic|oblique|normal)?\s*(small-caps|normal)?\s*(bold|bolder|lighter|[1-9]00|normal)?\s*(\d+(?:\.\d+)?)(px|pt|em|rem|%)?\s*(?:\/\S+)?\s*(.+)?$/i);if(!R)return ie.font_description_from_string(e);let W=R[1]||``,Y=R[3]||``,X=parseFloat(R[4])||10,ae=(R[5]||`px`).toLowerCase(),le=(R[6]||`sans-serif`).replace(/['"]/g,``).trim();ae===`pt`?X=X*96/72:ae===`em`||ae===`rem`?X*=16:ae===`%`&&(X=X/100*16);let _e=le;W===`italic`?_e+=` Italic`:W===`oblique`&&(_e+=` Oblique`),Y===`bold`||Y===`bolder`||parseInt(Y)>=600?_e+=` Bold`:(Y===`lighter`||parseInt(Y)>0&&parseInt(Y)<=300)&&(_e+=` Light`);let ye=ie.font_description_from_string(_e);return ye.set_absolute_size(X*ie.SCALE),ye}function createTextLayout(e,R){let W=ae.create_layout(e._ctx);W.set_text(R,-1),W.get_context().set_base_dir(ie.Direction.LTR),W.context_changed();let Y=parseFontToDescription(e._state.font);return W.set_font_description(Y),W}function getTextAlignOffset(e,R){let[,W]=R.get_pixel_extents(),Y=W.width;switch(e._state.textAlign){case`center`:return-Y/2;case`right`:case`end`:return-Y;default:return 0}}function getTextBaselineOffset(e,R){let W=R.get_font_description()||parseFontToDescription(e._state.font),Y=R.get_context().get_metrics(W,null),X=Y.get_ascent()/ie.SCALE,ae=Y.get_descent()/ie.SCALE,le=X+ae;switch(e._state.textBaseline){case`top`:return 0;case`hanging`:return-(X*.2);case`middle`:return-(le/2);case`alphabetic`:return-X;case`ideographic`:return-(X+ae*.5);case`bottom`:return-le;default:return-X}}const Li={fillText(e,R,Y,X){this._ensureSurface(),this._applyCompositing();let ie=createTextLayout(this,e),le=getTextAlignOffset(this,ie),_e=getTextBaselineOffset(this,ie);if(this._hasShadow()){let e=parseColor(this._state.shadowColor);if(e){let[X,ye]=this._deviceToUserDistance(this._state.shadowOffsetX,this._state.shadowOffsetY),be=this._state.shadowBlur,Ce;if(be>0){let[R]=this._deviceToUserDistance(be,0),[,W]=this._deviceToUserDistance(0,be);Ce=[[X,ye,e.a],[X+R,ye,e.a*.5],[X-R,ye,e.a*.5],[X,ye+W,e.a*.5],[X,ye-W,e.a*.5]]}else Ce=[[X,ye,e.a]];let Te=this._state.imageSmoothingEnabled?W.Antialias.DEFAULT:W.Antialias.NONE;for(let[W,X,ye]of Ce)this._ctx.save(),this._ctx.setAntialias(Te),this._ctx.setSourceRGBA(e.r,e.g,e.b,ye),this._ctx.moveTo(R+le+W,Y+_e+X),ae.show_layout(this._ctx,ie),this._ctx.restore()}}this._applyFillStyle(),this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?W.Antialias.DEFAULT:W.Antialias.NONE),this._ctx.moveTo(R+le,Y+_e),ae.show_layout(this._ctx,ie),this._ctx.restore()},strokeText(e,R,Y,X){this._ensureSurface(),this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle();let ie=createTextLayout(this,e),le=getTextAlignOffset(this,ie),_e=getTextBaselineOffset(this,ie);this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?W.Antialias.DEFAULT:W.Antialias.NONE),this._ctx.moveTo(R+le,Y+_e),ae.layout_path(this._ctx,ie),this._ctx.stroke(),this._ctx.restore()},measureText(e){this._ensureSurface();let R=createTextLayout(this,e),[W,Y]=R.get_pixel_extents(),X=R.get_baseline()/ie.SCALE,ae=Math.max(0,X-W.y),le=Math.max(0,W.y+W.height-X),_e=R.get_font_description()||parseFontToDescription(this._state.font),ye=R.get_context().get_metrics(_e,null),be=ye.get_ascent()/ie.SCALE,Ce=ye.get_descent()/ie.SCALE;return{width:Y.width,actualBoundingBoxAscent:ae,actualBoundingBoxDescent:le,actualBoundingBoxLeft:Math.max(0,-W.x),actualBoundingBoxRight:W.x+W.width,fontBoundingBoxAscent:be,fontBoundingBoxDescent:Ce,alphabeticBaseline:0,emHeightAscent:be,emHeightDescent:Ce,hangingBaseline:be*.8,ideographicBaseline:-Ce}}};function installTextMethods(e){Object.assign(e,Li)}const zi={createLinearGradient(e,R,W,Y){return new CanvasGradient(`linear`,e,R,W,Y)},createRadialGradient(e,R,W,Y,X,ie){return new CanvasGradient(`radial`,e,R,Y,X,W,ie)},createPattern(e,R){return ki.create(e,R)}};function installFactoryMethods(e){Object.assign(e,zi)}function installAllContextMethods$1(e){installTransformMethods(e),installPathMethods(e),installDrawingMethods$1(e),installPixelMethods(e),installTextMethods(e),installFactoryMethods(e)}__name$1(installAllContextMethods$1,`installAllContextMethods`);function createDefaultState(){return{fillStyle:`#000000`,fillColor:{...Si},strokeStyle:`#000000`,strokeColor:{...Si},lineWidth:1,lineCap:`butt`,lineJoin:`miter`,miterLimit:10,lineDash:[],lineDashOffset:0,globalAlpha:1,globalCompositeOperation:`source-over`,shadowColor:`rgba(0, 0, 0, 0)`,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,font:`10px sans-serif`,textAlign:`start`,textBaseline:`alphabetic`,direction:`ltr`,imageSmoothingEnabled:!0,imageSmoothingQuality:`low`}}function cloneState(e){return{...e,fillColor:{...e.fillColor},strokeColor:{...e.strokeColor},lineDash:[...e.lineDash]}}var CanvasRenderingContext2D=class{constructor(e,R){this._stateStack=[],this.canvas=e,this._surfaceWidth=e.width||300,this._surfaceHeight=e.height||150,this._surface=new W.ImageSurface(W.Format.ARGB32,this._surfaceWidth,this._surfaceHeight),this._ctx=new W.Context(this._surface),this._state=createDefaultState()}_ensureSurface(){let e=this.canvas.width||300,R=this.canvas.height||150;(e!==this._surfaceWidth||R!==this._surfaceHeight)&&(this._ctx.$dispose(),this._surface.finish(),this._surfaceWidth=e,this._surfaceHeight=R,this._surface=new W.ImageSurface(W.Format.ARGB32,e,R),this._ctx=new W.Context(this._surface),this._stateStack=[])}_resetState(){this._state=createDefaultState(),this._stateStack=[]}_applyFillStyle(){let e=this._state.fillStyle;if(typeof e==`string`){let e=this._state.fillColor,R=e.a*this._state.globalAlpha;this._ctx.setSourceRGBA(e.r,e.g,e.b,R)}else e instanceof CanvasGradient?this._ctx.setSource(e._getCairoPattern()):e instanceof ki&&(this._ctx.setSource(e._getCairoPattern()),this._applyPatternFilter())}_applyStrokeStyle(){let e=this._state.strokeStyle;if(typeof e==`string`){let e=this._state.strokeColor,R=e.a*this._state.globalAlpha;this._ctx.setSourceRGBA(e.r,e.g,e.b,R)}else e instanceof CanvasGradient?this._ctx.setSource(e._getCairoPattern()):e instanceof ki&&(this._ctx.setSource(e._getCairoPattern()),this._applyPatternFilter())}_applyPatternFilter(){let e=asCairoPattern(this._ctx.getSource?.());if(!e)return;let R;R=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?W.Filter.BEST:W.Filter.BILINEAR:W.Filter.NEAREST,e.setFilter(R)}_applyLineStyle(){this._ctx.setLineWidth(this._state.lineWidth),this._ctx.setLineCap(Ei[this._state.lineCap]),this._ctx.setLineJoin(Di[this._state.lineJoin]),this._ctx.setMiterLimit(this._state.miterLimit),this._ctx.setDash(this._state.lineDash,this._state.lineDashOffset)}_applyCompositing(){let e=Ti[this._state.globalCompositeOperation];e!==void 0&&this._ctx.setOperator(e)}_getSurface(){return this._surface}_hasShadow(){if(this._state.shadowBlur===0&&this._state.shadowOffsetX===0&&this._state.shadowOffsetY===0)return!1;let e=parseColor(this._state.shadowColor);return e!==null&&e.a>0}_deviceToUserDistance(e,R){let W=this._ctx.userToDevice(0,0),Y=this._ctx.userToDevice(1,0),X=this._ctx.userToDevice(0,1),ie=(Y[0]??0)-(W[0]??0),ae=(Y[1]??0)-(W[1]??0),le=(X[0]??0)-(W[0]??0),_e=(X[1]??0)-(W[1]??0),ye=ie*_e-ae*le;return Math.abs(ye)<1e-10?[e,R]:[(_e*e-le*R)/ye,(-ae*e+ie*R)/ye]}_renderShadow(e){}save(){this._ensureSurface(),this._stateStack.push(cloneState(this._state)),this._ctx.save()}restore(){this._ensureSurface();let e=this._stateStack.pop();e&&(this._state=e,this._ctx.restore())}get fillStyle(){return this._state.fillStyle}set fillStyle(e){if(typeof e==`string`){let R=parseColor(e);R&&(this._state.fillStyle=e,this._state.fillColor=R)}else this._state.fillStyle=e}get strokeStyle(){return this._state.strokeStyle}set strokeStyle(e){if(typeof e==`string`){let R=parseColor(e);R&&(this._state.strokeStyle=e,this._state.strokeColor=R)}else this._state.strokeStyle=e}get lineWidth(){return this._state.lineWidth}set lineWidth(e){e>0&&isFinite(e)&&(this._state.lineWidth=e)}get lineCap(){return this._state.lineCap}set lineCap(e){(e===`butt`||e===`round`||e===`square`)&&(this._state.lineCap=e)}get lineJoin(){return this._state.lineJoin}set lineJoin(e){(e===`miter`||e===`round`||e===`bevel`)&&(this._state.lineJoin=e)}get miterLimit(){return this._state.miterLimit}set miterLimit(e){e>0&&isFinite(e)&&(this._state.miterLimit=e)}get globalAlpha(){return this._state.globalAlpha}set globalAlpha(e){e>=0&&e<=1&&isFinite(e)&&(this._state.globalAlpha=e)}get globalCompositeOperation(){return this._state.globalCompositeOperation}set globalCompositeOperation(e){Ti[e]!==void 0&&(this._state.globalCompositeOperation=e)}get imageSmoothingEnabled(){return this._state.imageSmoothingEnabled}set imageSmoothingEnabled(e){this._state.imageSmoothingEnabled=!!e}get imageSmoothingQuality(){return this._state.imageSmoothingQuality}set imageSmoothingQuality(e){(e===`low`||e===`medium`||e===`high`)&&(this._state.imageSmoothingQuality=e)}setLineDash(e){e.some(e=>e<0||!isFinite(e))||(this._state.lineDash=[...e])}getLineDash(){return[...this._state.lineDash]}get lineDashOffset(){return this._state.lineDashOffset}set lineDashOffset(e){isFinite(e)&&(this._state.lineDashOffset=e)}get shadowColor(){return this._state.shadowColor}set shadowColor(e){this._state.shadowColor=e}get shadowBlur(){return this._state.shadowBlur}set shadowBlur(e){e>=0&&isFinite(e)&&(this._state.shadowBlur=e)}get shadowOffsetX(){return this._state.shadowOffsetX}set shadowOffsetX(e){isFinite(e)&&(this._state.shadowOffsetX=e)}get shadowOffsetY(){return this._state.shadowOffsetY}set shadowOffsetY(e){isFinite(e)&&(this._state.shadowOffsetY=e)}get font(){return this._state.font}set font(e){this._state.font=e}get textAlign(){return this._state.textAlign}set textAlign(e){this._state.textAlign=e}get textBaseline(){return this._state.textBaseline}set textBaseline(e){this._state.textBaseline=e}get direction(){return this._state.direction}set direction(e){this._state.direction=e}_toDataURL(e,R){this._surface.flush();let W=imports.gi.Gio,Y=imports.gi.GLib,[,X]=Y.file_open_tmp(`canvas-XXXXXX.png`);try{this._surface.writeToPNG(X);let[,e]=W.File.new_for_path(X).load_contents(null);return`data:image/png;base64,${Y.base64_encode(e)}`}finally{try{Y.unlink(X)}catch{}}}_dispose(){this._ctx.$dispose(),this._surface.finish()}};installAllContextMethods$1(CanvasRenderingContext2D.prototype),defineGlobal(`HTMLCanvasElement`,gi),defineGlobal(`CanvasRenderingContext2D`,CanvasRenderingContext2D),defineGlobal(`DOMMatrix`,_i),defineGlobal(`DOMMatrixReadOnly`,yi);const Vi=Symbol.for(`gjsify_canvas2d_context`);gi.registerContextFactory(`2d`,(e,R)=>{let W=e,Y=W[Vi];if(Y)return Y;let X=new CanvasRenderingContext2D(e,R);return W[Vi]=X,X});var CharacterData=class extends ni{constructor(e=``){super(),this[Wt]=ir.TEXT_NODE,this._data=e}get data(){return this._data}set data(e){this._data=e}get textContent(){return this._data}set textContent(e){this._data=e}get nodeValue(){return this._data}set nodeValue(e){this._data=e}get length(){return this._data.length}appendData(e){this._data+=e}deleteData(e,R){this._data=this._data.substring(0,e)+this._data.substring(e+R)}insertData(e,R){this._data=this._data.substring(0,e)+R+this._data.substring(e)}replaceData(e,R,W){this._data=this._data.substring(0,e)+W+this._data.substring(e+R)}substringData(e,R){return this._data.substring(e,e+R)}cloneNode(e=!1){return new this.constructor(this._data)}get[Symbol.toStringTag](){return`CharacterData`}},Hi=class Comment extends CharacterData{constructor(e=``){super(e),this[Wt]=ir.COMMENT_NODE}get nodeName(){return`#comment`}cloneNode(e=!1){return new Comment(this.data)}get[Symbol.toStringTag](){return`Comment`}},Ui=class Text extends CharacterData{constructor(e=``){super(e),this[Wt]=ir.TEXT_NODE}get nodeName(){return`#text`}get wholeText(){let e=this.data,R=this.previousSibling;for(;R&&R instanceof Text;)e=R.data+e,R=R.previousSibling;let W=this.nextSibling;for(;W&&W instanceof Text;)e+=W.data,W=W.nextSibling;return e}splitText(e){let R=this.data.substring(e);this.data=this.data.substring(0,e);let W=new Text(R);return this.parentNode&&this.parentNode.insertBefore(W,this.nextSibling),W}cloneNode(e=!1){return new Text(this.data)}get[Symbol.toStringTag](){return`Text`}},Wi=class DocumentFragment extends ni{constructor(){super(),this[Wt]=ir.DOCUMENT_FRAGMENT_NODE}get nodeName(){return`#document-fragment`}get children(){return this[qt]}get childElementCount(){return this[qt].length}get firstElementChild(){return this[qt][0]??null}get lastElementChild(){let e=this[qt];return e[e.length-1]??null}get textContent(){let e=``;for(let R of this.childNodes)R.textContent!==null&&(e+=R.textContent);return e}set textContent(e){for(;this.firstChild;)this.removeChild(this.firstChild);e&&this.appendChild(new Ui(e))}append(...e){for(let R of e)typeof R==`string`?this.appendChild(new Ui(R)):this.appendChild(R)}prepend(...e){let R=this.firstChild;for(let W of e)typeof W==`string`?this.insertBefore(new Ui(W),R):this.insertBefore(W,R)}replaceChildren(...e){for(;this.firstChild;)this.removeChild(this.firstChild);this.append(...e)}getElementById(e){for(let R of this.children){if(R.id===e)return R;let W=this._findById(R,e);if(W)return W}return null}_findById(e,R){for(let W of e.children){if(W.id===R)return W;let e=this._findById(W,R);if(e)return e}return null}cloneNode(e=!1){let R=new DocumentFragment;if(e)for(let e of this.childNodes)R.appendChild(e.cloneNode(!0));return R}get[Symbol.toStringTag](){return`DocumentFragment`}},Gi=le;xt(),$e(),st();var HTMLImageElement=class extends HTMLElement$1{constructor(){super(),this._complete=!1,this._naturalHeight=0,this._naturalWidth=0,this[Yt]=`IMG`,this[Xt]=`img`,this[Zt]=ii.html}get complete(){return this._complete}get naturalHeight(){return this._naturalHeight}get naturalWidth(){return this._naturalWidth}get currentSrc(){return this.src}get x(){return 0}get y(){return 0}get alt(){return this.getAttribute(`alt`)??``}set alt(e){this.setAttribute(`alt`,e)}get crossOrigin(){return this.getAttribute(`crossorigin`)}set crossOrigin(e){e===null?this.removeAttribute(`crossorigin`):this.setAttribute(`crossorigin`,e)}get decoding(){return this.getAttribute(`decoding`)??`auto`}set decoding(e){this.setAttribute(`decoding`,e)}get loading(){let e=this.getAttribute(`loading`);return e===`lazy`||e===`eager`?e:`auto`}set loading(e){this.setAttribute(`loading`,e)}get referrerPolicy(){return this.getAttribute(`referrerpolicy`)??``}set referrerPolicy(e){this.setAttribute(`referrerpolicy`,e)}get sizes(){return this.getAttribute(`sizes`)??``}set sizes(e){this.setAttribute(`sizes`,e)}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,e);let R=globalThis.__GJSIFY_DEBUG_IMG===!0;if(e.startsWith(`data:`)){let W=e.indexOf(`,`);if(W===-1){this._complete=!0,this.dispatchEvent(new Event$1(`error`));return}let Y=e.slice(5,W),X=e.slice(W+1),ie=Y.includes(`;base64`);try{let e;e=ie?Qe.base64_decode(X):new TextEncoder().encode(decodeURIComponent(X));let W=Qe.Bytes.new(e),Y=at.MemoryInputStream.new_from_bytes(W);this._pixbuf=Gi.Pixbuf.new_from_stream(Y,null),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,R&&bt.log(`[img] ok data: (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event$1(`load`))}catch(e){R&&bt.warn(`[img] error data:: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new Event$1(`error`))}return}let W;if(e.startsWith(`file://`))W=Qe.filename_from_uri(e)[0];else if(e.startsWith(`http://`)||e.startsWith(`https://`)){this._complete=!0,this.dispatchEvent(new Event$1(`error`));return}else{let R=Qe.path_get_dirname(_e.programInvocationName);W=Qe.build_filenamev([R,e])}try{R&&bt.log(`[img] load ${W}`),this._pixbuf=Gi.Pixbuf.new_from_file(W),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,R&&bt.log(`[img] ok ${W} (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event$1(`load`))}catch(e){R&&bt.warn(`[img] error ${W}: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new Event$1(`error`))}}get srcset(){return this.getAttribute(`srcset`)??``}set srcset(e){this.setAttribute(`srcset`,e)}get useMap(){return this.getAttribute(`usemap`)??``}set useMap(e){this.setAttribute(`usemap`,e)}get height(){if(this._pixbuf)return this._pixbuf.get_height();let e=this.getAttribute(`height`);return e===null?0:Number(e)}set height(e){this.setAttribute(`height`,String(e))}get width(){if(this._pixbuf)return this._pixbuf.get_width();let e=this.getAttribute(`width`);return e===null?0:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get isMap(){return this.hasAttribute(`ismap`)}set isMap(e){e?this.setAttribute(`ismap`,``):this.removeAttribute(`ismap`)}decode(){return Promise.resolve()}cloneNode(e=!1){return super.cloneNode(e)}getImageData(){if(!this._pixbuf)return null;let e=this._pixbuf.get_has_alpha()?this._pixbuf:this._pixbuf.add_alpha(!1,0,0,0)??this._pixbuf;return{colorSpace:`srgb`,data:new Uint8ClampedArray(e.get_pixels()),height:e.get_height(),width:e.get_width()}}isPixbuf(){return!!this._pixbuf}get[Symbol.toStringTag](){return`HTMLImageElement`}},HTMLMediaElement=class extends HTMLElement$1{constructor(...e){super(...e),this._src=``,this._srcObject=null,this.currentTime=0,this.duration=NaN,this.paused=!0,this.ended=!1,this.volume=1,this.muted=!1,this.defaultMuted=!1,this.loop=!1,this.autoplay=!1,this.preload=``,this.playbackRate=1,this.defaultPlaybackRate=1,this.readyState=0,this.networkState=0}get buffered(){return{length:0,start:()=>0,end:()=>0}}get seekable(){return{length:0,start:()=>0,end:()=>0}}get played(){return{length:0,start:()=>0,end:()=>0}}get src(){return this._src}set src(e){this._src=e,this._srcObject=null,this.dispatchEvent(new Event$1(`srcchange`))}get srcObject(){return this._srcObject}set srcObject(e){this._srcObject=e,this._src=``,this.dispatchEvent(new Event$1(`srcobjectchange`))}play(){return this.paused=!1,this.ended=!1,this.dispatchEvent(new Event$1(`play`)),Promise.resolve()}pause(){this.paused=!0,this.dispatchEvent(new Event$1(`pause`))}load(){this.readyState=0,this.networkState=2,this.dispatchEvent(new Event$1(`loadstart`))}canPlayType(e){return``}static{this.HAVE_NOTHING=0}static{this.HAVE_METADATA=1}static{this.HAVE_CURRENT_DATA=2}static{this.HAVE_FUTURE_DATA=3}static{this.HAVE_ENOUGH_DATA=4}static{this.NETWORK_EMPTY=0}static{this.NETWORK_IDLE=1}static{this.NETWORK_LOADING=2}static{this.NETWORK_NO_SOURCE=3}get[Symbol.toStringTag](){return`HTMLMediaElement`}};const Ki=1e9;function secondsToGstTime(e){return BigInt(Math.round(e*Ki))}function gstTimeToSeconds(e){return Number(e)/Ki}var HTMLVideoElement=class extends HTMLMediaElement{constructor(){super(),this._pipeline=null,this._videoWidth=0,this._videoHeight=0,this.poster=``,this[Yt]=`VIDEO`,this[Xt]=`video`,this[Zt]=ii.html;let e=this;Object.defineProperty(this,"paused",{get(){if(!e._pipeline)return!0;let[,R]=e._pipeline.get_state(0n);return R!==4},configurable:!0,enumerable:!0}),Object.defineProperty(this,"currentTime",{get(){if(!e._pipeline)return 0;let[R,W]=e._pipeline.query_position(3);return R?gstTimeToSeconds(W):0},set(R){e._pipeline?.seek(1,3,5,1,secondsToGstTime(R),0,-1n)},configurable:!0,enumerable:!0}),Object.defineProperty(this,"duration",{get(){if(!e._pipeline)return NaN;let[R,W]=e._pipeline.query_duration(3);return R&&Number(W)>0?gstTimeToSeconds(W):NaN},configurable:!0,enumerable:!0}),Object.defineProperty(this,"volume",{get(){return e._playbin()?.volume??1},set(R){let W=e._playbin();W&&(W.volume=Math.max(0,Math.min(1,R)))},configurable:!0,enumerable:!0}),Object.defineProperty(this,"muted",{get(){return e._playbin()?.mute??!1},set(R){let W=e._playbin();W&&(W.mute=R)},configurable:!0,enumerable:!0})}async play(){this._pipeline?.set_state(4),this.dispatchEvent(new Event$1(`play`)),this.dispatchEvent(new Event$1(`playing`))}pause(){this._pipeline?.set_state(3),this.dispatchEvent(new Event$1(`pause`))}get videoWidth(){return this._videoWidth}set videoWidth(e){this._videoWidth=e}get videoHeight(){return this._videoHeight}set videoHeight(e){this._videoHeight=e}get[Symbol.toStringTag](){return`HTMLVideoElement`}_playbin(){return this._pipeline?.get_by_name(`playbin`)??null}};const qi=new class Document extends ni{static{this._elementFactories=new Map}constructor(){super(),this.body=new HTMLElement$1,this.head=new HTMLElement$1,this.documentElement=new HTMLElement$1,this.appendChild(this.documentElement),this.documentElement.appendChild(this.body)}static registerElementFactory(e,R){Document._elementFactories.set(e.toLowerCase(),R)}createElementNS(e,R){let W=R.toLowerCase();switch(W){case`img`:return new HTMLImageElement;case`video`:return new HTMLVideoElement;case`canvas`:return new gi;default:{let e=Document._elementFactories.get(W);return e?e():new HTMLElement$1}}}createElement(e){return this.createElementNS(`http://www.w3.org/1999/xhtml`,e)}createTextNode(e){return new Ui(e)}createComment(e){return new Hi(e)}createDocumentFragment(){return new Wi}createEvent(e){return new Event$1(e)}getElementById(e){return this._findById(this.body,e)}_findById(e,R){if(e.id===R)return e;for(let W of e.children){let e=this._findById(W,R);if(e)return e}return null}get[Symbol.toStringTag](){return`Document`}};var DOMTokenList=class{constructor(e,R){this._ownerElement=e,this._attributeName=R}_getTokens(){let e=this._ownerElement.getAttribute(this._attributeName);return e?e.split(/\s+/).filter(e=>e.length>0):[]}_setTokens(e){let R=e.join(` `);R?this._ownerElement.setAttribute(this._attributeName,R):this._ownerElement.removeAttribute(this._attributeName)}get length(){return this._getTokens().length}get value(){return this._ownerElement.getAttribute(this._attributeName)??``}set value(e){e?this._ownerElement.setAttribute(this._attributeName,e):this._ownerElement.removeAttribute(this._attributeName)}item(e){let R=this._getTokens();return e>=0&&e<R.length?R[e]:null}contains(e){return this._getTokens().includes(e)}add(...e){let R=this._getTokens();for(let W of e)W&&!R.includes(W)&&R.push(W);this._setTokens(R)}remove(...e){let R=this._getTokens().filter(R=>!e.includes(R));this._setTokens(R)}toggle(e,R){let W=this.contains(e);return R===void 0?W?(this.remove(e),!1):(this.add(e),!0):R?(this.add(e),!0):(this.remove(e),!1)}replace(e,R){let W=this._getTokens(),Y=W.indexOf(e);return Y===-1?!1:(W[Y]=R,this._setTokens(W),!0)}supports(e){return!0}forEach(e){let R=this._getTokens();for(let W=0;W<R.length;W++)e(R[W],W,this)}keys(){return this._getTokens().keys()}values(){return this._getTokens().values()}entries(){return this._getTokens().entries()}[Symbol.iterator](){return this._getTokens().values()}toString(){return this.value}get[Symbol.toStringTag](){return`DOMTokenList`}};xt(),defineGlobal(`Text`,Ui),defineGlobal(`Comment`,Hi),defineGlobal(`DocumentFragment`,Wi),defineGlobal(`DOMTokenList`,DOMTokenList),defineGlobal(`document`,qi),defineGlobalIfMissing(`self`,globalThis);var Window$1=class{static{__name$1(this,`Window`)}};defineGlobalIfMissing(`Window`,Window$1),defineGlobalIfMissing(`window`,globalThis),defineGlobalIfMissing(`focus`,()=>{}),defineGlobalIfMissing(`blur`,()=>{});{let e=globalThis;if(typeof e.addEventListener!=`function`){let R=new EventTarget$1;e.__gjsify_globalEventTarget=R,e.addEventListener=(e,W,Y)=>R.addEventListener(e,W,Y),e.removeEventListener=(e,W,Y)=>R.removeEventListener(e,W,Y),e.dispatchEvent=e=>R.dispatchEvent(e)}}defineGlobalIfMissing(`devicePixelRatio`,1),defineGlobalIfMissing(`scrollX`,0),defineGlobalIfMissing(`scrollY`,0),defineGlobalIfMissing(`pageXOffset`,0),defineGlobalIfMissing(`pageYOffset`,0),defineGlobalIfMissing(`alert`,(...e)=>bt.error(`alert:`,...e)),globalThis.top===void 0&&Object.defineProperty(globalThis,"top",{get:()=>globalThis,configurable:!0});var FontFace$1=class{static{__name$1(this,`FontFace`)}constructor(e,R,W){this.status=`unloaded`,this.display=`auto`,this.style=`normal`,this.weight=`normal`,this.stretch=`normal`,this.unicodeRange=`U+0-10FFFF`,this.variant=`normal`,this.featureSettings=`normal`,this.family=e,this.source=typeof R==`string`?R:`[binary]`,this.loaded=Promise.resolve(this)}_extractFilePath(){let e=this.source.match(/url\s*\(\s*["']?(file:\/\/\/[^"')]+)["']?\s*\)/i);return e?e[1].replace(/^file:\/\//,``):null}async load(){this.status=`loading`;let e=this._extractFilePath();if(e)try{let{default:R}=await import(`gi://PangoCairo?version=1.0`);R.font_map_get_default().add_font_file(e)}catch{}return this.status=`loaded`,this}},FontFaceSet=class{constructor(){this.status=`loaded`,this.ready=Promise.resolve(this),this._faces=new Set}addEventListener(e,R){}removeEventListener(e,R){}dispatchEvent(e){return!0}add(e){return this._faces.add(e),this}delete(e){return this._faces.delete(e)}clear(){this._faces.clear()}has(e){return this._faces.has(e)}check(e,R){return!1}load(e,R){return Promise.resolve([])}forEach(e){this._faces.forEach(R=>e(R,R,this))}values(){return this._faces.values()}keys(){return this._faces.values()}entries(){return Array.from(this._faces).map(e=>[e,e])[Symbol.iterator]()}[Symbol.iterator](){return this._faces[Symbol.iterator]()}get size(){return this._faces.size}};const Ji=globalThis;defineGlobalIfMissing(`FontFace`,FontFace$1),Ji.FontFace===void 0&&(Ji.FontFace=FontFace$1);const Xi=Ji.document;Xi&&Xi.fonts===void 0&&Object.defineProperty(Xi,"fonts",{value:new FontFaceSet,configurable:!0,writable:!0});var Image$1=class extends HTMLImageElement{static{__name$1(this,`Image`)}constructor(e=null,R=null){super(),e!==null&&(this.width=e),R!==null&&(this.height=R)}};defineGlobal(`HTMLImageElement`,HTMLImageElement),defineGlobal(`Image`,Image$1),defineGlobalIfMissing(`location`,{href:`file://`,origin:`file://`,protocol:`file:`,host:``,hostname:``,port:``,pathname:`/`,search:``,hash:``,assign(e){},replace(e){},reload(){},toString(){return this.href},ancestorOrigins:{length:0,item:()=>null,contains:()=>!1,[Symbol.iterator]:function*(){}}});var MediaQueryList=class extends EventTarget$1{constructor(e){super(),this.onchange=null,this.media=e,this.matches=!1}addListener(e){}removeListener(e){}};function matchMedia(e){return new MediaQueryList(e)}defineGlobalIfMissing(`matchMedia`,matchMedia),globalThis.navigator===void 0&&(globalThis.navigator={});var MutationObserver=class{constructor(e){}observe(e,R){}disconnect(){}takeRecords(){return[]}};xt();const $i=new Set;let na=!1;function scheduleFlush(){na||(na=!0,queueMicrotask(()=>{na=!1;let e=Array.from($i);$i.clear();for(let R of e)R._deliver()}))}var ResizeObserver$1=class{static{__name$1(this,`ResizeObserver`)}constructor(e){this._observed=new Map,this._pending=new Map,this._callback=e}observe(e,R){if(this._observed.has(e))return;let W=e._onResize((R,W)=>{this._enqueue(e,R,W)});this._observed.set(e,W),queueMicrotask(()=>{if(!this._observed.has(e))return;let R=readClientRect(e);this._enqueue(e,R.width,R.height)})}unobserve(e){let R=this._observed.get(e);R&&(R(),this._observed.delete(e),this._pending.delete(e))}disconnect(){for(let e of this._observed.values())e();this._observed.clear(),this._pending.clear(),$i.delete(this)}_deliver(){if(this._pending.size===0)return;let e=Array.from(this._pending.values());this._pending.clear();try{this._callback(e,this)}catch(e){bt.error(`ResizeObserver callback threw:`,e)}}_enqueue(e,R,W){let Y={inlineSize:R,blockSize:W};this._pending.set(e,{target:e,contentRect:{x:0,y:0,width:R,height:W,top:0,right:R,bottom:W,left:0},borderBoxSize:[Y],contentBoxSize:[Y],devicePixelContentBoxSize:[Y]}),$i.add(this),scheduleFlush()}};function readClientRect(e){let R=e.getBoundingClientRect;if(typeof R==`function`){let W=R.call(e);return{width:W.width??0,height:W.height??0}}return{width:0,height:0}}var IntersectionObserver=class{constructor(e,R){this.root=R?.root??null,this.rootMargin=R?.rootMargin??`0px`,this.thresholds=Array.isArray(R?.threshold)?R.threshold:[R?.threshold??0]}observe(e){}unobserve(e){}disconnect(){}takeRecords(){return[]}};defineGlobal(`MutationObserver`,MutationObserver),defineGlobal(`ResizeObserver`,ResizeObserver$1),defineGlobal(`IntersectionObserver`,IntersectionObserver);var DOMNode=class{nodeType;nodeName;nodeValue;parentNode=null;childNodes=[];constructor(e,R,W=null){this.nodeType=e,this.nodeName=R,this.nodeValue=W}get textContent(){return this.nodeType===3||this.nodeType===4?this.nodeValue??``:this.childNodes.map(e=>e.textContent??``).join(``)}},DOMElement=class extends DOMNode{tagName;localName;_attrs=new Map;constructor(e){super(1,e.toUpperCase()),this.tagName=e.toLowerCase(),this.localName=this.tagName}get children(){return this.childNodes.filter(e=>e.nodeType===1)}getAttribute(e){return this._attrs.has(e)?this._attrs.get(e)??null:null}setAttribute(e,R){this._attrs.set(e,R)}hasAttribute(e){return this._attrs.has(e)}get attributes(){return Array.from(this._attrs.entries()).map(([e,R])=>({name:e,value:R}))}get innerHTML(){return this.childNodes.map(e=>e.nodeType===1?e.outerHTML:e.nodeType===3?e.nodeValue??``:e.nodeType===4?`<![CDATA[`+(e.nodeValue??``)+`]]>`:``).join(``)}get outerHTML(){let e=Array.from(this._attrs.entries()).map(([e,R])=>` `+e+`="`+R.replace(/"/g,`"`)+`"`).join(``);return this.childNodes.length===0?`<`+this.tagName+e+`/>`:`<`+this.tagName+e+`>`+this.innerHTML+`</`+this.tagName+`>`}querySelector(e){let R=e.trim().split(/\s*>\s*/);if(R.length>1)return this._queryChildChain(R);let W=e.trim().split(/\s+/);return W.length>1?this._queryDescendantChain(W):this._find(e.trim().toLowerCase())??null}querySelectorAll(e){let R=e.trim().toLowerCase(),W=[];return this._findAll(R,W),W}_find(e){for(let R of this.children){if(R.tagName===e)return R;let W=R._find(e);if(W)return W}}_findAll(e,R){for(let W of this.children)W.tagName===e&&R.push(W),W._findAll(e,R)}_queryChildChain(e){let[R,...W]=e,Y=this.children.filter(e=>e.tagName===R.trim().toLowerCase());if(W.length===0)return Y[0]??null;for(let e of Y){let R=e._queryChildChain(W);if(R)return R}return null}_queryDescendantChain(e){let[R,...W]=e,Y=[];if(this._findAll(R.trim().toLowerCase(),Y),W.length===0)return Y[0]??null;for(let e of Y){let R=e._queryDescendantChain(W);if(R)return R}return null}},DOMDocument=class extends DOMElement{documentElement=null;constructor(){super(`#document`),this.nodeType=9,this.nodeName=`#document`}querySelector(e){if(this.documentElement){let R=e.trim().toLowerCase();return this.documentElement.tagName===R?this.documentElement:this.documentElement.querySelector(e)}return super.querySelector(e)}querySelectorAll(e){let R=e.trim().toLowerCase(),W=[];return this.documentElement&&(this.documentElement.tagName===R&&W.push(this.documentElement),this.documentElement._findAll(R,W)),W}};const aa=/\s+([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+))/g;function parseAttributes(e,R){let W;for(aa.lastIndex=0;(W=aa.exec(e))!==null;)R.setAttribute(W[1],W[2]??W[3]??W[4]??``)}function parseXml(e){let R=new DOMDocument,W=[R],Y=0,X=e.length;for(;Y<X;){let ie=e.indexOf(`<`,Y);if(ie===-1){let R=e.slice(Y);if(R.trim()){let e=new DOMNode(3,`#text`,R),Y=W[W.length-1];e.parentNode=Y,Y.childNodes.push(e)}break}if(ie>Y){let R=e.slice(Y,ie);if(R.trim()){let e=new DOMNode(3,`#text`,R),Y=W[W.length-1];e.parentNode=Y,Y.childNodes.push(e)}}if(e.startsWith(`<![CDATA[`,ie)){let R=e.indexOf(`]]>`,ie);if(R===-1)break;let X=new DOMNode(4,`#cdata-section`,e.slice(ie+9,R)),ae=W[W.length-1];X.parentNode=ae,ae.childNodes.push(X),Y=R+3;continue}if(e.startsWith(`<!--`,ie)){let R=e.indexOf(`-->`,ie);Y=R===-1?X:R+3;continue}if(e.startsWith(`<?`,ie)||e.startsWith(`<!`,ie)){let R=e.indexOf(`>`,ie);Y=R===-1?X:R+1;continue}let ae=findTagEnd(e,ie+1);if(ae===-1)break;let le=e.slice(ie+1,ae);if(le.startsWith(`/`)){W.length>1&&W.pop(),Y=ae+1;continue}let _e=le.endsWith(`/`),ye=_e?le.slice(0,-1):le,be=ye.search(/\s/),Ce=(be===-1?ye:ye.slice(0,be)).trim();if(!Ce){Y=ae+1;continue}let Te=new DOMElement(Ce);be!==-1&&parseAttributes(ye.slice(be),Te);let Oe=W[W.length-1];Te.parentNode=Oe,Oe.childNodes.push(Te),Oe===R&&!R.documentElement&&(R.documentElement=Te),_e||W.push(Te),Y=ae+1}return R}function findTagEnd(e,R){let W=!1,Y=!1;for(let X=R;X<e.length;X++){let R=e[X];if(R===`"`&&!W){Y=!Y;continue}if(R===`'`&&!Y){W=!W;continue}if(R===`>`&&!W&&!Y)return X}return-1}var DOMParser$1=class{static{__name$1(this,`DOMParser`)}parseFromString(e,R){return parseXml(e)}};const sa=globalThis;sa.DOMParser===void 0&&(sa.DOMParser=DOMParser$1);var GamepadEvent=class extends Event$1{gamepad;constructor(e,R){super(e,R),this.gamepad=R.gamepad}get[Symbol.toStringTag](){return`GamepadEvent`}};const ca={LEFT_X:0,LEFT_Y:1,RIGHT_X:2,RIGHT_Y:3,LEFT_TRIGGER:4,RIGHT_TRIGGER:5},da={LEFT_STICK_X:0,LEFT_STICK_Y:1,RIGHT_STICK_X:2,RIGHT_STICK_Y:3},pa=new Map([[ca.LEFT_X,da.LEFT_STICK_X],[ca.LEFT_Y,da.LEFT_STICK_Y],[ca.RIGHT_X,da.RIGHT_STICK_X],[ca.RIGHT_Y,da.RIGHT_STICK_Y]]),_a=.5,ya={BTN_SOUTH:304,BTN_EAST:305,BTN_C:306,BTN_NORTH:307,BTN_WEST:308,BTN_Z:309,BTN_TL:310,BTN_TR:311,BTN_TL2:312,BTN_TR2:313,BTN_SELECT:314,BTN_START:315,BTN_MODE:316,BTN_THUMBL:317,BTN_THUMBR:318,BTN_DPAD_UP:544,BTN_DPAD_DOWN:545,BTN_DPAD_LEFT:546,BTN_DPAD_RIGHT:547},ba={FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,LEFT_BUMPER:4,RIGHT_BUMPER:5,LEFT_TRIGGER:6,RIGHT_TRIGGER:7,SELECT:8,START:9,LEFT_STICK:10,RIGHT_STICK:11,DPAD_UP:12,DPAD_DOWN:13,DPAD_LEFT:14,DPAD_RIGHT:15,HOME:16},xa=new Map([[ya.BTN_SOUTH,ba.FACE_1],[ya.BTN_EAST,ba.FACE_2],[ya.BTN_WEST,ba.FACE_3],[ya.BTN_NORTH,ba.FACE_4],[ya.BTN_TL,ba.LEFT_BUMPER],[ya.BTN_TR,ba.RIGHT_BUMPER],[ya.BTN_TL2,ba.LEFT_TRIGGER],[ya.BTN_TR2,ba.RIGHT_TRIGGER],[ya.BTN_SELECT,ba.SELECT],[ya.BTN_START,ba.START],[ya.BTN_THUMBL,ba.LEFT_STICK],[ya.BTN_THUMBR,ba.RIGHT_STICK],[ya.BTN_DPAD_UP,ba.DPAD_UP],[ya.BTN_DPAD_DOWN,ba.DPAD_DOWN],[ya.BTN_DPAD_LEFT,ba.DPAD_LEFT],[ya.BTN_DPAD_RIGHT,ba.DPAD_RIGHT],[ya.BTN_MODE,ba.HOME]]);var GamepadButton=class{pressed;touched;value;constructor(e=!1,R=!1,W=0){this.pressed=e,this.touched=R,this.value=W}get[Symbol.toStringTag](){return`GamepadButton`}},Gamepad$1=class{static{__name$1(this,`Gamepad`)}id;index;connected;timestamp;mapping;axes;buttons;vibrationActuator;constructor(e){this.id=e.id,this.index=e.index,this.connected=e.connected,this.timestamp=e.timestamp,this.mapping=e.mapping,this.axes=Object.freeze([...e.axes]),this.buttons=Object.freeze(e.buttons),this.vibrationActuator=e.vibrationActuator??null}get[Symbol.toStringTag](){return`Gamepad`}},ManetteHapticActuator=class{effects;_device;constructor(e){this._device=e,this.effects=e.has_rumble()?[`dual-rumble`]:[]}playEffect(e,R){if(e!==`dual-rumble`||!this._device.has_rumble())return Promise.resolve(`complete`);let W=R?.duration??200,Y=Math.round((R?.strongMagnitude??1)*65535),X=Math.round((R?.weakMagnitude??1)*65535);return this._device.rumble(Y,X,Math.min(W,32767)),Promise.resolve(`complete`)}reset(){return this._device.has_rumble()&&this._device.rumble(0,0,0),Promise.resolve(`complete`)}},GamepadManager=class{_monitor=null;_slots=Array.from({length:4}).fill(null);_monitorSignalIds=[];_ManetteModule=null;_initPromise=null;_initialized=!1;_ensureInit(){this._initialized||(this._initPromise||=this._init())}async _init(){try{let e=await import(`gi://Manette`);this._ManetteModule=e.default}catch{this._initialized=!0;return}let e=new this._ManetteModule.Monitor;this._monitor=e;let R=e.iterate(),W=R.next();for(;W[0];){let e=W[1];e&&this._onDeviceConnected(e),W=R.next()}this._monitorSignalIds.push(e.connect(`device-connected`,(e,R)=>{this._onDeviceConnected(R)}),e.connect(`device-disconnected`,(e,R)=>{this._onDeviceDisconnected(R)})),this._initialized=!0}_onDeviceConnected(e){let R=-1;for(let e=0;e<4;e++)if(this._slots[e]===null){R=e;break}if(R===-1)return;let W={device:e,index:R,connected:!0,timestamp:performance.now(),buttons:new Float64Array(17),buttonsPressed:Array.from({length:17}).fill(!1),axes:new Float64Array(4),hapticActuator:new ManetteHapticActuator(e),signalIds:[]};W.signalIds.push(e.connect(`button-press-event`,(e,R)=>{this._onButtonPress(W,R)}),e.connect(`button-release-event`,(e,R)=>{this._onButtonRelease(W,R)}),e.connect(`absolute-axis-event`,(e,R)=>{this._onAxisChange(W,R)}),e.connect(`hat-axis-event`,(e,R)=>{this._onHatChange(W,R)}),e.connect(`disconnected`,()=>{this._onDeviceDisconnected(e)})),this._slots[R]=W;let Y=this._createSnapshot(W);Y&&globalThis.dispatchEvent?.(new GamepadEvent(`gamepadconnected`,{gamepad:Y}))}_onDeviceDisconnected(e){let R=this._findStateByDevice(e);if(!R)return;for(let W of R.signalIds)e.disconnect(W);R.connected=!1;let W=this._createSnapshot(R);this._slots[R.index]=null,W&&globalThis.dispatchEvent?.(new GamepadEvent(`gamepaddisconnected`,{gamepad:W}))}_onButtonPress(e,R){let[W,Y]=R.get_button();if(!W)return;let X=xa.get(Y);X!==void 0&&(e.buttons[X]=1,e.buttonsPressed[X]=!0,e.timestamp=performance.now())}_onButtonRelease(e,R){let[W,Y]=R.get_button();if(!W)return;let X=xa.get(Y);X!==void 0&&(e.buttons[X]=0,e.buttonsPressed[X]=!1,e.timestamp=performance.now())}_onAxisChange(e,R){let[W,Y,X]=R.get_absolute();if(!W)return;let ie=pa.get(Y);if(ie!==void 0)e.axes[ie]=X;else if(Y===ca.LEFT_TRIGGER){let R=(X+1)/2;e.buttons[ba.LEFT_TRIGGER]=R,e.buttonsPressed[ba.LEFT_TRIGGER]=R>_a}else if(Y===ca.RIGHT_TRIGGER){let R=(X+1)/2;e.buttons[ba.RIGHT_TRIGGER]=R,e.buttonsPressed[ba.RIGHT_TRIGGER]=R>_a}e.timestamp=performance.now()}_onHatChange(e,R){let[W,Y,X]=R.get_hat();W&&(Y===0?(e.buttonsPressed[ba.DPAD_LEFT]=X<0,e.buttons[ba.DPAD_LEFT]=+(X<0),e.buttonsPressed[ba.DPAD_RIGHT]=X>0,e.buttons[ba.DPAD_RIGHT]=+(X>0)):Y===1&&(e.buttonsPressed[ba.DPAD_UP]=X<0,e.buttons[ba.DPAD_UP]=+(X<0),e.buttonsPressed[ba.DPAD_DOWN]=X>0,e.buttons[ba.DPAD_DOWN]=+(X>0)),e.timestamp=performance.now())}_findStateByDevice(e){for(let R of this._slots)if(R&&R.device===e)return R;return null}_createSnapshot(e){let R=[];for(let W=0;W<17;W++)R.push(new GamepadButton(e.buttonsPressed[W],e.buttonsPressed[W]||e.buttons[W]>0,e.buttons[W]));return new Gamepad$1({id:e.device.get_name()??`Gamepad (${e.device.get_guid()})`,index:e.index,connected:e.connected,timestamp:e.timestamp,mapping:`standard`,axes:Array.from(e.axes),buttons:R,vibrationActuator:e.hapticActuator})}getGamepads(){this._ensureInit();let e=[];for(let R=0;R<4;R++){let W=this._slots[R];e.push(W?this._createSnapshot(W):null)}return e}dispose(){for(let e of this._slots)if(e)for(let R of e.signalIds)e.device.disconnect(R);if(this._slots.fill(null),this._monitor){for(let e of this._monitorSignalIds)this._monitor.disconnect(e);this._monitorSignalIds=[],this._monitor=null}this._initialized=!1,this._initPromise=null}};const Ea=new GamepadManager,Da=globalThis;Da.navigator===void 0&&(Da.navigator={}),Da.navigator.getGamepads=()=>Ea.getGamepads(),Da.GamepadEvent===void 0&&(Da.GamepadEvent=GamepadEvent);function btoaPolyfill(e){if(typeof globalThis.btoa==`function`)return globalThis.btoa(e);let R=``,W=0;for(;W+2<e.length;W+=3){let Y=e.charCodeAt(W)<<16|e.charCodeAt(W+1)<<8|e.charCodeAt(W+2);R+=Oa[Y>>18&63]+Oa[Y>>12&63]+Oa[Y>>6&63]+Oa[Y&63]}if(W+1===e.length){let Y=e.charCodeAt(W)<<16;R+=Oa[Y>>18&63]+Oa[Y>>12&63]+`==`}else if(W+2===e.length){let Y=e.charCodeAt(W)<<16|e.charCodeAt(W+1)<<8;R+=Oa[Y>>18&63]+Oa[Y>>12&63]+Oa[Y>>6&63]+`=`}return R}function base64Decode(e){let R=e.replace(/[=\s]/g,``),W=new Uint8Array(R.length*3>>2),Y=0,X=0,ie=0;for(let e=0;e<R.length;e++)Y=Y<<6|Aa[R.charCodeAt(e)],X+=6,X>=8&&(X-=8,W[ie++]=Y>>X&255);return W.subarray(0,ie)}var Oa,Aa,Pa=__esmMin(()=>{Oa=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Aa=new Uint8Array(256);for(let e=0;e<64;e++)Aa[Oa.charCodeAt(e)]=e});function normalizeEncoding(e){if(!e||e===`utf8`||e===`utf-8`)return`utf8`;switch((``+e).toLowerCase().replace(/-/g,``)){case`utf8`:return`utf8`;case`ascii`:return`ascii`;case`latin1`:case`binary`:return`latin1`;case`base64`:return`base64`;case`base64url`:return`base64url`;case`hex`:return`hex`;case`ucs2`:case`utf16le`:return`utf16le`;default:return`utf8`}}function checkEncoding(e){let R=(``+e).toLowerCase().replace(/-/g,``);if(!La.includes(R))throw TypeError(`Unknown encoding: ${e}`)}var La,Ra=__esmMin(()=>{La=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`]});function encodeString(e,R){switch(R){case`utf8`:return Ba.encode(e);case`ascii`:{let R=new Uint8Array(e.length);for(let W=0;W<e.length;W++)R[W]=e.charCodeAt(W)&127;return R}case`latin1`:{let R=new Uint8Array(e.length);for(let W=0;W<e.length;W++)R[W]=e.charCodeAt(W)&255;return R}case`base64`:return base64Decode(e.replace(/-/g,`+`).replace(/_/g,`/`));case`base64url`:return encodeString(e.replace(/-/g,`+`).replace(/_/g,`/`),`base64`);case`hex`:{let R=e.length>>>1,W=new Uint8Array(R);for(let Y=0;Y<R;Y++){let R=parseInt(e[Y*2],16),X=parseInt(e[Y*2+1],16);if(Number.isNaN(R)||Number.isNaN(X))break;W[Y]=R<<4|X}return W}case`utf16le`:{let R=new Uint8Array(e.length*2);for(let W=0;W<e.length;W++){let Y=e.charCodeAt(W);R[W*2]=Y&255,R[W*2+1]=Y>>8&255}return R}default:return Ba.encode(e)}}function decodeString(e,R,W,Y){let X=W!==void 0||Y!==void 0?e.subarray(W??0,Y??e.length):e;switch(R){case`utf8`:return Va.decode(X);case`ascii`:{let e=``;for(let R=0;R<X.length;R++)e+=String.fromCharCode(X[R]&127);return e}case`latin1`:{let e=``;for(let R=0;R<X.length;R++)e+=String.fromCharCode(X[R]);return e}case`base64`:{let e=``;for(let R=0;R<X.length;R++)e+=String.fromCharCode(X[R]);return btoaPolyfill(e)}case`base64url`:return decodeString(X,`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);case`hex`:{let e=``;for(let R=0;R<X.length;R++)e+=X[R].toString(16).padStart(2,`0`);return e}case`utf16le`:{let e=``;for(let R=0;R+1<X.length;R+=2)e+=String.fromCharCode(X[R]|X[R+1]<<8);return e}default:return Va.decode(X)}}function checkOffset(e,R,W){if(e+R>W)throw RangeError(`Attempt to access memory outside buffer bounds`)}var Ba,Va,Ga=__esmMin(()=>{Pa(),Ba=new TextEncoder,Va=new TextDecoder}),Ka,qa,Ja=__esmMin(()=>{Ga(),Ra(),Ka=typeof SharedArrayBuffer<`u`,qa=class Buffer extends Uint8Array{static _isBuffer=!0;static alloc(e,R,W){if(typeof e!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof e}`);if(e<0)throw RangeError(`The value "${e}" is invalid for option "size"`);let Y=new Buffer(e);return R!==void 0&&R!==0&&Y.fill(R,0,e,W),Y}static allocUnsafe(e){if(typeof e!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof e}`);return new Buffer(e)}static allocUnsafeSlow(e){return Buffer.allocUnsafe(e)}static from(e,R,W){if(typeof e==`string`){let W=normalizeEncoding(R);if(R&&typeof R==`string`){let e=(``+R).toLowerCase().replace(/-/g,``);[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`,``].includes(e)||checkEncoding(R)}let Y=encodeString(e,W);return new Buffer(Y.buffer,Y.byteOffset,Y.byteLength)}if(ArrayBuffer.isView(e)){let R=new Buffer(e.buffer,e.byteOffset,e.byteLength),W=new Buffer(R.length);return W.set(R),W}if(e instanceof ArrayBuffer){let Y=R||0;return new Buffer(e,Y,W===void 0?e.byteLength-Y:W)}if(Ka&&e instanceof SharedArrayBuffer){let Y=R||0,X=W===void 0?e.byteLength-Y:W;return new Buffer(new Uint8Array(e,Y,X))}if(typeof e==`object`&&e&&typeof e.viewBytes==`function`&&typeof e.byteLength==`number`&&e.constructor?.name===`SharedBuffer`){let Y=e,X=R||0,ie=W===void 0?Y.byteLength-X:W,ae=Y.viewBytes(X,ie);return new Buffer(ae.buffer,ae.byteOffset,ae.byteLength)}if(Array.isArray(e)){let R=new Buffer(e.length);for(let W=0;W<e.length;W++)R[W]=e[W]&255;return R}throw TypeError(`The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array`)}static isBuffer(e){return e instanceof Buffer}static isEncoding(e){if(typeof e!=`string`)return!1;let R=e.toLowerCase().replace(/-/g,``);return[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`].includes(R)}static byteLength(e,R){if(typeof e!=`string`){if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Ka&&e instanceof SharedArrayBuffer)return e.byteLength;throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer`)}switch(normalizeEncoding(R)){case`utf8`:return new TextEncoder().encode(e).byteLength;case`ascii`:case`latin1`:return e.length;case`base64`:case`base64url`:{let R=e.length;for(;R>0&&(e[R-1]===`=`||e[R-1]===` `);)R--;return R*3>>>2}case`hex`:return e.length>>>1;case`utf16le`:return e.length*2;default:return new TextEncoder().encode(e).byteLength}}static compare(e,R){if(!(e instanceof Uint8Array)||!(R instanceof Uint8Array))throw TypeError(`Arguments must be Buffers or Uint8Arrays`);let W=Math.min(e.length,R.length);for(let Y=0;Y<W;Y++){if(e[Y]<R[Y])return-1;if(e[Y]>R[Y])return 1}return e.length<R.length?-1:+(e.length>R.length)}static concat(e,R){if(e.length===0)return Buffer.alloc(0);if(R===void 0){R=0;for(let W=0;W<e.length;W++)R+=e[W].length}let W=Buffer.alloc(R),Y=0;for(let X=0;X<e.length;X++){let ie=e[X],ae=Math.min(ie.length,R-Y);ae<=0||(W.set(ie.subarray(0,ae),Y),Y+=ae)}return W}static poolSize=8192;toString(e,R,W){let Y=normalizeEncoding(e);return decodeString(this,Y,R,W)}toJSON(){return{type:`Buffer`,data:Array.from(this)}}equals(e){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);if(this.length!==e.length)return!1;for(let R=0;R<this.length;R++)if(this[R]!==e[R])return!1;return!0}compare(e,R,W,Y,X){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);let ie=Y!==void 0||X!==void 0?this.subarray(Y??0,X??this.length):this,ae=R!==void 0||W!==void 0?e.subarray(R??0,W??e.length):e;return Buffer.compare(ie,ae)}copy(e,R=0,W=0,Y){let X=Y??this.length,ie=Math.min(X-W,e.length-R);return ie<=0?0:(e.set(this.subarray(W,W+ie),R),ie)}slice(e,R){let W=e??0,Y=R??this.length,X=super.subarray(W,Y);return new Buffer(X.buffer,X.byteOffset,X.byteLength)}subarray(e,R){let W=super.subarray(e,R);return new Buffer(W.buffer,W.byteOffset,W.byteLength)}write(e,R,W,Y){R??=0;let X=encodeString(e,normalizeEncoding(Y||(typeof W==`string`?W:void 0))),ie=W!==void 0&&typeof W==`number`?Math.min(W,this.length-R):this.length-R,ae=Math.min(X.length,ie);return this.set(X.subarray(0,ae),R),ae}fill(e,R,W,Y){let X=R??0,ie=W??this.length;if(typeof e==`number`)super.fill(e&255,X,ie);else if(typeof e==`string`){let R=encodeString(e,normalizeEncoding(Y));if(R.length===0)super.fill(0,X,ie);else if(R.length===1)super.fill(R[0],X,ie);else for(let e=X;e<ie;e++)this[e]=R[(e-X)%R.length]}else if(e instanceof Uint8Array)if(e.length===0)super.fill(0,X,ie);else for(let R=X;R<ie;R++)this[R]=e[(R-X)%e.length];return this}indexOf(e,R,W){if(typeof e==`number`)return super.indexOf(e&255,R);let Y=typeof e==`string`?encodeString(e,normalizeEncoding(W)):e,X=R??0;outer:for(let e=X;e<=this.length-Y.length;e++){for(let R=0;R<Y.length;R++)if(this[e+R]!==Y[R])continue outer;return e}return-1}lastIndexOf(e,R,W){if(typeof e==`number`)return R===void 0?super.lastIndexOf(e&255):super.lastIndexOf(e&255,R);let Y=typeof e==`string`?encodeString(e,normalizeEncoding(W)):e,X=R===void 0?this.length-Y.length:Math.min(R,this.length-Y.length);outer:for(let e=X;e>=0;e--){for(let R=0;R<Y.length;R++)if(this[e+R]!==Y[R])continue outer;return e}return-1}includes(e,R,W){return this.indexOf(e,R,W)!==-1}readUInt8(e=0){return checkOffset(e,1,this.length),this[e]}readUInt16BE(e=0){return checkOffset(e,2,this.length),this[e]<<8|this[e+1]}readUInt16LE(e=0){return checkOffset(e,2,this.length),this[e]|this[e+1]<<8}readUInt32BE(e=0){return checkOffset(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])}readUInt32LE(e=0){return checkOffset(e,4,this.length),this[e+3]*16777216+(this[e+2]<<16|this[e+1]<<8|this[e])>>>0}readInt8(e=0){return checkOffset(e,1,this.length),this[e]|(this[e]&128?4294967040:0)}readInt16BE(e=0){checkOffset(e,2,this.length);let R=this[e]<<8|this[e+1];return R&32768?R|4294901760:R}readInt16LE(e=0){checkOffset(e,2,this.length);let R=this[e]|this[e+1]<<8;return R&32768?R|4294901760:R}readInt32BE(e=0){return checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]}readInt32LE(e=0){return checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24}readFloatBE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!1)}readFloatLE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!0)}readDoubleBE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!1)}readDoubleLE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!0)}readBigInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!1)}readBigInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!0)}readBigUInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!1)}readBigUInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!0)}readUIntBE(e,R){checkOffset(e,R,this.length);let W=0;for(let Y=0;Y<R;Y++)W=W*256+this[e+Y];return W}readUIntLE(e,R){checkOffset(e,R,this.length);let W=0,Y=1;for(let X=0;X<R;X++)W+=this[e+X]*Y,Y*=256;return W}readIntBE(e,R){checkOffset(e,R,this.length);let W=0;for(let Y=0;Y<R;Y++)W=W*256+this[e+Y];return W>=2**(8*R-1)&&(W-=2**(8*R)),W}readIntLE(e,R){checkOffset(e,R,this.length);let W=0,Y=1;for(let X=0;X<R;X++)W+=this[e+X]*Y,Y*=256;return W>=2**(8*R-1)&&(W-=2**(8*R)),W}writeUInt8(e,R=0){return checkOffset(R,1,this.length),this[R]=e&255,R+1}writeUInt16BE(e,R=0){return checkOffset(R,2,this.length),this[R]=e>>>8&255,this[R+1]=e&255,R+2}writeUInt16LE(e,R=0){return checkOffset(R,2,this.length),this[R]=e&255,this[R+1]=e>>>8&255,R+2}writeUInt32BE(e,R=0){return checkOffset(R,4,this.length),this[R]=e>>>24&255,this[R+1]=e>>>16&255,this[R+2]=e>>>8&255,this[R+3]=e&255,R+4}writeUInt32LE(e,R=0){return checkOffset(R,4,this.length),this[R]=e&255,this[R+1]=e>>>8&255,this[R+2]=e>>>16&255,this[R+3]=e>>>24&255,R+4}writeInt8(e,R=0){return checkOffset(R,1,this.length),e<0&&(e=255+e+1),this[R]=e&255,R+1}writeInt16BE(e,R=0){return checkOffset(R,2,this.length),this[R]=e>>>8&255,this[R+1]=e&255,R+2}writeInt16LE(e,R=0){return checkOffset(R,2,this.length),this[R]=e&255,this[R+1]=e>>>8&255,R+2}writeInt32BE(e,R=0){return checkOffset(R,4,this.length),this[R]=e>>>24&255,this[R+1]=e>>>16&255,this[R+2]=e>>>8&255,this[R+3]=e&255,R+4}writeInt32LE(e,R=0){return checkOffset(R,4,this.length),this[R]=e&255,this[R+1]=e>>>8&255,this[R+2]=e>>>16&255,this[R+3]=e>>>24&255,R+4}writeFloatBE(e,R=0){return checkOffset(R,4,this.length),new DataView(this.buffer,this.byteOffset+R,4).setFloat32(0,e,!1),R+4}writeFloatLE(e,R=0){return checkOffset(R,4,this.length),new DataView(this.buffer,this.byteOffset+R,4).setFloat32(0,e,!0),R+4}writeDoubleBE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setFloat64(0,e,!1),R+8}writeDoubleLE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setFloat64(0,e,!0),R+8}writeBigInt64BE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setBigInt64(0,e,!1),R+8}writeBigInt64LE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setBigInt64(0,e,!0),R+8}writeBigUInt64BE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setBigUint64(0,e,!1),R+8}writeBigUInt64LE(e,R=0){return checkOffset(R,8,this.length),new DataView(this.buffer,this.byteOffset+R,8).setBigUint64(0,e,!0),R+8}swap16(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let R=0;R<e;R+=2){let e=this[R];this[R]=this[R+1],this[R+1]=e}return this}swap32(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let R=0;R<e;R+=4){let e=this[R],W=this[R+1];this[R]=this[R+3],this[R+1]=this[R+2],this[R+2]=W,this[R+3]=e}return this}swap64(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let R=0;R<e;R+=8){let e=this[R],W=this[R+1],Y=this[R+2],X=this[R+3];this[R]=this[R+7],this[R+1]=this[R+6],this[R+2]=this[R+5],this[R+3]=this[R+4],this[R+4]=X,this[R+5]=Y,this[R+6]=W,this[R+7]=e}return this}}}),Ya=__esmMin(()=>{Je(),Ja(),globalThis.atob,globalThis.btoa});Ya(),`Buffer`in globalThis||Object.defineProperty(globalThis,"Buffer",{value:qa,enumerable:!1,writable:!0,configurable:!0}),$e(),typeof globalThis.btoa!=`function`&&Object.defineProperty(globalThis,"btoa",{value:function btoa(e){let R=new Uint8Array(e.length);for(let W=0;W<e.length;W++)R[W]=e.charCodeAt(W)&255;return Qe.base64_encode(R)},enumerable:!0,writable:!0,configurable:!0}),typeof globalThis.atob!=`function`&&Object.defineProperty(globalThis,"atob",{value:function atob(e){let R=Qe.base64_decode(e),W=``;for(let e=0;e<R.length;e++)W+=String.fromCharCode(R[e]);return W},enumerable:!0,writable:!0,configurable:!0}),Ht(),typeof queueMicrotask!=`function`&&Object.defineProperty(globalThis,"queueMicrotask",{value:Ct,enumerable:!0,writable:!0,configurable:!0});function getGjsGlobal(){return globalThis}function getGioNamespace(){let e=getGjsGlobal().imports?.gi;if(!e)return null;let R=null;try{R=e.GioUnix??null}catch{}if(!R)try{R=e.Gio??null}catch{}return R}function getMonotonicTime(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_monotonic_time)return BigInt(e.get_monotonic_time())*1000n}catch{}return typeof performance?.now==`function`?BigInt(Math.round(performance.now()*1e6)):BigInt(Date.now())*1000000n}const go=getMonotonicTime();function hrtime(e){let R=getMonotonicTime()-go,W=Number(R/1000000000n),Y=Number(R%1000000000n);if(e){let R=W-e[0],X=Y-e[1];return X<0&&(R--,X+=1e9),[R,X]}return[W,Y]}function hrtimeBigint(){return getMonotonicTime()-go}function detectGjsVersion(){try{let e=getGjsGlobal().imports?.system;if(e?.version!==void 0){let R=Number(e.version);return`${Math.floor(R/1e4)}.${Math.floor(R%1e4/100)}.${R%100}`}}catch{}}function detectNodeVersion(){if(typeof globalThis.process?.versions?.node==`string`)return globalThis.process.versions.node}function detectVersionInfo(){if(detectNodeVersion())return{version:globalThis.process.version,versions:{...globalThis.process.versions},title:globalThis.process?.title||`node`};let e=detectGjsVersion(),R={node:`20.0.0`};return e&&(R.gjs=e),{version:`v20.0.0`,versions:R,title:`gjs`}}function detectPpid(){if(typeof globalThis.process?.ppid==`number`)return globalThis.process.ppid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,R]=e.file_get_contents(`/proc/self/status`);if(R){let e=new TextDecoder().decode(R).match(/PPid:\s+(\d+)/);if(e)return parseInt(e[1],10)}}}catch{}return 0}function detectPlatform(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e&&e.get_os_info(`ID`))return`linux`}catch{}return getGjsGlobal().imports?.system===void 0&&typeof globalThis.process?.platform==`string`?globalThis.process.platform:`linux`}function detectArch(){return typeof globalThis.process?.arch==`string`?globalThis.process.arch:`x64`}function getPid(){if(typeof globalThis.process?.pid==`number`)return globalThis.process.pid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,R]=e.file_get_contents(`/proc/self/stat`);if(R){let e=new TextDecoder().decode(R),W=parseInt(e,10);if(!isNaN(W))return W}}}catch{}return 0}function getEnvProxy(){if(typeof globalThis.process?.env==`object`)return globalThis.process.env;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return new Proxy({},{get(R,W){if(typeof W==`string`)return e.getenv(W)??void 0},set(R,W,Y){return typeof W==`string`?(e.setenv(W,String(Y),!0),!0):!1},deleteProperty(R,W){return typeof W==`string`?(e.unsetenv(W),!0):!1},has(R,W){return typeof W==`string`?e.getenv(W)!==null:!1},ownKeys(R){return e.listenv()},getOwnPropertyDescriptor(R,W){if(typeof W!=`string`)return;let Y=e.getenv(W);if(Y!==null)return{configurable:!0,enumerable:!0,writable:!0,value:Y}}})}catch{}return{}}function getArgv(){if(globalThis.process?.argv!==void 0)return globalThis.process.argv;try{let e=getGjsGlobal().imports?.system;if(e?.programArgs)return[`gjs`,e.programInvocationName||``,...e.programArgs]}catch{}return[`gjs`]}function getExecPath(){if(typeof globalThis.process?.execPath==`string`)return globalThis.process.execPath;try{let e=getGjsGlobal().imports?.system;if(e?.programInvocationName)return e.programInvocationName}catch{}return`/usr/bin/gjs`}function getCwd(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_current_dir)return e.get_current_dir()}catch{}return`/`}function chdir(e){let R=getGjsGlobal().imports?.gi?.GLib;try{if(R?.chdir){if(!R.file_test(e,16)){let R=Error(`ENOENT: no such file or directory, chdir '${e}'`);throw R.code=`ENOENT`,R.syscall=`chdir`,R.path=e,R}R.chdir(e);return}}catch(e){if(e&&typeof e==`object`&&e.code===`ENOENT`)throw e}if(!R){let R=globalThis.process;if(R&&typeof R.chdir==`function`){R.chdir(e);return}}throw Error(`process.chdir() is not supported in this environment`)}Ht();function exitProcess(e){let R=getGjsGlobal().imports,W=R?.gi?.GLib,Y=R?.system,X=W?.idle_add,ie=W?.SOURCE_REMOVE,ae=W?.PRIORITY_DEFAULT;if(Y?.exit&&X&&typeof ae==`number`&&typeof ie==`boolean`)return ensureMainLoop(),X(ae,()=>(quitMainLoop(),Y.exit(e),ie)),new Promise(()=>{});try{Y?.exit&&Y.exit(e)}catch{}let le=globalThis.process;throw le&&typeof le.exit==`function`&&le.exit(e),Error(`process.exit(${e})`)}function isGjs(){return getGjsGlobal().imports?.gi?.GLib!==void 0}function killPid(e,R){try{let W=getGjsGlobal().imports?.gi?.GLib;if(W){let Y=typeof R==`number`?String(R):R||`SIGTERM`,X=Y.startsWith(`SIG`)?`-${Y.slice(3)}`:`-${Y}`;return W.spawn_command_line_sync(`kill ${X} ${e}`),!0}}catch{}if(!isGjs()){let W=globalThis.process;if(W&&typeof W.kill==`function`)return W.kill(e,R)}throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,R]=e.file_get_contents(`/proc/self/status`);if(R){let e=new TextDecoder().decode(R).match(/VmRSS:\s+(\d+)/),W=e?parseInt(e[1],10)*1024:0;return{rss:W,heapTotal:W,heapUsed:W,external:0,arrayBuffers:0}}}}catch{}if(!isGjs()){let e=globalThis.process;if(e&&typeof e.memoryUsage==`function`)return e.memoryUsage()}return{rss:0,heapTotal:0,heapUsed:0,external:0,arrayBuffers:0}}function cpuUsage(e){if(!isGjs()){let R=globalThis.process;if(R&&typeof R.cpuUsage==`function`)return R.cpuUsage(e)}return{user:0,system:0}}let Vo=null;const Ko=globalThis.imports?.gi;if(Ko)try{Vo=Ko.GjsifyTerminal}catch{}const es=Vo;function onceWrapper(){let{target:e,type:R,listener:W}=this;return this.wrapperFn&&e.removeListener(R,this.wrapperFn),W.apply(e,Array.from(arguments))}function _onceWrap(e,R,W){let Y={target:e,type:R,listener:W,wrapperFn:void 0},X=onceWrapper.bind(Y);return Y.wrapperFn=X,X.listener=W,X}function arrayClone(e){switch(e.length){case 0:return[];case 1:return[e[0]];case 2:return[e[0],e[1]];case 3:return[e[0],e[1],e[2]];default:return e.slice()}}function checkListener(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}function validateNumber(e,R){if(typeof e!=`number`||e!==e)throw TypeError(`The "${R}" argument must be of type number. Received type ${typeof e}`)}function spliceOne(e,R){for(;R+1<e.length;R++)e[R]=e[R+1];e.pop()}function unwrapListeners(e){let R=Array.from({length:e.length});for(let W=0;W<R.length;++W)R[W]=e[W].listener??e[W];return R}function createAbortError$1(e){let R=Error(`The operation was aborted`);return R.name=`AbortError`,R.code=`ABORT_ERR`,e?.reason&&(R.cause=e.reason),R}var rs,as,os,ss=__esmMin(()=>{xt(),rs=Symbol(`kCapture`),as=Symbol.for(`nodejs.rejection`),os=class EventEmitter{static defaultMaxListeners=10;static errorMonitor=Symbol(`events.errorMonitor`);static captureRejectionSymbol=as;static _captureRejections=!1;static get captureRejections(){return EventEmitter._captureRejections}static set captureRejections(e){if(typeof e!=`boolean`)throw TypeError(`The "captureRejections" argument must be of type boolean.`);EventEmitter._captureRejections=e}_events;_eventsCount;_maxListeners;[rs];constructor(e){this._events=Object.create(null),this._eventsCount=0,this._maxListeners=void 0,this[rs]=e?.captureRejections??EventEmitter._captureRejections}setMaxListeners(e){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e);return this._maxListeners=e,this}getMaxListeners(){return this._maxListeners??EventEmitter.defaultMaxListeners}emit(e,...R){let W=this._events,Y=e===`error`;if(W!==void 0)Y&&W[EventEmitter.errorMonitor]!==void 0&&this.emit(EventEmitter.errorMonitor,...R),Y&&=W.error===void 0;else if(!Y)return!1;if(Y){let e;if(e=R.length>0?R[0]:Error(`Unhandled error.`),e instanceof Error)throw e;let W=Error(`Unhandled error. (`+e+`)`);throw W.context=e,W}let X=W[e];if(X===void 0)return!1;if(typeof X==`function`){let W=X.apply(this,R);W!=null&&this[rs]&&this._addCatch(W,e,R)}else{let W=arrayClone(X),Y=W.length;for(let X=0;X<Y;++X){let Y=W[X].apply(this,R);Y!=null&&this[rs]&&this._addCatch(Y,e,R)}}return!0}_addCatch(e,R,W){typeof e?.then==`function`&&e.then(void 0,e=>{let Y=this[as];if(typeof Y==`function`)Y.call(this,e,R,...W);else{let R=this[rs];try{this[rs]=!1,this.emit(`error`,e)}finally{this[rs]=R}}})}addListener(e,R){return this._addListener(e,R,!1)}on(e,R){return this._addListener(e,R,!1)}prependListener(e,R){return this._addListener(e,R,!0)}_addListener(e,R,W){checkListener(R);let Y=this._events;Y===void 0?(Y=this._events=Object.create(null),this._eventsCount=0):Y.newListener!==void 0&&(this.emit(`newListener`,e,R.listener??R),Y=this._events);let X=Y[e];X===void 0?(Y[e]=R,++this._eventsCount):typeof X==`function`?Y[e]=W?[R,X]:[X,R]:W?X.unshift(R):X.push(R);let ie=this.getMaxListeners();if(ie>0){let R=typeof Y[e]==`function`?1:Y[e].length;if(R>ie&&!Y[e].warned){typeof Y[e]!=`function`&&(Y[e].warned=!0);let W=Error(`Possible EventEmitter memory leak detected. ${R} ${String(e)} listeners added to [${this.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);W.name=`MaxListenersExceededWarning`,bt.warn(W.message)}}return this}once(e,R){return checkListener(R),this.on(e,_onceWrap(this,e,R)),this}prependOnceListener(e,R){return checkListener(R),this.prependListener(e,_onceWrap(this,e,R)),this}removeListener(e,R){checkListener(R);let W=this._events;if(W===void 0)return this;let Y=W[e];if(Y===void 0)return this;if(Y===R||Y.listener===R)--this._eventsCount===0?this._events=Object.create(null):(delete W[e],W.removeListener&&this.emit(`removeListener`,e,Y.listener??R));else if(typeof Y!=`function`){let X=-1;for(let e=Y.length-1;e>=0;e--)if(Y[e]===R||Y[e].listener===R){X=e;break}if(X<0)return this;X===0?Y.shift():spliceOne(Y,X),Y.length===1&&(W[e]=Y[0]),W.removeListener!==void 0&&this.emit(`removeListener`,e,R.listener??R)}return this}off(e,R){return this.removeListener(e,R)}removeAllListeners(e){let R=this._events;if(R===void 0)return this;if(R.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):R[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete R[e]),this;if(arguments.length===0){let e=Object.keys(R);for(let R=0;R<e.length;++R){let W=e[R];W!==`removeListener`&&this.removeAllListeners(W)}return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}let W=R[e];if(typeof W==`function`)this.removeListener(e,W);else if(W!==void 0)for(let R=W.length-1;R>=0;R--)this.removeListener(e,W[R]);return this}listeners(e){let R=this._events;if(R===void 0)return[];let W=R[e];return W===void 0?[]:typeof W==`function`?[W.listener??W]:unwrapListeners(W)}rawListeners(e){let R=this._events;if(R===void 0)return[];let W=R[e];return W===void 0?[]:typeof W==`function`?[W]:arrayClone(W)}listenerCount(e){let R=this._events;if(R===void 0)return 0;let W=R[e];return W===void 0?0:typeof W==`function`?1:W.length}eventNames(){return(this._eventsCount??0)>0?Reflect.ownKeys(this._events):[]}static once(e,R,W){return new Promise((Y,X)=>{let ie=W?.signal;if(ie?.aborted){X(createAbortError$1(ie));return}if(typeof e.addEventListener==`function`){let W=e,handler=(...e)=>{ie&&ie.removeEventListener(`abort`,abortHandler),Y(e)},errorHandler=e=>{ie&&ie.removeEventListener(`abort`,abortHandler),W.removeEventListener(`error`,errorHandler),X(e)},abortHandler=()=>{W.removeEventListener(R,handler),W.removeEventListener(`error`,errorHandler),X(createAbortError$1(ie))};W.addEventListener(R,handler,{once:!0}),R!==`error`&&W.addEventListener(`error`,errorHandler,{once:!0}),ie&&ie.addEventListener(`abort`,abortHandler,{once:!0});return}let ae=e,eventHandler=(...e)=>{ie&&ie.removeEventListener(`abort`,abortHandler),errorHandler!==void 0&&ae.removeListener(`error`,errorHandler),Y(e)},errorHandler;R!==`error`&&(errorHandler=e=>{ae.removeListener(R,eventHandler),ie&&ie.removeEventListener(`abort`,abortHandler),X(e)},ae.once(`error`,errorHandler)),ae.once(R,eventHandler);let abortHandler=()=>{ae.removeListener(R,eventHandler),errorHandler&&ae.removeListener(`error`,errorHandler),X(createAbortError$1(ie))};ie&&ie.addEventListener(`abort`,abortHandler,{once:!0})})}static on(e,R,W){let Y=W?.signal;if(Y?.aborted)throw createAbortError$1(Y);let X=W?.highWaterMark??2**53-1,ie=W?.lowWaterMark??1;validateNumber(X,`highWaterMark`),validateNumber(ie,`lowWaterMark`);let ae=[],le=[],_e=null,ye=!1,be=!1,eventHandler=(...R)=>{if(le.length>0){let{resolve:e}=le.shift();e({value:R,done:!1})}else ae.push(R),ae.length>=X&&!be&&(be=!0,typeof e.pause==`function`&&e.pause())},errorHandler=e=>{if(_e=e,le.length>0){let{reject:R}=le.shift();R(e)}Ce.return()},abortHandler=()=>{errorHandler(createAbortError$1(Y))};e.on(R,eventHandler),R!==`error`&&e.on(`error`,errorHandler),Y&&Y.addEventListener(`abort`,abortHandler,{once:!0});let cleanup=()=>{e.removeListener(R,eventHandler),e.removeListener(`error`,errorHandler),Y&&Y.removeEventListener(`abort`,abortHandler),ye=!0;for(let{resolve:e}of le)e({value:void 0,done:!0});le.length=0,ae.length=0},Ce={next(){if(ae.length>0){let R=ae.shift();return be&&ae.length<ie&&(be=!1,typeof e.resume==`function`&&e.resume()),Promise.resolve({value:R,done:!1})}if(_e){let e=Promise.reject(_e);return _e=null,e}return ye?Promise.resolve({value:void 0,done:!0}):new Promise((e,R)=>{le.push({resolve:e,reject:R})})},return(){return cleanup(),Promise.resolve({value:void 0,done:!0})},throw(e){return ye||(_e=e,cleanup()),Promise.reject(e)},[Symbol.asyncIterator](){return this}};return Ce}static listenerCount(e,R){return e.listenerCount(R)}static getEventListeners(e,R){return typeof e.listeners==`function`?e.listeners(R):[]}static setMaxListeners(e,...R){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range.`);if(R.length===0)EventEmitter.defaultMaxListeners=e;else for(let W of R)typeof W.setMaxListeners==`function`&&W.setMaxListeners(e)}static getMaxListeners(e){return typeof e.getMaxListeners==`function`?e.getMaxListeners():EventEmitter.defaultMaxListeners}static addAbortListener(e,R){e.aborted&&Promise.resolve().then(()=>R());let handler=()=>R();return e.addEventListener(`abort`,handler,{once:!0}),{[Symbol.dispose](){e.removeEventListener(`abort`,handler)}}}},os.EventEmitter=os;for(let e of[`setMaxListeners`,`getMaxListeners`,`emit`,`addListener`,`on`,`prependListener`,`once`,`prependOnceListener`,`removeListener`,`off`,`removeAllListeners`,`listeners`,`rawListeners`,`listenerCount`,`eventNames`]){let R=os.prototype[e];typeof R==`function`&&Object.defineProperty(os.prototype,e,{enumerable:!0,configurable:!0,writable:!0,value:R})}Object.defineProperty(os.prototype,"_events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(os.prototype,"_eventsCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(os.prototype,"_maxListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),__name$1(createAbortError$1,`createAbortError`)}),cs,ls=__esmMin(()=>{ss(),Ht(),cs=makeCallable(os),cs.EventEmitter=cs,cs.captureRejectionSymbol,cs.errorMonitor,cs.defaultMaxListeners,cs.setMaxListeners,cs.getMaxListeners,cs.once,cs.on,cs.getEventListeners,cs.listenerCount,cs.addAbortListener});xt(),ls(),Ht();const us=new TextEncoder;var ProcessWriteStream=class extends cs{fd;writable=!0;_outGio=null;constructor(e){super(),this.fd=e;let R=getGioNamespace();if(R){let e=R.UnixOutputStream??R.OutputStream;if(e)try{this._outGio=e.new(this.fd,!1)}catch{}}}write(e){if(this._outGio)try{let R=typeof e==`string`?us.encode(e):e;return this._outGio.write_all(R,null),!0}catch{}return this.fd===2?bt.error(e):bt.log(e),!0}get isTTY(){if(es)return es.Terminal.is_tty(this.fd);try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return!!e.log_writer_supports_color(this.fd)}catch{}return!1}get columns(){if(es){let[e,,R]=es.Terminal.get_size(this.fd);if(e&&R>0)return R}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let R=parseInt(e.getenv(`COLUMNS`)??`0`,10);if(R>0)return R}}catch{}return 80}end(){}destroy(){}get rows(){if(es){let[e,R]=es.Terminal.get_size(this.fd);if(e&&R>0)return R}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let R=parseInt(e.getenv(`LINES`)??`0`,10);if(R>0)return R}}catch{}return 24}},ProcessReadStream=class extends cs{fd;isRaw=!1;_gio=null;_stdinGio=null;_reading=!1;_flowing=!1;_sttyCleanupRegistered=!1;_mainLoopHeld=!1;_pendingRead=!1;constructor(e){super(),this.fd=e,this._gio=getGioNamespace()}get isTTY(){return es?es.Terminal.is_tty(this.fd):!1}setRawMode(e){return es&&es.Terminal.set_raw_mode(this.fd,e)?(this.isRaw=e,this):(this._setRawModeViaStty(e),this.isRaw=e,this)}_setRawModeViaStty(e){try{let R=globalThis.imports?.gi,W=R?.Gio??R?.Gio;if(!W)return;let Y=W.SubprocessFlags?.STDIN_INHERIT??2,X=e?[`stty`,`-icanon`,`-echo`,`-icrnl`,`min`,`1`,`time`,`0`]:[`stty`,`icanon`,`echo`,`icrnl`];if(new W.SubprocessLauncher({flags:Y}).spawnv(X).wait(null),e&&!this._sttyCleanupRegistered){this._sttyCleanupRegistered=!0;let e=globalThis.process;e?.once&&typeof e.once==`function`&&e.once(`exit`,()=>this._setRawModeViaStty(!1))}}catch{}}setEncoding(e){return this}resume(){return this._flowing=!0,this._gio&&this.fd===0&&!this._reading&&this._startReading(),this}pause(){if(this._flowing=!1,this._reading=!1,this._mainLoopHeld){this._mainLoopHeld=!1;let e=globalThis.imports?.gi,R=e?.GLib??e?.GLib;R?.idle_add?R.idle_add(300,()=>(this._mainLoopHeld||quitMainLoop(),!1)):quitMainLoop()}return this}read(){return null}_startReading(){if(!this._gio||this._reading)return;if(this._pendingRead){this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop());return}if(this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop()),!this._stdinGio){let e=this._gio.UnixInputStream??this._gio.InputStream;if(!e){this._reading=!1;return}try{this._stdinGio=e.new(this.fd,!1)}catch{this._reading=!1;return}}let loop=()=>{if(!this._reading){this._pendingRead=!1;return}this._pendingRead=!0,this._stdinGio.read_bytes_async(4096,0,null,(e,R)=>{this._pendingRead=!1;try{let W=e.read_bytes_finish(R)?.get_data?.()??null;if(W&&W.byteLength>0)this.emit(`data`,Buffer.from(W));else if(W!==null&&W.byteLength===0){this._reading=!1,this.emit(`end`);return}}catch{this._reading=!1;return}this._reading&&loop()})};loop()}};xt(),ls();const ds=Date.now();var Process=class extends cs{platform;arch;env;argv;argv0;execPath;pid;ppid;version;versions;title;execArgv;config;exitCode;constructor(){super(),this.platform=detectPlatform(),this.arch=detectArch(),this.env=getEnvProxy(),this.argv=getArgv(),this.argv0=this.argv[0]||`gjs`,this.execPath=getExecPath(),this.execArgv=globalThis.process?.execArgv??[],this.config=globalThis.process?.config??{target_defaults:{},variables:{}},this.pid=getPid(),this.ppid=detectPpid();let e=detectVersionInfo();this.version=e.version,this.versions=e.versions,this.title=e.title}cwd(){return getCwd()}chdir(e){chdir(e)}kill(e,R){return killPid(e,R)}exit(e){return this.exitCode=e??this.exitCode??0,this.emit(`exit`,this.exitCode),exitProcess(this.exitCode)}nextTick(e,...R){typeof queueMicrotask==`function`?queueMicrotask(()=>e(...R)):Promise.resolve().then(()=>e(...R))}hrtime(e){return hrtime(e)}uptime(){return(Date.now()-ds)/1e3}memoryUsage(){return memoryUsage()}cpuUsage(e){return cpuUsage(e)}stdout=new ProcessWriteStream(1);stderr=new ProcessWriteStream(2);stdin=new ProcessReadStream(0);abort(){this.exit(1)}umask(e){return 18}emitWarning(e,R){bt.warn(typeof e==`string`?`(${R||`Warning`}): ${e}`:e.message)}};Process.prototype.hrtime.bigint=function(){return hrtimeBigint()};const fs=new Process;if(es)try{let e=new es.ResizeWatcher;e.connect(`resized`,(e,R,W)=>{fs.stdout.emit(`resize`),fs.stderr.emit(`resize`)}),e.start()}catch{}fs.platform,fs.arch,fs.env,fs.argv,fs.argv0,fs.execPath,fs.pid,fs.ppid,fs.version,fs.versions,fs.cwd.bind(fs),fs.chdir.bind(fs),fs.exit.bind(fs),fs.nextTick.bind(fs),Object.assign(fs.hrtime.bind(fs),{bigint:hrtimeBigint}),fs.uptime.bind(fs),fs.memoryUsage.bind(fs),fs.cpuUsage.bind(fs),fs.kill.bind(fs),fs.abort.bind(fs),fs.umask.bind(fs),fs.emitWarning.bind(fs),fs.execArgv,fs.config,fs.stdout,fs.stderr,fs.stdin,Ht(),typeof Promise.withResolvers!=`function`&&(Promise.withResolvers=function(){let e,R;return{promise:new Promise((W,Y)=>{e=W,R=Y}),resolve:e,reject:R}}),initErrorV8Methods(Error),`global`in globalThis||Object.defineProperty(globalThis,"global",{value:globalThis,writable:!1,enumerable:!1,configurable:!0}),Object.defineProperty(globalThis,"process",{value:fs,enumerable:!1,writable:!0,configurable:!0}),Ht(),typeof globalThis.structuredClone!=`function`&&Object.defineProperty(globalThis,"structuredClone",{value:structuredClone$1,enumerable:!0,writable:!0,configurable:!0});function getGLib(){return globalThis.imports?.gi?.GLib}const ps=getGLib()!==void 0;var GjsifyTimeout=class{_id=null;_refed=!0;_callback;_delay;_args;_repeat;constructor(e,R,W,Y){this._callback=e,this._delay=R,this._args=W,this._repeat=Y,this._schedule()}_schedule(){let e=getGLib();if(!e)return;let R=e.timeout_add.bind(e);this._id=R(e.PRIORITY_DEFAULT,this._delay,()=>{try{this._callback.apply(globalThis,this._args)}catch(e){setTimeout(()=>{throw e},0)}return this._repeat?e.SOURCE_CONTINUE:(this._id=null,e.SOURCE_REMOVE)})}ref(){return this._refed=!0,this}unref(){return this._refed=!1,this}hasRef(){return this._refed}refresh(){return this._cancel(),this._schedule(),this}_cancel(){if(this._id!==null){try{getGLib()?.Source.remove(this._id)}catch{}this._id=null}}[Symbol.toPrimitive](){return this._id}[Symbol.dispose](){this._cancel()}};function removeById(e){if(e instanceof GjsifyTimeout)e._cancel();else if(typeof e==`number`)try{getGLib()?.Source.remove(e)}catch{}}if(ps){let setT=(e,R=0,...W)=>new GjsifyTimeout(e,Math.max(0,R|0),W,!1),setI=(e,R=0,...W)=>new GjsifyTimeout(e,Math.max(0,R|0),W,!0),e=globalThis;e.setTimeout=setT,e.clearTimeout=removeById,e.setInterval=setI,e.clearInterval=removeById}function setImmediate(e,...R){return setTimeout(e,0,...R)}function clearImmediate(e){clearTimeout(e)}`setImmediate`in globalThis||Object.defineProperty(globalThis,"setImmediate",{value:setImmediate,enumerable:!0,writable:!0,configurable:!0}),`clearImmediate`in globalThis||Object.defineProperty(globalThis,"clearImmediate",{value:clearImmediate,enumerable:!0,writable:!0,configurable:!0}),$e();const ms=Qe.UriFlags.HAS_PASSWORD|Qe.UriFlags.ENCODED|Qe.UriFlags.SCHEME_NORMALIZE;var hs=class URLSearchParams{_entries=[];constructor(e){if(e)if(typeof e==`string`){let R=e.startsWith(`?`)?e.slice(1):e;if(R)for(let e of R.split(`&`)){let R=e.indexOf(`=`);R===-1?this._entries.push([decodeComponent(e),``]):this._entries.push([decodeComponent(e.slice(0,R)),decodeComponent(e.slice(R+1))])}}else if(Array.isArray(e))for(let[R,W]of e)this._entries.push([String(R),String(W)]);else if(e instanceof URLSearchParams)this._entries=e._entries.map(([e,R])=>[e,R]);else for(let R of Object.keys(e))this._entries.push([R,String(e[R])])}get(e){for(let[R,W]of this._entries)if(R===e)return W;return null}getAll(e){return this._entries.filter(([R])=>R===e).map(([,e])=>e)}set(e,R){let W=!1;if(this._entries=this._entries.filter(([R])=>R===e?W?!1:(W=!0,!0):!0),W){for(let W=0;W<this._entries.length;W++)if(this._entries[W][0]===e){this._entries[W][1]=R;break}}else this._entries.push([e,R])}has(e){return this._entries.some(([R])=>R===e)}delete(e){this._entries=this._entries.filter(([R])=>R!==e)}append(e,R){this._entries.push([e,R])}sort(){this._entries.sort((e,R)=>e[0]<R[0]?-1:+(e[0]>R[0]))}toString(){return this._entries.map(([e,R])=>encodeComponent(e)+`=`+encodeComponent(R)).join(`&`)}forEach(e){for(let[R,W]of this._entries)e(W,R,this)}*entries(){yield*this._entries}*keys(){for(let[e]of this._entries)yield e}*values(){for(let[,e]of this._entries)yield e}[Symbol.iterator](){return this.entries()}get size(){return this._entries.length}};function decodeComponent(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}}function encodeComponent(e){return encodeURIComponent(e).replace(/%20/g,`+`)}var gs=class URL{#e;#t;constructor(e,R){let W=e instanceof URL?e.href:String(e);try{if(R!==void 0){let e=R instanceof URL?R.href:String(R),Y=Qe.Uri.parse(e,ms);this.#e=Y.parse_relative(W,ms)}else this.#e=Qe.Uri.parse(W,ms)}catch{throw TypeError(`Invalid URL: ${W}`)}if(!this.#e)throw TypeError(`Invalid URL: ${W}`);this.#t=new hs(this.#e.get_query()||``)}get protocol(){return this.#e.get_scheme()+`:`}get hostname(){return(this.#e.get_host()||``).toLowerCase()}get port(){let e=this.#e.get_port();if(e===-1)return``;let R=this.#e.get_scheme();return(R===`http`||R===`ws`)&&e===80||(R===`https`||R===`wss`)&&e===443||R===`ftp`&&e===21?``:String(e)}get host(){let e=this.hostname,R=this.port;return R?`${e}:${R}`:e}get pathname(){return this.#e.get_path()||`/`}get search(){let e=this.#e.get_query();return e?`?`+e:``}get hash(){let e=this.#e.get_fragment();return e?`#`+e:``}get origin(){let e=this.protocol;return e===`http:`||e===`https:`||e===`ftp:`?`${e}//${this.host}`:`null`}get username(){return this.#e.get_user()||``}get password(){return this.#e.get_password()||``}get href(){let e=this.protocol,R=this.#e.get_scheme();(R===`http`||R===`https`||R===`ftp`||R===`file`||R===`ws`||R===`wss`||this.hostname)&&(e+=`//`);let W=this.username,Y=this.password;W&&(e+=W,Y&&(e+=`:`+Y),e+=`@`),e+=this.hostname,this.port&&(e+=`:`+this.port);let X=this.pathname;return e+=X,e+=this.search,e+=this.hash,e}get searchParams(){return this.#t}toString(){return this.href}toJSON(){return this.href}static _objectURLPaths=new Map;static _objectURLCounter=0;static createObjectURL(e){let R=e?._tmpPath;if(typeof R==`string`&&R.length>0){let e=`file://${R}`;return URL._objectURLPaths.set(e,R),e}return`file:///dev/null`}static revokeObjectURL(e){let R=URL._objectURLPaths.get(e);if(R){try{Qe.unlink(R)}catch{}URL._objectURLPaths.delete(e)}}};typeof globalThis.URL!=`function`&&Object.defineProperty(globalThis,"URL",{value:gs,enumerable:!1,writable:!0,configurable:!0}),typeof globalThis.URLSearchParams!=`function`&&Object.defineProperty(globalThis,"URLSearchParams",{value:hs,enumerable:!1,writable:!0,configurable:!0});let _s;if(globalThis.performance)_s=globalThis.performance;else{let e,_now;try{let R=globalThis.imports?.gi?.GLib;if(!R)throw Error(`GJS imports.gi.GLib not available`);e=R.get_monotonic_time(),_now=()=>(R.get_monotonic_time()-e)/1e3}catch{let R=Date.now();e=0,_now=()=>Date.now()-R}let R=[],W=Date.now()-_now();_s={timeOrigin:W,now:_now,mark(e){let W={name:e,entryType:`mark`,startTime:_now(),duration:0};return R.push(W),W},measure(e,W,Y){let X=0,ie=_now();if(W){let e=R.find(e=>e.entryType===`mark`&&e.name===W);e&&(X=e.startTime)}if(Y){let e=R.find(e=>e.entryType===`mark`&&e.name===Y);e&&(ie=e.startTime)}let ae={name:e,entryType:`measure`,startTime:X,duration:ie-X};return R.push(ae),ae},getEntries(){return[...R]},getEntriesByName(e){return R.filter(R=>R.name===e)},getEntriesByType(e){return R.filter(R=>R.entryType===e)},clearMarks(e){for(let W=R.length-1;W>=0;W--)R[W].entryType===`mark`&&(!e||R[W].name===e)&&R.splice(W,1)},clearMeasures(e){for(let W=R.length-1;W>=0;W--)R[W].entryType===`measure`&&(!e||R[W].name===e)&&R.splice(W,1)},clearResourceTimings(){},setResourceTimingBufferSize(){},toJSON(){return{timeOrigin:W}}}}var PerformanceObserverStub=class{_callback;constructor(e){this._callback=e}observe(e){}disconnect(){}takeRecords(){return[]}};const ys=globalThis,bs=ys.PerformanceObserver||PerformanceObserverStub;ys.PerformanceEntry,ys.PerformanceObserverEntryList,ys.PerformanceMark,ys.PerformanceMeasure;const Cs=globalThis;globalThis.performance===void 0&&(Cs.performance=_s),typeof Cs.PerformanceObserver!=`function`&&(Cs.PerformanceObserver=bs);var AudioNode=class{_outputs=new Set;_inputs=new Set;numberOfInputs;numberOfOutputs;channelCount;constructor(e=1,R=1){this.numberOfInputs=e,this.numberOfOutputs=R,this.channelCount=2}connect(e){return this._outputs.add(e),e._inputs.add(this),e}disconnect(e){if(e)this._outputs.delete(e),e._inputs.delete(this);else{for(let e of this._outputs)e._inputs.delete(this);this._outputs.clear()}}};let Ts=!1;function ensureGstInit(){Ts||=(ye.init(null),!0)}var AudioParam=class{defaultValue;minValue;maxValue;_onChange=null;_value;_rampTimerId=null;constructor(e=0,R=-34028235e31,W=34028235e31){this.defaultValue=e,this.minValue=R,this.maxValue=W,this._value=e}get value(){return this._value}set value(e){this._cancelRamp(),this._value=Math.max(this.minValue,Math.min(this.maxValue,e)),this._onChange?.(this._value)}setValueAtTime(e,R){return this.value=e,this}linearRampToValueAtTime(e,R){return this.value=e,this}exponentialRampToValueAtTime(e,R){return this.value=e,this}setTargetAtTime(R,W,Y){if(this._cancelRamp(),Y<=0)return this.value=R,this;let X=Math.max(10,Math.round(Y*100));return this._rampTimerId=e.timeout_add(e.PRIORITY_DEFAULT,X,()=>{let W=R-this._value;if(Math.abs(W)<.001)return this._value=R,this._onChange?.(this._value),this._rampTimerId=null,e.SOURCE_REMOVE;let ie=1-Math.exp(-X/(Y*1e3));return this._value+=W*ie,this._onChange?.(this._value),e.SOURCE_CONTINUE}),this}setValueCurveAtTime(e,R,W){return this}cancelScheduledValues(e){return this._cancelRamp(),this}cancelAndHoldAtTime(e){return this._cancelRamp(),this}_cancelRamp(){this._rampTimerId!==null&&(e.source_remove(this._rampTimerId),this._rampTimerId=null)}},GainNode=class extends AudioNode{gain;_activePlayers=new Set;constructor(){super(1,1),this.gain=new AudioParam(1,0,10),this.gain._onChange=e=>{for(let R of this._activePlayers)R.setVolume(e)}}},GstPlayer=class{_pipeline=null;_volumeElement=null;_busWatchId=null;_ended=!1;_loop;_onEnded;_audioBuffer;constructor(e){ensureGstInit(),this._loop=e.loop,this._onEnded=e.onEnded,this._audioBuffer=e.audioBuffer;let{audioBuffer:R,volume:W,offset:Y,duration:X,playbackRate:ie}=e,ae=R.sampleRate,le=R.numberOfChannels,_e=this._interleave(R,Y,X);if(_e.length===0){this._fireEnded();return}let be=`appsrc name=src caps="${`audio/x-raw,format=F32LE,rate=${ae},channels=${le},layout=interleaved`}" format=3 ! audioconvert ! volume name=vol ! autoaudiosink`;this._pipeline=ye.parse_launch(be),this._volumeElement=this._pipeline.get_by_name(`vol`);let Ce=this._pipeline.get_by_name(`src`);this._volumeElement.set_property(`volume`,Math.max(0,Math.min(W,10)));let Te=this._pipeline.get_bus();this._busWatchId=Te.add_watch(0,(e,R)=>(R.type===ye.MessageType.EOS?this._loop&&!this._ended?this._restartPlayback(Ce,_e):this._fireEnded():R.type===ye.MessageType.ERROR&&this._fireEnded(),!0));let Oe=ye.Buffer.new_wrapped(_e),Ae=_e.length/(4*le);Oe.pts=0,Oe.duration=Math.floor(Ae/ae*Number(ye.SECOND)),Ce.push_buffer(Oe),Ce.end_of_stream(),ie!==1&&(this._pipeline.set_state(ye.State.PAUSED),this._pipeline.seek(ie,ye.Format.TIME,ye.SeekFlags.FLUSH|ye.SeekFlags.ACCURATE,ye.SeekType.SET,0,ye.SeekType.NONE,-1)),this._pipeline.set_state(ye.State.PLAYING)}setVolume(e){this._volumeElement&&!this._ended&&this._volumeElement.set_property(`volume`,Math.max(0,Math.min(e,10)))}setLoop(e){this._loop=e}stop(){this._ended||this._fireEnded()}get ended(){return this._ended}_restartPlayback(e,R){this._pipeline&&this._pipeline.seek_simple(ye.Format.TIME,ye.SeekFlags.FLUSH,0)}_fireEnded(){this._ended||(this._ended=!0,this._cleanup(),this._onEnded())}_cleanup(){let R=this._pipeline;this._pipeline=null,this._volumeElement=null,this._busWatchId=null,R&&e.idle_add(e.PRIORITY_LOW,()=>(R.set_state(ye.State.NULL),e.SOURCE_REMOVE))}_interleave(e,R,W){let Y=e.numberOfChannels,X=Math.min(Math.floor(R*e.sampleRate),e.length),ie=e.length-X,ae=W===void 0?ie:Math.min(Math.floor(W*e.sampleRate),ie);if(ae<=0)return new Uint8Array;let le=new Float32Array(ae*Y);for(let R=0;R<ae;R++)for(let W=0;W<Y;W++)le[R*Y+W]=e._channelData[W][X+R];return new Uint8Array(le.buffer)}},AudioBufferSourceNode=class extends AudioNode{buffer=null;loop=!1;loopStart=0;loopEnd=0;playbackRate;onended=null;_player=null;_started=!1;constructor(){super(0,1),this.playbackRate=new AudioParam(1,.0625,16)}start(e=0,R=0,W){if(this._started)throw new DOMException(`AudioBufferSourceNode can only be started once`,`InvalidStateError`);if(this._started=!0,!this.buffer)return;let Y=this._findGainNode(),X=Y?Y.gain.value:1;this._player=new GstPlayer({audioBuffer:this.buffer,volume:X,loop:this.loop,offset:R,duration:W,playbackRate:this.playbackRate.value,onEnded:()=>{Y&&Y._activePlayers.delete(this._player),this._player=null,this.onended?.()}}),Y&&this._player&&Y._activePlayers.add(this._player)}stop(e=0){this._player&&this._player.stop()}_findGainNode(){for(let e of this._outputs){if(e instanceof GainNode)return e;for(let R of e._outputs)if(R instanceof GainNode)return R}return null}},AudioBuffer=class{sampleRate;length;duration;numberOfChannels;_channelData;constructor(e){this.sampleRate=e.sampleRate,this.length=e.length,this.numberOfChannels=e.numberOfChannels,this.duration=this.length/this.sampleRate,this._channelData=[];for(let e=0;e<this.numberOfChannels;e++)this._channelData.push(new Float32Array(this.length))}getChannelData(e){if(e<0||e>=this.numberOfChannels)throw RangeError(`channel index ${e} out of range [0, ${this.numberOfChannels})`);return this._channelData[e]}copyFromChannel(e,R,W=0){let Y=this.getChannelData(R),X=Math.min(e.length,Y.length-W);e.set(Y.subarray(W,W+X))}copyToChannel(e,R,W=0){let Y=this.getChannelData(R),X=Math.min(e.length,Y.length-W);Y.set(e.subarray(0,X),W)}},AudioDestinationNode=class extends AudioNode{maxChannelCount=2;constructor(){super(1,0)}};function decodeAudioDataSync(e){if(ensureGstInit(),!(e instanceof ArrayBuffer)||e.byteLength===0)throw new DOMException(`Unable to decode audio data`,`EncodingError`);let R=ye.parse_launch(`appsrc name=src ! decodebin ! audioconvert ! audioresample ! capsfilter caps=audio/x-raw,format=F32LE,layout=interleaved ! appsink name=sink sync=false`),W=R.get_by_name(`src`),Y=R.get_by_name(`sink`);R.set_state(ye.State.PLAYING);let X=new Uint8Array(e);W.push_buffer(ye.Buffer.new_wrapped(X)),W.end_of_stream();let ie=[],ae=0,le=0;for(;;){let e=Y.try_pull_sample(2*Number(ye.SECOND));if(!e)break;if(ae===0){let R=e.get_caps();if(R){let e=R.get_structure(0);[,ae]=e.get_int(`rate`),[,le]=e.get_int(`channels`)}}let R=e.get_buffer();if(!R)continue;let[W,X]=R.map(ye.MapFlags.READ);W&&(ie.push(new Uint8Array(X.data)),R.unmap(X))}if(R.set_state(ye.State.NULL),ae===0||le===0)throw new DOMException(`Unable to decode audio data`,`EncodingError`);let _e=0;for(let e of ie)_e+=e.length;let be=_e/(4*le),Ce=new AudioBuffer({numberOfChannels:le,length:be,sampleRate:ae}),Te=0;for(let e of ie){let R=new Float32Array(e.buffer,e.byteOffset,e.length/4),W=R.length/le;for(let e=0;e<W;e++)for(let W=0;W<le;W++)Ce._channelData[W][Te+e]=R[e*le+W];Te+=W}return Ce}var AudioContext$1=class{static{__name$1(this,`AudioContext`)}state=`suspended`;sampleRate=44100;destination;listener={};_startTime;constructor(){ensureGstInit(),this._startTime=e.get_monotonic_time(),this.destination=new AudioDestinationNode}get currentTime(){return(e.get_monotonic_time()-this._startTime)/1e6}createGain(){return new GainNode}createBufferSource(){return new AudioBufferSourceNode}createBuffer(e,R,W){return new AudioBuffer({numberOfChannels:e,length:R,sampleRate:W})}decodeAudioData(e,R,W){try{let W=decodeAudioDataSync(e);return R?.(W),Promise.resolve(W)}catch(e){let R=e instanceof DOMException?e:new DOMException(`Unable to decode audio data`,`EncodingError`);return W?.(R),Promise.reject(R)}}async resume(){this.state=`running`}async suspend(){this.state=`suspended`}async close(){this.state=`closed`}createAnalyser(){return{connect:()=>{},disconnect:()=>{},fftSize:2048,frequencyBinCount:1024,getByteFrequencyData:()=>{},getFloatFrequencyData:()=>{}}}createDynamicsCompressor(){return new AudioNode}createBiquadFilter(){return new AudioNode}createConvolver(){return new AudioNode}createPanner(){return new AudioNode}createStereoPanner(){return new AudioNode}addEventListener(e,R){}removeEventListener(e,R){}};const Es=new Set([`audio/mpeg`,`audio/mp3`,`audio/wav`,`audio/x-wav`,`audio/ogg`,`audio/webm`,`audio/flac`,`audio/x-flac`,`audio/aac`,`audio/mp4`]);var HTMLAudioElement=class{src=``;volume=1;loop=!1;paused=!0;currentTime=0;duration=0;readyState=0;_pipeline=null;canPlayType(e){let R=e.split(`;`)[0].trim().toLowerCase();return Es.has(R)?`maybe`:``}play(){return!this.src||(ensureGstInit(),this._cleanup(),this._pipeline=ye.ElementFactory.make(`playbin`,`player`),!this._pipeline)?Promise.resolve():(this._pipeline.set_property(`uri`,this.src),this._pipeline.set_property(`volume`,this.volume),this._pipeline.set_state(ye.State.PLAYING),this.paused=!1,Promise.resolve())}pause(){this._pipeline&&(this._pipeline.set_state(ye.State.PAUSED),this.paused=!0)}load(){this._cleanup()}addEventListener(e,R){}removeEventListener(e,R){}_cleanup(){this._pipeline&&=(this._pipeline.set_state(ye.State.NULL),null)}};const As=globalThis;As.AudioContext===void 0&&(As.AudioContext=AudioContext$1),As.webkitAudioContext===void 0&&(As.webkitAudioContext=AudioContext$1),As.Audio===void 0&&(As.Audio=HTMLAudioElement),As.HTMLAudioElement===void 0&&(As.HTMLAudioElement=HTMLAudioElement);const js=Symbol(`abort`),Ms=Symbol(`internal`);var Ns=class AbortSignal extends EventTarget$1{#e=!1;reason=void 0;onabort=null;constructor(e){if(super(),e!==Ms)throw TypeError(`Illegal constructor.`)}get aborted(){if(!(this instanceof AbortSignal))throw TypeError(`'get aborted' called on an object that is not a valid instance of AbortSignal.`);return this.#e}get[Symbol.toStringTag](){return`AbortSignal`}throwIfAborted(){if(this.#e)throw this.reason}[js](e){if(this.#e)return;this.#e=!0,this.reason=e??new lr(`The operation was aborted.`,`AbortError`);let R=new Event$1(`abort`);typeof this.onabort==`function`&&this.onabort.call(this,R),this.dispatchEvent(R)}static abort(e){let R=new AbortSignal(Ms);return R[js](e),R}static timeout(e){let R=new AbortSignal(Ms);return setTimeout(()=>{R[js](new lr(`The operation timed out.`,`TimeoutError`))},e),R}static any(e){let R=new AbortSignal(Ms);for(let W of e)if(W.aborted)return R[js](W.reason),R;let onAbort=()=>{if(!R.aborted){let W=e.find(e=>e.aborted);R[js](W?.reason)}};for(let R of e)R.addEventListener(`abort`,onAbort,{once:!0});return R}},Is=class AbortController{signal;constructor(){this.signal=new Ns(Ms)}abort(e){if(!(this instanceof AbortController))throw TypeError(`'abort' called on an object that is not a valid instance of AbortController.`);this.signal[js](e)}};const zs=globalThis;globalThis.AbortController===void 0&&(zs.AbortController=Is),globalThis.AbortSignal===void 0&&(zs.AbortSignal=Ns);const Bs=Symbol(`kState`),Hs=Symbol(`kType`);function isBrandCheck(e){return R=>typeof R==`object`&&!!R&&R[Bs]!==void 0&&R[Hs]===e}function dequeueValue(e){let R=e[Bs].queue.shift();if(R===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:W,size:Y}=R;return e[Bs].queueTotalSize=Math.max(0,e[Bs].queueTotalSize-Y),W}function resetQueue(e){e[Bs].queue=[],e[Bs].queueTotalSize=0}function peekQueueValue(e){return e[Bs].queue[0].value}function enqueueValueWithSize(e,R,W){if(W=+W,typeof W!=`number`||W<0||Number.isNaN(W)||W===1/0)throw RangeError(`Invalid size: ${W}`);e[Bs].queue.push({value:R,size:W}),e[Bs].queueTotalSize+=W}function extractHighWaterMark(e,R){if(e===void 0)return R;if(e=+e,typeof e!=`number`||Number.isNaN(e)||e<0)throw RangeError(`Invalid highWaterMark: ${e}`);return e}function extractSizeAlgorithm(e){if(e===void 0)return()=>1;if(typeof e!=`function`)throw TypeError(`strategy.size must be a function`);return e}function transferArrayBuffer(e){return typeof ArrayBuffer.prototype.transfer==`function`?e.transfer():e.slice(0)}function isDetachedBuffer(e){if(typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||e.byteLength!==0)return!1;try{return e.slice(0,0),!1}catch{return!0}}function typedArrayConstructorByTag(e){switch(e){case`Int8Array`:return Int8Array;case`Uint8Array`:return Uint8Array;case`Uint8ClampedArray`:return Uint8ClampedArray;case`Int16Array`:return Int16Array;case`Uint16Array`:return Uint16Array;case`Int32Array`:return Int32Array;case`Uint32Array`:return Uint32Array;case`Float32Array`:return Float32Array;case`Float64Array`:return Float64Array;case`BigInt64Array`:return typeof BigInt64Array<`u`?BigInt64Array:void 0;case`BigUint64Array`:return typeof BigUint64Array<`u`?BigUint64Array:void 0;default:return}}function elementSizeByTag(e){switch(e){case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:return 1;case`Int16Array`:case`Uint16Array`:return 2;case`Int32Array`:case`Uint32Array`:case`Float32Array`:return 4;case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:return 8;default:return 1}}function setPromiseHandled(e){e.then(()=>{},()=>{})}function createPromiseCallback(e,R,W){if(typeof R!=`function`)throw TypeError(`${e} must be a function`);return async(...e)=>R.call(W,...e)}async function nonOpFlush(){}function nonOpStart(){}async function nonOpPull(){}async function nonOpCancel(){}async function nonOpWrite(){}const Us={__proto__:Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),next:void 0,return:void 0};function createAsyncFromSyncIterator(e){let R={[Symbol.iterator]:()=>e.iterator},W=(async function*(){return yield*R})();return{iterator:W,nextMethod:W.next,done:!1}}function getIterator(e,R=`sync`,W){if(W===void 0)if(R===`async`){if(W=e[Symbol.asyncIterator],W==null){let R=e[Symbol.iterator];if(R===void 0)throw TypeError(`Object is not iterable`);return createAsyncFromSyncIterator(getIterator(e,`sync`,R))}}else W=e[Symbol.iterator];if(W===void 0)throw TypeError(`Object is not iterable`);let Y=W.call(e);if(typeof Y!=`object`||!Y)throw TypeError(`The iterator method must return an object`);return{iterator:Y,nextMethod:Y.next,done:!1}}function iteratorNext(e,R){let W;if(W=R===void 0?e.nextMethod.call(e.iterator):e.nextMethod.call(e.iterator,R),typeof W!=`object`||!W)throw TypeError(`The iterator.next() method must return an object`);return W}const Ws=typeof globalThis.AbortController==`function`?globalThis.AbortController:class AbortControllerShim{signal={aborted:!1,reason:void 0,addEventListener(){},removeEventListener(){}};abort(e){this.signal.aborted=!0,this.signal.reason=e}},Xs=Symbol(`kAbort`),Zs=Symbol(`kCloseSentinel`),$s=Symbol(`kError`),ec=Symbol(`kSkipThrow`);var WritableStream=class{[Hs]=`WritableStream`;[Bs];constructor(e={},R={}){if(e!=null&&typeof e!=`object`)throw TypeError(`sink must be an object`);if(R!=null&&typeof R!=`object`)throw TypeError(`strategy must be an object`);let W=e?.type;if(W!==void 0)throw RangeError(`Invalid type: ${W}`);this[Bs]=createWritableStreamState();let Y=extractSizeAlgorithm(R?.size),X=extractHighWaterMark(R?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,e,X,Y)}get locked(){if(!tc(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(e){return tc(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){return tc(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamCloseQueuedOrInFlight(this)?Promise.reject(TypeError(`Failure closing WritableStream`)):writableStreamClose(this):Promise.reject(TypeError(`Invalid this`))}getWriter(){if(!tc(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[Hs]=`WritableStreamDefaultWriter`;[Bs];constructor(e){if(!tc(e))throw TypeError(`Expected a WritableStream`);this[Bs]={stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0},ready:{promise:void 0,resolve:void 0,reject:void 0}},setupWritableStreamDefaultWriter(this,e)}get closed(){return nc(this)?this[Bs].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!nc(this))throw TypeError(`Invalid this`);if(this[Bs].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return nc(this)?this[Bs].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(e){return nc(this)?this[Bs].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){if(!nc(this))return Promise.reject(TypeError(`Invalid this`));let{stream:e}=this[Bs];return e===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamCloseQueuedOrInFlight(e)?Promise.reject(TypeError(`Failure to close WritableStream`)):writableStreamDefaultWriterClose(this)}releaseLock(){if(!nc(this))throw TypeError(`Invalid this`);let{stream:e}=this[Bs];e!==void 0&&writableStreamDefaultWriterRelease(this)}write(e){return nc(this)?this[Bs].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterWrite(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`WritableStreamDefaultWriter`}},WritableStreamDefaultController=class{[Hs]=`WritableStreamDefaultController`;[Bs];constructor(e){if(e!==ec)throw TypeError(`Illegal constructor`)}[Xs](e){let R=this[Bs].abortAlgorithm(e);return writableStreamDefaultControllerClearAlgorithms(this),R}[$s](){resetQueue(this)}get signal(){if(!sc(this))throw TypeError(`Invalid this`);return this[Bs].abortController.signal}error(e){if(!sc(this))throw TypeError(`Invalid this`);this[Bs].stream[Bs].state===`writable`&&writableStreamDefaultControllerError(this,e)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const tc=isBrandCheck(`WritableStream`),nc=isBrandCheck(`WritableStreamDefaultWriter`),sc=isBrandCheck(`WritableStreamDefaultController`);function createEmptyPromiseRecord(){return{promise:void 0,resolve:void 0,reject:void 0}}function createWritableStreamState(){return{close:Promise.withResolvers(),closeRequest:createEmptyPromiseRecord(),inFlightWriteRequest:createEmptyPromiseRecord(),inFlightCloseRequest:createEmptyPromiseRecord(),pendingAbortRequest:{abort:createEmptyPromiseRecord(),reason:void 0,wasAlreadyErroring:!1},backpressure:!1,controller:void 0,state:`writable`,storedError:void 0,writeRequests:[],writer:void 0}}function isWritableStreamLocked(e){return e[Bs].writer!==void 0}function setupWritableStreamDefaultWriter(e,R){if(isWritableStreamLocked(R))throw TypeError(`WritableStream is locked`);switch(e[Bs].stream=R,R[Bs].writer=e,R[Bs].state){case`writable`:!writableStreamCloseQueuedOrInFlight(R)&&R[Bs].backpressure?e[Bs].ready=Promise.withResolvers():e[Bs].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Bs].close=Promise.withResolvers();break;case`erroring`:e[Bs].ready={promise:Promise.reject(R[Bs].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].ready.promise),e[Bs].close=Promise.withResolvers();break;case`closed`:e[Bs].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Bs].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:e[Bs].ready={promise:Promise.reject(R[Bs].storedError),resolve:void 0,reject:void 0},e[Bs].close={promise:Promise.reject(R[Bs].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].ready.promise),setPromiseHandled(e[Bs].close.promise)}}function writableStreamAbort(e,R){let{state:W,controller:Y}=e[Bs];if(W===`closed`||W===`errored`)return Promise.resolve();if(Y[Bs].abortController.abort(R),e[Bs].pendingAbortRequest.abort.promise!==void 0)return e[Bs].pendingAbortRequest.abort.promise;let X=!1;W===`erroring`&&(X=!0,R=void 0);let ie=Promise.withResolvers();return e[Bs].pendingAbortRequest={abort:ie,reason:R,wasAlreadyErroring:X},X||writableStreamStartErroring(e,R),ie.promise}function writableStreamClose(e){let{state:R,writer:W,backpressure:Y,controller:X}=e[Bs];if(R===`closed`||R===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));e[Bs].closeRequest=Promise.withResolvers();let{promise:ie}=e[Bs].closeRequest;return W!==void 0&&Y&&R===`writable`&&W[Bs].ready.resolve?.(),writableStreamDefaultControllerClose(X),ie}function writableStreamUpdateBackpressure(e,R){let{writer:W}=e[Bs];W!==void 0&&e[Bs].backpressure!==R&&(R?W[Bs].ready=Promise.withResolvers():W[Bs].ready.resolve?.()),e[Bs].backpressure=R}function writableStreamStartErroring(e,R){let{controller:W,writer:Y}=e[Bs];e[Bs].state=`erroring`,e[Bs].storedError=R,Y!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(Y,R),!writableStreamHasOperationMarkedInFlight(e)&&W[Bs].started&&writableStreamFinishErroring(e)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){e[Bs].closeRequest.promise!==void 0&&(e[Bs].closeRequest.reject?.(e[Bs].storedError),e[Bs].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(e[Bs].close.promise),e[Bs].close.reject?.(e[Bs].storedError);let{writer:R}=e[Bs];R!==void 0&&(setPromiseHandled(R[Bs].close.promise),R[Bs].close.reject?.(e[Bs].storedError))}function writableStreamMarkFirstWriteRequestInFlight(e){let R=e[Bs].writeRequests.shift();e[Bs].inFlightWriteRequest=R}function writableStreamMarkCloseRequestInFlight(e){e[Bs].inFlightCloseRequest=e[Bs].closeRequest,e[Bs].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(e){return e[Bs].inFlightWriteRequest.promise!==void 0||e[Bs].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(e,R){e[Bs].inFlightWriteRequest.reject?.(R),e[Bs].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(e,R)}function writableStreamFinishInFlightWrite(e){e[Bs].inFlightWriteRequest.resolve?.(),e[Bs].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(e,R){e[Bs].inFlightCloseRequest.reject?.(R),e[Bs].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Bs].pendingAbortRequest.abort.promise!==void 0&&(e[Bs].pendingAbortRequest.abort.reject?.(R),e[Bs].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(e,R)}function writableStreamFinishInFlightClose(e){e[Bs].inFlightCloseRequest.resolve?.(),e[Bs].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Bs].state===`erroring`&&(e[Bs].storedError=void 0,e[Bs].pendingAbortRequest.abort.promise!==void 0&&(e[Bs].pendingAbortRequest.abort.resolve?.(),e[Bs].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),e[Bs].state=`closed`,e[Bs].writer!==void 0&&e[Bs].writer[Bs].close.resolve?.(),e[Bs].close.resolve?.()}function writableStreamFinishErroring(e){e[Bs].state=`errored`,e[Bs].controller[$s]();let R=e[Bs].storedError;for(let W of e[Bs].writeRequests)W.reject?.(R);if(e[Bs].writeRequests=[],e[Bs].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}let W=e[Bs].pendingAbortRequest;if(e[Bs].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1},W.wasAlreadyErroring){W.abort.reject?.(R),writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}e[Bs].controller[Xs](W.reason).then(()=>{W.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)},R=>{W.abort.reject?.(R),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)})}function writableStreamDealWithRejection(e,R){if(e[Bs].state===`writable`){writableStreamStartErroring(e,R);return}writableStreamFinishErroring(e)}function writableStreamCloseQueuedOrInFlight(e){return e[Bs].closeRequest.promise!==void 0||e[Bs].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(e){let{promise:R,resolve:W,reject:Y}=Promise.withResolvers();return e[Bs].writeRequests.push({promise:R,resolve:W,reject:Y}),R}function writableStreamDefaultWriterWrite(e,R){let{stream:W}=e[Bs],{controller:Y}=W[Bs],X=writableStreamDefaultControllerGetChunkSize(Y,R);if(W!==e[Bs].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:ie}=W[Bs];if(ie===`errored`)return Promise.reject(W[Bs].storedError);if(writableStreamCloseQueuedOrInFlight(W)||ie===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(ie===`erroring`)return Promise.reject(W[Bs].storedError);let ae=writableStreamAddWriteRequest(W);return writableStreamDefaultControllerWrite(Y,R,X),ae}function writableStreamDefaultWriterRelease(e){let{stream:R}=e[Bs],W=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(e,W),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,W),R[Bs].writer=void 0,e[Bs].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(e){let{stream:R}=e[Bs];switch(R[Bs].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(R[Bs].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,R){e[Bs].ready.reject?(e[Bs].ready.reject(R),e[Bs].ready.resolve=void 0,e[Bs].ready.reject=void 0):e[Bs].ready={promise:Promise.reject(R),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,R){e[Bs].close.reject?(e[Bs].close.reject(R),e[Bs].close.resolve=void 0,e[Bs].close.reject=void 0):e[Bs].close={promise:Promise.reject(R),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(e){let{stream:R}=e[Bs],{state:W}=R[Bs];return writableStreamCloseQueuedOrInFlight(R)||W===`closed`?Promise.resolve():W===`errored`?Promise.reject(R[Bs].storedError):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterClose(e){return writableStreamClose(e[Bs].stream)}function writableStreamDefaultWriterAbort(e,R){return writableStreamAbort(e[Bs].stream,R)}function writableStreamDefaultControllerWrite(e,R,W){try{enqueueValueWithSize(e,R,W)}catch(R){writableStreamDefaultControllerErrorIfNeeded(e,R);return}let{stream:Y}=e[Bs];!writableStreamCloseQueuedOrInFlight(Y)&&Y[Bs].state===`writable`&&writableStreamUpdateBackpressure(Y,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerProcessWrite(e,R){let{stream:W,writeAlgorithm:Y}=e[Bs];writableStreamMarkFirstWriteRequestInFlight(W),Y(R,e).then(()=>{writableStreamFinishInFlightWrite(W);let{state:R}=W[Bs];dequeueValue(e),!writableStreamCloseQueuedOrInFlight(W)&&R===`writable`&&writableStreamUpdateBackpressure(W,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)},R=>{W[Bs].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(W,R)})}function writableStreamDefaultControllerProcessClose(e){let{closeAlgorithm:R,stream:W}=e[Bs];writableStreamMarkCloseRequestInFlight(W),dequeueValue(e);let Y=R();writableStreamDefaultControllerClearAlgorithms(e),Y.then(()=>writableStreamFinishInFlightClose(W),e=>writableStreamFinishInFlightCloseWithError(W,e))}function writableStreamDefaultControllerGetDesiredSize(e){return e[Bs].highWaterMark-e[Bs].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(e,R){let{sizeAlgorithm:W}=e[Bs];if(W===void 0)return 1;try{return W(R)}catch(R){return writableStreamDefaultControllerErrorIfNeeded(e,R),1}}function writableStreamDefaultControllerErrorIfNeeded(e,R){e[Bs].stream[Bs].state===`writable`&&writableStreamDefaultControllerError(e,R)}function writableStreamDefaultControllerError(e,R){writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(e[Bs].stream,R)}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,Zs,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerClearAlgorithms(e){e[Bs].writeAlgorithm=void 0,e[Bs].closeAlgorithm=void 0,e[Bs].abortAlgorithm=void 0,e[Bs].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){let{queue:R,started:W,stream:Y}=e[Bs];if(!W||Y[Bs].inFlightWriteRequest.promise!==void 0)return;if(Y[Bs].state===`erroring`){writableStreamFinishErroring(Y);return}if(!R.length)return;let X=peekQueueValue(e);X===Zs?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,X)}function setupWritableStreamDefaultControllerFromSink(e,R,W,Y){let X=new WritableStreamDefaultController(ec),ie=R?.start,ae=R?.write,le=R?.close,_e=R?.abort;setupWritableStreamDefaultController(e,X,ie?ie.bind(R,X):nonOpStart,ae?createPromiseCallback(`sink.write`,ae,R):nonOpWrite,le?createPromiseCallback(`sink.close`,le,R):nonOpCancel,_e?createPromiseCallback(`sink.abort`,_e,R):nonOpCancel,W,Y)}function setupWritableStreamDefaultController(e,R,W,Y,X,ie,ae,le){R[Bs]={abortAlgorithm:ie,closeAlgorithm:X,highWaterMark:ae,queue:[],queueTotalSize:0,abortController:new Ws,sizeAlgorithm:le,started:!1,stream:e,writeAlgorithm:Y},e[Bs].controller=R,writableStreamUpdateBackpressure(e,writableStreamDefaultControllerGetBackpressure(R));let _e=W();new Promise(e=>e(_e)).then(()=>{R[Bs].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(R)},W=>{R[Bs].started=!0,writableStreamDealWithRejection(e,W)})}function createWritableStream(e,R,W,Y,X=1,ie=()=>1){let ae=Object.create(WritableStream.prototype);return ae[Hs]=`WritableStream`,ae[Bs]=createWritableStreamState(),setupWritableStreamDefaultController(ae,new WritableStreamDefaultController(ec),e,R,W,Y,X,ie),ae}Ht();const uc=Symbol(`kCancel`),hc=Symbol(`kClose`),Ac=Symbol(`kChunk`),Ic=Symbol(`kError`),Hc=Symbol(`kPull`),el=Symbol(`kRelease`),nl=Symbol(`kSkipThrow`);let sl,fl;function lazyReadableReleasedError(){return sl||(sl=TypeError(`Reader released`),sl)}function lazyReadableReleasingError(){return fl||(fl=TypeError(`Releasing reader`),fl)}function createAbortError(){if(typeof globalThis.DOMException==`function`)return new DOMException(`The operation was aborted`,`AbortError`);let e=Error(`The operation was aborted`);return e.name=`AbortError`,e}function createReadableStreamState(){return{disturbed:!1,reader:void 0,state:`readable`,storedError:void 0,controller:void 0,closedPromise:Promise.withResolvers()}}var ReadableStream$1=class{static{__name$1(this,`ReadableStream`)}[Hs]=`ReadableStream`;[Bs];constructor(e={},R={}){if(e!=null&&typeof e!=`object`)throw TypeError(`source must be an object`);if(R!=null&&typeof R!=`object`)throw TypeError(`strategy must be an object`);this[Bs]=createReadableStreamState();let W=R?.size,Y=R?.highWaterMark,X=e?.type;if(X!==void 0){if(`${X}`==`bytes`){if(W!==void 0)throw RangeError(`strategy.size must not be set for a byte stream`);setupReadableByteStreamControllerFromSource(this,e,extractHighWaterMark(Y,0));return}throw RangeError(`Invalid type: ${X}`)}setupReadableStreamDefaultControllerFromSource(this,e,extractHighWaterMark(Y,1),extractSizeAlgorithm(W))}get locked(){if(!ml(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(e){return readableStreamFromIterable(e)}cancel(e=void 0){return ml(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,e):Promise.reject(TypeError(`Invalid this`))}getReader(e={}){if(!ml(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let R=e?.mode;if(R===void 0)return new ReadableStreamDefaultReader(this);if(`${R}`==`byob`)return new ReadableStreamBYOBReader(this);throw RangeError(`Invalid mode: ${R}`)}pipeThrough(e,R={}){if(!ml(this))throw TypeError(`Invalid this`);let W=e?.readable;if(!ml(W))throw TypeError(`transform.readable must be a ReadableStream`);let Y=e?.writable;if(!tc(Y))throw TypeError(`transform.writable must be a WritableStream`);if(R!=null&&typeof R!=`object`)throw TypeError(`options must be an object`);let X=R?.preventAbort,ie=R?.preventCancel,ae=R?.preventClose,le=R?.signal;if(le!==void 0&&!(le instanceof Object&&`aborted`in le))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(Y))throw TypeError(`The WritableStream is locked`);return setPromiseHandled(readableStreamPipeTo(this,Y,!!ae,!!X,!!ie,le)),W}pipeTo(e,R={}){try{if(!ml(this))throw TypeError(`Invalid this`);if(!tc(e))throw TypeError(`destination must be a WritableStream`);if(R!=null&&typeof R!=`object`)throw TypeError(`options must be an object`);let W=R?.preventAbort,Y=R?.preventCancel,X=R?.preventClose,ie=R?.signal;if(ie!==void 0&&!(ie instanceof Object&&`aborted`in ie))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(e))throw TypeError(`The WritableStream is locked`);return readableStreamPipeTo(this,e,!!X,!!W,!!Y,ie)}catch(e){return Promise.reject(e)}}tee(){if(!ml(this))throw TypeError(`Invalid this`);let e=this[Bs].controller;return yl(e)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(e={}){if(!ml(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let R=!!e?.preventCancel,W=new ReadableStreamDefaultReader(this),Y={done:!1,current:void 0},X=!1;function nextSteps(){if(Y.done)return Promise.resolve({done:!0,value:void 0});if(W[Bs].stream===void 0)return Promise.reject(TypeError(`The reader is not bound to a ReadableStream`));let{promise:e,resolve:R,reject:X}=Promise.withResolvers();return readableStreamDefaultReaderRead(W,{[Ac](e){Y.current=void 0,R({value:e,done:!1})},[hc](){Y.current=void 0,Y.done=!0,readableStreamReaderGenericRelease(W),R({done:!0,value:void 0})},[Ic](e){Y.current=void 0,Y.done=!0,readableStreamReaderGenericRelease(W),X(e)}}),e}async function returnSteps(e){if(Y.done)return{done:!0,value:e};if(Y.done=!0,W[Bs].stream===void 0)throw TypeError(`The reader is not bound to a ReadableStream`);if(!R){let R=readableStreamReaderGenericCancel(W,e);return readableStreamReaderGenericRelease(W),await R,{done:!0,value:e}}return readableStreamReaderGenericRelease(W),{done:!0,value:e}}return Object.setPrototypeOf({next(){return X||=(Y.current=Promise.resolve(),!0),Y.current=Y.current===void 0?nextSteps():Y.current.then(nextSteps,nextSteps),Y.current},return(e){return X=!0,Y.current=Y.current===void 0?returnSteps(e):Y.current.then(()=>returnSteps(e),()=>returnSteps(e)),Y.current},[Symbol.asyncIterator](){return this}},Us)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[Bs];constructor(){this[Bs]=Promise.withResolvers()}[Ac](e){this[Bs].resolve?.({value:e,done:!1})}[hc](){this[Bs].resolve?.({value:void 0,done:!0})}[Ic](e){this[Bs].reject?.(e)}get promise(){return this[Bs].promise}},ReadableStreamDefaultReader=class{[Hs]=`ReadableStreamDefaultReader`;[Bs];constructor(e){if(!ml(e))throw TypeError(`Expected a ReadableStream`);this[Bs]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,e)}read(){if(!vl(this))return Promise.reject(TypeError(`Invalid this`));if(this[Bs].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let e=this[Bs].stream,R=e[Bs].controller;if(e[Bs].state===`readable`&&_l(R)&&R[Bs].queue.length>0){e[Bs].disturbed=!0;let W=dequeueValue(R);return R[Bs].closeRequested&&!R[Bs].queue.length?(readableStreamDefaultControllerClearAlgorithms(R),readableStreamClose(e)):readableStreamDefaultControllerCallPullIfNeeded(R),Promise.resolve({value:W,done:!1})}let W=new DefaultReadRequest;return readableStreamDefaultReaderRead(this,W),W.promise}releaseLock(){if(!vl(this))throw TypeError(`Invalid this`);this[Bs].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return vl(this)?this[Bs].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return vl(this)?this[Bs].stream===void 0?Promise.reject(TypeError(`The reader is not attached to a stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamDefaultReader`}},ReadableStreamDefaultController=class{[Hs]=`ReadableStreamDefaultController`;[Bs];constructor(e){if(e!==nl)throw TypeError(`Illegal constructor`)}get desiredSize(){return readableStreamDefaultControllerGetDesiredSize(this)}close(){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerClose(this)}enqueue(e=void 0){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerEnqueue(this,e)}error(e=void 0){readableStreamDefaultControllerError(this,e)}[uc](e){return readableStreamDefaultControllerCancelSteps(this,e)}[Hc](e){readableStreamDefaultControllerPullSteps(this,e)}[el](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const ml=isBrandCheck(`ReadableStream`),_l=isBrandCheck(`ReadableStreamDefaultController`),vl=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(e){return e[Bs].reader!==void 0}function readableStreamCancel(e,R){switch(e[Bs].disturbed=!0,e[Bs].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(e[Bs].storedError)}readableStreamClose(e);let W=e[Bs].reader;if(W!==void 0&&readableStreamHasBYOBReader(e)){let e=W[Bs].readIntoRequests;W[Bs].readIntoRequests=[];for(let R=0;R<e.length;R++)e[R][hc](void 0)}return e[Bs].controller[uc](R).then(()=>{})}function readableStreamClose(e){e[Bs].state=`closed`,e[Bs].closedPromise.resolve();let{reader:R}=e[Bs];if(R!==void 0&&(R[Bs].close.resolve?.(),readableStreamHasDefaultReader(e))){for(let e=0;e<R[Bs].readRequests.length;e++)R[Bs].readRequests[e][hc]();R[Bs].readRequests=[]}}function readableStreamError(e,R){e[Bs].state=`errored`,e[Bs].storedError=R,setPromiseHandled(e[Bs].closedPromise.promise),e[Bs].closedPromise.reject(R);let{reader:W}=e[Bs];if(W!==void 0){if(setPromiseHandled(W[Bs].close.promise),W[Bs].close.reject?.(R),readableStreamHasDefaultReader(e)){for(let e=0;e<W[Bs].readRequests.length;e++)W[Bs].readRequests[e][Ic](R);W[Bs].readRequests=[]}else if(readableStreamHasBYOBReader(e)){for(let e=0;e<W[Bs].readIntoRequests.length;e++)W[Bs].readIntoRequests[e][Ic](R);W[Bs].readIntoRequests=[]}}}function readableStreamHasDefaultReader(e){let{reader:R}=e[Bs];return R===void 0?!1:R[Bs]!==void 0&&R[Hs]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(e){return e[Bs].reader[Bs].readRequests.length}function readableStreamFulfillReadRequest(e,R,W){let{reader:Y}=e[Bs],X=Y[Bs].readRequests.shift();W?X[hc]():X[Ac](R)}function readableStreamAddReadRequest(e,R){e[Bs].reader[Bs].readRequests.push(R)}function readableStreamReaderGenericCancel(e,R){let{stream:W}=e[Bs];return readableStreamCancel(W,R)}function readableStreamReaderGenericInitialize(e,R){switch(e[Bs].stream=R,R[Bs].reader=e,R[Bs].state){case`readable`:e[Bs].close=Promise.withResolvers();break;case`closed`:e[Bs].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:e[Bs].close={promise:Promise.reject(R[Bs].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].close.promise);break}}function readableStreamReaderGenericRelease(e){let{stream:R}=e[Bs],W=lazyReadableReleasedError();R[Bs].state===`readable`?e[Bs].close.reject?.(W):e[Bs].close={promise:Promise.reject(W),resolve:void 0,reject:void 0},setPromiseHandled(e[Bs].close.promise),R[Bs].controller[el](),R[Bs].reader=void 0,e[Bs].stream=void 0}function readableStreamDefaultReaderRelease(e){readableStreamReaderGenericRelease(e),readableStreamDefaultReaderErrorReadRequests(e,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(e,R){for(let W=0;W<e[Bs].readRequests.length;++W)e[Bs].readRequests[W][Ic](R);e[Bs].readRequests=[]}function readableStreamDefaultReaderRead(e,R){let{stream:W}=e[Bs];switch(W[Bs].disturbed=!0,W[Bs].state){case`closed`:R[hc]();break;case`errored`:R[Ic](W[Bs].storedError);break;case`readable`:W[Bs].controller[Hc](R);break}}function setupReadableStreamDefaultReader(e,R){if(isReadableStreamLocked(R))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(e,R),e[Bs].readRequests=[]}function readableStreamDefaultControllerClose(e){readableStreamDefaultControllerCanCloseOrEnqueue(e)&&(e[Bs].closeRequested=!0,e[Bs].queue.length||(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(e[Bs].stream)))}function readableStreamDefaultControllerEnqueue(e,R){if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return;let{stream:W}=e[Bs];if(isReadableStreamLocked(W)&&readableStreamGetNumReadRequests(W))readableStreamFulfillReadRequest(W,R,!1);else try{enqueueValueWithSize(e,R,e[Bs].sizeAlgorithm(R))}catch(R){throw readableStreamDefaultControllerError(e,R),R}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){let{stream:R}=e[Bs];return!e[Bs].closeRequested&&R[Bs].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(e){let{stream:R,highWaterMark:W,queueTotalSize:Y}=e[Bs];switch(R[Bs].state){case`errored`:return null;case`closed`:return 0;default:return W-Y}}function readableStreamDefaultControllerHasBackpressure(e){return!readableStreamDefaultControllerShouldCallPull(e)}function readableStreamDefaultControllerShouldCallPull(e){let{stream:R}=e[Bs];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e)||!e[Bs].started)return!1;if(isReadableStreamLocked(R)&&readableStreamGetNumReadRequests(R))return!0;let W=readableStreamDefaultControllerGetDesiredSize(e);return W!==null&&W>0}function readableStreamDefaultControllerCallPullIfNeeded(e){if(readableStreamDefaultControllerShouldCallPull(e)){if(e[Bs].pulling){e[Bs].pullAgain=!0;return}e[Bs].pulling=!0,e[Bs].pullAlgorithm(e).then(()=>{e[Bs].pulling=!1,e[Bs].pullAgain&&(e[Bs].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(e))},R=>readableStreamDefaultControllerError(e,R))}}function readableStreamDefaultControllerClearAlgorithms(e){e[Bs].pullAlgorithm=void 0,e[Bs].cancelAlgorithm=void 0,e[Bs].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(e,R){let{stream:W}=e[Bs];W[Bs].state===`readable`&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(W,R))}function readableStreamDefaultControllerCancelSteps(e,R){resetQueue(e);let W=e[Bs].cancelAlgorithm?.(R)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(e),W}function readableStreamDefaultControllerPullSteps(e,R){let{stream:W,queue:Y}=e[Bs];if(Y.length){let X=dequeueValue(e);e[Bs].closeRequested&&!Y.length?(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(W)):readableStreamDefaultControllerCallPullIfNeeded(e),R[Ac](X);return}readableStreamAddReadRequest(W,R),readableStreamDefaultControllerCallPullIfNeeded(e)}function setupReadableStreamDefaultController(e,R,W,Y,X,ie,ae){R[Bs]={cancelAlgorithm:X,closeRequested:!1,highWaterMark:ie,pullAgain:!1,pullAlgorithm:Y,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:ae,stream:e},e[Bs].controller=R;let le=W();new Promise(e=>e(le)).then(()=>{R[Bs].started=!0,readableStreamDefaultControllerCallPullIfNeeded(R)},e=>readableStreamDefaultControllerError(R,e))}function setupReadableStreamDefaultControllerFromSource(e,R,W,Y){let X=new ReadableStreamDefaultController(nl),ie=R?.start,ae=R?.pull,le=R?.cancel;setupReadableStreamDefaultController(e,X,ie?ie.bind(R,X):nonOpStart,ae?createPromiseCallback(`source.pull`,ae,R):nonOpPull,le?createPromiseCallback(`source.cancel`,le,R):nonOpCancel,W,Y)}function createReadableStream(e,R,W,Y=1,X=()=>1){let ie=Object.create(ReadableStream$1.prototype);return ie[Hs]=`ReadableStream`,ie[Bs]=createReadableStreamState(),setupReadableStreamDefaultController(ie,new ReadableStreamDefaultController(nl),e,R,W,Y,X),ie}function readableStreamFromIterable(e){let R,W=getIterator(e,`async`),Y=nonOpStart;async function pullAlgorithm(){let e=iteratorNext(W);return Promise.resolve(e).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.next() method must fulfill with an object`);e.done?readableStreamDefaultControllerClose(R[Bs].controller):readableStreamDefaultControllerEnqueue(R[Bs].controller,e.value)})}async function cancelAlgorithm(e){let R=W.iterator,Y=R.return;if(Y===void 0)return Promise.resolve();let X=Y.call(R,e);return Promise.resolve(X).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.return() method must fulfill with an object`)})}return R=createReadableStream(Y,pullAlgorithm,cancelAlgorithm,0),R}function readableStreamPipeTo(e,R,W,Y,X,ie){let ae,le;try{ae=new ReadableStreamDefaultReader(e),le=new WritableStreamDefaultWriter(R)}catch(e){return Promise.reject(e)}e[Bs].disturbed=!0;let _e=!1,{promise:ye,resolve:be,reject:Ce}=Promise.withResolvers(),Te={currentWrite:Promise.resolve()},Oe;function finalize(e,R){writableStreamDefaultWriterRelease(le),readableStreamReaderGenericRelease(ae),ie!==void 0&&Oe&&(ie.removeEventListener(`abort`,Oe),Oe=void 0),e?Ce(R):be()}async function waitForCurrentWrite(){let e=Te.currentWrite;await e,e!==Te.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(e,W,Y){if(_e)return;if(_e=!0,R[Bs].state===`writable`&&!writableStreamCloseQueuedOrInFlight(R)){waitForCurrentWrite().then(complete,e=>finalize(!0,e));return}complete();function complete(){e().then(()=>finalize(!!W,Y),e=>finalize(!0,e))}}function shutdown(e,W){if(!_e){if(_e=!0,R[Bs].state===`writable`&&!writableStreamCloseQueuedOrInFlight(R)){waitForCurrentWrite().then(()=>finalize(!!e,W),e=>finalize(!0,e));return}finalize(!!e,W)}}function abortAlgorithm(){let W;W=ie.reason&&ie.reason.name===`AbortError`?createAbortError():ie.reason;let ae=[];Y||ae.push(()=>R[Bs].state===`writable`?writableStreamAbort(R,W):Promise.resolve()),X||ae.push(()=>e[Bs].state===`readable`?readableStreamCancel(e,W):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(ae.map(e=>e())).then(()=>void 0),!0,W)}function watchErrored(e,R,W){e[Bs].state===`errored`?W(e[Bs].storedError):R.then(void 0,W)}function watchClosed(e,R,W){e[Bs].state===`closed`?W():R.then(W,()=>{})}class PipeToReadRequest{[Ac](e){Ct(()=>{Te.currentWrite=writableStreamDefaultWriterWrite(le,e),setPromiseHandled(Te.currentWrite),Ae.resolve(!1)})}[hc](){Ae.resolve(!0)}[Ic](e){Ae.reject(e)}}let Ae={resolve:null,reject:null};async function step(){if(_e||R[Bs].backpressure&&(await le[Bs].ready.promise,_e))return!0;let W=e[Bs].controller;if(e[Bs].state===`readable`&&_l(W)&&W[Bs].queue.length>0){for(;W[Bs].queue.length>0;){if(_e)return!0;let Y=dequeueValue(W);if(W[Bs].closeRequested&&!W[Bs].queue.length&&(readableStreamDefaultControllerClearAlgorithms(W),readableStreamClose(e)),Te.currentWrite=writableStreamDefaultWriterWrite(le,Y),setPromiseHandled(Te.currentWrite),R[Bs].backpressure||R[Bs].state!==`writable`||writableStreamCloseQueuedOrInFlight(R))break}return readableStreamDefaultControllerCallPullIfNeeded(W),e[Bs].state===`closed`}let{promise:Y,resolve:X,reject:ie}=Promise.withResolvers();return Ae={resolve:X,reject:ie},readableStreamDefaultReaderRead(ae,new PipeToReadRequest),Y}async function run(){for(;!await step(););}if(ie!==void 0){if(ie.aborted)return abortAlgorithm(),ye;Oe=abortAlgorithm,ie.addEventListener(`abort`,Oe,{once:!0})}if(setPromiseHandled(run()),watchErrored(e,ae[Bs].close.promise,e=>{if(!Y)return shutdownWithAnAction(()=>writableStreamAbort(R,e),!0,e);shutdown(!0,e)}),watchErrored(R,le[Bs].close.promise,R=>{if(!X)return shutdownWithAnAction(()=>readableStreamCancel(e,R),!0,R);shutdown(!0,R)}),watchClosed(e,ae[Bs].close.promise,()=>{if(!W)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(le));shutdown()}),writableStreamCloseQueuedOrInFlight(R)||R[Bs].state===`closed`){let R=TypeError(`Destination WritableStream is closed`);X?shutdown(!0,R):shutdownWithAnAction(()=>readableStreamCancel(e,R),!0,R)}return ye}function readableStreamDefaultTee(e,R){let W=new ReadableStreamDefaultReader(e),Y=!1,X=!1,ie=!1,ae,le,_e,ye,be=Promise.withResolvers();async function pullAlgorithm(){Y||(Y=!0,readableStreamDefaultReaderRead(W,{[Ac](e){Ct(()=>{Y=!1;let W=e,ae=e;if(!ie&&R)try{ae=structuredClone(ae)}catch{}X||readableStreamDefaultControllerEnqueue(_e[Bs].controller,W),ie||readableStreamDefaultControllerEnqueue(ye[Bs].controller,ae)})},[hc](){Ct(()=>{Y=!1,X||readableStreamDefaultControllerClose(_e[Bs].controller),ie||readableStreamDefaultControllerClose(ye[Bs].controller),(!X||!ie)&&be.resolve(void 0)})},[Ic](){Y=!1}}))}function cancel1Algorithm(R){if(X=!0,ae=R,ie){let R=[ae,le];be.resolve(readableStreamCancel(e,R))}return be.promise}function cancel2Algorithm(R){if(ie=!0,le=R,X){let R=[ae,le];be.resolve(readableStreamCancel(e,R))}return be.promise}return _e=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),ye=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),W[Bs].close.promise.then(void 0,e=>{readableStreamDefaultControllerError(_e[Bs].controller,e),readableStreamDefaultControllerError(ye[Bs].controller,e),(!X||!ie)&&be.resolve(void 0)}),[_e,ye]}var BYOBReadIntoRequest=class{[Bs];constructor(){this[Bs]=Promise.withResolvers()}[Ac](e){this[Bs].resolve?.({value:e,done:!1})}[hc](e){this[Bs].resolve?.({value:e,done:!0})}[Ic](e){this[Bs].reject?.(e)}get promise(){return this[Bs].promise}},ReadableStreamBYOBReader=class{[Hs]=`ReadableStreamBYOBReader`;[Bs];constructor(e){if(!ml(e))throw TypeError(`Expected a ReadableStream`);this[Bs]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,e)}read(e,R={}){if(!bl(this))return Promise.reject(TypeError(`Invalid this`));if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))return Promise.reject(TypeError(`view must be an ArrayBufferView`));let W=e.buffer,Y=e.byteLength;if(Y===0)return Promise.reject(TypeError(`view must have non-zero byteLength`));if(W.byteLength===0)return isDetachedBuffer(W)?Promise.reject(TypeError(`view's buffer has been detached`)):Promise.reject(TypeError(`view's buffer must have non-zero byteLength`));let X=R?.min??1;if(typeof X!=`number`||X<1||!Number.isInteger(X)||Number.isNaN(X))return Promise.reject(TypeError(`options.min must be a positive integer`));let ie=e[Symbol.toStringTag];if(ie!==void 0&&ie!==`DataView`){if(X>e.length)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`))}else if(X>Y)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`));if(this[Bs].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let ae=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,e,X,ae),ae.promise}releaseLock(){if(!bl(this))throw TypeError(`Invalid this`);this[Bs].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return bl(this)?this[Bs].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return bl(this)?this[Bs].stream===void 0?Promise.reject(TypeError(`Reader has no associated stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamBYOBReader`}},ReadableStreamBYOBRequest=class{[Hs]=`ReadableStreamBYOBRequest`;[Bs];constructor(e){if(e!==nl)throw TypeError(`Illegal constructor`)}get view(){if(!xl(this))throw TypeError(`Invalid this`);return this[Bs].view}respond(e){if(!xl(this))throw TypeError(`Invalid this`);if(this[Bs].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(e=+e,!Number.isInteger(e)||e<0||!Number.isFinite(e))throw RangeError(`bytesWritten must be a non-negative integer`);let R=this[Bs].view;if(isDetachedBuffer(R.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[Bs].controller,e)}respondWithNewView(e){if(!xl(this))throw TypeError(`Invalid this`);if(this[Bs].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`view must be an ArrayBufferView`);if(isDetachedBuffer(e.buffer))throw TypeError(`The given view's buffer has been detached`);readableByteStreamControllerRespondWithNewView(this[Bs].controller,e)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[Hs]=`ReadableByteStreamController`;[Bs];constructor(e){if(e!==nl)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!yl(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!yl(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!yl(this))throw TypeError(`Invalid this`);if(this[Bs].closeRequested)throw TypeError(`Close already requested`);if(this[Bs].stream[Bs].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(e){if(!yl(this))throw TypeError(`Invalid this`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`chunk must be an ArrayBufferView`);if(e.byteLength===0)throw TypeError(`chunk length must be non-zero`);if(e.buffer.byteLength===0)throw TypeError(`chunk's buffer length must be non-zero`);if(this[Bs].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[Bs].stream[Bs].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,e)}error(e=void 0){if(!yl(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,e)}[uc](e){return readableByteStreamControllerCancelSteps(this,e)}[Hc](e){readableByteStreamControllerPullSteps(this,e)}[el](){if(this[Bs].pendingPullIntos.length>0){let e=this[Bs].pendingPullIntos[0];e.readerType=`none`,this[Bs].pendingPullIntos=[e]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const yl=isBrandCheck(`ReadableByteStreamController`),bl=isBrandCheck(`ReadableStreamBYOBReader`),xl=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(e){let{reader:R}=e[Bs];return R===void 0?!1:R[Bs]!==void 0&&R[Hs]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(e){return e[Bs].reader[Bs].readIntoRequests.length}function readableStreamAddReadIntoRequest(e,R){e[Bs].reader[Bs].readIntoRequests.push(R)}function readableStreamFulfillReadIntoRequest(e,R,W){let{reader:Y}=e[Bs],X=Y[Bs].readIntoRequests.shift();W?X[hc](R):X[Ac](R)}function setupReadableStreamBYOBReader(e,R){if(isReadableStreamLocked(R))throw TypeError(`ReadableStream is locked`);if(!yl(R[Bs].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(e,R),e[Bs].readIntoRequests=[]}function readableStreamBYOBReaderRead(e,R,W,Y){let{stream:X}=e[Bs];X[Bs].disturbed=!0,X[Bs].state===`errored`?Y[Ic](X[Bs].storedError):readableByteStreamControllerPullInto(X[Bs].controller,R,W,Y)}function readableStreamBYOBReaderRelease(e){readableStreamReaderGenericRelease(e);let R=TypeError(`Reader was released`);for(let W=0;W<e[Bs].readIntoRequests.length;W++)e[Bs].readIntoRequests[W][Ic](R);e[Bs].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(e){e[Bs].pullAlgorithm=void 0,e[Bs].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[Bs].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(e){let R=e[Bs].byobRequest;R!=null&&(R[Bs].controller=void 0,R[Bs].view=null,e[Bs].byobRequest=null)}function readableByteStreamControllerError(e,R){let{stream:W}=e[Bs];W[Bs].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(W,R))}function readableByteStreamControllerGetDesiredSize(e){let R=e[Bs].stream[Bs].state;return R===`errored`?null:R===`closed`?0:e[Bs].highWaterMark-e[Bs].queueTotalSize}function readableByteStreamControllerShouldCallPull(e){let{stream:R}=e[Bs];if(R[Bs].state!==`readable`||e[Bs].closeRequested||!e[Bs].started)return!1;if(readableStreamHasDefaultReader(R)&&readableStreamGetNumReadRequests(R)>0||readableStreamHasBYOBReader(R)&&readableStreamGetNumReadIntoRequests(R)>0)return!0;let W=readableByteStreamControllerGetDesiredSize(e);return W!==null&&W>0}function readableByteStreamControllerCallPullIfNeeded(e){if(readableByteStreamControllerShouldCallPull(e)){if(e[Bs].pulling){e[Bs].pullAgain=!0;return}e[Bs].pulling=!0,e[Bs].pullAlgorithm(e).then(()=>{e[Bs].pulling=!1,e[Bs].pullAgain&&(e[Bs].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(e))},R=>readableByteStreamControllerError(e,R))}}function readableByteStreamControllerHandleQueueDrain(e){e[Bs].queueTotalSize===0&&e[Bs].closeRequested?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[Bs].stream)):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,R,W,Y){e[Bs].queue.push({buffer:R,byteOffset:W,byteLength:Y}),e[Bs].queueTotalSize+=Y}function readableByteStreamControllerEnqueueClonedChunkToQueue(e,R,W,Y){let X;try{X=R.slice(W,W+Y)}catch(R){readableByteStreamControllerError(e,R);return}readableByteStreamControllerEnqueueChunkToQueue(e,X,0,Y)}function readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,R){R.bytesFilled>0&&readableByteStreamControllerEnqueueClonedChunkToQueue(e,R.buffer,R.byteOffset,R.bytesFilled),readableByteStreamControllerShiftPendingPullInto(e)}function readableByteStreamControllerShiftPendingPullInto(e){return e[Bs].pendingPullIntos.shift()}function readableByteStreamControllerFillHeadPullIntoDescriptor(e,R,W){W.bytesFilled+=R}function readableByteStreamControllerConvertPullIntoDescriptor(e){let R=e.bytesFilled,W=e.elementSize,Y=transferArrayBuffer(e.buffer);return e.buffer=Y,new e.viewConstructor(Y,e.byteOffset,R/W)}function readableByteStreamControllerCommitPullIntoDescriptor(e,R){let W=!1;e[Bs].state===`closed`&&(W=!0);let Y=readableByteStreamControllerConvertPullIntoDescriptor(R);R.readerType==="default"?readableStreamFulfillReadRequest(e,Y,W):readableStreamFulfillReadIntoRequest(e,Y,W)}function readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,R){let W=Math.min(e[Bs].queueTotalSize,R.byteLength-R.bytesFilled),Y=R.bytesFilled+W,X=W,ie=!1,ae=Y-Y%R.elementSize;ae>=R.minimumFill&&(X=ae-R.bytesFilled,ie=!0);let le=e[Bs].queue;for(;X>0;){let W=le[0],Y=Math.min(X,W.byteLength),ie=R.byteOffset+R.bytesFilled,ae=new Uint8Array(R.buffer,ie,Y),_e=new Uint8Array(W.buffer,W.byteOffset,Y);ae.set(_e),W.byteLength===Y?le.shift():(W.byteOffset+=Y,W.byteLength-=Y),e[Bs].queueTotalSize-=Y,readableByteStreamControllerFillHeadPullIntoDescriptor(e,Y,R),X-=Y}return ie}function readableByteStreamControllerFillReadRequestFromQueue(e,R){let W=e[Bs].queue.shift();e[Bs].queueTotalSize-=W.byteLength,readableByteStreamControllerHandleQueueDrain(e);let Y=new Uint8Array(W.buffer,W.byteOffset,W.byteLength);R[Ac](Y)}function readableByteStreamControllerProcessReadRequestsUsingQueue(e){let R=e[Bs].stream[Bs].reader;for(;R[Bs].readRequests.length!==0;){if(e[Bs].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(e,R[Bs].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){for(;e[Bs].pendingPullIntos.length!==0;){if(e[Bs].queueTotalSize===0)return;let R=e[Bs].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,R)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[Bs].stream,R))}}function readableByteStreamControllerGetBYOBRequest(e){if(e[Bs].byobRequest===null&&e[Bs].pendingPullIntos.length!==0){let R=e[Bs].pendingPullIntos[0],W=new Uint8Array(R.buffer,R.byteOffset+R.bytesFilled,R.byteLength-R.bytesFilled),Y=new ReadableStreamBYOBRequest(nl);Y[Bs]={controller:e,view:W},e[Bs].byobRequest=Y}return e[Bs].byobRequest}function readableByteStreamControllerEnqueue(e,R){let{stream:W}=e[Bs];if(e[Bs].closeRequested||W[Bs].state!==`readable`)return;let Y=R.buffer,X=R.byteLength,ie=R.byteOffset;if(isDetachedBuffer(Y))throw TypeError(`chunk's buffer is detached`);let ae=transferArrayBuffer(Y);if(e[Bs].pendingPullIntos.length!==0){let R=e[Bs].pendingPullIntos[0];if(isDetachedBuffer(R.buffer))throw TypeError(`BYOB request's buffer has been detached`);readableByteStreamControllerInvalidateBYOBRequest(e),R.buffer=transferArrayBuffer(R.buffer),R.readerType===`none`&&readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,R)}readableStreamHasDefaultReader(W)?(readableByteStreamControllerProcessReadRequestsUsingQueue(e),readableStreamGetNumReadRequests(W)===0?readableByteStreamControllerEnqueueChunkToQueue(e,ae,ie,X):(e[Bs].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(e),readableStreamFulfillReadRequest(W,new Uint8Array(ae,ie,X),!1))):readableStreamHasBYOBReader(W)?(readableByteStreamControllerEnqueueChunkToQueue(e,ae,ie,X),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,ae,ie,X),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerClose(e){let{stream:R}=e[Bs];if(!(e[Bs].closeRequested||R[Bs].state!==`readable`)){if(e[Bs].queueTotalSize>0){e[Bs].closeRequested=!0;return}if(e[Bs].pendingPullIntos.length!==0){let R=e[Bs].pendingPullIntos[0];if(R.bytesFilled%R.elementSize!==0){let R=TypeError(`Insufficient bytes to fill elements in the given buffer`);throw readableByteStreamControllerError(e,R),R}}readableByteStreamControllerClearAlgorithms(e),readableStreamClose(R)}}function readableByteStreamControllerPullInto(e,R,W,Y){let X=e[Bs].stream,ie=R[Symbol.toStringTag],ae,le;if(ie===void 0||ie===`DataView`)ae=DataView,le=1;else{let e=typedArrayConstructorByTag(ie);if(!e){Y[Ic](TypeError(`Unsupported typed array: ${ie}`));return}ae=e,le=elementSizeByTag(ie)}let _e=R.buffer,ye=R.byteLength,be=R.byteOffset,Ce=W*le,Te;try{Te=transferArrayBuffer(_e)}catch(e){Y[Ic](e);return}let Oe={buffer:Te,bufferByteLength:Te.byteLength,byteOffset:be,byteLength:ye,bytesFilled:0,minimumFill:Ce,elementSize:le,viewConstructor:ae,readerType:`byob`};if(e[Bs].pendingPullIntos.length!==0){e[Bs].pendingPullIntos.push(Oe),readableStreamAddReadIntoRequest(X,Y);return}if(X[Bs].state===`closed`){let e=new ae(Oe.buffer,Oe.byteOffset,0);Y[hc](e);return}if(e[Bs].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,Oe)){let R=readableByteStreamControllerConvertPullIntoDescriptor(Oe);readableByteStreamControllerHandleQueueDrain(e),Y[Ac](R);return}if(e[Bs].closeRequested){let R=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(e,R),Y[Ic](R);return}}e[Bs].pendingPullIntos.push(Oe),readableStreamAddReadIntoRequest(X,Y),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespond(e,R){let W=e[Bs].pendingPullIntos[0];if(e[Bs].stream[Bs].state===`closed`){if(R!==0)throw TypeError(`bytesWritten must be 0 when calling respond() on a closed stream`)}else{if(R===0)throw TypeError(`bytesWritten must be greater than 0 when calling respond() on a readable stream`);if(W.bytesFilled+R>W.byteLength)throw RangeError(`bytesWritten out of range`)}W.buffer=transferArrayBuffer(W.buffer),readableByteStreamControllerRespondInternal(e,R)}function readableByteStreamControllerRespondWithNewView(e,R){let W=e[Bs].pendingPullIntos[0],Y=e[Bs].stream[Bs].state,X=R.byteLength,ie=R.byteOffset,ae=R.buffer;if(Y===`closed`){if(X!==0)throw TypeError(`view's length must be 0 when calling respondWithNewView() on a closed stream`)}else if(X===0)throw TypeError(`view's length must be greater than 0 when calling respondWithNewView() on a readable stream`);if(W.byteOffset+W.bytesFilled!==ie)throw RangeError(`The region specified by view does not match byobRequest`);if(W.bufferByteLength!==ae.byteLength)throw RangeError(`The buffer of view has different capacity than byobRequest`);if(W.bytesFilled+X>W.byteLength)throw RangeError(`The region specified by view is larger than byobRequest`);W.buffer=transferArrayBuffer(ae),readableByteStreamControllerRespondInternal(e,X)}function readableByteStreamControllerRespondInternal(e,R){let W=e[Bs].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(e),e[Bs].stream[Bs].state===`closed`?readableByteStreamControllerRespondInClosedState(e,W):readableByteStreamControllerRespondInReadableState(e,R,W),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondInClosedState(e,R){R.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(e);let W=e[Bs].stream;if(readableStreamHasBYOBReader(W))for(;readableStreamGetNumReadIntoRequests(W)>0;)readableByteStreamControllerCommitPullIntoDescriptor(W,readableByteStreamControllerShiftPendingPullInto(e))}function readableByteStreamControllerRespondInReadableState(e,R,W){if(readableByteStreamControllerFillHeadPullIntoDescriptor(e,R,W),W.readerType===`none`){readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,W),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e);return}if(W.bytesFilled<W.minimumFill)return;readableByteStreamControllerShiftPendingPullInto(e);let Y=W.bytesFilled%W.elementSize;if(Y>0){let R=W.byteOffset+W.bytesFilled;readableByteStreamControllerEnqueueClonedChunkToQueue(e,W.buffer,R-Y,Y)}W.bytesFilled-=Y,readableByteStreamControllerCommitPullIntoDescriptor(e[Bs].stream,W),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerCancelSteps(e,R){readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e);let W=e[Bs].cancelAlgorithm?.(R)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(e),W}function readableByteStreamControllerPullSteps(e,R){let W=e[Bs].stream;if(e[Bs].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(e,R);return}let Y=e[Bs].autoAllocateChunkSize;if(Y!==void 0){let W;try{W=new ArrayBuffer(Y)}catch(e){R[Ic](e);return}let X={buffer:W,bufferByteLength:Y,byteOffset:0,byteLength:Y,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};e[Bs].pendingPullIntos.push(X)}readableStreamAddReadRequest(W,R),readableByteStreamControllerCallPullIfNeeded(e)}function setupReadableByteStreamController(e,R,W,Y,X,ie,ae){R[Bs]={cancelAlgorithm:X,closeRequested:!1,highWaterMark:ie,pullAgain:!1,pullAlgorithm:Y,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:e,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:ae},e[Bs].controller=R;let le=W();new Promise(e=>e(le)).then(()=>{R[Bs].started=!0,readableByteStreamControllerCallPullIfNeeded(R)},e=>readableByteStreamControllerError(R,e))}function setupReadableByteStreamControllerFromSource(e,R,W){let Y=new ReadableByteStreamController(nl),X=R?.start,ie=R?.pull,ae=R?.cancel,le=R?.autoAllocateChunkSize;if(le!==void 0&&(le===0||!Number.isInteger(le)||le<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(e,Y,X?X.bind(R,Y):nonOpStart,ie?createPromiseCallback(`source.pull`,ie,R):nonOpPull,ae?createPromiseCallback(`source.cancel`,ae,R):nonOpCancel,W,le)}function readableByteStreamTee(e){let R=new ReadableStreamDefaultReader(e),W=!1,Y=!1,X=!1,ie,ae,le=Promise.withResolvers(),_e,ye,be,Ce;function pullAlgorithm(){return W?Promise.resolve():(W=!0,R.read().then(e=>{if(W=!1,e.done){Y||be.close(),X||Ce.close();return}let R=e.value,ie=new Uint8Array(R.buffer.slice(R.byteOffset,R.byteOffset+R.byteLength));Y||be.enqueue(ie),X||Ce.enqueue(new Uint8Array(ie))},()=>{}),Promise.resolve())}return _e=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(R){if(Y=!0,ie=R,X){let R=readableStreamCancel(e,[ie,ae]);return le.resolve(),R}return le.promise}}),ye=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(R){if(X=!0,ae=R,Y){let R=readableStreamCancel(e,[ie,ae]);return le.resolve(),R}return le.promise}}),be=_e[Bs].controller,Ce=ye[Bs].controller,R.closed.catch(e=>{be.error(e),Ce.error(e),(!Y||!X)&&le.resolve()}),[_e,ye]}const Sl=Symbol(`kSkipThrow`);var TransformStream=class{[Hs]=`TransformStream`;[Bs];constructor(e={},R={},W={}){if(e!=null&&typeof e!=`object`)throw TypeError(`transformer must be an object`);if(R!=null&&typeof R!=`object`)throw TypeError(`writableStrategy must be an object`);if(W!=null&&typeof W!=`object`)throw TypeError(`readableStrategy must be an object`);let Y=e?.readableType,X=e?.writableType,ie=e?.start;if(Y!==void 0)throw RangeError(`Invalid readableType: ${Y}`);if(X!==void 0)throw RangeError(`Invalid writableType: ${X}`);let ae=extractHighWaterMark(W?.highWaterMark,0),le=extractSizeAlgorithm(W?.size),_e=extractHighWaterMark(R?.highWaterMark,1),ye=extractSizeAlgorithm(R?.size),be=Promise.withResolvers();initializeTransformStream(this,be,_e,ye,ae,le),setupTransformStreamDefaultControllerFromTransformer(this,e),ie===void 0?be.resolve():be.resolve(ie.call(e,this[Bs].controller))}get readable(){if(!Cl(this))throw TypeError(`Invalid this`);return this[Bs].readable}get writable(){if(!Cl(this))throw TypeError(`Invalid this`);return this[Bs].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[Hs]=`TransformStreamDefaultController`;[Bs];constructor(e){if(e!==Sl)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!wl(this))throw TypeError(`Invalid this`);let{stream:e}=this[Bs],{readable:R}=e[Bs],W=R[Bs].controller;return readableStreamDefaultControllerGetDesiredSize(W)}enqueue(e){if(!wl(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!wl(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,e)}terminate(){if(!wl(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const Cl=isBrandCheck(`TransformStream`),wl=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(e,R){transformStreamDefaultControllerEnqueue(R,e)}function initializeTransformStream(e,R,W,Y,X,ie){let startAlgorithm=()=>R.promise,ae=createWritableStream(startAlgorithm,R=>transformStreamDefaultSinkWriteAlgorithm(e,R),()=>transformStreamDefaultSinkCloseAlgorithm(e),R=>transformStreamDefaultSinkAbortAlgorithm(e,R),W,Y);e[Bs]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(e),R=>transformStreamDefaultSourceCancelAlgorithm(e,R),X,ie),writable:ae,controller:void 0,backpressure:void 0,backpressureChange:{promise:void 0,resolve:void 0,reject:void 0}},transformStreamSetBackpressure(e,!0)}function transformStreamError(e,R){let{readable:W}=e[Bs];readableStreamDefaultControllerError(W[Bs].controller,R),transformStreamErrorWritableAndUnblockWrite(e,R)}function transformStreamErrorWritableAndUnblockWrite(e,R){let{controller:W,writable:Y}=e[Bs];transformStreamDefaultControllerClearAlgorithms(W),writableStreamDefaultControllerErrorIfNeeded(Y[Bs].controller,R),transformStreamUnblockWrite(e)}function transformStreamUnblockWrite(e){e[Bs].backpressure&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,R){e[Bs].backpressureChange.promise!==void 0&&e[Bs].backpressureChange.resolve?.(),e[Bs].backpressureChange=Promise.withResolvers(),e[Bs].backpressure=R}function setupTransformStreamDefaultController(e,R,W,Y,X){R[Bs]={stream:e,transformAlgorithm:W,flushAlgorithm:Y,cancelAlgorithm:X,finishPromise:void 0},e[Bs].controller=R}function setupTransformStreamDefaultControllerFromTransformer(e,R){let W=new TransformStreamDefaultController(Sl),Y=R?.transform,X=R?.flush,ie=R?.cancel;setupTransformStreamDefaultController(e,W,Y?createPromiseCallback(`transformer.transform`,Y,R):defaultTransformAlgorithm,X?createPromiseCallback(`transformer.flush`,X,R):nonOpFlush,ie?createPromiseCallback(`transformer.cancel`,ie,R):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(e){e[Bs].transformAlgorithm=void 0,e[Bs].flushAlgorithm=void 0,e[Bs].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(e,R){let{stream:W}=e[Bs],{readable:Y}=W[Bs],X=Y[Bs].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(X))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(X,R)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(W,e),Y[Bs].storedError}readableStreamDefaultControllerHasBackpressure(X)!==W[Bs].backpressure&&transformStreamSetBackpressure(W,!0)}function transformStreamDefaultControllerError(e,R){transformStreamError(e[Bs].stream,R)}async function transformStreamDefaultControllerPerformTransform(e,R){try{let W=e[Bs].transformAlgorithm;if(W===void 0)return;await W(R,e)}catch(R){throw transformStreamError(e[Bs].stream,R),R}}function transformStreamDefaultControllerTerminate(e){let{stream:R}=e[Bs],{readable:W}=R[Bs];readableStreamDefaultControllerClose(W[Bs].controller),transformStreamErrorWritableAndUnblockWrite(R,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(e,R){let{controller:W}=e[Bs];return e[Bs].backpressure?e[Bs].backpressureChange.promise.then(()=>{let{writable:Y}=e[Bs];if(Y[Bs].state===`erroring`)throw Y[Bs].storedError;return transformStreamDefaultControllerPerformTransform(W,R)}):transformStreamDefaultControllerPerformTransform(W,R)}async function transformStreamDefaultSinkAbortAlgorithm(e,R){let{controller:W,readable:Y}=e[Bs];if(W[Bs].finishPromise!==void 0)return W[Bs].finishPromise;let{promise:X,resolve:ie,reject:ae}=Promise.withResolvers();W[Bs].finishPromise=X;let le=W[Bs].cancelAlgorithm(R);return transformStreamDefaultControllerClearAlgorithms(W),le.then(()=>{Y[Bs].state===`errored`?ae(Y[Bs].storedError):(readableStreamDefaultControllerError(Y[Bs].controller,R),ie())},e=>{readableStreamDefaultControllerError(Y[Bs].controller,e),ae(e)}),W[Bs].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(e){let{readable:R,controller:W}=e[Bs];if(W[Bs].finishPromise!==void 0)return W[Bs].finishPromise;let{promise:Y,resolve:X,reject:ie}=Promise.withResolvers();W[Bs].finishPromise=Y;let ae=W[Bs].flushAlgorithm(W);return transformStreamDefaultControllerClearAlgorithms(W),ae.then(()=>{R[Bs].state===`errored`?ie(R[Bs].storedError):(readableStreamDefaultControllerClose(R[Bs].controller),X())},e=>{readableStreamDefaultControllerError(R[Bs].controller,e),ie(e)}),W[Bs].finishPromise}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[Bs].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(e,R){let{controller:W,writable:Y}=e[Bs];if(W[Bs].finishPromise!==void 0)return W[Bs].finishPromise;let{promise:X,resolve:ie,reject:ae}=Promise.withResolvers();W[Bs].finishPromise=X;let le=W[Bs].cancelAlgorithm(R);return transformStreamDefaultControllerClearAlgorithms(W),le.then(()=>{Y[Bs].state===`errored`?ae(Y[Bs].storedError):(writableStreamDefaultControllerErrorIfNeeded(Y[Bs].controller,R),transformStreamUnblockWrite(e),ie())},R=>{writableStreamDefaultControllerErrorIfNeeded(Y[Bs].controller,R),transformStreamUnblockWrite(e),ae(R)}),W[Bs].finishPromise}const Tl=Object.defineProperty(e=>e.byteLength,"name",{value:`size`}),El=Object.defineProperty(()=>1,"name",{value:`size`});var ByteLengthQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return Tl}get[Symbol.toStringTag](){return`ByteLengthQueuingStrategy`}},CountQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return El}get[Symbol.toStringTag](){return`CountQueuingStrategy`}},TextEncoderStream=class{#e=null;#t=new TextEncoder;#n;constructor(){this.#n=new TransformStream({transform:(e,R)=>{if(e=String(e),e===``)return;this.#e!==null&&(e=this.#e+e);let W=e.charCodeAt(e.length-1);55296<=W&&W<=56319?(this.#e=e.slice(-1),e=e.slice(0,-1)):this.#e=null,e&&R.enqueue(this.#t.encode(e))},flush:e=>{this.#e!==null&&e.enqueue(new Uint8Array([239,191,189]))}})}get encoding(){return`utf-8`}get readable(){return this.#n.readable}get writable(){return this.#n.writable}};function hasStreamingSupport(){try{return new TextDecoder().decode(new Uint8Array([195]),{stream:!0}),!0}catch{return!1}}const Al=hasStreamingSupport();function incompleteUtf8Tail(e){let R=e.length;if(R===0)return 0;for(let W=1;W<=Math.min(3,R);W++){let Y=e[R-W];if(!(Y&128))return 0;if((Y&192)!=128){let e;if((Y&224)==192)e=2;else if((Y&240)==224)e=3;else if((Y&248)==240)e=4;else return 0;return W<e?W:0}}return 0}var TextDecoderStream=class{#e;#t;constructor(e,R){if(this.#e=new TextDecoder(e,R),Al)this.#t=new TransformStream({transform:(e,R)=>{let W=toUint8Array$2(e),Y=this.#e.decode(W,{stream:!0});Y&&R.enqueue(Y)},flush:e=>{let R=this.#e.decode();R&&e.enqueue(R)},cancel:()=>{this.#e.decode()}});else{let e=new Uint8Array;this.#t=new TransformStream({transform:(R,W)=>{let Y=toUint8Array$2(R),X;e.length>0?(X=new Uint8Array(e.length+Y.length),X.set(e,0),X.set(Y,e.length)):X=Y;let ie=incompleteUtf8Tail(X),ae;if(ie>0?(ae=X.slice(0,X.length-ie),e=X.slice(X.length-ie)):(ae=X,e=new Uint8Array),ae.length>0){let e=this.#e.decode(ae);e&&W.enqueue(e)}},flush:R=>{if(e.length>0){let W=this.#e.decode(e);W&&R.enqueue(W),e=new Uint8Array}},cancel:()=>{e=new Uint8Array}})}}get encoding(){return this.#e.encoding}get fatal(){return this.#e.fatal}get ignoreBOM(){return this.#e.ignoreBOM}get readable(){return this.#t.readable}get writable(){return this.#t.writable}};function toUint8Array$2(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`chunk must be a BufferSource`)}__name$1(toUint8Array$2,`toUint8Array`);function isNativeStreamUsable$3(e,R){try{return typeof e==`function`?typeof e.prototype?.[R]==`function`:!1}catch{return!1}}__name$1(isNativeStreamUsable$3,`isNativeStreamUsable`);const jl=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,Ml=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,Nl=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,Fl=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,Ll=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,Rl=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,zl=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;var Bl=__esmMin(()=>{Ht()});function _setPipeImpl(e){Vl=e}var Vl,Stream_,Gl=__esmMin(()=>{ls(),Stream_=class extends cs{constructor(e){super(e)}pipe(e,R){return Vl(this,e,R)}}});function getDefaultHighWaterMark(e){return e?Jl:ql}function setDefaultHighWaterMark(e,R){if(typeof R!=`number`||R<0||Number.isNaN(R))throw TypeError(`Invalid highWaterMark: ${R}`);e?Jl=R:ql=R}function validateHighWaterMark(e,R){if(R!==void 0&&(typeof R!=`number`||Number.isNaN(R))){let W=TypeError(`The value of "${e}" is invalid. Received ${R}`);throw W.code=`ERR_INVALID_ARG_VALUE`,W}}var ql,Jl,Yl=__esmMin(()=>{ql=16384,Jl=16});function chunkLength(e){if(e==null)return 1;let R=e.length;return typeof R==`number`?R:1}function sliceChunk(e,R,W){if(typeof e==`string`)return W===void 0?e.slice(R):e.slice(R,W);let Y=e.slice;return typeof Y==`function`?Y.call(e,R,W):e}var Xl,Zl=__esmMin(()=>{Gl(),Yl(),Ht(),Xl=class Readable_ extends Stream_{readable=!0;readableFlowing=null;readableLength=0;readableHighWaterMark;readableEncoding;readableObjectMode;readableEnded=!1;readableAborted=!1;destroyed=!1;_pipeDests=[];_buffer=[];_readableState={ended:!1,endEmitted:!1,reading:!1,constructed:!0,highWaterMark:0,objectMode:!1,pipes:[]};_err;_readablePending=!1;_readImpl;_destroyImpl;_constructImpl;constructor(e){super(e),this.readableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.readableEncoding=e?.encoding??null,this.readableObjectMode=e?.objectMode??!1,this._readableState.highWaterMark=this.readableHighWaterMark,this._readableState.objectMode=this.readableObjectMode,e?.read&&(this._readImpl=e.read),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Readable_.prototype._construct)&&(this._readableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._readableState.constructed=!0,e?this.destroy(e):this.readableFlowing===!0&&this._flow()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_read(e){this._readImpl&&this._readImpl.call(this,e)}read(e){if(!this._readableState.constructed)return null;if(this._buffer.length===0){if(this._readableState.ended)return null;this._readableState.reading=!0,this._read(e??this.readableHighWaterMark),this._readableState.reading=!1}if(this._buffer.length===0||e===0)return null;if(this.readableObjectMode){if(e===void 0){let e=this._buffer.shift();return--this.readableLength,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),e}if(e>this.readableLength)return null;let R=this._buffer.shift();return--this.readableLength,R}if(e!=null)return e>this.readableLength?null:this._readBytes(e);let R=this._buffer.splice(0);if(this.readableLength=0,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),R.length===1)return R[0];if(R.length===0)return null;if(typeof R[0]==`string`)return R.join(``);let W=globalThis.Buffer;return W?.concat?W.concat(R):R}_readBytes(e){let R=0,W=[];for(;R<e&&this._buffer.length>0;){let Y=this._buffer[0],X=chunkLength(Y);if(R+X<=e)W.push(this._buffer.shift()),R+=X,this.readableLength-=X;else{let X=e-R;W.push(sliceChunk(Y,0,X)),this._buffer[0]=sliceChunk(Y,X),this.readableLength-=X,R+=X}}if(W.length===1)return W[0];let Y=globalThis.Buffer;return Y?.concat?Y.concat(W):W}push(e,R){if(e===null)return this._readableState.ended=!0,this.readableEnded=!0,this._buffer.length===0&&!this._readableState.endEmitted&&nextTick(()=>this._emitEnd()),this._scheduleReadable(),!1;if(!this.readableObjectMode&&!(typeof e==`string`||ArrayBuffer.isView(e))){let R=Object.assign(TypeError(`Invalid non-string/buffer chunk type: ${typeof e}`),{code:`ERR_INVALID_ARG_TYPE`});return nextTick(()=>this.emit(`error`,R)),!1}return this._buffer.push(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e),this.readableFlowing&&!this._flowing&&nextTick(()=>this._flow()),this.readableFlowing!==!0&&this._scheduleReadable(),this.readableLength<this.readableHighWaterMark}_emitEnd(){this._readableState.endEmitted||(this._readableState.endEmitted=!0,this.emit(`end`),nextTick(()=>this._autoClose()))}_autoClose(){this.emit(`close`)}_scheduleReadable(){this._readablePending||this.listenerCount(`readable`)===0||(this._readablePending=!0,nextTick(()=>{this._readablePending=!1,this.destroyed||this.emit(`readable`)}))}on(e,R){return super.on(e,R),e===`data`&&this.readableFlowing!==!1&&this.resume(),e===`readable`&&(this._buffer.length>0||this._readableState.ended)&&this._scheduleReadable(),this}unshift(e){this._buffer.unshift(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e)}setEncoding(e){return this.readableEncoding=e,this}pause(){return this.readableFlowing=!1,this.emit(`pause`),this}resume(){return this.readableFlowing!==!0&&(this.readableFlowing=!0,this.emit(`resume`),this._readableState.constructed&&this._flow()),this}_flowing=!1;_flow(){if(!(this.readableFlowing!==!0||this._flowing||this.destroyed)&&this._readableState.constructed){this._flowing=!0;try{for(;this._buffer.length>0&&this.readableFlowing&&!this.destroyed;){let e=this._buffer.shift();if(this.readableLength-=this.readableObjectMode?1:chunkLength(e),this.readableEncoding&&typeof e!=`string`){let R=globalThis.Buffer;R?.isBuffer&&R.isBuffer(e)?e=e.toString(this.readableEncoding):e instanceof Uint8Array&&(e=new TextDecoder(this.readableEncoding).decode(e))}this.emit(`data`,e)}if(this.destroyed)return;if(this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted){nextTick(()=>this._emitEnd());return}!this._readableState.ended&&!this._readableState.reading&&!this.destroyed&&(this._readableState.reading=!0,this._read(this.readableHighWaterMark),this._readableState.reading=!1)}finally{this._flowing=!1}this._buffer.length>0&&this.readableFlowing&&!this.destroyed&&nextTick(()=>this._flow())}}isPaused(){return this.readableFlowing===!1}unpipe(e){if(e){let R=this._pipeDests.findIndex(R=>R.dest===e);if(R!==-1){this._pipeDests[R].cleanup(),this._pipeDests.splice(R,1);let W=this._readableState.pipes.indexOf(e);W!==-1&&this._readableState.pipes.splice(W,1),e.emit(`unpipe`,this),this._pipeDests.length===0&&(this.readableFlowing=!1)}}else{for(let e of this._pipeDests)e.cleanup(),e.dest.emit(`unpipe`,this);this._pipeDests=[],this._readableState.pipes=[],this.readableFlowing=!1}return this}_destroy(e,R){this._destroyImpl?this._destroyImpl.call(this,e,R):R(e??void 0)}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.readable=!1,this.readableAborted=!this.readableEnded,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return Object.prototype.hasOwnProperty.call(this,`_destroy`)?this._destroy(e??null,cb):this._destroyImpl?this._destroyImpl.call(this,e??null,cb):cb(e),this}static toWeb(e){return new ReadableStream({start(R){e.on(`data`,e=>{typeof e==`string`?R.enqueue(new TextEncoder().encode(e)):e instanceof Uint8Array?R.enqueue(e):e&&typeof e.length==`number`&&R.enqueue(new Uint8Array(e))}),e.on(`end`,()=>{R.close()}),e.on(`error`,e=>{R.error(e)})},cancel(){e.destroy()}})}static fromWeb(e,R){let W=e.getReader();return new Readable_({...R,read(){W.read().then(({done:e,value:R})=>{e?this.push(null):this.push(R)},e=>{this.destroy(e)})},destroy(e,R){W.cancel(e?.message).then(()=>R(null),R)}})}[Symbol.asyncIterator](){let e=this,R=[],W=!1,Y=null,X=null,ie=null;return e.on(`data`,e=>{if(X){let R=X;X=null,ie=null,R({value:e,done:!1})}else R.push(e)}),e.on(`end`,()=>{if(W=!0,X){let e=X;X=null,ie=null,e({value:void 0,done:!0})}}),e.on(`error`,e=>{if(Y=e,W=!0,ie){let R=ie;X=null,ie=null,R(e)}}),{next(){return Y?Promise.reject(Y):R.length>0?Promise.resolve({value:R.shift(),done:!1}):W?Promise.resolve({value:void 0,done:!0}):new Promise((e,R)=>{X=e,ie=R})},return(){return e.destroy(),Promise.resolve({value:void 0,done:!0})},[Symbol.asyncIterator](){return this}}}static from(e,R){let W=new Readable_({objectMode:!0,...R,read(){}});return typeof e==`string`||ArrayBuffer.isView(e)?(W.push(e),W.push(null),W):((async()=>{try{for await(let R of e)W.push(R)||await new Promise(e=>W.once(`drain`,e));W.push(null)}catch(e){W.destroy(e)}})(),W)}}});function chunkLen$1(e){if(e==null)return 1;let R=e.length;return typeof R==`number`?R:1}var Duplex_,Ql=__esmMin(()=>{Yl(),Zl(),Ht(),Duplex_=class extends Xl{writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;allowHalfOpen;_decodeStrings;_writableState={highWaterMark:0,objectMode:!1};_duplexCorkedBuffer=[];_duplexWriting=!1;_duplexWriteQueue=[];_writeImpl;_finalImpl;_defaultEncoding=`utf8`;_pendingWrites=0;_pendingEndCb=null;constructor(e){super(e),validateHighWaterMark(`writableHighWaterMark`,e?.writableHighWaterMark),validateHighWaterMark(`readableHighWaterMark`,e?.readableHighWaterMark),this.writableObjectMode=e?.writableObjectMode??e?.objectMode??!1,this.writableHighWaterMark=e?.highWaterMark??e?.writableHighWaterMark??getDefaultHighWaterMark(this.writableObjectMode),this._writableState.highWaterMark=this.writableHighWaterMark,this._writableState.objectMode=this.writableObjectMode,e?.highWaterMark===void 0&&e?.readableHighWaterMark!==void 0&&(this.readableHighWaterMark=e.readableHighWaterMark,this._readableState.highWaterMark=e.readableHighWaterMark),e?.readableObjectMode!==void 0&&(this.readableObjectMode=e.readableObjectMode,this._readableState.objectMode=e.readableObjectMode,e?.readableHighWaterMark===void 0&&e?.highWaterMark===void 0&&(this.readableHighWaterMark=getDefaultHighWaterMark(e.readableObjectMode),this._readableState.highWaterMark=this.readableHighWaterMark)),this.allowHalfOpen=e?.allowHalfOpen!==!1,this._decodeStrings=e?.decodeStrings!==!1,e?.write&&(this._writeImpl=e.write),e?.final&&(this._finalImpl=e.final),this.allowHalfOpen||this.once(`end`,()=>{this.writableEnded||nextTick(()=>this.end())})}_write(e,R,W){this._writeImpl?this._writeImpl.call(this,e,R,W):W()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}destroy(e){return this.destroyed?this:(this.writable=!1,super.destroy(e))}write(e,R,W){let Y,X;if(typeof R==`function`?(Y=R,X=this._defaultEncoding):(X=R??this._defaultEncoding,Y=W??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let R=globalThis.Buffer;R&&(e=R.from(e,X),X=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let R=globalThis.Buffer;(R&&R.isBuffer(e)||e instanceof Uint8Array)&&(X=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{Y(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen$1(e),this.writableCorked>0)return this._duplexCorkedBuffer.push({chunk:e,encoding:X,callback:Y}),this.writableLength<this.writableHighWaterMark;let ie=this.writableLength<this.writableHighWaterMark;return ie||(this.writableNeedDrain=!0),this._duplexDoWrite(e,X,Y),ie}_duplexDoWrite(e,R,W){if(this._duplexWriting){this._duplexWriteQueue.push({chunk:e,encoding:R,callback:W});return}this._duplexWriting=!0,this._duplexStartWrite(e,R,W)}_duplexStartWrite(e,R,W){this._pendingWrites++,this._write(e,R,R=>{this._pendingWrites--,this.writableLength-=this.writableObjectMode?1:chunkLen$1(e),nextTick(R?()=>{if(W(R),this._duplexWriting=!1,this.emit(`error`,R),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexWriting=!0,this._duplexStartWrite(e.chunk,e.encoding,e.callback)}}:()=>{if(W(),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexStartWrite(e.chunk,e.encoding,e.callback);return}if(this._duplexWriting=!1,this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._pendingWrites===0&&this._pendingEndCb){let e=this._pendingEndCb;this._pendingEndCb=null,e()}})})}end(e,R,W){typeof e==`function`&&(W=e,e=void 0),typeof R==`function`&&(W=R,R=void 0),e!=null&&this.write(e,R),this.writableEnded=!0;let doFinal=()=>{this._final(e=>{this.writableFinished=!0,this._doPrefinishHooks(()=>{nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),nextTick(()=>this.emit(`close`)),W&&W()})})})};return this._pendingWrites>0||this._duplexWriting||this._duplexWriteQueue.length>0?this._pendingEndCb=doFinal:doFinal(),this}_doPrefinishHooks(e){e()}cork(){this.writableCorked++}uncork(){if(this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._duplexCorkedBuffer.length>0)){let e=this._duplexCorkedBuffer.splice(0);for(let{chunk:R,encoding:W,callback:Y}of e)this._write(R,W,e=>{this.writableLength-=this.writableObjectMode?1:chunkLen$1(R),e?(Y(e),this.emit(`error`,e)):Y()});this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,nextTick(()=>this.emit(`drain`)))}}setDefaultEncoding(e){return this._defaultEncoding=e,this}},__name$1(chunkLen$1,`chunkLen`)});function pipe(e,R,W){let Y=e,X=W?.end!==!1,ie=!1,ondrain=()=>{ie=!1,R.removeListener(`drain`,ondrain);let e=Y;typeof e.resume==`function`&&e.resume()},ondata=e=>{if(R.writable){let W=Y;R.write(e)===!1&&typeof W.pause==`function`&&(W.pause(),ie||(ie=!0,R.on(`drain`,ondrain)))}};Y.on(`data`,ondata);let ae=!1,onend=()=>{ae||(ae=!0,X&&R.end())},onclose=()=>{if(!ae&&(ae=!0,X&&!(Y instanceof Xl))){let e=R;typeof e.destroy==`function`&&e.destroy()}};X&&(Y.on(`end`,onend),Y.on(`close`,onclose));let cleanup=()=>{Y.removeListener(`data`,ondata),ie&&R.removeListener(`drain`,ondrain),Y.removeListener(`end`,onend),Y.removeListener(`close`,onclose),Y.removeListener(`end`,cleanup),Y.removeListener(`close`,cleanup),R.removeListener(`close`,cleanup)};return Y.on(`end`,cleanup),Y.on(`close`,cleanup),R.on(`close`,cleanup),Y instanceof Xl&&(Y._pipeDests.push({dest:R,cleanup}),Y._readableState.pipes.push(R)),R.emit(`pipe`,Y),R}var eu=__esmMin(()=>{Gl(),Zl(),_setPipeImpl(pipe)});function chunkLen(e){if(e==null)return 1;let R=e.length;return typeof R==`number`?R:1}var tu,nu=__esmMin(()=>{Gl(),Yl(),Ht(),tu=class Writable_ extends Stream_{static[Symbol.hasInstance](e){let R=this;return R.prototype!==void 0&&Object.prototype.isPrototypeOf.call(R.prototype,e)?!0:R.prototype!==Writable_.prototype||e==null?!1:typeof e.writableHighWaterMark==`number`}writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;destroyed=!1;_err;_writableState={ended:!1,finished:!1,constructed:!0,writing:!1};_corkedBuffer=[];_writeBuffer=[];_pendingConstruct=[];_ending=!1;_endCallback;_pendingEnd=null;_writeImpl;_writev;_finalImpl;_destroyImpl;_constructImpl;_decodeStrings;_defaultEncoding=`utf8`;constructor(e){super(e),this.writableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.writableObjectMode=e?.objectMode??!1,this._decodeStrings=e?.decodeStrings!==!1,e?.write&&(this._writeImpl=e.write),e?.writev&&(this._writev=e.writev),e?.final&&(this._finalImpl=e.final),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Writable_.prototype._construct)&&(this._writableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._writableState.constructed=!0,e?this.destroy(e):this._maybeFlush()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_write(e,R,W){this._writeImpl?this._writeImpl.call(this,e,R,W):W()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}_destroy(e,R){this._destroyImpl?this._destroyImpl.call(this,e,R):R(e)}_maybeFlush(){let e=this._pendingConstruct.splice(0);if(e.length>0){let[R,...W]=e;this._writeBuffer.push(...W),this._doWrite(R.chunk,R.encoding,R.callback)}if(this._pendingEnd){let{chunk:e,encoding:R,callback:W}=this._pendingEnd;this._pendingEnd=null,this._doEnd(e,R,W)}}_doWrite(e,R,W){this._writableState.writing=!0;let Y=!0;this._write(e,R,R=>{if(this.writableLength-=this.writableObjectMode?1:chunkLen(e),Y){nextTick(()=>{if(R){W(R),this.emit(`error`,R);return}W(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}),R||this._drainWriteBuffer();return}nextTick(R?()=>{W(R),this.emit(`error`,R),this._drainWriteBuffer()}:()=>{W(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._drainWriteBuffer()})}),Y=!1}_drainWriteBuffer(){if(this._writeBuffer.length>0){let e=this._writeBuffer.shift();this._doWrite(e.chunk,e.encoding,e.callback)}else this._writableState.writing=!1,this._maybeFinish()}_maybeFinish(){!this._ending||this._writableState.finished||this._writableState.writing||this._writeBuffer.length>0||(this._ending=!1,this._final(e=>{this.writableFinished=!0,this._writableState.finished=!0,nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),nextTick(()=>this.emit(`close`)),this._endCallback&&this._endCallback()})}))}write(e,R,W){let Y,X;if(typeof R==`function`?(Y=R,X=this._defaultEncoding):(X=R??this._defaultEncoding,Y=W??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let R=globalThis.Buffer;R&&(e=R.from(e,X),X=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let R=globalThis.Buffer;(R&&R.isBuffer(e)||e instanceof Uint8Array)&&(X=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{Y(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen(e),this.writableCorked>0)return this._corkedBuffer.push({chunk:e,encoding:X,callback:Y}),this.writableLength<this.writableHighWaterMark;if(!this._writableState.constructed)return this._pendingConstruct.push({chunk:e,encoding:X,callback:Y}),this.writableLength<this.writableHighWaterMark;let ie=this.writableLength<this.writableHighWaterMark;return ie||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:e,encoding:X,callback:Y}):this._doWrite(e,X,Y),ie}_doEnd(e,R,W){e!=null&&this.write(e,R),this.writableEnded=!0,this._writableState.ended=!0,this._ending=!0,this._endCallback=W,this._maybeFinish()}end(e,R,W){return typeof e==`function`&&(W=e,e=void 0),typeof R==`function`&&(W=R,R=void 0),this.writableEnded?(W&&nextTick(W),this):this._writableState.constructed?(this._doEnd(e,R,W),this):(this._pendingEnd={chunk:e,encoding:R,callback:W},this)}cork(){this.writableCorked++}uncork(){this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._corkedBuffer.length>0&&this._flushCorkedBuffer())}_flushCorkedBuffer(){if(this._writev&&this._corkedBuffer.length>1){let e=this._corkedBuffer.splice(0),R=e.map(e=>({chunk:e.chunk,encoding:e.encoding}));this._writev.call(this,R,R=>{for(let R of e)this.writableLength-=this.writableObjectMode?1:chunkLen(R.chunk);if(R){for(let W of e)W.callback(R);this.emit(`error`,R)}else{for(let R of e)R.callback();this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}})}else{let e=this._corkedBuffer.splice(0);if(e.length>0){let[R,...W]=e;this._writeBuffer.push(...W),this._doWrite(R.chunk,R.encoding,R.callback)}}}setDefaultEncoding(e){return this._defaultEncoding=e,this}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.writable=!1,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return this._destroy(e??null,cb),this}}}),ru,iu=__esmMin(()=>{Ql(),Ht(),ru=class Transform_ extends Duplex_{constructor(e){super({...e,write:void 0,final:void 0});let R=this;e?.transform&&(R._transform=e.transform),e?.flush&&(R._flush=e.flush),e?.final&&(R._final=e.final)}_transform(e,R,W){throw Object.assign(Error(`The _transform() method is not implemented`),{code:`ERR_METHOD_NOT_IMPLEMENTED`})}_flush(e){e()}_write(e,R,W){let Y=!1;try{this._transform(e,R,(e,R)=>{if(Y){let e=Object.assign(Error(`Callback called multiple times`),{code:`ERR_MULTIPLE_CALLBACK`});nextTick(()=>this.emit(`error`,e));return}if(Y=!0,e){W(e);return}R!=null&&this.push(R),W()})}catch(e){if(e?.code===`ERR_METHOD_NOT_IMPLEMENTED`)throw e;W(e)}}_final(e){this._flush((R,W)=>{if(R){e(R);return}W!=null&&this.push(W),this.push(null),e()})}_doPrefinishHooks(e){let R=Transform_.prototype._final;this._final===R?e():R.call(this,e)}}}),PassThrough_,au=__esmMin(()=>{iu(),PassThrough_=class extends ru{constructor(e){super({...e,transform(e,R,W){W(null,e)}})}}});function pipeline(...e){let R=e,W=typeof R[R.length-1]==`function`?R.pop():void 0,Y=R;if(Y.length<2)throw Error(`pipeline requires at least 2 streams`);let X=null;function onError(e){if(!X){X=e;for(let e of Y)typeof e.destroy==`function`&&e.destroy();W&&W(e)}}let ie=Y[0];for(let e=1;e<Y.length;e++){let R=Y[e];ie.pipe(R),ie.on(`error`,onError),ie=R}let ae=Y[Y.length-1];return ae.on(`error`,onError),ae.on(`finish`,()=>{W&&!X&&W(null)}),ae}var ou=__esmMin(()=>{});function finished(e,R,W){let Y;Y=typeof R==`function`?R:W;let X=!1;function done(e){X||(X=!0,Y(e))}let onFinish=()=>done(),onEnd=()=>done(),onError=e=>done(e),onClose=()=>{let R=e,W=e;!R.writableFinished&&!W.readableEnded&&done(Error(`premature close`))};e.on(`finish`,onFinish),e.on(`end`,onEnd),e.on(`error`,onError),e.on(`close`,onClose);let ie=e,ae=typeof e.write==`function`,le=typeof e.read==`function`,_e=ie.writableFinished===!0,ye=ie.readableEnded===!0;if(ie.destroyed===!0){let e=ie._err;Ct(e?()=>done(e):ae&&_e||le&&ye?()=>done():()=>done(Error(`premature close`)))}else (ae&&!le&&_e||!ae&&le&&ye||ae&&le&&_e&&ye)&&Ct(()=>done());return function cleanup(){e.removeListener(`finish`,onFinish),e.removeListener(`end`,onEnd),e.removeListener(`error`,onError),e.removeListener(`close`,onClose)}}function addAbortSignal(e,R){if(!(e instanceof AbortSignal))throw TypeError(`The first argument must be an AbortSignal`);if(!(R instanceof Stream_))throw TypeError(`The second argument must be a Stream`);let W=R;if(e.aborted)W.destroy(Error(`The operation was aborted`));else{let onAbort=()=>{W.destroy(Error(`The operation was aborted`))};e.addEventListener(`abort`,onAbort,{once:!0}),R.once(`close`,()=>{e.removeEventListener(`abort`,onAbort)})}return R}function isReadable(e){if(e==null)return!1;let R=e;return typeof R.readable!=`boolean`||typeof R.read!=`function`||R.destroyed===!0||R.readableEnded===!0?!1:R.readable===!0}function isWritable(e){if(e==null)return!1;let R=e;return typeof R.writable!=`boolean`||typeof R.write!=`function`||R.destroyed===!0||R.writableEnded===!0?!1:R.writable===!0}function isDestroyed(e){return e==null?!1:e.destroyed===!0}function isDisturbed(e){if(e==null)return!1;let R=e;return R.readableDidRead===!0||R.readableFlowing!==null&&R.readableFlowing!==void 0}function isErrored(e){if(e==null)return!1;let R=e;return R.destroyed===!0&&typeof R.readable==`boolean`&&R.readable===!1||R.destroyed===!0&&typeof R.writable==`boolean`&&R.writable===!1}var su=__esmMin(()=>{Gl(),Ht()}),cu,lu,uu,du,fu,pu,mu,hu=__esmMin(()=>{Bl(),Gl(),Yl(),Zl(),Ql(),eu(),nu(),iu(),au(),ou(),su(),cu=makeCallable(Stream_),lu=makeCallable(Xl),uu=makeCallable(tu),du=makeCallable(Duplex_),fu=makeCallable(ru),pu=makeCallable(PassThrough_),mu=Object.assign(cu,{Stream:cu,Readable:lu,Writable:uu,Duplex:du,Transform:fu,PassThrough:pu,pipeline,finished,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark})});function getGioCompressorFormat(e){switch(e){case`gzip`:return at.ZlibCompressorFormat.GZIP;case`deflate`:return at.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return at.ZlibCompressorFormat.RAW}}function toUint8Array$1(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function createGzip(e){return new ZlibTransform(`gzip`,`compress`,e)}function createGunzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createDeflate(e){return new ZlibTransform(`deflate`,`compress`,e)}function createInflate(e){return new ZlibTransform(`deflate`,`decompress`,e)}function createDeflateRaw(e){return new ZlibTransform(`deflate-raw`,`compress`,e)}function createInflateRaw(e){return new ZlibTransform(`deflate-raw`,`decompress`,e)}function createUnzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createBrotliCompress(e){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(e){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}var ZlibTransform,gu=__esmMin(()=>{st(),$e(),hu(),__name$1(toUint8Array$1,`toUint8Array`),ZlibTransform=class extends fu{_format;_mode;_chunks=[];constructor(e,R,W){super(W),this._format=e,this._mode=R}_transform(e,R,W){this._chunks.push(toUint8Array$1(e)),W()}_flush(e){let R=this._chunks.reduce((e,R)=>e+R.length,0),W=new Uint8Array(R),Y=0;for(let e of this._chunks)W.set(e,Y),Y+=e.length;this._chunks=[];try{let R=this._mode===`compress`?this._compress(W):this._decompress(W);this.push(Buffer.from(R)),e()}catch(R){e(R instanceof Error?R:Error(String(R)))}}_compress(e){let R=new at.ZlibCompressor({format:getGioCompressorFormat(this._format)}),W=new at.ConverterOutputStream({base_stream:at.MemoryOutputStream.new_resizable(),converter:R});W.write_bytes(new Qe.Bytes(e),null),W.close(null);let Y=W.get_base_stream().steal_as_bytes();return new Uint8Array(Y.get_data()??[])}_decompress(e){let R=new at.ZlibDecompressor({format:getGioCompressorFormat(this._format)}),W=at.MemoryInputStream.new_from_bytes(new Qe.Bytes(e)),Y=new at.ConverterInputStream({base_stream:W,converter:R}),X=[];for(;;){let e=Y.read_bytes(4096,null);if(e.get_size()===0)break;X.push(new Uint8Array(e.get_data()))}Y.close(null);let ie=X.reduce((e,R)=>e+R.length,0),ae=new Uint8Array(ie),le=0;for(let e of X)ae.set(e,le),le+=e.length;return ae}}}),_u=__exportAll$1({ZlibTransform:()=>ZlibTransform,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>bu,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,default:()=>xu,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip,gunzipSync:()=>gunzipSync,gzip:()=>gzip,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync});function getGioFormat(e){switch(e){case`gzip`:return at.ZlibCompressorFormat.GZIP;case`deflate`:return at.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return at.ZlibCompressorFormat.RAW}}function compressWithGio(e,R){let W=new at.ZlibCompressor({format:getGioFormat(R)}),Y=new at.ConverterOutputStream({base_stream:at.MemoryOutputStream.new_resizable(),converter:W});Y.write_bytes(new Qe.Bytes(e),null),Y.close(null);let X=Y.get_base_stream().steal_as_bytes();return new Uint8Array(X.get_data()??[])}function decompressStreamWithGio(e,R){let W=new at.ZlibDecompressor({format:getGioFormat(R)}),Y=at.MemoryInputStream.new_from_bytes(new Qe.Bytes(e)),X=new at.ConverterInputStream({base_stream:Y,converter:W}),ie=[];for(;;){let e=X.read_bytes(4096,null);if(e.get_size()===0)break;ie.push(new Uint8Array(e.get_data()))}X.close(null);let ae=ie.reduce((e,R)=>e+R.length,0),le=new Uint8Array(ae),_e=0;for(let e of ie)le.set(e,_e),_e+=e.length;return le}function findGzipMemberEnd(e){let R=new at.ZlibDecompressor({format:at.ZlibCompressorFormat.GZIP}),W=new Uint8Array(65536),Y=0,X=!1;for(;!X;){let ie=e.subarray(Y);try{let[e,ae]=R.convert(ie,W,at.ConverterFlags.NONE);Y+=ae,e===at.ConverterResult.FINISHED&&(X=!0)}catch{X=!0}}return Y}function decompressWithGio(e,R){if(R!==`gzip`)return decompressStreamWithGio(e,R);let W=[],Y=0;for(;Y<e.length&&!(e.length-Y<2||e[Y]!==31||e[Y+1]!==139);){let R=e.subarray(Y),X=findGzipMemberEnd(R);if(X<=0)break;let ie=decompressStreamWithGio(R.subarray(0,X),`gzip`);W.push(ie),Y+=X}if(W.length===0)return decompressStreamWithGio(e,`gzip`);let X=W.reduce((e,R)=>e+R.length,0),ie=new Uint8Array(X),ae=0;for(let e of W)ie.set(e,ae),ae+=e.length;return ie}async function compressWithWeb(e,R){let W=new CompressionStream(R),Y=W.writable.getWriter();Y.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Y.close();let X=[],ie=W.readable.getReader();for(;;){let{done:e,value:R}=await ie.read();if(e)break;X.push(R)}let ae=X.reduce((e,R)=>e+R.length,0),le=new Uint8Array(ae),_e=0;for(let e of X)le.set(e,_e),_e+=e.length;return le}async function decompressWithWeb(e,R){let W=new DecompressionStream(R),Y=W.writable.getWriter();Y.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Y.close();let X=[],ie=W.readable.getReader();for(;;){let{done:e,value:R}=await ie.read();if(e)break;X.push(R)}let ae=X.reduce((e,R)=>e+R.length,0),le=new Uint8Array(ae),_e=0;for(let e of X)le.set(e,_e),_e+=e.length;return le}async function compress(e,R){return vu?compressWithWeb(e,R):compressWithGio(e,R)}async function decompress(e,R){return vu?decompressWithWeb(e,R):decompressWithGio(e,R)}function toUint8Array(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function gzip(e,R,W){let Y=typeof R==`function`?R:W;compress(toUint8Array(e),`gzip`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gunzip(e,R,W){let Y=typeof R==`function`?R:W;decompress(toUint8Array(e),`gzip`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflate(e,R,W){let Y=typeof R==`function`?R:W;compress(toUint8Array(e),`deflate`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflate(e,R,W){let Y=typeof R==`function`?R:W;decompress(toUint8Array(e),`deflate`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflateRaw(e,R,W){let Y=typeof R==`function`?R:W;compress(toUint8Array(e),`deflate-raw`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflateRaw(e,R,W){let Y=typeof R==`function`?R:W;decompress(toUint8Array(e),`deflate-raw`).then(e=>Y(null,e),e=>Y(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gzipSync(e,R){return compressWithGio(toUint8Array(e),`gzip`)}function gunzipSync(e,R){return decompressWithGio(toUint8Array(e),`gzip`)}function deflateSync(e,R){return compressWithGio(toUint8Array(e),`deflate`)}function inflateSync(e,R){return decompressWithGio(toUint8Array(e),`deflate`)}function deflateRawSync(e,R){return compressWithGio(toUint8Array(e),`deflate-raw`)}function inflateRawSync(e,R){return decompressWithGio(toUint8Array(e),`deflate-raw`)}function brotliCompress(e,R,W){(typeof R==`function`?R:W)(Error(`brotliCompress: Brotli is not supported in this environment`),yu)}function brotliDecompress(e,R,W){(typeof R==`function`?R:W)(Error(`brotliDecompress: Brotli is not supported in this environment`),yu)}function brotliCompressSync(e,R){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(e,R){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}var vu,yu,bu,xu,Su=__esmMin(()=>{gu(),st(),$e(),vu=globalThis.CompressionStream!==void 0,yu=new Uint8Array,bu={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_DEFLATED:8},xu={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,constants:bu}});const Cu=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(e){if(!Cu.has(e))throw TypeError(`Unsupported compression format: '${e}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return e}const wu=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let Tu=!1,Eu,Du,Ou,ku,Au,ju;async function loadZlib(){if(Tu)return;let e=await Promise.resolve().then(()=>(Su(),_u));Eu=e.gzipSync,Du=e.gunzipSync,Ou=e.deflateSync,ku=e.inflateSync,Au=e.deflateRawSync,ju=e.inflateRawSync,Tu=!0}function getCompressFn(e){switch(e){case`gzip`:return e=>Eu(e);case`deflate`:return e=>Ou(e);case`deflate-raw`:return e=>Au(e)}}function getDecompressFn(e){switch(e){case`gzip`:return e=>Du(e);case`deflate`:return e=>ku(e);case`deflate-raw`:return e=>ju(e)}}let Mu,Nu;if(wu)Mu=globalThis.CompressionStream,Nu=globalThis.DecompressionStream;else{let e=loadZlib();Mu=class CompressionStream{readable;writable;constructor(R){let W=validateFormat(R),Y=new Nl({async transform(R,Y){try{await e,Y.enqueue(getCompressFn(W)(R))}catch(e){Y.error(e)}}});this.readable=Y.readable,this.writable=Y.writable}},Nu=class DecompressionStream{readable;writable;constructor(R){let W=validateFormat(R),Y=new Nl({async transform(R,Y){try{await e,Y.enqueue(getDecompressFn(W)(R))}catch(e){Y.error(e)}}});this.readable=Y.readable,this.writable=Y.writable}}}const Pu=globalThis;globalThis.CompressionStream===void 0&&(Pu.CompressionStream=Mu),globalThis.DecompressionStream===void 0&&(Pu.DecompressionStream=Nu);const Fu={CustomEvent,MessageEvent,ErrorEvent,CloseEvent,ProgressEvent:ProgressEvent$1};for(let[e,R]of Object.entries(Fu))globalThis[e]===void 0&&Object.defineProperty(globalThis,e,{value:R,writable:!0,configurable:!0});const Iu=globalThis;Iu.Event===void 0&&Object.defineProperty(globalThis,"Event",{value:Event$1,writable:!0,configurable:!0}),Iu.EventTarget===void 0&&Object.defineProperty(globalThis,"EventTarget",{value:EventTarget$1,writable:!0,configurable:!0});const Lu={UIEvent,MouseEvent,PointerEvent:PointerEvent$1,KeyboardEvent:KeyboardEvent$1,WheelEvent:WheelEvent$1,FocusEvent};for(let[e,R]of Object.entries(Lu))globalThis[e]===void 0&&Object.defineProperty(globalThis,e,{value:R,writable:!0,configurable:!0});const Ru=globalThis;globalThis.DOMException===void 0&&(Ru.DOMException=lr);var zu,__name,Bu=__esmMin(()=>{zu=Object.defineProperty,__name=(e,R)=>zu(e,`name`,{value:R,configurable:!0})}),Vu=be;function validateHeaderName(e){if(typeof e!=`string`||!/^[\^`\-\w!#$%&'*+.|~]+$/.test(e)){let R=TypeError(`Header name must be a valid HTTP token ["${e}"]`);throw Object.defineProperty(R,"code",{value:`ERR_INVALID_HTTP_TOKEN`}),R}}function validateHeaderValue(e,R){if(R===void 0){let R=TypeError(`Header "${e}" value must not be undefined`);throw Object.defineProperty(R,"code",{value:`ERR_HTTP_INVALID_HEADER_VALUE`}),R}if(typeof R==`string`&&/[^\t -~-ÿ]/.test(R)){let R=TypeError(`Invalid character in header content ["${e}"]`);throw Object.defineProperty(R,"code",{value:`ERR_INVALID_CHAR`}),R}}const Hu=Symbol(`Headers.headers`);function isBoxedPrimitive(e){return e instanceof String||e instanceof Number||e instanceof Boolean||typeof Symbol<`u`&&e instanceof Symbol||typeof BigInt<`u`&&e instanceof BigInt}var Uu=class Headers{[Hu];constructor(e){if(this[Hu]=new Map,e!=null){if(e instanceof Headers){for(let[R,W]of e[Hu])this[Hu].set(R,[...W]);return}if(typeof e==`object`&&!isBoxedPrimitive(e)){let R=e[Symbol.iterator];if(R==null)for(let[R,W]of Object.entries(e))validateHeaderName(R),validateHeaderValue(R,String(W)),this.append(R,String(W));else{if(typeof R!=`function`)throw TypeError(`Header pairs must be iterable`);for(let R of e){if(typeof R!=`object`||isBoxedPrimitive(R))throw TypeError(`Each header pair must be an iterable object`);let e=[...R];if(e.length!==2)throw TypeError(`Each header pair must be a name/value tuple`);validateHeaderName(e[0]),validateHeaderValue(e[0],String(e[1])),this.append(e[0],String(e[1]))}}}else throw TypeError(`Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)'`)}}append(e,R){validateHeaderName(e),validateHeaderValue(e,R);let W=String(e).toLowerCase(),Y=String(R),X=this[Hu].get(W);X?X.push(Y):this[Hu].set(W,[Y])}set(e,R){validateHeaderName(e),validateHeaderValue(e,R);let W=String(e).toLowerCase();this[Hu].set(W,[String(R)])}delete(e){this[Hu].delete(String(e).toLowerCase())}has(e){return this[Hu].has(String(e).toLowerCase())}get(e){let R=this[Hu].get(String(e).toLowerCase());if(!R||R.length===0)return null;let W=R.join(`, `);return/^content-encoding$/i.test(e)&&(W=W.toLowerCase()),W}getAll(e){return this[Hu].get(String(e).toLowerCase())??[]}getSetCookie(){return this[Hu].get(`set-cookie`)??[]}forEach(e,R){for(let W of this.keys())Reflect.apply(e,R,[this.get(W),W,this])}*keys(){let e=[...this[Hu].keys()].sort(),R=new Set;for(let W of e)R.has(W)||(R.add(W),yield W)}*values(){for(let e of this.keys())yield this.get(e)}*entries(){for(let e of this.keys())yield[e,this.get(e)]}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return`Headers`}toString(){return Object.prototype.toString.call(this)}raw(){let e={};for(let R of this.keys())e[R]=this.getAll(R);return e}_appendToSoupMessage(e,R=Vu.MessageHeadersType.REQUEST){let W=e?e.get_request_headers():new Vu.MessageHeaders(R);for(let[e,R]of this.entries())W.append(e,R);return W}static _newFromSoupMessage(e,R=Vu.MessageHeadersType.RESPONSE){let W=new Headers,Y;return Y=R===Vu.MessageHeadersType.RESPONSE?e.get_response_headers():e.get_request_headers(),Y.foreach((e,R)=>{W.append(e,R)}),W}[Symbol.for(`nodejs.util.inspect.custom`)](){let e={};for(let R of this.keys()){let W=this.getAll(R);R===`host`?e[R]=W[0]:e[R]=W.length>1?W:W[0]}return e}};Object.defineProperties(Uu.prototype,[`get`,`entries`,`forEach`,`values`].reduce((e,R)=>(e[R]={enumerable:!0},e),{}));var Wu=__esmMin(()=>{Ya()});Wu();var FetchBaseError=class extends Error{type;constructor(e,R){super(e),typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,this.constructor),this.type=R}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}},FetchError=class extends FetchBaseError{code;errno;erroredSysCall;constructor(e,R,W){super(e,R),W&&(this.code=this.errno=W.code,this.erroredSysCall=W.syscall)}};const Gu=Symbol.toStringTag,isURLSearchParameters=e=>typeof e==`object`&&typeof e.append==`function`&&typeof e.delete==`function`&&typeof e.get==`function`&&typeof e.getAll==`function`&&typeof e.has==`function`&&typeof e.set==`function`&&typeof e.sort==`function`&&e[Gu]===`URLSearchParams`,isBlob=e=>{if(!e||typeof e!=`object`)return!1;let R=e;return typeof R.arrayBuffer==`function`&&typeof R.type==`string`&&typeof R.stream==`function`&&typeof R.constructor==`function`&&/^(Blob|File)$/.test(R[Gu])},isAbortSignal=e=>{if(typeof e!=`object`||!e)return!1;let R=e;return R[Gu]===`AbortSignal`||R[Gu]===`EventTarget`},isDomainOrSubdomain=(e,R)=>{let W=new gs(R).hostname,Y=new gs(e).hostname;return W===Y||W.endsWith(`.${Y}`)},isSameProtocol=(e,R)=>new gs(R).protocol===new gs(e).protocol;var Ku,qu,File$1,Ju=__esmMin(()=>{Ku=Symbol(`File.name`),qu=Symbol(`File.lastModified`),File$1=class extends Blob{static{__name$1(this,`File`)}[Ku];[qu];webkitRelativePath=``;constructor(e,R,W){super(e,W),this[Ku]=String(R),this[qu]=W?.lastModified??Date.now()}get name(){return this[Ku]}get lastModified(){return this[qu]}get[Symbol.toStringTag](){return`File`}}});function generateBoundary(){let e=`----formdata-`;for(let R=0;R<24;R++)e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*62));return e}function escape(e){return e.replace(/\n/g,`%0A`).replace(/\r/g,`%0D`).replace(/"/g,`%22`)}function formDataToBlob(e,R){R??=generateBoundary();let W=[],Y=`--${R}\r\nContent-Disposition: form-data; name="`;for(let[R,X]of e.entries())if(typeof X==`string`)W.push(`${Y}${escape(R)}"\r\n\r\n${X.replace(/\r(?!\n)|(?<!\r)\n/g,`\r
|
|
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 Yu=__esmMin(()=>{Ju()});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 Xu,FormData,Zu=__esmMin(()=>{Ju(),Xu=Symbol(`FormData.entries`),FormData=class{[Xu]=[];constructor(){}append(e,R,W){this[Xu].push({name:String(e),value:normalizeValue(e,R,W)})}delete(e){let R=String(e);this[Xu]=this[Xu].filter(e=>e.name!==R)}get(e){let R=String(e),W=this[Xu].find(e=>e.name===R);return W?W.value:null}getAll(e){let R=String(e);return this[Xu].filter(e=>e.name===R).map(e=>e.value)}has(e){let R=String(e);return this[Xu].some(e=>e.name===R)}set(e,R,W){let Y=String(e),X=normalizeValue(Y,R,W),ie=!1;this[Xu]=this[Xu].filter(e=>e.name===Y?ie?!1:(ie=!0,e.value=X,!0):!0),ie||this[Xu].push({name:Y,value:X})}forEach(e,R){for(let W of this[Xu])e.call(R,W.value,W.name,this)}*entries(){for(let e of this[Xu])yield[e.name,e.value]}*keys(){for(let e of this[Xu])yield e.name}*values(){for(let e of this[Xu])yield e.value}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return`FormData`}}}),Qu=__esmMin(()=>{Yu(),Zu()}),$u=__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 ed,td,lower,noop,MultipartParser,nd=__esmMin(()=>{Qu(),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`)}}});xt(),Bu(),Wu(),Ya(),hu(),Qu(),__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=qa.from(e.toString());else if(isBlob(e))this[rd].body=e;else if(qa.isBuffer(e))this[rd].body=e;else if(isAnyArrayBuffer(e))this[rd].body=qa.from(e);else if(ArrayBuffer.isView(e))this[rd].body=qa.from(e.buffer,e.byteOffset,e.byteLength);else if(e instanceof lu)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=qa.from(e):e instanceof hs?this[rd].body=qa.from(e.toString()):(bt.warn(`Unknown body type "${typeof e}", try to parse the body to string!`),this[rd].body=qa.from(String(e)));let W=this[rd].body;qa.isBuffer(W)?this[rd].stream=lu.from(W):isBlob(W)?this[rd].stream=lu.from(blobToAsyncIterable(W)):W instanceof lu&&(this[rd].stream=W),W instanceof cu&&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:qa.isBuffer(e)?e:e instanceof Uint8Array?qa.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 hs(await this.text());for(let[W,Y]of R)e.append(W,Y);return e}let{toFormData:R}=await Promise.resolve().then(()=>(nd(),$u));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 cu))return qa.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`)?qa.from(W.join(``)):qa.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 cu&&typeof X.getBoundary!=`function`&&(W=new pu({highWaterMark:R}),Y=new pu({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:qa.isBuffer(e)||isAnyArrayBuffer(e)||ArrayBuffer.isView(e)?null:e instanceof FormData?`multipart/form-data; boundary=${R[rd].boundary}`:e instanceof cu?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(qa.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 lu({async read(){try{let{done:e,value:W}=await R.read();e?this.push(null):this.push(qa.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 Uu(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 gs(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 Uu(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}}),hu(),$e(),Ht();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 lu.from(inputStreamAsyncIterator(e),R)}st(),$e(),hu(),Ht(),st(),Ht(),ls(),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 gs(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 gs(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 gs(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 gs(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 getSharedSession(){if(ld===null){ld=new Vu.Session;try{ld.remove_feature_by_type(Vu.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.NONE)}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 gs(W.url),ie=W):X=new gs(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 Uu(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 gs(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 Vu.Message({method:ae,uri:Qe.Uri.parse(X.toString(),Qe.UriFlags.NONE)})),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 Uu(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 gs&&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};xt(),hu(),$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&&bt.log(`[fetch] rewrite ${e} → ${X}`),X}catch(R){return W&&bt.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&&bt.log(`[fetch] file:// ${W.url}`);try{let R=Qe.filename_from_uri(W.url)[0];e&&bt.log(`[fetch] file:// path=${R}`);let[Y,X]=Qe.file_get_contents(R);if(e&&bt.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&&bt.log(`[fetch] file:// response created`),le}catch(R){let Y=R instanceof Error?R:Error(String(R));throw e&&bt.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=Uu._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 gs(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 Uu(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 mu.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=Uu),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=Fl),globalThis.CountQueuingStrategy===void 0&&(md.CountQueuingStrategy=Ll);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=jl),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=Rl),globalThis.TextDecoderStream===void 0&&(gd.TextDecoderStream=zl);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=Nl}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=Ml}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}},WebGLActiveInfo=class{constructor(e){this.size=e.size,this.type=e.type,this.name=e.name}},WebGLShaderPrecisionFormat=class{constructor(e){this.rangeMin=e.rangeMin,this.rangeMax=e.rangeMax,this.precision=e.precision}};$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){if(!(e===this.GENERATE_MIPMAP_HINT||this._extensions.oes_standard_derivatives&&e===this._extensions.oes_standard_derivatives.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){return e===this.FUNC_ADD||e===this.FUNC_SUBTRACT||e===this.FUNC_REVERSE_SUBTRACT||this._extensions.ext_blend_minmax&&(e===this._extensions.ext_blend_minmax.MIN_EXT||e===this._extensions.ext_blend_minmax.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)}var Cd=__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 wd={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)},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))},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&&!(Cd.isPow2(ie)&&Cd.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)))},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}if(this._extensions.ext_texture_filter_anisotropic&&R===this._extensions.ext_texture_filter_anisotropic.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}if(this._extensions.ext_texture_filter_anisotropic&&R===this._extensions.ext_texture_filter_anisotropic.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)}return this._extensions.ext_texture_filter_anisotropic&&R===this._extensions.ext_texture_filter_anisotropic.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()},_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 installTextureManagementMethods(e){Object.assign(e,wd)}const Td={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{webgl_draw_buffers:R}=this._extensions;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,Td)}var Ed=__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(`.`)})),Dd=__commonJSMin(((e,R)=>{R.exports=`<<= >>= ++ -- << >> <= >= == != && || += -= *= /= %= &= ^^ ^= |= ( ) [ ] . ! ~ * / % + - < > & ^ | ? : = , ; { }`.split(` `)})),Od=__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(`.`)})),kd=__commonJSMin(((e,R)=>{R.exports=Ed().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(`.`))})),Ad=__commonJSMin(((e,R)=>{var W=Od();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(`.`))})),jd=__commonJSMin(((e,R)=>{R.exports=tokenize;var W=Ed(),Y=Dd(),X=Od(),ie=kd(),ae=Ad(),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};xt(),hu(),$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&&bt.log(`[fetch] rewrite ${e} → ${X}`),X}catch(R){return W&&bt.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&&bt.log(`[fetch] file:// ${W.url}`);try{let R=Qe.filename_from_uri(W.url)[0];e&&bt.log(`[fetch] file:// path=${R}`);let[Y,X]=Qe.file_get_contents(R);if(e&&bt.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&&bt.log(`[fetch] file:// response created`),le}catch(R){let Y=R instanceof Error?R:Error(String(R));throw e&&bt.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=Uu._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 gs(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 Uu(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 mu.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=Uu),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=Fl),globalThis.CountQueuingStrategy===void 0&&(md.CountQueuingStrategy=Ll);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=jl),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=Rl),globalThis.TextDecoderStream===void 0&&(gd.TextDecoderStream=zl);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=Nl}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=Ml}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}},WebGLActiveInfo=class{constructor(e){this.size=e.size,this.type=e.type,this.name=e.name}},WebGLShaderPrecisionFormat=class{constructor(e){this.rangeMin=e.rangeMin,this.rangeMax=e.rangeMax,this.precision=e.precision}};$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)}var Cd=__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 wd={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)},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))},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&&!(Cd.isPow2(ie)&&Cd.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)))},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()},_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 installTextureManagementMethods(e){Object.assign(e,wd)}const Td={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,Td)}var Ed=__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(`.`)})),Dd=__commonJSMin(((e,R)=>{R.exports=`<<= >>= ++ -- << >> <= >= == != && || += -= *= /= %= &= ^^ ^= |= ( ) [ ] . ! ~ * / % + - < > & ^ | ? : = , ; { }`.split(` `)})),Od=__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(`.`)})),kd=__commonJSMin(((e,R)=>{R.exports=Ed().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(`.`))})),Ad=__commonJSMin(((e,R)=>{var W=Od();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(`.`))})),jd=__commonJSMin(((e,R)=>{R.exports=tokenize;var W=Ed(),Y=Dd(),X=Od(),ie=kd(),ae=Ad(),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}}})),Md=__commonJSMin(((e,R)=>{var W=jd();R.exports=tokenizeString;function tokenizeString(e,R){var Y=W(R),X=[];return X=X.concat(Y(e)),X=X.concat(Y(null)),X}}));xt();var Nd=__toESM(Md(),1);const Pd={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},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)},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)}},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},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},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},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},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`)){bt.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)},_checkShaderSource(e){let R=e._source,W=(0,Nd.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,Nd.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},_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 installShaderProgramMethods(e){Object.assign(e,Pd)}xt();const Fd={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()){bt.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,Fd)}function installAllContextMethods(e){installStateMethods(e),installBufferBindingMethods(e),installTextureManagementMethods(e),installFramebufferMethods(e),installShaderProgramMethods(e),installDrawingMethods(e)}var Id=Ae;Ht();let Ld=0;const Rd={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._=Ld++;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=Cd.log2(Cd.nextPow2(this._maxTextureSize)),this._maxCubeMapSize=this.getParameter(this.MAX_CUBE_MAP_TEXTURE_SIZE),this._maxCubeMapLevel=Cd.log2(Cd.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 Id.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=Rd[R]?Rd[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)}}return this._extensions.oes_standard_derivatives&&e===this._extensions.oes_standard_derivatives.FRAGMENT_SHADER_DERIVATIVE_HINT_OES||this._extensions.ext_texture_filter_anisotropic&&e===this._extensions.ext_texture_filter_anisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT?this._getParameterDirect(e):this._extensions.oes_vertex_array_object&&e===this._extensions.oes_vertex_array_object.VERTEX_ARRAY_BINDING_OES?this._extensions.oes_vertex_array_object._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 Id.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)){if(this._vertexObjectState._attribs[0]._isPointer||this._extensions.webgl_draw_buffers&&this._extensions.webgl_draw_buffers._buffersState&&this._extensions.webgl_draw_buffers._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)}};Ht();const zd={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,zd)}const Bd={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,Bd)}const Vd={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,Vd)}const Hd={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,Hd)}xt();function debugGlEnabled(){return globalThis.__GJSIFY_DEBUG_GL===!0}const Ud={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)&&bt.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&&bt.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&&bt.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,Ud)}Ht();var Wd=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 Id.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(Wd.prototype),installTexImage3DMethods(Wd.prototype),installUniformMethods(Wd.prototype),installClearBufferMethods(Wd.prototype),installInstancedAndFramebufferOpsMethods(Wd.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 gi{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 Wd(this,R)),this._webgl2):super.getContext(e,R)}};const Gd={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`},Kd={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&&Gd[R])return Gd[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&&Kd[R])return Kd[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)}xt();const qd=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&&bt.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 Jd=globalThis;Jd.WebGLRenderingContext=WebGLRenderingContext,Jd.WebGL2RenderingContext=Wd;const Yd=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 gi,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()}}}),Xd=Symbol.for(`gjsify_canvas2d_context`);gi.registerContextFactory(`2d`,(e,R)=>{let W=e[Xd];if(W)return W;let Y=new CanvasRenderingContext2D(e,R);return e[Xd]=Y,Y}),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:Oi,writable:!0,configurable:!0}),xt();
|
|
19
|
+
`+Y+R:Y&&(R=Y+R)}else Y&&(R=Y+R);return R},_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 installShaderProgramMethods(e){Object.assign(e,Pd)}xt();const Fd={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()){bt.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,Fd)}function installAllContextMethods(e){installStateMethods(e),installBufferBindingMethods(e),installTextureManagementMethods(e),installFramebufferMethods(e),installShaderProgramMethods(e),installDrawingMethods(e)}var Id=Ae;Ht();let Ld=0;const Rd={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._=Ld++;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=Cd.log2(Cd.nextPow2(this._maxTextureSize)),this._maxCubeMapSize=this.getParameter(this.MAX_CUBE_MAP_TEXTURE_SIZE),this._maxCubeMapLevel=Cd.log2(Cd.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 Id.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=Rd[R]?Rd[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 Id.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)}};Ht();const zd={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,zd)}const Bd={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,Bd)}const Vd={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,Vd)}const Hd={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,Hd)}xt();function debugGlEnabled(){return globalThis.__GJSIFY_DEBUG_GL===!0}const Ud={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)&&bt.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&&bt.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&&bt.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,Ud)}Ht();var Wd=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 Id.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(Wd.prototype),installTexImage3DMethods(Wd.prototype),installUniformMethods(Wd.prototype),installClearBufferMethods(Wd.prototype),installInstancedAndFramebufferOpsMethods(Wd.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 gi{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 Wd(this,R)),this._webgl2):super.getContext(e,R)}};const Gd={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`},Kd={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&&Gd[R])return Gd[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&&Kd[R])return Kd[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)}xt();const qd=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&&bt.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 Jd=globalThis;Jd.WebGLRenderingContext=WebGLRenderingContext,Jd.WebGL2RenderingContext=Wd;const Yd=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 gi,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()}}}),Xd=Symbol.for(`gjsify_canvas2d_context`);gi.registerContextFactory(`2d`,(e,R)=>{let W=e,Y=W[Xd];if(Y)return Y;let X=new CanvasRenderingContext2D(e,R);return W[Xd]=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:Oi,writable:!0,configurable:!0}),xt();
|
|
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>
|
|
@@ -894,7 +894,7 @@ void main(){
|
|
|
894
894
|
`;return W=W.replace(`%%texture_picker%%`,Y),W}_addImageAsTexture(e){if(this._images.has(e))return;let R=e.getAttribute(vp.Filtering),W=R?parseImageFiltering(R):void 0,Y=parseImageWrapping(e.getAttribute(vp.WrappingX)),X=parseImageWrapping(e.getAttribute(vp.WrappingY)),ie=e.getAttribute(`forceUpload`)===`true`,ae=this._context.textureLoader.load(e,{filtering:W,wrapping:{x:Y,y:X}},ie);e.removeAttribute(`forceUpload`),this._textures.indexOf(ae)===-1&&(this._textures.push(ae),this._textureToIndex.set(ae,this._textureIndex++),this._images.add(e))}_bindTextures(e){let R=Math.min(this._textureIndex,this._maxTextures);for(let W=0;W<R;W++)e.activeTexture(e.TEXTURE0+W),e.bindTexture(e.TEXTURE_2D,this._textures[W]||this._textures[0])}_getTextureIdForImage(e){if(e){let R=this._context.textureLoader.get(e);return this._textureToIndex.get(R)??-1}return-1}_isFull(){return this._imageCount>=this._maxImages||this._textures.length>=this._maxTextures}_getImageWidth(e){let R=this._imageToWidth.get(e);return R===void 0&&(R=e.width,this._imageToWidth.set(e,R)),R}_getImageHeight(e){let R=this._imageToHeight.get(e);return R===void 0&&(R=e.height,this._imageToHeight.set(e,R)),R}draw(e,R,W,Y,X,ie,ae,le,_e){this._isFull()&&this.flush(),this._imageCount++,this._addImageAsTexture(e);let ye=this._getImageWidth(e),be=this._getImageHeight(e),Ce=ye||Y||0,Te=be||X||0;this._view[0]=0,this._view[1]=0,this._view[2]=Y??ye??0,this._view[3]=X??be??0,this._dest[0]=R??1,this._dest[1]=W??1,ie!==void 0&&ae!==void 0&&le!==void 0&&_e!==void 0&&(this._view[0]=R??1,this._view[1]=W??1,this._view[2]=Y??ye??0,this._view[3]=X??be??0,this._dest[0]=ie,this._dest[1]=ae,Ce=le,Te=_e),R=this._view[0],W=this._view[1];let Oe=this._view[2],Ae=this._view[3],Me=this._context.getTransform(),Pe=this._context.opacity;this._context.snapToPixel&&(this._dest[0]=~~(this._dest[0]+Wp),this._dest[1]=~~(this._dest[1]+Wp));let Re=this._context.tint||this._defaultTint,Be=this._getTextureIdForImage(e),Ve=ye||Ce,He=be||Te,Ue=(R+this.uvPadding)/Ve,We=(W+this.uvPadding)/He,Ge=(R+Oe-this.uvPadding)/Ve,Ke=(W+Ae-this.uvPadding)/He,qe=ye,Je=be,Ye=this._transformData.bufferData;Ye[this._vertexIndex++]=this._dest[0],Ye[this._vertexIndex++]=this._dest[1],Ye[this._vertexIndex++]=Me.data[0],Ye[this._vertexIndex++]=Me.data[1],Ye[this._vertexIndex++]=Me.data[2],Ye[this._vertexIndex++]=Me.data[3],Ye[this._vertexIndex++]=Me.data[4],Ye[this._vertexIndex++]=Me.data[5],Ye[this._vertexIndex++]=Pe,Ye[this._vertexIndex++]=Ce,Ye[this._vertexIndex++]=Te,Ye[this._vertexIndex++]=qe,Ye[this._vertexIndex++]=Je,Ye[this._vertexIndex++]=Be,Ye[this._vertexIndex++]=Ue,Ye[this._vertexIndex++]=We,Ye[this._vertexIndex++]=Ge,Ye[this._vertexIndex++]=Ke,Ye[this._vertexIndex++]=Re.r/255,Ye[this._vertexIndex++]=Re.g/255,Ye[this._vertexIndex++]=Re.b/255,Ye[this._vertexIndex++]=Re.a}hasPendingDraws(){return this._imageCount!==0}flush(){if(this._imageCount===0)return;let e=this._gl;this._shader.use(),this._bindData(e),this._shader.setUniformMatrix(`u_matrix`,this._context.ortho),this._shader.setUniformBoolean(`u_pixelart`,this.pixelArtSampler),this._bindTextures(e),e.drawArraysInstanced(e.TRIANGLES,0,6,this._imageCount),Pp.DrawnImagesCount+=this._imageCount,Pp.DrawCallCount++,e.bindVertexArray(null),this._imageCount=0,this._vertexIndex=0,this._textures.length=0,this._textureIndex=0,this._textureToIndex.clear(),this._images.clear(),this._imageToWidth.clear(),this._imageToHeight.clear()}};const Wp=1e-4;var ExcaliburGraphicsContextWebGLDebug=class{constructor(e){this._webglCtx=e,this._debugText=new DebugText}drawRect(e,R,W,Y,X={color:gf.Black}){this.drawLine(vec(e,R),vec(e+W,R),{...X}),this.drawLine(vec(e+W,R),vec(e+W,R+Y),{...X}),this.drawLine(vec(e+W,R+Y),vec(e,R+Y),{...X}),this.drawLine(vec(e,R+Y),vec(e,R),{...X})}drawLine(e,R,W){this._webglCtx.save(),this._webglCtx.z=W?.dashed?wp.config.settings.z.dashed:wp.config.settings.z.solid,this._webglCtx.draw(`ex.debug-line`,e,R,W?.color??gf.Black,W?.lineWidth,W?.dashed),this._webglCtx.restore()}drawPoint(e,R={color:gf.Black,size:5}){this._webglCtx.save(),this._webglCtx.z=wp.config.settings.z.point,this._webglCtx.draw(`ex.debug-point`,e,R.color,R.size),this._webglCtx.restore()}drawCircle(e,R,W,Y,X){this._webglCtx.save(),this._webglCtx.z=wp.config.settings.z.solid,this._webglCtx.draw(`ex.debug-circle`,e,R,W,Y,X),this._webglCtx.restore()}drawText(e,R){this._webglCtx.save(),this._webglCtx.z=wp.config.settings.z.text,this._debugText.write(this._webglCtx,e,R),this._webglCtx.restore()}},ExcaliburGraphicsContextWebGL=class{constructor(e){this._logger=bf.getInstance(),this._renderers=new Map,this._lazyRenderersFactory=new Map,this.imageRenderer=Qd.isEnabled(`use-legacy-image-renderer`)?`ex.image`:`ex.image-v2`,this._isDrawLifecycle=!1,this.useDrawSorting=!0,this._drawCallPool=new Pool(()=>new DrawCall,void 0,4e3),this._drawCallIndex=0,this._drawCalls=Array(4e3).fill(null),this._postProcessTargets=[],this._postprocessors=[],this._transform=new TransformStack,this._state=new StateStack,this.snapToPixel=!1,this.smoothing=!1,this.pixelArtSampler=!1,this.uvPadding=.01,this.backgroundColor=gf.ExcaliburBlue,this.multiSampleAntialiasing=!0,this.transparency=!0,this._isContextLost=!1,this._disposed=!1,this._imageToWidth=new Map,this._imageToHeight=new Map,this._totalPostProcessorTime=0;let{canvasElement:R,context:W,enableTransparency:Y,antialiasing:X,uvPadding:ie,multiSampleAntialiasing:ae,pixelArtSampler:le,powerPreference:_e,snapToPixel:ye,backgroundColor:be,useDrawSorting:Ce,garbageCollector:Te,handleContextLost:Oe,handleContextRestored:Ae}=e;if(this.__gl=W??R.getContext(`webgl2`,{antialias:X??this.smoothing,premultipliedAlpha:!1,alpha:Y??this.transparency,depth:!1,powerPreference:_e??`high-performance`}),!this.__gl)throw Error(`Failed to retrieve webgl context from browser`);Oe&&this.__gl.canvas.addEventListener(`webglcontextlost`,Oe,!1),Ae&&this.__gl.canvas.addEventListener(`webglcontextrestored`,Ae,!1),this.__gl.canvas.addEventListener(`webglcontextlost`,()=>{this._isContextLost=!0}),this.__gl.canvas.addEventListener(`webglcontextrestored`,()=>{this._isContextLost=!1}),this.textureLoader=new _p(this.__gl,Te),this.snapToPixel=ye??this.snapToPixel,this.smoothing=X??this.smoothing,this.transparency=Y??this.transparency,this.pixelArtSampler=le??this.pixelArtSampler,this.uvPadding=ie??this.uvPadding,this.multiSampleAntialiasing=typeof ae==`boolean`?ae:this.multiSampleAntialiasing,this.samples=typeof ae==`object`?ae.samples:void 0,this.backgroundColor=be??this.backgroundColor,this.useDrawSorting=Ce??this.useDrawSorting,this._drawCallPool.disableWarnings=!0,this._drawCallPool.preallocate(),this._init()}get z(){return this._state.current.z}set z(e){this._state.current.z=e}get opacity(){return this._state.current.opacity}set opacity(e){this._state.current.opacity=e}get tint(){return this._state.current.tint}set tint(e){this._state.current.tint=e}get width(){return this.__gl.canvas.width}get height(){return this.__gl.canvas.height}get ortho(){return this._ortho}checkIfResolutionSupported(e){let R=!0;return(e.width>4096||e.height>4096)&&(R=!1),R}dispose(){if(!this._disposed){this._disposed=!0,this.textureLoader.dispose();for(let e of this._renderers.values())e.dispose();this._renderers.clear(),this._drawCallPool.dispose(),this._drawCalls.length=0,this.__gl=null}}_init(){let e=this.__gl;if(this._ortho=cf.ortho(0,e.canvas.width,e.canvas.height,0,400,-400),e.viewport(0,0,e.canvas.width,e.canvas.height),e.clearColor(this.backgroundColor.r/255,this.backgroundColor.g/255,this.backgroundColor.b/255,this.backgroundColor.a),e.clear(e.COLOR_BUFFER_BIT),e.enable(e.BLEND),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),e.depthMask(!1),this.register(new ImageRenderer({uvPadding:this.uvPadding,pixelArtSampler:this.pixelArtSampler})),this.register(new MaterialRenderer),this.register(new RectangleRenderer),this.register(new CircleRenderer),this.lazyRegister(`ex.debug-circle`,()=>new DebugCircleRenderer),this.lazyRegister(`ex.debug-point`,()=>new DebugPointRenderer),this.lazyRegister(`ex.debug-line`,()=>new DebugLineRenderer),this.lazyRegister(`ex.particle`,()=>new ParticleRenderer),this.register(new ImageRendererV2({uvPadding:this.uvPadding,pixelArtSampler:this.pixelArtSampler})),this.materialScreenTexture=e.createTexture(),!this.materialScreenTexture)throw Error(`Could not create screen texture!`);e.bindTexture(e.TEXTURE_2D,this.materialScreenTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.width,this.height,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.bindTexture(e.TEXTURE_2D,null),this._screenRenderer=new ScreenPassPainter(this),this._renderTarget=new RenderTarget({gl:e,transparency:this.transparency,width:e.canvas.width,height:e.canvas.height}),this._postProcessTargets=[new RenderTarget({gl:e,transparency:this.transparency,width:e.canvas.width,height:e.canvas.height}),new RenderTarget({gl:e,transparency:this.transparency,width:e.canvas.width,height:e.canvas.height})],this._msaaTarget=new RenderTarget({gl:e,transparency:this.transparency,width:e.canvas.width,height:e.canvas.height,antialias:this.multiSampleAntialiasing,samples:this.samples}),this.debug=new ExcaliburGraphicsContextWebGLDebug(this)}register(e){this._renderers.set(e.type,e),e.initialize(this.__gl,this)}lazyRegister(e,R){this._lazyRenderersFactory.set(e,R)}get(e){let R=this._renderers.get(e);if(!R){let W=this._lazyRenderersFactory.get(e);W&&(this._logger.debug(`lazy init renderer:`,e),R=W(),this.register(R))}return R}_isCurrentRenderer(e){return!this._currentRenderer||this._currentRenderer===e}beginDrawLifecycle(){this._isDrawLifecycle=!0}endDrawLifecycle(){this._isDrawLifecycle=!1}draw(e,...R){if(R.length>9)throw Error(`Only 10 or less renderer arguments are supported!;`);if(this._isDrawLifecycle||this._logger.warnOnce(`Attempting to draw outside the the drawing lifecycle (preDraw/postDraw) is not supported and is a source of bugs/errors.
|
|
895
895
|
If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPostDraw handler.`),this._isContextLost){this._logger.errorOnce(`Unable to draw ${e}, the webgl context is lost`);return}let W=this.get(e);if(W)if(this.useDrawSorting){let Y=this._drawCallPool.get();Y.z=this._state.current.z,Y.priority=W.priority,Y.renderer=e,this.getTransform().clone(Y.transform),Y.state.z=this._state.current.z,Y.state.opacity=this._state.current.opacity,Y.state.tint=this._state.current.tint,Y.state.material=this._state.current.material,Y.args[0]=R[0],Y.args[1]=R[1],Y.args[2]=R[2],Y.args[3]=R[3],Y.args[4]=R[4],Y.args[5]=R[5],Y.args[6]=R[6],Y.args[7]=R[7],Y.args[8]=R[8],Y.args[9]=R[9],this._drawCalls[this._drawCallIndex++]=Y}else this._currentRenderer||=W,this._isCurrentRenderer(W)||this._currentRenderer.flush(),W.draw(R[0],R[1],R[2],R[3],R[4],R[5],R[6],R[7],R[8],R[9]),this._currentRenderer=W;else throw Error(`No renderer with name ${e} has been registered`)}resetTransform(){this._transform.reset()}updateViewport(e){let R=this.__gl;this._ortho=this._ortho=cf.ortho(0,e.width,e.height,0,400,-400),this._renderTarget.setResolution(R.canvas.width,R.canvas.height),this._msaaTarget.setResolution(R.canvas.width,R.canvas.height),this._postProcessTargets[0].setResolution(R.canvas.width,R.canvas.height),this._postProcessTargets[1].setResolution(R.canvas.width,R.canvas.height)}_getImageWidth(e){let R=this._imageToWidth.get(e);return R===void 0&&(R=e.width,this._imageToWidth.set(e,R)),R}_getImageHeight(e){let R=this._imageToHeight.get(e);return R===void 0&&(R=e.height,this._imageToHeight.set(e,R)),R}drawImage(e,R,W,Y,X,ie,ae,le,_e){if(!(Y===0||X===0)&&!(le===0||_e===0)&&!(this._getImageWidth(e)===0||this._getImageHeight(e)===0)){if(!e){bf.getInstance().warn(`Cannot draw a null or undefined image`),bt.trace&&bt.trace();return}this._state.current.material?this.draw(`ex.material`,e,R,W,Y,X,ie,ae,le,_e):(this.imageRenderer,this.draw(this.imageRenderer,e,R,W,Y,X,ie,ae,le,_e))}}drawLine(e,R,W,Y=1){this.draw(`ex.rectangle`,e,R,W,Y)}drawRectangle(e,R,W,Y,X,ie){this.draw(`ex.rectangle`,e,R,W,Y,X,ie)}drawCircle(e,R,W,Y,X){this.draw(`ex.circle`,e,R,W,Y,X)}save(){this._transform.save(),this._state.save()}restore(){this._transform.restore(),this._state.restore()}translate(e,R){this._transform.translate(this.snapToPixel?~~(e+Wp):e,this.snapToPixel?~~(R+Wp):R)}rotate(e){this._transform.rotate(e)}scale(e,R){this._transform.scale(e,R)}transform(e){this._transform.current=e}getTransform(){return this._transform.current}multiply(e){this._transform.current.multiply(e,this._transform.current)}addPostProcessor(e){this._postprocessors.push(e),e.initialize(this)}removePostProcessor(e){let R=this._postprocessors.indexOf(e);R!==-1&&this._postprocessors.splice(R,1)}clearPostProcessors(){this._postprocessors.length=0}updatePostProcessors(e){for(let R of this._postprocessors){let W=R.getShader();W.use();let Y=W.getUniformDefinitions();this._totalPostProcessorTime+=e,Y.find(e=>e.name===`u_time_ms`)&&W.setUniformFloat(`u_time_ms`,this._totalPostProcessorTime),Y.find(e=>e.name===`u_elapsed_ms`)&&W.setUniformFloat(`u_elapsed_ms`,e),Y.find(e=>e.name===`u_resolution`)&&W.setUniformFloatVector(`u_resolution`,vec(this.width,this.height)),R.onUpdate&&R.onUpdate(e)}}set material(e){this._state.current.material=e}get material(){return this._state.current.material}createMaterial(e){return new Up({...e,graphicsContext:this})}createShader(e){let{name:R,vertexSource:W,fragmentSource:Y,uniforms:X,images:ie,startingTextureSlot:ae}=e,le=new Lp({name:R,graphicsContext:this,vertexSource:W,fragmentSource:Y,uniforms:X,images:ie,startingTextureSlot:ae});return le.compile(),le}clear(){let e=this.__gl;(this.multiSampleAntialiasing?this._msaaTarget:this._renderTarget).use(),e.clearColor(this.backgroundColor.r/255,this.backgroundColor.g/255,this.backgroundColor.b/255,this.backgroundColor.a),e.clear(e.COLOR_BUFFER_BIT)}flush(){if(this._isContextLost){this._logger.errorOnce(`Unable to flush the webgl context is lost`);return}let e=this.multiSampleAntialiasing?this._msaaTarget:this._renderTarget;if(e.use(),this.useDrawSorting){for(let e=this._drawCallIndex;e<this._drawCalls.length;e++)this._drawCalls[e]=null;let R=new Map;for(let[e]of this._renderers){let W=0;for(W=0;W<this._drawCallIndex&&this._drawCalls[W].renderer!==e;W++);R.set(e,W)}this._drawCalls.sort((e,W)=>{if(e===null||W===null)return 0;let Y=e.z-W.z,X=R.get(e.renderer)-R.get(W.renderer),ie=e.priority-W.priority;return Y===0?ie===0?X:ie:Y});let W=this._transform.current,Y=this._state.current;if(this._drawCalls.length&&this._drawCallIndex){let R=this._drawCalls[0].renderer,W=this.get(R);for(let Y=0;Y<this._drawCallIndex;Y++)this._transform.current=this._drawCalls[Y].transform,this._state.current=this._drawCalls[Y].state,this._drawCalls[Y].renderer!==R&&(W.flush(),R=this._drawCalls[Y].renderer,W=this.get(R),Pp.RendererSwaps++),W instanceof MaterialRenderer&&this.material?.isUsingScreenTexture&&(e.copyToTexture(this.materialScreenTexture),e.use()),W.draw(...this._drawCalls[Y].args);W.hasPendingDraws()&&W.flush()}this._transform.current=W,this._state.current=Y,this._drawCallPool.done(),this._drawCallIndex=0,this._imageToHeight.clear(),this._imageToWidth.clear()}else for(let e of this._renderers.values())e.hasPendingDraws()&&e.flush();e.disable(),this._postprocessors.length>0&&e.toRenderSource().use();for(let R=0;R<this._postprocessors.length;R++)e=this._postProcessTargets[R%2],this._postProcessTargets[R%2].use(),this._screenRenderer.renderWithPostProcessor(this._postprocessors[R]),this._postProcessTargets[R%2].toRenderSource().use();e.blitToScreen()}},Gp=class FontTextInstance{constructor(e,R,W,Y){this.font=e,this.text=R,this.color=W,this.maxWidth=Y,this._textFragments=[],this.disposed=!1,this._dirty=!0,this.canvas=document.createElement(`canvas`);let X=this.canvas.getContext(`2d`);if(!X)throw Error(`Unable to create FontTextInstance, internal canvas failed to create`);this.ctx=X,this.dimensions=this.measureText(R),this._setDimension(this.dimensions,this.ctx),this._lastHashCode=this.getHashCode()}measureText(e,R){if(this.disposed)throw Error(`Accessing disposed text instance! `+this.text);let W=null;W=R==null?e.split(`
|
|
896
896
|
`):this._getLinesFromText(e,R);let Y=W.reduce((e,R)=>e.length>R.length?e:R);this._applyFont(this.ctx);let X=this.ctx.measureText(Y),ie=Math.abs(X.actualBoundingBoxAscent)+Math.abs(X.actualBoundingBoxDescent),ae=ie*W.length;ie=ae;let le=ae-Math.abs(X.actualBoundingBoxAscent);return new Pf({left:0-Math.abs(X.actualBoundingBoxLeft)-this.font.padding,top:0-Math.abs(X.actualBoundingBoxAscent)-this.font.padding,bottom:0+le+this.font.padding,right:0+Math.abs(X.actualBoundingBoxRight)+this.font.padding})}_setDimension(e,R){let W=1;this.font.lineHeight&&(W=this.font.lineHeight/this.font.size),R.canvas.width=(e.width+this.font.padding*2)*2*this.font.quality,R.canvas.height=(e.height+this.font.padding*2)*2*this.font.quality*W}static getHashCode(e,R,W){return R+`__hashcode__`+e.fontString+e.showDebug+e.textAlign+e.baseAlign+e.direction+e.lineHeight+JSON.stringify(e.shadow)+(e.padding.toString()+e.smoothing.toString()+e.lineWidth.toString()+e.lineDash.toString()+e.strokeColor?.toString()+(W?W.toString():e.color.toString()))}getHashCode(e=!0){return FontTextInstance.getHashCode(this.font,this.text,e?this.color:void 0)}_applyRasterProperties(e){e.translate(this.font.padding,this.font.padding),e.imageSmoothingEnabled=this.font.smoothing,e.lineWidth=this.font.lineWidth,e.setLineDash(this.font.lineDash??e.getLineDash()),e.strokeStyle=this.font.strokeColor?.toString()??``,e.fillStyle=this.color.toString()}_applyFont(e){e.resetTransform(),e.translate(this.font.padding+e.canvas.width/2,this.font.padding+e.canvas.height/2),e.scale(this.font.quality,this.font.quality),e.textAlign=this.font.textAlign,e.textBaseline=this.font.baseAlign,e.font=this.font.fontString,e.direction=this.font.direction,this.font.shadow&&(this.font.shadow.color&&(e.shadowColor=this.font.shadow.color.toString()),this.font.shadow.blur&&(e.shadowBlur=this.font.shadow.blur),this.font.shadow.offset&&(e.shadowOffsetX=this.font.shadow.offset.x,e.shadowOffsetY=this.font.shadow.offset.y))}_drawText(e,R,W){this._applyRasterProperties(e),this._applyFont(e);for(let Y=0;Y<R.length;Y++){let X=R[Y];this.color&&e.fillText(X,0,Y*W),this.font.strokeColor&&e.strokeText(X,0,Y*W)}this.font.showDebug&&(line(e,gf.Green,-e.canvas.width/2,0,e.canvas.width/2,0,2),line(e,gf.Red,0,-e.canvas.height/2,0,e.canvas.height/2,2))}_splitTextBitmap(e){let R=[],W=0,Y=0,X=Math.min(4096,e.canvas.width),ie=Math.min(4096,e.canvas.height);for(;W<e.canvas.width;){for(;Y<e.canvas.height;){let ae=document.createElement(`canvas`);ae.width=X,ae.height=ie;let le=ae.getContext(`2d`);if(!le)throw Error(`Unable to split internal FontTextInstance bitmap, failed to create internal canvas`);le.drawImage(e.canvas,W,Y,X,ie,0,0,X,ie),R.push({x:W,y:Y,canvas:ae}),Y+=ie}W+=X,Y=0}return R}flagDirty(){this._dirty=!0}render(e,R,W,Y){if(this.disposed)throw Error(`Accessing disposed text instance! `+this.text);this._ex=e;let X=this.getHashCode();if(this._lastHashCode!==X&&(this._dirty=!0),this._dirty){this.dimensions=this.measureText(this.text,Y),this._setDimension(this.dimensions,this.ctx);let R=this._getLinesFromText(this.text,Y),W=this.font.lineHeight??this.dimensions.height/R.length;if(this._drawText(this.ctx,R,W),e instanceof ExcaliburGraphicsContextWebGL)for(let R of this._textFragments)e.textureLoader.delete(R.canvas);if(this._textFragments=this._splitTextBitmap(this.ctx),e instanceof ExcaliburGraphicsContextWebGL)for(let R of this._textFragments)e.textureLoader.load(R.canvas,{filtering:this.font.filtering},!0);this._lastHashCode=X,this._dirty=!1}for(let Y of this._textFragments)e.drawImage(Y.canvas,0,0,Y.canvas.width,Y.canvas.height,Y.x/this.font.quality+R-this.ctx.canvas.width/this.font.quality/2,Y.y/this.font.quality+W-this.ctx.canvas.height/this.font.quality/2,Y.canvas.width/this.font.quality,Y.canvas.height/this.font.quality)}dispose(){if(this.disposed=!0,this.dimensions=void 0,this.canvas=void 0,this.ctx=void 0,this._ex instanceof ExcaliburGraphicsContextWebGL)for(let e of this._textFragments)this._ex.textureLoader.delete(e.canvas);this._textFragments.length=0}_getLinesFromText(e,R){if(this._cachedText===e&&this._cachedRenderWidth===R&&this._cachedLines?.length)return this._cachedLines;let W=e.split(`
|
|
897
|
-
`);if(R==null)return W;for(let e=0;e<W.length;e++){let Y=W[e],X=``;if(this.measureText(Y).width>R){for(;this.measureText(Y).width>R;)X=Y[Y.length-1]+X,Y=Y.slice(0,-1);W[e]=Y,W[e+1]=X}}return this._cachedText=e,this._cachedLines=W,this._cachedRenderWidth=R,W}},Kp=class Font extends rp{constructor(e={}){super(e),this.filtering=pp.Blended,this.quality=2,this.padding=2,this.smoothing=!1,this.lineWidth=1,this.lineDash=[],this.color=gf.Black,this.family=`sans-serif`,this.style=dp.Normal,this.bold=!1,this.unit=cp.Px,this.textAlign=lp.Left,this.baseAlign=up.Top,this.direction=fp.LeftToRight,this.lineHeight=void 0,this.size=10,this._textBounds=new Pf,this.smoothing=e?.smoothing??this.smoothing,this.padding=e?.padding??this.padding,this.color=e?.color??this.color,this.strokeColor=e?.strokeColor??this.strokeColor,this.lineDash=e?.lineDash??this.lineDash,this.lineWidth=e?.lineWidth??this.lineWidth,this.filtering=e?.filtering??this.filtering,this.family=e?.family??this.family,this.style=e?.style??this.style,this.bold=e?.bold??this.bold,this.size=e?.size??this.size,this.unit=e?.unit??this.unit,this.textAlign=e?.textAlign??this.textAlign,this.baseAlign=e?.baseAlign??this.baseAlign,this.direction=e?.direction??this.direction,this.lineHeight=e?.lineHeight??this.lineHeight,this.quality=e?.quality??this.quality,e?.shadow&&(this.shadow={},this.shadow.blur=e.shadow.blur??this.shadow.blur,this.shadow.offset=e.shadow.offset??this.shadow.offset,this.shadow.color=e.shadow.color??this.shadow.color),this._textMeasurement=new Gp(this,``,gf.Black)}clone(){return new Font({...this.cloneGraphicOptions(),size:this.size,unit:this.unit,family:this.family,style:this.style,bold:this.bold,textAlign:this.textAlign,baseAlign:this.baseAlign,direction:this.direction,shadow:this.shadow?{blur:this.shadow.blur,offset:this.shadow.offset,color:this.shadow.color}:void 0})}get fontString(){return`${this.style} ${this.bold?`bold`:``} ${this.size}${this.unit} ${this.family}`}get localBounds(){return this._textBounds}_drawImage(e,R,W){}_rotate(e){let R=this.origin??this._textBounds.center;e.translate(R.x,R.y),e.rotate(this.rotation),e.translate(-R.x,-R.y)}_flip(e){this.flipHorizontal&&(e.translate(this._textBounds.width/this.scale.x,0),e.scale(-1,1)),this.flipVertical&&(e.translate(0,-this._textBounds.height/2/this.scale.y),e.scale(1,-1))}measureTextWithoutCache(e,R){return this._textMeasurement.measureText(e,R)}measureText(e,R){return Ep.measureText(e,this,R)}_postDraw(e){e.restore()}render(e,R,W,Y,X,ie){let ae=Ep.getTextInstance(R,this,W);this._textBounds=ae.dimensions,this._preDraw(e,Y,X),ae.render(e,Y,X,ie),this._postDraw(e)}},qp=class Text extends rp{constructor(e){super(e),this._text=``,this._textWidth=0,this._textHeight=0,this.font=e.font??new Kp,this.color=e.color??this.color,this.text=e.text,this.maxWidth=e.maxWidth}clone(){return new Text({text:this.text.slice(),color:this.color?.clone()??gf.Black,font:this.font.clone(),maxWidth:this.maxWidth})}get text(){return this._text}set text(e){this._text=e,this._calculateDimension()}get font(){return this._font}set font(e){this._font=e}get width(){return this._textWidth===0&&this._calculateDimension(),this._textWidth*this.scale.x}get height(){return this._textHeight===0&&this._calculateDimension(),this._textHeight*this.scale.y}_calculateDimension(){let{width:e,height:R}=this.font.measureText(this._text,this.maxWidth);this._textWidth=e,this._textHeight=R}get localBounds(){return this.font.measureText(this._text,this.maxWidth).scale(this.scale)}_rotate(e){}_flip(e){}_preDraw(e,R,W){(this.isStale()||this.font.isStale())&&(this.font.flipHorizontal=this.flipHorizontal,this.font.flipVertical=this.flipVertical,this.font.rotation=this.rotation,this.font.origin=this.origin,this.font.opacity=this.opacity),this.font.tint=this.tint,super._preDraw(e,R,W)}_drawImage(e,R,W){let Y=gf.Black;this.font instanceof Kp&&(Y=this.color??this.font.color);let{width:X,height:ie}=this.font.measureText(this._text,this.maxWidth);this._textWidth=X,this._textHeight=ie,this.font.render(e,this._text,Y,R,W,this.maxWidth),this.font.showDebug&&(e.debug.drawRect(R-X,W-ie,X*2,ie*2),this.maxWidth!=null&&e.debug.drawRect(R,W,this.maxWidth,this.height,{color:gf.Yellow}))}};function hasGraphicsTick(e){return!!e.tick}var Jp=class GraphicsComponent extends Component{constructor(e){super(),this._logger=bf.getInstance(),this._current=`default`,this._graphics={},this._options={},this.material=null,this.isVisible=!0,this.forceOnScreen=!1,this.opacity=1,this._offset=new WatchVector(sf.Zero,()=>this.recalculateBounds()),this._anchor=new WatchVector(sf.Half,()=>this.recalculateBounds()),this.flipHorizontal=!1,this.flipVertical=!1,this.copyGraphics=!1,e={visible:this.isVisible,graphics:{},...e};let{current:R,anchor:W,color:Y,opacity:X,visible:ie,graphics:ae,offset:le,copyGraphics:_e,onPreDraw:ye,onPostDraw:be,onPreTransformDraw:Ce,onPostTransformDraw:Te}=e;for(let[e,R]of Object.entries(ae))R instanceof rp?this._graphics[e]=R:(this._graphics[e]=R.graphic,this._options[e]=R.options);this.offset=le??this.offset,this.opacity=X??this.opacity,this.anchor=W??this.anchor,this.color=Y??this.color,this.copyGraphics=_e??this.copyGraphics,this.onPreDraw=ye??this.onPreDraw,this.onPostDraw=be??this.onPostDraw,this.onPreDraw=Ce??this.onPreTransformDraw,this.onPostTransformDraw=Te??this.onPostTransformDraw,this.isVisible=!!ie,this._current=R??this._current,R&&this._graphics[R]&&this.use(R)}get visible(){return this.isVisible}set visible(e){this.isVisible=e}get offset(){return this._offset}set offset(e){this._offset=new WatchVector(e,()=>this.recalculateBounds()),this.recalculateBounds()}get anchor(){return this._anchor}set anchor(e){this._anchor=new WatchVector(e,()=>this.recalculateBounds()),this.recalculateBounds()}get color(){return this._color}set color(e){if(e){this._color=e.clone();let R=this.current;(R instanceof Raster||R instanceof qp)&&(R.color=this._color)}}getGraphic(e){return this._graphics[e]}getOptions(e){return this._options[e]}getNames(){return Object.keys(this._graphics)}get current(){return this._graphics[this._current]}get currentOptions(){return this._options[this._current]}get graphics(){return this._graphics}get options(){return this._options}add(e,R,W){let Y=`default`,X=null,ie;if(typeof e==`string`&&R instanceof rp&&(Y=e,X=R,ie=W),e instanceof rp&&!(R instanceof rp)&&(X=e,ie=R),!X)throw Error(`Need to provide a graphic or valid graphic string`);return this._graphics[Y]=this.copyGraphics?X.clone():X,this._options[Y]=this.copyGraphics?{...ie}:ie,Y===`default`&&this.use(`default`),X}remove(e){delete this._graphics[e],delete this._options[e],this._current===e&&(this._current=`default`,this.recalculateBounds())}use(e,R){if(e instanceof rp){let W=e;this.copyGraphics&&(W=e.clone()),this._current=`default`,this._graphics[this._current]=W,this._options[this._current]=R}else this._current=e,this._options[this._current]=R,this._current in this._graphics||this._logger.warn(`Graphic ${this._current} is not registered with the graphics component owned by ${this.owner?.name}. Nothing will be drawn.`);return this.recalculateBounds(),this.current}hide(){this._current=`ex.none`}set localBounds(e){this._localBounds=e}recalculateBounds(){let e=new Pf,R=this._graphics[this._current],W=this._options[this._current];if(!R){this._localBounds=e;return}let Y=this.anchor,X=this.offset;W?.anchor&&(Y=W.anchor),W?.offset&&(X=W.offset);let ie=R.localBounds,ae=-ie.width*Y.x+X.x,le=-ie.height*Y.y+X.y;e=R instanceof sp&&!R.useAnchor?R?.localBounds.combine(e):R?.localBounds.translate(vec(ae,le)).combine(e),this._localBounds=e}get localBounds(){return(!this._localBounds||this._localBounds.hasZeroDimensions())&&this.recalculateBounds(),this._localBounds}get bounds(){let e=this.localBounds;if(this.owner){let R=this.owner.get(Sf);R&&(e=e.transform(R.get().matrix))}return e}update(e,R=0){let W=this.current;W&&hasGraphicsTick(W)&&W.tick(e,R)}clone(){let e=new GraphicsComponent;return e._graphics={...this._graphics},e._options={...this._options},e.offset=this.offset.clone(),this.color&&(e.color=this.color.clone()),e.opacity=this.opacity,e.anchor=this.anchor.clone(),e.copyGraphics=this.copyGraphics,e.onPreDraw=this.onPreDraw,e.onPostDraw=this.onPostDraw,e.isVisible=this.isVisible,e}},PointerComponent=class extends Component{constructor(e){super(),this.useColliderShape=!0,this.useGraphicsBounds=!0,this.useColliderShape=e?.useColliderShape??this.useColliderShape,this.useGraphicsBounds=e?.useGraphicsBounds??this.useGraphicsBounds,this.localBounds=e?.localBounds}};function isLegacyEasing(e){return!!e&&e.length===4}const Yp=class _EasingFunctions2{static CreateReversibleEasingFunction(e){return(R,W,Y,X)=>Y<W?W-(e(R,Y,W,X)-Y):e(R,W,Y,X)}static CreateVectorEasingFunction(e){return(R,W,Y,X)=>new sf(e(R,W.x,Y.x,X),e(R,W.y,Y.y,X))}};Yp.Linear=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,W*e/Y+R)),Yp.EaseInQuad=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y,W*e*e+R)),Yp.EaseOutQuad=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y,-W*e*(e-2)+R)),Yp.EaseInOutQuad=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y/2,e<1?W/2*e*e+R:(e--,-W/2*(e*(e-2)-1)+R))),Yp.EaseInCubic=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y,W*e*e*e+R)),Yp.EaseOutCubic=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y,e--,W*(e*e*e+1)+R)),Yp.EaseInOutCubic=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y/2,e<1?W/2*e*e*e+R:(e-=2,W/2*(e*e*e+2)+R)));let Xp=Yp;var ActionQueue=class{constructor(e){this._actions=[],this._currentAction=null,this._completedActions=[],this._entity=e}add(e){this._actions.push(e)}remove(e){let R=this._actions.indexOf(e);this._actions.splice(R,1)}clearActions(){this._actions.length=0,this._completedActions.length=0,this._currentAction&&this._currentAction.stop()}getActions(){return this._actions.concat(this._completedActions)}getIncompleteActions(){return this._actions}getCurrentAction(){return this._currentAction}hasNext(){return this._actions.length>0}isComplete(){return this._actions.length===0}reset(){this._actions=this.getActions();let e=this._actions.length;for(let R=0;R<e;R++)this._actions[R].reset();this._completedActions=[]}update(e){if(this._actions.length>0&&(this._currentAction!==this._actions[0]&&(this._currentAction=this._actions[0],this._entity.emit(`actionstart`,new ActionStartEvent(this._currentAction,this._entity))),this._currentAction.update(e),this._currentAction.isComplete(this._entity))){this._entity.emit(`actioncomplete`,new ActionCompleteEvent(this._currentAction,this._entity));let e=this._actions.shift();e&&this._completedActions.push(e)}}};let Zp=0;function nextActionId(){return Zp++}var Repeat=class{constructor(e,R,W){this.id=nextActionId(),this._stopped=!1,this._repeatBuilder=R,this._repeatContext=new ActionContext(e),this._actionQueue=this._repeatContext.getQueue(),this._repeat=W,this._originalRepeat=W,this._repeatBuilder(this._repeatContext),this._repeat--}update(e){this._actionQueue.isComplete()&&(this._actionQueue.clearActions(),this._repeatBuilder(this._repeatContext),this._repeat--),this._actionQueue.update(e)}isComplete(){return this._stopped||this._repeat<=0&&this._actionQueue.isComplete()}stop(){this._stopped=!0}reset(){this._repeat=this._originalRepeat}},RepeatForever=class{constructor(e,R){this.id=nextActionId(),this._stopped=!1,this._repeatBuilder=R,this._repeatContext=new ActionContext(e),this._actionQueue=this._repeatContext.getQueue(),this._repeatBuilder(this._repeatContext)}update(e){this._stopped||(this._actionQueue.isComplete()&&(this._actionQueue.clearActions(),this._repeatBuilder(this._repeatContext)),this._actionQueue.update(e))}isComplete(){return this._stopped}stop(){this._stopped=!0,this._actionQueue.clearActions()}reset(){}};function isMoveByOptions(e){return e.offset instanceof sf&&typeof e.duration==`number`}var MoveByWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._legacyEasing=Xp.Linear,this._easing=linear,this._useLegacyEasing=!1,this._offset=R.offset,this._easing=R.easing??this._easing,isLegacyEasing(R.easing)&&(this._legacyEasing=R.easing,this._useLegacyEasing=!0),this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only MoveBy on Entities with TransformComponents.`);this._durationMs=R.duration,this._currentMs=this._durationMs}update(e){this._started||=(this._start=this._tx.pos.clone(),this._end=this._start.add(this._offset),!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=this._tx.pos,Y=0,X=0;this._useLegacyEasing?(Y=this._legacyEasing(R,this._start.x,this._end.x,1),X=this._legacyEasing(R,this._start.y,this._end.y,1)):(Y=lerp(this._start.x,this._end.x,this._easing(R)),X=lerp(this._start.y,this._end.y,this._easing(R)));let ie=e/1e3,ae=ie===0?0:(Y-W.x)/ie,le=ie===0?0:(X-W.y)/ie;this._motion.vel.x=ae,this._motion.vel.y=le,this.isComplete(this.entity)&&(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0))}isComplete(e){return this._stopped||this._currentMs<0}stop(){this._motion.vel=vec(0,0),this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},MoveBy=class{constructor(e,R,W,Y){if(this.id=nextActionId(),this._started=!1,this._stopped=!1,this._entity=e,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._speed=Y,this._offset=new sf(R,W),Y<=0)throw bf.getInstance().error(`Attempted to moveBy with speed less than or equal to zero : `+Y),Error(`Speed must be greater than 0 pixels per second`)}update(e){this._started||(this._started=!0,this._start=new sf(this._tx.pos.x,this._tx.pos.y),this._end=this._start.add(this._offset),this._distance=this._offset.magnitude,this._dir=this._end.sub(this._start).normalize()),this.isComplete(this._entity)?(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0)):this._motion.vel=this._dir.scale(this._speed)}isComplete(e){let R=e.get(Sf);return this._stopped||R.pos.distance(this._start)>=this._distance}stop(){this._motion.vel=vec(0,0),this._stopped=!0}reset(){this._started=!1,this._stopped=!1}};function isMoveToOptions(e){return e.pos instanceof sf&&typeof e.duration==`number`}var MoveToWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._easing=linear,this._legacyEasing=Xp.Linear,this._useLegacyEasing=!1,this._end=R.pos,this._easing=R.easing??this._easing,isLegacyEasing(R.easing)&&(this._legacyEasing=R.easing,this._useLegacyEasing=!0),this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only moveTo on Entities with TransformComponents.`);this._durationMs=R.duration,this._currentMs=this._durationMs}update(e){this._started||=(this._start=this._tx.pos.clone(),!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=this._tx.pos,Y=0,X=0;this._useLegacyEasing?(Y=this._legacyEasing(R,this._start.x,this._end.x,1),X=this._legacyEasing(R,this._start.y,this._end.y,1)):(Y=lerp(this._start.x,this._end.x,this._easing(R)),X=lerp(this._start.y,this._end.y,this._easing(R)));let ie=e/1e3,ae=ie===0?0:(Y-W.x)/ie,le=ie===0?0:(X-W.y)/ie;this._motion.vel.x=ae,this._motion.vel.y=le,this.isComplete(this.entity)&&(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0))}isComplete(e){return this._stopped||this._currentMs<0}stop(){this._motion.vel=vec(0,0),this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},MoveTo=class{constructor(e,R,W,Y){this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._end=new sf(R,W),this._speed=Y}update(e){this._started||(this._started=!0,this._start=new sf(this._tx.pos.x,this._tx.pos.y),this._distance=this._start.distance(this._end),this._dir=this._end.sub(this._start).normalize());let R=this._dir.scale(this._speed);this._motion.vel=vec(R.x,R.y),this.isComplete(this.entity)&&(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0))}isComplete(e){let R=e.get(Sf);return this._stopped||new sf(R.pos.x,R.pos.y).distance(this._start)>=this._distance}stop(){this._motion.vel=vec(0,0),this._stopped=!0}reset(){this._started=!1,this._stopped=!1}},RotateToWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._endAngle=0,this._startAngle=0,this._endAngle=R.angle,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only RotateTo on Entities with TransformComponents.`);this._durationMs=R.duration,this._rotationType=R.rotationType??ef.ShortestPath,this._currentMs=this._durationMs}update(e){this._started||=(this._startAngle=this._tx.rotation,!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=lerpAngle(this._startAngle,this._endAngle,this._rotationType,R),Y=this._tx.rotation,X=e/1e3,ie=X===0?0:(W-Y)/X;this._motion.angularVelocity=ie,this.isComplete(this.entity)&&(this._tx.rotation=this._endAngle,this._motion.angularVelocity=0)}isComplete(e){return this._stopped||this._currentMs<0}stop(){this._motion.angularVelocity=0,this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},RotateTo=class{constructor(e,R,W,Y){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._end=R,this._speed=W,this._rotationType=Y||ef.ShortestPath}update(e){if(!this._started){this._started=!0,this._start=this._tx.rotation,this._currentNonCannonAngle=this._tx.rotation;let e=Math.abs(this._end-this._start),R=af-e;switch(e>R?(this._shortDistance=R,this._longDistance=e):(this._shortDistance=e,this._longDistance=R),this._shortestPathIsPositive=(this._start-this._end+af)%af>=Math.PI,this._rotationType){case ef.ShortestPath:this._distance=this._shortDistance,this._shortestPathIsPositive?this._direction=1:this._direction=-1;break;case ef.LongestPath:this._distance=this._longDistance,this._shortestPathIsPositive?this._direction=-1:this._direction=1;break;case ef.Clockwise:this._direction=1,this._shortestPathIsPositive?this._distance=this._shortDistance:this._distance=this._longDistance;break;case ef.CounterClockwise:this._direction=-1,this._shortestPathIsPositive?this._distance=this._longDistance:this._distance=this._shortDistance;break}}this._motion.angularVelocity=this._direction*this._speed,this._currentNonCannonAngle+=this._direction*this._speed*(e/1e3),this.isComplete()&&(this._tx.rotation=this._end,this._motion.angularVelocity=0,this._stopped=!0)}isComplete(){let e=Math.abs(this._currentNonCannonAngle-this._start);return this._stopped||e>=Math.abs(this._distance)}stop(){this._motion.angularVelocity=0,this._stopped=!0}reset(){this._started=!1,this._stopped=!1}},RotateByWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._offset=0,this._startAngle=0,this._endAngle=0,this._offset=R.angleRadiansOffset,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only RotateBy on Entities with TransformComponents.`);this._durationMs=R.duration,this._rotationType=R.rotationType??ef.ShortestPath,this._currentMs=this._durationMs}update(e){this._started||=(this._startAngle=this._tx.rotation,this._endAngle=canonicalizeAngle(this._startAngle+this._offset),!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=lerpAngle(this._startAngle,this._endAngle,this._rotationType,R),Y=this._tx.rotation,X=e/1e3,ie=X===0?0:(W-Y)/X;this._motion.angularVelocity=ie,this.isComplete()&&(this._tx.rotation=this._endAngle,this._motion.angularVelocity=0)}isComplete(){return this._stopped||this._currentMs<0}stop(){this._motion.angularVelocity=0,this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},RotateBy=class{constructor(e,R,W,Y){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._speed=W,this._offset=R,this._rotationType=Y||ef.ShortestPath}update(e){if(!this._started){this._started=!0,this._start=this._tx.rotation,this._currentNonCannonAngle=this._tx.rotation,this._end=this._start+this._offset;let e=Math.abs(this._end-this._start),R=af-e;switch(e>R?(this._shortDistance=R,this._longDistance=e):(this._shortDistance=e,this._longDistance=R),this._shortestPathIsPositive=(this._start-this._end+af)%af>=Math.PI,this._rotationType){case ef.ShortestPath:this._distance=this._shortDistance,this._shortestPathIsPositive?this._direction=1:this._direction=-1;break;case ef.LongestPath:this._distance=this._longDistance,this._shortestPathIsPositive?this._direction=-1:this._direction=1;break;case ef.Clockwise:this._direction=1,this._shortDistance>=0?this._distance=this._shortDistance:this._distance=this._longDistance;break;case ef.CounterClockwise:this._direction=-1,this._shortDistance<=0?this._distance=this._shortDistance:this._distance=this._longDistance;break}}this._motion.angularVelocity=this._direction*this._speed,this._currentNonCannonAngle+=this._direction*this._speed*(e/1e3),this.isComplete()&&(this._tx.rotation=this._end,this._motion.angularVelocity=0,this._stopped=!0)}isComplete(){let e=Math.abs(this._currentNonCannonAngle-this._start);return this._stopped||e>=Math.abs(this._distance)}stop(){this._motion.angularVelocity=0,this._stopped=!0}reset(){this._started=!1,this._stopped=!1,this._start=void 0,this._currentNonCannonAngle=void 0,this._distance=void 0}};function isScaleToOptions(e){return typeof e.scale==`object`&&typeof e.duration==`number`}var ScaleToWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._endScale=vec(1,1),this._startScale=vec(1,1),this._endScale=R.scale,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only ScaleTo on Entities with TransformComponents.`);this._durationMs=R.duration,this._currentMs=this._durationMs}update(e){this._started||=(this._startScale=this._tx.scale,!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=lerpVector(this._startScale,this._endScale,R),Y=this._tx.scale,X=e/1e3,ie=W.sub(Y).scale(X===0?0:1/X);this._motion.scaleFactor=ie,this.isComplete()&&(this._tx.scale=this._endScale,this._motion.angularVelocity=0)}isComplete(){return this._stopped||this._currentMs<0}stop(){this._motion.scaleFactor=sf.Zero,this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},ScaleTo=class{constructor(e,R,W,Y,X){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._endX=R,this._endY=W,this._speedX=Y,this._speedY=X}update(e){if(this._started||(this._started=!0,this._startX=this._tx.scale.x,this._startY=this._tx.scale.y,this._distanceX=Math.abs(this._endX-this._startX),this._distanceY=Math.abs(this._endY-this._startY)),Math.abs(this._tx.scale.x-this._startX)>=this._distanceX)this._motion.scaleFactor.x=0;else{let e=this._endY<this._startY?-1:1;this._motion.scaleFactor.x=this._speedX*e}if(Math.abs(this._tx.scale.y-this._startY)>=this._distanceY)this._motion.scaleFactor.y=0;else{let e=this._endY<this._startY?-1:1;this._motion.scaleFactor.y=this._speedY*e}this.isComplete()&&(this._tx.scale=vec(this._endX,this._endY),this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0)}isComplete(){return this._stopped||Math.abs(this._tx.scale.x-this._startX)>=this._distanceX-.01&&Math.abs(this._tx.scale.y-this._startY)>=this._distanceY-.01}stop(){this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0,this._stopped=!0}reset(){this._started=!1,this._stopped=!1}};function isScaleByOptions(e){return typeof e.scaleOffset==`object`&&typeof e.duration==`number`}var ScaleByWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._endScale=vec(1,1),this._scaleOffset=vec(0,0),this._startScale=vec(1,1),this._scaleOffset=R.scaleOffset,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only ScaleBy on Entities with TransformComponents.`);this._durationMs=R.duration,this._currentMs=this._durationMs}update(e){this._started||=(this._startScale=this._tx.scale,this._endScale=this._startScale.add(this._scaleOffset),!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=lerpVector(this._startScale,this._endScale,R),Y=this._tx.scale,X=e/1e3,ie=W.sub(Y).scale(X===0?0:1/X);this._motion.scaleFactor=ie,this.isComplete()&&(this._tx.scale=this._endScale,this._motion.angularVelocity=0)}isComplete(){return this._stopped||this._currentMs<0}stop(){this._motion.scaleFactor=sf.Zero,this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},ScaleBy=class{constructor(e,R,W,Y){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._offset=new sf(R,W),this._speedX=this._speedY=Y}update(e){this._started||(this._started=!0,this._startScale=this._tx.scale.clone(),this._endScale=this._startScale.add(this._offset),this._distanceX=Math.abs(this._endScale.x-this._startScale.x),this._distanceY=Math.abs(this._endScale.y-this._startScale.y),this._directionX=this._endScale.x<this._startScale.x?-1:1,this._directionY=this._endScale.y<this._startScale.y?-1:1),this._motion.scaleFactor.x=this._speedX*this._directionX,this._motion.scaleFactor.y=this._speedY*this._directionY,this.isComplete()&&(this._tx.scale=this._endScale,this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0)}isComplete(){return this._stopped||Math.abs(this._tx.scale.x-this._startScale.x)>=this._distanceX-.01&&Math.abs(this._tx.scale.y-this._startScale.y)>=this._distanceY-.01}stop(){this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0,this._stopped=!0}reset(){this._started=!1,this._stopped=!1}},CallMethod=class{constructor(e){this.id=nextActionId(),this._hasBeenCalled=!1,this._method=e}update(e){this._method(),this._hasBeenCalled=!0}isComplete(){return this._hasBeenCalled}reset(){this._hasBeenCalled=!1}stop(){this._hasBeenCalled=!0}},EaseTo=class{constructor(e,R,W,Y,X){this.easingFcn=X,this.id=nextActionId(),this._currentLerpTime=0,this._lerpDuration=1*1e3,this._lerpStart=new sf(0,0),this._lerpEnd=new sf(0,0),this._initialized=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._lerpDuration=Y,this._lerpEnd=new sf(R,W)}_initialize(){this._lerpStart=new sf(this._tx.pos.x,this._tx.pos.y),this._currentLerpTime=0}update(e){this._initialized||=(this._initialize(),!0),this._currentLerpTime+=e;let R=this._tx.pos.x,W=this._tx.pos.y;if(this._currentLerpTime<this._lerpDuration){R=this._lerpEnd.x<this._lerpStart.x?this._lerpStart.x-(this.easingFcn(this._currentLerpTime,this._lerpEnd.x,this._lerpStart.x,this._lerpDuration)-this._lerpEnd.x):this.easingFcn(this._currentLerpTime,this._lerpStart.x,this._lerpEnd.x,this._lerpDuration),W=this._lerpEnd.y<this._lerpStart.y?this._lerpStart.y-(this.easingFcn(this._currentLerpTime,this._lerpEnd.y,this._lerpStart.y,this._lerpDuration)-this._lerpEnd.y):this.easingFcn(this._currentLerpTime,this._lerpStart.y,this._lerpEnd.y,this._lerpDuration);let Y=e/1e3;this._motion.vel=vec(Y===0?0:(R-this._tx.pos.x)/Y,Y===0?0:(W-this._tx.pos.y)/Y)}else this._tx.pos=vec(this._lerpEnd.x,this._lerpEnd.y),this._motion.vel=sf.Zero}isComplete(){return this._stopped||this._currentLerpTime>=this._lerpDuration}reset(){this._initialized=!1,this._stopped=!1,this._currentLerpTime=0}stop(){this._motion.vel=vec(0,0),this._stopped=!0}},EaseBy=class{constructor(e,R,W,Y,X){this.easingFcn=X,this.id=nextActionId(),this._currentLerpTime=0,this._lerpDuration=1*1e3,this._lerpStart=new sf(0,0),this._lerpEnd=new sf(0,0),this._initialized=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._lerpDuration=Y,this._offset=new sf(R,W)}_initialize(){this._lerpStart=new sf(this._tx.pos.x,this._tx.pos.y),this._currentLerpTime=0,this._lerpEnd=this._lerpStart.add(this._offset)}update(e){this._initialized||=(this._initialize(),!0),this._currentLerpTime+=e;let R=this._tx.pos.x,W=this._tx.pos.y;if(this._currentLerpTime<this._lerpDuration){R=this._lerpEnd.x<this._lerpStart.x?this._lerpStart.x-(this.easingFcn(this._currentLerpTime,this._lerpEnd.x,this._lerpStart.x,this._lerpDuration)-this._lerpEnd.x):this.easingFcn(this._currentLerpTime,this._lerpStart.x,this._lerpEnd.x,this._lerpDuration),W=this._lerpEnd.y<this._lerpStart.y?this._lerpStart.y-(this.easingFcn(this._currentLerpTime,this._lerpEnd.y,this._lerpStart.y,this._lerpDuration)-this._lerpEnd.y):this.easingFcn(this._currentLerpTime,this._lerpStart.y,this._lerpEnd.y,this._lerpDuration);let Y=e/1e3;this._motion.vel=vec(Y===0?0:(R-this._tx.pos.x)/Y,Y===0?0:(W-this._tx.pos.y)/Y)}else this._tx.pos=vec(this._lerpEnd.x,this._lerpEnd.y),this._motion.vel=sf.Zero}isComplete(){return this._stopped||this._currentLerpTime>=this._lerpDuration}reset(){this._initialized=!1,this._stopped=!1,this._currentLerpTime=0}stop(){this._motion.vel=vec(0,0),this._stopped=!0}},Blink=class{constructor(e,R,W,Y=1){this.id=nextActionId(),this._timeVisible=0,this._timeNotVisible=0,this._elapsedTime=0,this._totalTime=0,this._stopped=!1,this._started=!1,this._graphics=e.get(Jp),this._timeVisible=R,this._timeNotVisible=W,this._duration=(R+W)*Y}update(e){this._started||(this._started=!0,this._elapsedTime=0,this._totalTime=0),this._graphics&&(this._elapsedTime+=e,this._totalTime+=e,this._graphics.isVisible&&this._elapsedTime>=this._timeVisible&&(this._graphics.isVisible=!1,this._elapsedTime=0),!this._graphics.isVisible&&this._elapsedTime>=this._timeNotVisible&&(this._graphics.isVisible=!0,this._elapsedTime=0),this.isComplete()&&(this._graphics.isVisible=!0))}isComplete(){return this._stopped||this._totalTime>=this._duration}stop(){this._graphics&&(this._graphics.isVisible=!0),this._stopped=!0}reset(){this._started=!1,this._stopped=!1,this._elapsedTime=0,this._totalTime=0}},Fade=class{constructor(e,R,W){this.id=nextActionId(),this._multiplier=1,this._started=!1,this._stopped=!1,this._graphics=e.get(Jp),this._endOpacity=R,this._remainingTime=this._originalTime=W}update(e){this._graphics&&(this._started||(this._started=!0,this._remainingTime=this._originalTime,this._endOpacity<this._graphics.opacity?this._multiplier=-1:this._multiplier=1),this._remainingTime>0&&(this._graphics.opacity+=this._multiplier*(Math.abs(this._graphics.opacity-this._endOpacity)*e)/this._remainingTime),this._remainingTime-=e,this.isComplete()&&(this._graphics.opacity=this._endOpacity),bf.getInstance().debug(`[Action fade] Actor opacity:`,this._graphics.opacity))}isComplete(){return this._stopped||this._remainingTime<=0}stop(){this._stopped=!0}reset(){this._started=!1,this._stopped=!1,this._remainingTime=this._originalTime}},Delay=class{constructor(e){this.id=nextActionId(),this._elapsedTime=0,this._started=!1,this._stopped=!1,this._delay=e}update(e){this._started||=!0,this._elapsedTime+=e}isComplete(){return this._stopped||this._elapsedTime>=this._delay}stop(){this._stopped=!0}reset(){this._elapsedTime=0,this._started=!1,this._stopped=!1}},Die=class{constructor(e){this.id=nextActionId(),this._stopped=!1,this._entity=e}update(e){this._entity.get(ActionsComponent).clearActions(),this._entity.kill(),this._stopped=!0}isComplete(){return this._stopped}stop(){}reset(){}},Follow=class{constructor(e,R,W){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._followTx=R.get(Sf),this._followMotion=R.get(MotionComponent),this._current=new sf(this._tx.pos.x,this._tx.pos.y),this._end=new sf(this._followTx.pos.x,this._followTx.pos.y),this._maximumDistance=W===void 0?this._current.distance(this._end):W,this._speed=0}update(e){this._started||(this._started=!0,this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize());let R=Math.sqrt(this._followMotion.vel.x**2+this._followMotion.vel.y**2);if(R!==0&&(this._speed=R),this._current=vec(this._tx.pos.x,this._tx.pos.y),this._end=vec(this._followTx.pos.x,this._followTx.pos.y),this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize(),this._distanceBetween>=this._maximumDistance){let e=this._dir.scale(this._speed);this._motion.vel=vec(e.x,e.y)}else this._motion.vel=vec(0,0);this.isComplete()&&(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0))}stop(){this._motion.vel=vec(0,0),this._stopped=!0}isComplete(){return this._stopped}reset(){this._started=!1,this._stopped=!1}},Meet=class{constructor(e,R,W,Y){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._speedWasSpecified=!1,this._tolerance=1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._meetTx=R.get(Sf),this._meetMotion=R.get(MotionComponent),this._current=new sf(this._tx.pos.x,this._tx.pos.y),this._end=new sf(this._meetTx.pos.x,this._meetTx.pos.y),this._speed=W||0,W!==void 0&&(this._speedWasSpecified=!0),Y!==void 0&&(this._tolerance=Y)}update(e){this._started||(this._started=!0,this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize());let R=Math.sqrt(this._meetMotion.vel.x**2+this._meetMotion.vel.y**2);R!==0&&!this._speedWasSpecified&&(this._speed=R),this._current=vec(this._tx.pos.x,this._tx.pos.y),this._end=vec(this._meetTx.pos.x,this._meetTx.pos.y),this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize();let W=this._dir.scale(this._speed);this._motion.vel=vec(W.x,W.y),this.isComplete()&&(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0))}isComplete(){return this._stopped||this._distanceBetween<=this._tolerance}stop(){this._motion.vel=vec(0,0),this._stopped=!0}reset(){this._started=!1,this._stopped=!1,this._distanceBetween=1/0}},Flash=class{constructor(e,R,W=1e3){this.id=nextActionId(),this._stopped=!1,this._started=!1,this._total=0,this._currentDuration=0,this._graphics=e.get(Jp),this._duration=W,this._entity=e,this._material=e.scene?.engine.graphicsContext.createMaterial({name:`flash-material`,color:R,fragmentSource:`#version 300 es
|
|
897
|
+
`);if(R==null)return W;for(let e=0;e<W.length;e++){let Y=W[e],X=``;if(this.measureText(Y).width>R){for(;this.measureText(Y).width>R;)X=Y[Y.length-1]+X,Y=Y.slice(0,-1);W[e]=Y,W[e+1]=X}}return this._cachedText=e,this._cachedLines=W,this._cachedRenderWidth=R,W}},Kp=class Font extends rp{constructor(e={}){super(e),this.filtering=pp.Blended,this.quality=2,this.padding=2,this.smoothing=!1,this.lineWidth=1,this.lineDash=[],this.color=gf.Black,this.family=`sans-serif`,this.style=dp.Normal,this.bold=!1,this.unit=cp.Px,this.textAlign=lp.Left,this.baseAlign=up.Top,this.direction=fp.LeftToRight,this.lineHeight=void 0,this.size=10,this._textBounds=new Pf,this.smoothing=e?.smoothing??this.smoothing,this.padding=e?.padding??this.padding,this.color=e?.color??this.color,this.strokeColor=e?.strokeColor??this.strokeColor,this.lineDash=e?.lineDash??this.lineDash,this.lineWidth=e?.lineWidth??this.lineWidth,this.filtering=e?.filtering??this.filtering,this.family=e?.family??this.family,this.style=e?.style??this.style,this.bold=e?.bold??this.bold,this.size=e?.size??this.size,this.unit=e?.unit??this.unit,this.textAlign=e?.textAlign??this.textAlign,this.baseAlign=e?.baseAlign??this.baseAlign,this.direction=e?.direction??this.direction,this.lineHeight=e?.lineHeight??this.lineHeight,this.quality=e?.quality??this.quality,e?.shadow&&(this.shadow={},this.shadow.blur=e.shadow.blur??this.shadow.blur,this.shadow.offset=e.shadow.offset??this.shadow.offset,this.shadow.color=e.shadow.color??this.shadow.color),this._textMeasurement=new Gp(this,``,gf.Black)}clone(){return new Font({...this.cloneGraphicOptions(),size:this.size,unit:this.unit,family:this.family,style:this.style,bold:this.bold,textAlign:this.textAlign,baseAlign:this.baseAlign,direction:this.direction,shadow:this.shadow?{blur:this.shadow.blur,offset:this.shadow.offset,color:this.shadow.color}:void 0})}get fontString(){return`${this.style} ${this.bold?`bold`:``} ${this.size}${this.unit} ${this.family}`}get localBounds(){return this._textBounds}_drawImage(e,R,W){}_rotate(e){let R=this.origin??this._textBounds.center;e.translate(R.x,R.y),e.rotate(this.rotation),e.translate(-R.x,-R.y)}_flip(e){this.flipHorizontal&&(e.translate(this._textBounds.width/this.scale.x,0),e.scale(-1,1)),this.flipVertical&&(e.translate(0,-this._textBounds.height/2/this.scale.y),e.scale(1,-1))}measureTextWithoutCache(e,R){return this._textMeasurement.measureText(e,R)}measureText(e,R){return Ep.measureText(e,this,R)}_postDraw(e){e.restore()}render(e,R,W,Y,X,ie){let ae=Ep.getTextInstance(R,this,W);this._textBounds=ae.dimensions,this._preDraw(e,Y,X),ae.render(e,Y,X,ie),this._postDraw(e)}},qp=class Text extends rp{constructor(e){super(e),this._text=``,this._textWidth=0,this._textHeight=0,this.font=e.font??new Kp,this.color=e.color??this.color,this.text=e.text,this.maxWidth=e.maxWidth}clone(){return new Text({text:this.text.slice(),color:this.color?.clone()??gf.Black,font:this.font.clone(),maxWidth:this.maxWidth})}get text(){return this._text}set text(e){this._text=e,this._calculateDimension()}get font(){return this._font}set font(e){this._font=e}get width(){return this._textWidth===0&&this._calculateDimension(),this._textWidth*this.scale.x}get height(){return this._textHeight===0&&this._calculateDimension(),this._textHeight*this.scale.y}_calculateDimension(){let{width:e,height:R}=this.font.measureText(this._text,this.maxWidth);this._textWidth=e,this._textHeight=R}get localBounds(){return this.font.measureText(this._text,this.maxWidth).scale(this.scale)}_rotate(e){}_flip(e){}_preDraw(e,R,W){(this.isStale()||this.font.isStale())&&(this.font.flipHorizontal=this.flipHorizontal,this.font.flipVertical=this.flipVertical,this.font.rotation=this.rotation,this.font.origin=this.origin,this.font.opacity=this.opacity),this.font.tint=this.tint,super._preDraw(e,R,W)}_drawImage(e,R,W){let Y=gf.Black;this.font instanceof Kp&&(Y=this.color??this.font.color);let{width:X,height:ie}=this.font.measureText(this._text,this.maxWidth);this._textWidth=X,this._textHeight=ie,this.font.render(e,this._text,Y,R,W,this.maxWidth),this.font.showDebug&&(e.debug.drawRect(R-X,W-ie,X*2,ie*2),this.maxWidth!=null&&e.debug.drawRect(R,W,this.maxWidth,this.height,{color:gf.Yellow}))}};function hasGraphicsTick(e){return!!e.tick}var Jp=class GraphicsComponent extends Component{constructor(e){super(),this._logger=bf.getInstance(),this._current=`default`,this._graphics={},this._options={},this.material=null,this.isVisible=!0,this.forceOnScreen=!1,this.opacity=1,this._offset=new WatchVector(sf.Zero,()=>this.recalculateBounds()),this._anchor=new WatchVector(sf.Half,()=>this.recalculateBounds()),this.flipHorizontal=!1,this.flipVertical=!1,this.copyGraphics=!1,e={visible:this.isVisible,graphics:{},...e};let{current:R,anchor:W,color:Y,opacity:X,visible:ie,graphics:ae,offset:le,copyGraphics:_e,onPreDraw:ye,onPostDraw:be,onPreTransformDraw:Ce,onPostTransformDraw:Te}=e;for(let[e,R]of Object.entries(ae))R instanceof rp?this._graphics[e]=R:(this._graphics[e]=R.graphic,this._options[e]=R.options);this.offset=le??this.offset,this.opacity=X??this.opacity,this.anchor=W??this.anchor,this.color=Y??this.color,this.copyGraphics=_e??this.copyGraphics,this.onPreDraw=ye??this.onPreDraw,this.onPostDraw=be??this.onPostDraw,this.onPreDraw=Ce??this.onPreTransformDraw,this.onPostTransformDraw=Te??this.onPostTransformDraw,this.isVisible=!!ie,this._current=R??this._current,R&&this._graphics[R]&&this.use(R)}get visible(){return this.isVisible}set visible(e){this.isVisible=e}get offset(){return this._offset}set offset(e){this._offset=new WatchVector(e,()=>this.recalculateBounds()),this.recalculateBounds()}get anchor(){return this._anchor}set anchor(e){this._anchor=new WatchVector(e,()=>this.recalculateBounds()),this.recalculateBounds()}get color(){return this._color}set color(e){if(e){this._color=e.clone();let R=this.current;(R instanceof Raster||R instanceof qp)&&(R.color=this._color)}}getGraphic(e){return this._graphics[e]}getOptions(e){return this._options[e]}getNames(){return Object.keys(this._graphics)}get current(){return this._graphics[this._current]}get currentOptions(){return this._options[this._current]}get graphics(){return this._graphics}get options(){return this._options}add(e,R,W){let Y=`default`,X=null,ie;if(typeof e==`string`&&R instanceof rp&&(Y=e,X=R,ie=W),e instanceof rp&&!(R instanceof rp)&&(X=e,ie=R),!X)throw Error(`Need to provide a graphic or valid graphic string`);return this._graphics[Y]=this.copyGraphics?X.clone():X,this._options[Y]=this.copyGraphics?{...ie}:ie,Y==="default"&&this.use(`default`),X}remove(e){delete this._graphics[e],delete this._options[e],this._current===e&&(this._current=`default`,this.recalculateBounds())}use(e,R){if(e instanceof rp){let W=e;this.copyGraphics&&(W=e.clone()),this._current=`default`,this._graphics[this._current]=W,this._options[this._current]=R}else this._current=e,this._options[this._current]=R,this._current in this._graphics||this._logger.warn(`Graphic ${this._current} is not registered with the graphics component owned by ${this.owner?.name}. Nothing will be drawn.`);return this.recalculateBounds(),this.current}hide(){this._current=`ex.none`}set localBounds(e){this._localBounds=e}recalculateBounds(){let e=new Pf,R=this._graphics[this._current],W=this._options[this._current];if(!R){this._localBounds=e;return}let Y=this.anchor,X=this.offset;W?.anchor&&(Y=W.anchor),W?.offset&&(X=W.offset);let ie=R.localBounds,ae=-ie.width*Y.x+X.x,le=-ie.height*Y.y+X.y;e=R instanceof sp&&!R.useAnchor?R?.localBounds.combine(e):R?.localBounds.translate(vec(ae,le)).combine(e),this._localBounds=e}get localBounds(){return(!this._localBounds||this._localBounds.hasZeroDimensions())&&this.recalculateBounds(),this._localBounds}get bounds(){let e=this.localBounds;if(this.owner){let R=this.owner.get(Sf);R&&(e=e.transform(R.get().matrix))}return e}update(e,R=0){let W=this.current;W&&hasGraphicsTick(W)&&W.tick(e,R)}clone(){let e=new GraphicsComponent;return e._graphics={...this._graphics},e._options={...this._options},e.offset=this.offset.clone(),this.color&&(e.color=this.color.clone()),e.opacity=this.opacity,e.anchor=this.anchor.clone(),e.copyGraphics=this.copyGraphics,e.onPreDraw=this.onPreDraw,e.onPostDraw=this.onPostDraw,e.isVisible=this.isVisible,e}},PointerComponent=class extends Component{constructor(e){super(),this.useColliderShape=!0,this.useGraphicsBounds=!0,this.useColliderShape=e?.useColliderShape??this.useColliderShape,this.useGraphicsBounds=e?.useGraphicsBounds??this.useGraphicsBounds,this.localBounds=e?.localBounds}};function isLegacyEasing(e){return!!e&&e.length===4}const Yp=class _EasingFunctions2{static CreateReversibleEasingFunction(e){return(R,W,Y,X)=>Y<W?W-(e(R,Y,W,X)-Y):e(R,W,Y,X)}static CreateVectorEasingFunction(e){return(R,W,Y,X)=>new sf(e(R,W.x,Y.x,X),e(R,W.y,Y.y,X))}};Yp.Linear=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,W*e/Y+R)),Yp.EaseInQuad=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y,W*e*e+R)),Yp.EaseOutQuad=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y,-W*e*(e-2)+R)),Yp.EaseInOutQuad=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y/2,e<1?W/2*e*e+R:(e--,-W/2*(e*(e-2)-1)+R))),Yp.EaseInCubic=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y,W*e*e*e+R)),Yp.EaseOutCubic=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y,e--,W*(e*e*e+1)+R)),Yp.EaseInOutCubic=Yp.CreateReversibleEasingFunction((e,R,W,Y)=>(W-=R,e/=Y/2,e<1?W/2*e*e*e+R:(e-=2,W/2*(e*e*e+2)+R)));let Xp=Yp;var ActionQueue=class{constructor(e){this._actions=[],this._currentAction=null,this._completedActions=[],this._entity=e}add(e){this._actions.push(e)}remove(e){let R=this._actions.indexOf(e);this._actions.splice(R,1)}clearActions(){this._actions.length=0,this._completedActions.length=0,this._currentAction&&this._currentAction.stop()}getActions(){return this._actions.concat(this._completedActions)}getIncompleteActions(){return this._actions}getCurrentAction(){return this._currentAction}hasNext(){return this._actions.length>0}isComplete(){return this._actions.length===0}reset(){this._actions=this.getActions();let e=this._actions.length;for(let R=0;R<e;R++)this._actions[R].reset();this._completedActions=[]}update(e){if(this._actions.length>0&&(this._currentAction!==this._actions[0]&&(this._currentAction=this._actions[0],this._entity.emit(`actionstart`,new ActionStartEvent(this._currentAction,this._entity))),this._currentAction.update(e),this._currentAction.isComplete(this._entity))){this._entity.emit(`actioncomplete`,new ActionCompleteEvent(this._currentAction,this._entity));let e=this._actions.shift();e&&this._completedActions.push(e)}}};let Zp=0;function nextActionId(){return Zp++}var Repeat=class{constructor(e,R,W){this.id=nextActionId(),this._stopped=!1,this._repeatBuilder=R,this._repeatContext=new ActionContext(e),this._actionQueue=this._repeatContext.getQueue(),this._repeat=W,this._originalRepeat=W,this._repeatBuilder(this._repeatContext),this._repeat--}update(e){this._actionQueue.isComplete()&&(this._actionQueue.clearActions(),this._repeatBuilder(this._repeatContext),this._repeat--),this._actionQueue.update(e)}isComplete(){return this._stopped||this._repeat<=0&&this._actionQueue.isComplete()}stop(){this._stopped=!0}reset(){this._repeat=this._originalRepeat}},RepeatForever=class{constructor(e,R){this.id=nextActionId(),this._stopped=!1,this._repeatBuilder=R,this._repeatContext=new ActionContext(e),this._actionQueue=this._repeatContext.getQueue(),this._repeatBuilder(this._repeatContext)}update(e){this._stopped||(this._actionQueue.isComplete()&&(this._actionQueue.clearActions(),this._repeatBuilder(this._repeatContext)),this._actionQueue.update(e))}isComplete(){return this._stopped}stop(){this._stopped=!0,this._actionQueue.clearActions()}reset(){}};function isMoveByOptions(e){return e.offset instanceof sf&&typeof e.duration==`number`}var MoveByWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._legacyEasing=Xp.Linear,this._easing=linear,this._useLegacyEasing=!1,this._offset=R.offset,this._easing=R.easing??this._easing,isLegacyEasing(R.easing)&&(this._legacyEasing=R.easing,this._useLegacyEasing=!0),this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only MoveBy on Entities with TransformComponents.`);this._durationMs=R.duration,this._currentMs=this._durationMs}update(e){this._started||=(this._start=this._tx.pos.clone(),this._end=this._start.add(this._offset),!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=this._tx.pos,Y=0,X=0;this._useLegacyEasing?(Y=this._legacyEasing(R,this._start.x,this._end.x,1),X=this._legacyEasing(R,this._start.y,this._end.y,1)):(Y=lerp(this._start.x,this._end.x,this._easing(R)),X=lerp(this._start.y,this._end.y,this._easing(R)));let ie=e/1e3,ae=ie===0?0:(Y-W.x)/ie,le=ie===0?0:(X-W.y)/ie;this._motion.vel.x=ae,this._motion.vel.y=le,this.isComplete(this.entity)&&(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0))}isComplete(e){return this._stopped||this._currentMs<0}stop(){this._motion.vel=vec(0,0),this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},MoveBy=class{constructor(e,R,W,Y){if(this.id=nextActionId(),this._started=!1,this._stopped=!1,this._entity=e,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._speed=Y,this._offset=new sf(R,W),Y<=0)throw bf.getInstance().error(`Attempted to moveBy with speed less than or equal to zero : `+Y),Error(`Speed must be greater than 0 pixels per second`)}update(e){this._started||(this._started=!0,this._start=new sf(this._tx.pos.x,this._tx.pos.y),this._end=this._start.add(this._offset),this._distance=this._offset.magnitude,this._dir=this._end.sub(this._start).normalize()),this.isComplete(this._entity)?(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0)):this._motion.vel=this._dir.scale(this._speed)}isComplete(e){let R=e.get(Sf);return this._stopped||R.pos.distance(this._start)>=this._distance}stop(){this._motion.vel=vec(0,0),this._stopped=!0}reset(){this._started=!1,this._stopped=!1}};function isMoveToOptions(e){return e.pos instanceof sf&&typeof e.duration==`number`}var MoveToWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._easing=linear,this._legacyEasing=Xp.Linear,this._useLegacyEasing=!1,this._end=R.pos,this._easing=R.easing??this._easing,isLegacyEasing(R.easing)&&(this._legacyEasing=R.easing,this._useLegacyEasing=!0),this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only moveTo on Entities with TransformComponents.`);this._durationMs=R.duration,this._currentMs=this._durationMs}update(e){this._started||=(this._start=this._tx.pos.clone(),!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=this._tx.pos,Y=0,X=0;this._useLegacyEasing?(Y=this._legacyEasing(R,this._start.x,this._end.x,1),X=this._legacyEasing(R,this._start.y,this._end.y,1)):(Y=lerp(this._start.x,this._end.x,this._easing(R)),X=lerp(this._start.y,this._end.y,this._easing(R)));let ie=e/1e3,ae=ie===0?0:(Y-W.x)/ie,le=ie===0?0:(X-W.y)/ie;this._motion.vel.x=ae,this._motion.vel.y=le,this.isComplete(this.entity)&&(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0))}isComplete(e){return this._stopped||this._currentMs<0}stop(){this._motion.vel=vec(0,0),this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},MoveTo=class{constructor(e,R,W,Y){this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._end=new sf(R,W),this._speed=Y}update(e){this._started||(this._started=!0,this._start=new sf(this._tx.pos.x,this._tx.pos.y),this._distance=this._start.distance(this._end),this._dir=this._end.sub(this._start).normalize());let R=this._dir.scale(this._speed);this._motion.vel=vec(R.x,R.y),this.isComplete(this.entity)&&(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0))}isComplete(e){let R=e.get(Sf);return this._stopped||new sf(R.pos.x,R.pos.y).distance(this._start)>=this._distance}stop(){this._motion.vel=vec(0,0),this._stopped=!0}reset(){this._started=!1,this._stopped=!1}},RotateToWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._endAngle=0,this._startAngle=0,this._endAngle=R.angle,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only RotateTo on Entities with TransformComponents.`);this._durationMs=R.duration,this._rotationType=R.rotationType??ef.ShortestPath,this._currentMs=this._durationMs}update(e){this._started||=(this._startAngle=this._tx.rotation,!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=lerpAngle(this._startAngle,this._endAngle,this._rotationType,R),Y=this._tx.rotation,X=e/1e3,ie=X===0?0:(W-Y)/X;this._motion.angularVelocity=ie,this.isComplete(this.entity)&&(this._tx.rotation=this._endAngle,this._motion.angularVelocity=0)}isComplete(e){return this._stopped||this._currentMs<0}stop(){this._motion.angularVelocity=0,this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},RotateTo=class{constructor(e,R,W,Y){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._end=R,this._speed=W,this._rotationType=Y||ef.ShortestPath}update(e){if(!this._started){this._started=!0,this._start=this._tx.rotation,this._currentNonCannonAngle=this._tx.rotation;let e=Math.abs(this._end-this._start),R=af-e;switch(e>R?(this._shortDistance=R,this._longDistance=e):(this._shortDistance=e,this._longDistance=R),this._shortestPathIsPositive=(this._start-this._end+af)%af>=Math.PI,this._rotationType){case ef.ShortestPath:this._distance=this._shortDistance,this._shortestPathIsPositive?this._direction=1:this._direction=-1;break;case ef.LongestPath:this._distance=this._longDistance,this._shortestPathIsPositive?this._direction=-1:this._direction=1;break;case ef.Clockwise:this._direction=1,this._shortestPathIsPositive?this._distance=this._shortDistance:this._distance=this._longDistance;break;case ef.CounterClockwise:this._direction=-1,this._shortestPathIsPositive?this._distance=this._longDistance:this._distance=this._shortDistance;break}}this._motion.angularVelocity=this._direction*this._speed,this._currentNonCannonAngle+=this._direction*this._speed*(e/1e3),this.isComplete()&&(this._tx.rotation=this._end,this._motion.angularVelocity=0,this._stopped=!0)}isComplete(){let e=Math.abs(this._currentNonCannonAngle-this._start);return this._stopped||e>=Math.abs(this._distance)}stop(){this._motion.angularVelocity=0,this._stopped=!0}reset(){this._started=!1,this._stopped=!1}},RotateByWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._offset=0,this._startAngle=0,this._endAngle=0,this._offset=R.angleRadiansOffset,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only RotateBy on Entities with TransformComponents.`);this._durationMs=R.duration,this._rotationType=R.rotationType??ef.ShortestPath,this._currentMs=this._durationMs}update(e){this._started||=(this._startAngle=this._tx.rotation,this._endAngle=canonicalizeAngle(this._startAngle+this._offset),!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=lerpAngle(this._startAngle,this._endAngle,this._rotationType,R),Y=this._tx.rotation,X=e/1e3,ie=X===0?0:(W-Y)/X;this._motion.angularVelocity=ie,this.isComplete()&&(this._tx.rotation=this._endAngle,this._motion.angularVelocity=0)}isComplete(){return this._stopped||this._currentMs<0}stop(){this._motion.angularVelocity=0,this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},RotateBy=class{constructor(e,R,W,Y){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._speed=W,this._offset=R,this._rotationType=Y||ef.ShortestPath}update(e){if(!this._started){this._started=!0,this._start=this._tx.rotation,this._currentNonCannonAngle=this._tx.rotation,this._end=this._start+this._offset;let e=Math.abs(this._end-this._start),R=af-e;switch(e>R?(this._shortDistance=R,this._longDistance=e):(this._shortDistance=e,this._longDistance=R),this._shortestPathIsPositive=(this._start-this._end+af)%af>=Math.PI,this._rotationType){case ef.ShortestPath:this._distance=this._shortDistance,this._shortestPathIsPositive?this._direction=1:this._direction=-1;break;case ef.LongestPath:this._distance=this._longDistance,this._shortestPathIsPositive?this._direction=-1:this._direction=1;break;case ef.Clockwise:this._direction=1,this._shortDistance>=0?this._distance=this._shortDistance:this._distance=this._longDistance;break;case ef.CounterClockwise:this._direction=-1,this._shortDistance<=0?this._distance=this._shortDistance:this._distance=this._longDistance;break}}this._motion.angularVelocity=this._direction*this._speed,this._currentNonCannonAngle+=this._direction*this._speed*(e/1e3),this.isComplete()&&(this._tx.rotation=this._end,this._motion.angularVelocity=0,this._stopped=!0)}isComplete(){let e=Math.abs(this._currentNonCannonAngle-this._start);return this._stopped||e>=Math.abs(this._distance)}stop(){this._motion.angularVelocity=0,this._stopped=!0}reset(){this._started=!1,this._stopped=!1,this._start=void 0,this._currentNonCannonAngle=void 0,this._distance=void 0}};function isScaleToOptions(e){return typeof e.scale==`object`&&typeof e.duration==`number`}var ScaleToWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._endScale=vec(1,1),this._startScale=vec(1,1),this._endScale=R.scale,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only ScaleTo on Entities with TransformComponents.`);this._durationMs=R.duration,this._currentMs=this._durationMs}update(e){this._started||=(this._startScale=this._tx.scale,!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=lerpVector(this._startScale,this._endScale,R),Y=this._tx.scale,X=e/1e3,ie=W.sub(Y).scale(X===0?0:1/X);this._motion.scaleFactor=ie,this.isComplete()&&(this._tx.scale=this._endScale,this._motion.angularVelocity=0)}isComplete(){return this._stopped||this._currentMs<0}stop(){this._motion.scaleFactor=sf.Zero,this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},ScaleTo=class{constructor(e,R,W,Y,X){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._endX=R,this._endY=W,this._speedX=Y,this._speedY=X}update(e){if(this._started||(this._started=!0,this._startX=this._tx.scale.x,this._startY=this._tx.scale.y,this._distanceX=Math.abs(this._endX-this._startX),this._distanceY=Math.abs(this._endY-this._startY)),Math.abs(this._tx.scale.x-this._startX)>=this._distanceX)this._motion.scaleFactor.x=0;else{let e=this._endY<this._startY?-1:1;this._motion.scaleFactor.x=this._speedX*e}if(Math.abs(this._tx.scale.y-this._startY)>=this._distanceY)this._motion.scaleFactor.y=0;else{let e=this._endY<this._startY?-1:1;this._motion.scaleFactor.y=this._speedY*e}this.isComplete()&&(this._tx.scale=vec(this._endX,this._endY),this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0)}isComplete(){return this._stopped||Math.abs(this._tx.scale.x-this._startX)>=this._distanceX-.01&&Math.abs(this._tx.scale.y-this._startY)>=this._distanceY-.01}stop(){this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0,this._stopped=!0}reset(){this._started=!1,this._stopped=!1}};function isScaleByOptions(e){return typeof e.scaleOffset==`object`&&typeof e.duration==`number`}var ScaleByWithOptions=class{constructor(e,R){if(this.entity=e,this.id=nextActionId(),this._started=!1,this._stopped=!1,this._endScale=vec(1,1),this._scaleOffset=vec(0,0),this._startScale=vec(1,1),this._scaleOffset=R.scaleOffset,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),!this._tx)throw Error(`Entity ${e.name} has no TransformComponent, can only ScaleBy on Entities with TransformComponents.`);this._durationMs=R.duration,this._currentMs=this._durationMs}update(e){this._started||=(this._startScale=this._tx.scale,this._endScale=this._startScale.add(this._scaleOffset),!0),this._currentMs-=e;let R=clamp(remap(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1),W=lerpVector(this._startScale,this._endScale,R),Y=this._tx.scale,X=e/1e3,ie=W.sub(Y).scale(X===0?0:1/X);this._motion.scaleFactor=ie,this.isComplete()&&(this._tx.scale=this._endScale,this._motion.angularVelocity=0)}isComplete(){return this._stopped||this._currentMs<0}stop(){this._motion.scaleFactor=sf.Zero,this._stopped=!0,this._currentMs=0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}},ScaleBy=class{constructor(e,R,W,Y){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._offset=new sf(R,W),this._speedX=this._speedY=Y}update(e){this._started||(this._started=!0,this._startScale=this._tx.scale.clone(),this._endScale=this._startScale.add(this._offset),this._distanceX=Math.abs(this._endScale.x-this._startScale.x),this._distanceY=Math.abs(this._endScale.y-this._startScale.y),this._directionX=this._endScale.x<this._startScale.x?-1:1,this._directionY=this._endScale.y<this._startScale.y?-1:1),this._motion.scaleFactor.x=this._speedX*this._directionX,this._motion.scaleFactor.y=this._speedY*this._directionY,this.isComplete()&&(this._tx.scale=this._endScale,this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0)}isComplete(){return this._stopped||Math.abs(this._tx.scale.x-this._startScale.x)>=this._distanceX-.01&&Math.abs(this._tx.scale.y-this._startScale.y)>=this._distanceY-.01}stop(){this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0,this._stopped=!0}reset(){this._started=!1,this._stopped=!1}},CallMethod=class{constructor(e){this.id=nextActionId(),this._hasBeenCalled=!1,this._method=e}update(e){this._method(),this._hasBeenCalled=!0}isComplete(){return this._hasBeenCalled}reset(){this._hasBeenCalled=!1}stop(){this._hasBeenCalled=!0}},EaseTo=class{constructor(e,R,W,Y,X){this.easingFcn=X,this.id=nextActionId(),this._currentLerpTime=0,this._lerpDuration=1*1e3,this._lerpStart=new sf(0,0),this._lerpEnd=new sf(0,0),this._initialized=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._lerpDuration=Y,this._lerpEnd=new sf(R,W)}_initialize(){this._lerpStart=new sf(this._tx.pos.x,this._tx.pos.y),this._currentLerpTime=0}update(e){this._initialized||=(this._initialize(),!0),this._currentLerpTime+=e;let R=this._tx.pos.x,W=this._tx.pos.y;if(this._currentLerpTime<this._lerpDuration){R=this._lerpEnd.x<this._lerpStart.x?this._lerpStart.x-(this.easingFcn(this._currentLerpTime,this._lerpEnd.x,this._lerpStart.x,this._lerpDuration)-this._lerpEnd.x):this.easingFcn(this._currentLerpTime,this._lerpStart.x,this._lerpEnd.x,this._lerpDuration),W=this._lerpEnd.y<this._lerpStart.y?this._lerpStart.y-(this.easingFcn(this._currentLerpTime,this._lerpEnd.y,this._lerpStart.y,this._lerpDuration)-this._lerpEnd.y):this.easingFcn(this._currentLerpTime,this._lerpStart.y,this._lerpEnd.y,this._lerpDuration);let Y=e/1e3;this._motion.vel=vec(Y===0?0:(R-this._tx.pos.x)/Y,Y===0?0:(W-this._tx.pos.y)/Y)}else this._tx.pos=vec(this._lerpEnd.x,this._lerpEnd.y),this._motion.vel=sf.Zero}isComplete(){return this._stopped||this._currentLerpTime>=this._lerpDuration}reset(){this._initialized=!1,this._stopped=!1,this._currentLerpTime=0}stop(){this._motion.vel=vec(0,0),this._stopped=!0}},EaseBy=class{constructor(e,R,W,Y,X){this.easingFcn=X,this.id=nextActionId(),this._currentLerpTime=0,this._lerpDuration=1*1e3,this._lerpStart=new sf(0,0),this._lerpEnd=new sf(0,0),this._initialized=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._lerpDuration=Y,this._offset=new sf(R,W)}_initialize(){this._lerpStart=new sf(this._tx.pos.x,this._tx.pos.y),this._currentLerpTime=0,this._lerpEnd=this._lerpStart.add(this._offset)}update(e){this._initialized||=(this._initialize(),!0),this._currentLerpTime+=e;let R=this._tx.pos.x,W=this._tx.pos.y;if(this._currentLerpTime<this._lerpDuration){R=this._lerpEnd.x<this._lerpStart.x?this._lerpStart.x-(this.easingFcn(this._currentLerpTime,this._lerpEnd.x,this._lerpStart.x,this._lerpDuration)-this._lerpEnd.x):this.easingFcn(this._currentLerpTime,this._lerpStart.x,this._lerpEnd.x,this._lerpDuration),W=this._lerpEnd.y<this._lerpStart.y?this._lerpStart.y-(this.easingFcn(this._currentLerpTime,this._lerpEnd.y,this._lerpStart.y,this._lerpDuration)-this._lerpEnd.y):this.easingFcn(this._currentLerpTime,this._lerpStart.y,this._lerpEnd.y,this._lerpDuration);let Y=e/1e3;this._motion.vel=vec(Y===0?0:(R-this._tx.pos.x)/Y,Y===0?0:(W-this._tx.pos.y)/Y)}else this._tx.pos=vec(this._lerpEnd.x,this._lerpEnd.y),this._motion.vel=sf.Zero}isComplete(){return this._stopped||this._currentLerpTime>=this._lerpDuration}reset(){this._initialized=!1,this._stopped=!1,this._currentLerpTime=0}stop(){this._motion.vel=vec(0,0),this._stopped=!0}},Blink=class{constructor(e,R,W,Y=1){this.id=nextActionId(),this._timeVisible=0,this._timeNotVisible=0,this._elapsedTime=0,this._totalTime=0,this._stopped=!1,this._started=!1,this._graphics=e.get(Jp),this._timeVisible=R,this._timeNotVisible=W,this._duration=(R+W)*Y}update(e){this._started||(this._started=!0,this._elapsedTime=0,this._totalTime=0),this._graphics&&(this._elapsedTime+=e,this._totalTime+=e,this._graphics.isVisible&&this._elapsedTime>=this._timeVisible&&(this._graphics.isVisible=!1,this._elapsedTime=0),!this._graphics.isVisible&&this._elapsedTime>=this._timeNotVisible&&(this._graphics.isVisible=!0,this._elapsedTime=0),this.isComplete()&&(this._graphics.isVisible=!0))}isComplete(){return this._stopped||this._totalTime>=this._duration}stop(){this._graphics&&(this._graphics.isVisible=!0),this._stopped=!0}reset(){this._started=!1,this._stopped=!1,this._elapsedTime=0,this._totalTime=0}},Fade=class{constructor(e,R,W){this.id=nextActionId(),this._multiplier=1,this._started=!1,this._stopped=!1,this._graphics=e.get(Jp),this._endOpacity=R,this._remainingTime=this._originalTime=W}update(e){this._graphics&&(this._started||(this._started=!0,this._remainingTime=this._originalTime,this._endOpacity<this._graphics.opacity?this._multiplier=-1:this._multiplier=1),this._remainingTime>0&&(this._graphics.opacity+=this._multiplier*(Math.abs(this._graphics.opacity-this._endOpacity)*e)/this._remainingTime),this._remainingTime-=e,this.isComplete()&&(this._graphics.opacity=this._endOpacity),bf.getInstance().debug(`[Action fade] Actor opacity:`,this._graphics.opacity))}isComplete(){return this._stopped||this._remainingTime<=0}stop(){this._stopped=!0}reset(){this._started=!1,this._stopped=!1,this._remainingTime=this._originalTime}},Delay=class{constructor(e){this.id=nextActionId(),this._elapsedTime=0,this._started=!1,this._stopped=!1,this._delay=e}update(e){this._started||=!0,this._elapsedTime+=e}isComplete(){return this._stopped||this._elapsedTime>=this._delay}stop(){this._stopped=!0}reset(){this._elapsedTime=0,this._started=!1,this._stopped=!1}},Die=class{constructor(e){this.id=nextActionId(),this._stopped=!1,this._entity=e}update(e){this._entity.get(ActionsComponent).clearActions(),this._entity.kill(),this._stopped=!0}isComplete(){return this._stopped}stop(){}reset(){}},Follow=class{constructor(e,R,W){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._followTx=R.get(Sf),this._followMotion=R.get(MotionComponent),this._current=new sf(this._tx.pos.x,this._tx.pos.y),this._end=new sf(this._followTx.pos.x,this._followTx.pos.y),this._maximumDistance=W===void 0?this._current.distance(this._end):W,this._speed=0}update(e){this._started||(this._started=!0,this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize());let R=Math.sqrt(this._followMotion.vel.x**2+this._followMotion.vel.y**2);if(R!==0&&(this._speed=R),this._current=vec(this._tx.pos.x,this._tx.pos.y),this._end=vec(this._followTx.pos.x,this._followTx.pos.y),this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize(),this._distanceBetween>=this._maximumDistance){let e=this._dir.scale(this._speed);this._motion.vel=vec(e.x,e.y)}else this._motion.vel=vec(0,0);this.isComplete()&&(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0))}stop(){this._motion.vel=vec(0,0),this._stopped=!0}isComplete(){return this._stopped}reset(){this._started=!1,this._stopped=!1}},Meet=class{constructor(e,R,W,Y){this.id=nextActionId(),this._started=!1,this._stopped=!1,this._speedWasSpecified=!1,this._tolerance=1,this._tx=e.get(Sf),this._motion=e.get(MotionComponent),this._meetTx=R.get(Sf),this._meetMotion=R.get(MotionComponent),this._current=new sf(this._tx.pos.x,this._tx.pos.y),this._end=new sf(this._meetTx.pos.x,this._meetTx.pos.y),this._speed=W||0,W!==void 0&&(this._speedWasSpecified=!0),Y!==void 0&&(this._tolerance=Y)}update(e){this._started||(this._started=!0,this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize());let R=Math.sqrt(this._meetMotion.vel.x**2+this._meetMotion.vel.y**2);R!==0&&!this._speedWasSpecified&&(this._speed=R),this._current=vec(this._tx.pos.x,this._tx.pos.y),this._end=vec(this._meetTx.pos.x,this._meetTx.pos.y),this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize();let W=this._dir.scale(this._speed);this._motion.vel=vec(W.x,W.y),this.isComplete()&&(this._tx.pos=vec(this._end.x,this._end.y),this._motion.vel=vec(0,0))}isComplete(){return this._stopped||this._distanceBetween<=this._tolerance}stop(){this._motion.vel=vec(0,0),this._stopped=!0}reset(){this._started=!1,this._stopped=!1,this._distanceBetween=1/0}},Flash=class{constructor(e,R,W=1e3){this.id=nextActionId(),this._stopped=!1,this._started=!1,this._total=0,this._currentDuration=0,this._graphics=e.get(Jp),this._duration=W,this._entity=e,this._material=e.scene?.engine.graphicsContext.createMaterial({name:`flash-material`,color:R,fragmentSource:`#version 300 es
|
|
898
898
|
|
|
899
899
|
precision mediump float;
|
|
900
900
|
uniform float u_blend;
|
|
@@ -1102,7 +1102,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`),W&&this
|
|
|
1102
1102
|
Pass an engine parameter to ex.coroutine(engine, function * {...})`)}let be=!1,Ce=!1,Te=!1,Oe=W.bind(Y),Ae=Oe(),loop,Me=new Promise((e,R)=>{loop=W=>{try{if(Te){Ce=!0,e();return}let{done:R,value:Y}=jm.scope(!0,()=>Ae.next(W));if(R||Te){Ce=!0,e();return}Y instanceof Promise?Y.then(()=>{ye.clock.schedule(loop,0,le)}):Y===void 0||Y===void 0?ye.clock.schedule(loop,0,le):ye.clock.schedule(loop,Y||0,le)}catch(e){R(e);return}},_e&&(be=!0,loop(ye.clock.elapsed()))}),Pe={isRunning:()=>be&&!Te&&!Ce,isComplete:()=>Ce,cancel:()=>{Te=!0},start:()=>(be?R.warn(`.start() was called on a coroutine that was already started, this is probably a bug:
|
|
1103
1103
|
`,Function.prototype.toString.call(Oe)):(be=!0,loop(ye.clock.elapsed())),Pe),generator:Ae,done:Me,then:Me.then.bind(Me),[Symbol.iterator]:()=>Ae};return Pe}var Transition=class extends Of{constructor(e){super(),this._logger=bf.getInstance(),this.transform=new Sf,this.graphics=new Jp,this._completeFuture=new Future,this.started=!1,this._currentDistance=0,this._currentProgress=0,this.done=this._completeFuture.promise,this._useLegacyEasing=!1,this.name=`Transition#${this.id}`,this.duration=e.duration,isLegacyEasing(e.easing)?(this.legacyEasing=e.easing??Xp.Linear,this._useLegacyEasing=!0):this.easing=e.easing??linear,this.direction=e.direction??`out`,this.hideLoader=e.hideLoader??!1,this.blockInput=e.blockInput??!1,this.transform.coordPlane=df.Screen,this.transform.pos=sf.Zero,this.transform.z=1/0,this.graphics.anchor=sf.Zero,this.addComponent(this.transform),this.addComponent(this.graphics),this.direction===`out`?this._currentProgress=0:this._currentProgress=1}get progress(){return this._currentProgress}get distance(){return this._currentDistance}get complete(){return this.direction===`out`?this.progress>=1:this.progress<=0}updateTransition(e,R){this.complete||(this._currentDistance+=clamp(R/this.duration,0,1),this._currentDistance>=1&&(this._currentDistance=1),this.direction===`out`?this._useLegacyEasing?this._currentProgress=clamp(this.legacyEasing(this._currentDistance,0,1,1),0,1):this._currentProgress=clamp(lerp(0,1,this.easing(this._currentDistance)),0,1):this._useLegacyEasing?this._currentProgress=clamp(this.legacyEasing(this._currentDistance,1,0,1),0,1):this._currentProgress=clamp(lerp(1,0,this.easing(this._currentDistance)),0,1))}async onPreviousSceneDeactivate(e){}onStart(e){}onUpdate(e){}onEnd(e){}onReset(){}reset(){this.started=!1,this._completeFuture=new Future,this.done=this._completeFuture.promise,this._currentDistance=0,this.direction===`out`?this._currentProgress=0:this._currentProgress=1,this.onReset()}_addToTargetScene(e,R){let W=R;if(this.started&&this._logger.warn(`Attempted to add a transition ${this.name} that is already playing.`),W.world.entityManager.getById(this.id))return this._co;this._engine=e,W.add(this);let Y=this;return this._co=coroutine(e,function*(){for(;!Y.complete;){let e=yield;Y.updateTransition(Y._engine,e),Y._execute()}},{autostart:!1}),this._co}async _play(){this.started&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that is already playing, reset transition.`)),(!this._engine||!this._co)&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that hasn't been added`)),this._co&&await this._co.start()}_execute(){this.isInitialized&&(this.started||(this.started=!0,this.onStart(this.progress)),this.onUpdate(this.progress),this.complete&&!this._completeFuture.isCompleted&&(this.onEnd(this.progress),this._completeFuture.resolve()))}},FadeInOut=class extends Transition{constructor(e){super({...e,duration:e.duration??2e3}),this.name=`FadeInOut#${this.id}`,this.color=e.color??gf.Black}onInitialize(e){this.transform.pos=e.screen.unsafeArea.topLeft,this.screenCover=new Op({width:e.screen.resolution.width,height:e.screen.resolution.height,color:this.color}),this.graphics.add(this.screenCover),this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onStart(e){this.graphics.opacity=e}onEnd(e){this.graphics.opacity=e}onUpdate(e){this.graphics.opacity=e}};const Nm=`0.32.0`;polyfill();var Pm=__exportAll$1({default:()=>Fm}),Fm={};xt();var Im={83(e,R,W){var Y=W(447),X=W(805),ie=W(996),ae=W(681),le=W(674),_e=W(442),ye=W(414),be=Object.prototype.toString;function g(e){if(!(this instanceof g))return new g(e);this.options=X.assign({chunkSize:16384,windowBits:0,to:``},e||{});var R=this.options;R.raw&&R.windowBits>=0&&R.windowBits<16&&(R.windowBits=-R.windowBits,R.windowBits===0&&(R.windowBits=-15)),!(R.windowBits>=0&&R.windowBits<16)||e&&e.windowBits||(R.windowBits+=32),R.windowBits>15&&R.windowBits<48&&(15&R.windowBits||(R.windowBits|=15)),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new _e,this.strm.avail_out=0;var W=Y.inflateInit2(this.strm,R.windowBits);if(W!==ae.Z_OK||(this.header=new ye,Y.inflateGetHeader(this.strm,this.header),R.dictionary&&(typeof R.dictionary==`string`?R.dictionary=ie.string2buf(R.dictionary):be.call(R.dictionary)===`[object ArrayBuffer]`&&(R.dictionary=new Uint8Array(R.dictionary)),R.raw&&(W=Y.inflateSetDictionary(this.strm,R.dictionary))!==ae.Z_OK)))throw Error(le[W])}function d(e,R){var W=new g(R);if(W.push(e,!0),W.err)throw W.msg||le[W.err];return W.result}g.prototype.push=function(e,R){var W,le,_e,ye,Ce,Te=this.strm,Oe=this.options.chunkSize,Ae=this.options.dictionary,Me=!1;if(this.ended)return!1;le=R===~~R?R:!0===R?ae.Z_FINISH:ae.Z_NO_FLUSH,typeof e==`string`?Te.input=ie.binstring2buf(e):be.call(e)===`[object ArrayBuffer]`?Te.input=new Uint8Array(e):Te.input=e,Te.next_in=0,Te.avail_in=Te.input.length;do{if(Te.avail_out===0&&(Te.output=new X.Buf8(Oe),Te.next_out=0,Te.avail_out=Oe),(W=Y.inflate(Te,ae.Z_NO_FLUSH))===ae.Z_NEED_DICT&&Ae&&(W=Y.inflateSetDictionary(this.strm,Ae)),W===ae.Z_BUF_ERROR&&!0===Me&&(W=ae.Z_OK,Me=!1),W!==ae.Z_STREAM_END&&W!==ae.Z_OK)return this.onEnd(W),this.ended=!0,!1;Te.next_out&&(Te.avail_out!==0&&W!==ae.Z_STREAM_END&&(Te.avail_in!==0||le!==ae.Z_FINISH&&le!==ae.Z_SYNC_FLUSH)||(this.options.to===`string`?(_e=ie.utf8border(Te.output,Te.next_out),ye=Te.next_out-_e,Ce=ie.buf2string(Te.output,_e),Te.next_out=ye,Te.avail_out=Oe-ye,ye&&X.arraySet(Te.output,Te.output,_e,ye,0),this.onData(Ce)):this.onData(X.shrinkBuf(Te.output,Te.next_out)))),Te.avail_in===0&&Te.avail_out===0&&(Me=!0)}while((Te.avail_in>0||Te.avail_out===0)&&W!==ae.Z_STREAM_END);return W===ae.Z_STREAM_END&&(le=ae.Z_FINISH),le===ae.Z_FINISH?(W=Y.inflateEnd(this.strm),this.onEnd(W),this.ended=!0,W===ae.Z_OK):le!==ae.Z_SYNC_FLUSH||(this.onEnd(ae.Z_OK),Te.avail_out=0,!0)},g.prototype.onData=function(e){this.chunks.push(e)},g.prototype.onEnd=function(e){e===ae.Z_OK&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=X.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},R.Inflate=g,R.inflate=d,R.inflateRaw=function(e,R){return(R||={}).raw=!0,d(e,R)},R.ungzip=d},269(e){e.exports=function(e,R,W,Y){for(var X=65535&e,ie=e>>>16&65535,ae=0;W!==0;){W-=ae=W>2e3?2e3:W;do ie=ie+(X=X+R[Y++]|0)|0;while(--ae);X%=65521,ie%=65521}return X|ie<<16}},293(e){e.exports=function(e,R){var W=e.state,Y=e.next_in,X,ie,ae,le,_e,ye,be,Ce,Te,Oe,Ae,Me,Pe,Re,Be,Ve,He,Ue,We,Ge,Ke,qe=e.input,Je;X=Y+(e.avail_in-5),ie=e.next_out,Je=e.output,ae=ie-(R-e.avail_out),le=ie+(e.avail_out-257),_e=W.dmax,ye=W.wsize,be=W.whave,Ce=W.wnext,Te=W.window,Oe=W.hold,Ae=W.bits,Me=W.lencode,Pe=W.distcode,Re=(1<<W.lenbits)-1,Be=(1<<W.distbits)-1;e:do{Ae<15&&(Oe+=qe[Y++]<<Ae,Ae+=8,Oe+=qe[Y++]<<Ae,Ae+=8),Ve=Me[Oe&Re];t:for(;;){if(Oe>>>=He=Ve>>>24,Ae-=He,(He=Ve>>>16&255)==0)Je[ie++]=65535&Ve;else{if(!(16&He)){if(64&He){if(32&He){W.mode=12;break e}e.msg=`invalid literal/length code`,W.mode=30;break e}Ve=Me[(65535&Ve)+(Oe&(1<<He)-1)];continue t}for(Ue=65535&Ve,(He&=15)&&(Ae<He&&(Oe+=qe[Y++]<<Ae,Ae+=8),Ue+=Oe&(1<<He)-1,Oe>>>=He,Ae-=He),Ae<15&&(Oe+=qe[Y++]<<Ae,Ae+=8,Oe+=qe[Y++]<<Ae,Ae+=8),Ve=Pe[Oe&Be];;){if(Oe>>>=He=Ve>>>24,Ae-=He,16&(He=Ve>>>16&255)){if(We=65535&Ve,Ae<(He&=15)&&(Oe+=qe[Y++]<<Ae,(Ae+=8)<He&&(Oe+=qe[Y++]<<Ae,Ae+=8)),(We+=Oe&(1<<He)-1)>_e){e.msg=`invalid distance too far back`,W.mode=30;break e}if(Oe>>>=He,Ae-=He,We>(He=ie-ae)){if((He=We-He)>be&&W.sane){e.msg=`invalid distance too far back`,W.mode=30;break e}if(Ge=0,Ke=Te,Ce===0){if(Ge+=ye-He,He<Ue){Ue-=He;do Je[ie++]=Te[Ge++];while(--He);Ge=ie-We,Ke=Je}}else if(Ce<He){if(Ge+=ye+Ce-He,(He-=Ce)<Ue){Ue-=He;do Je[ie++]=Te[Ge++];while(--He);if(Ge=0,Ce<Ue){Ue-=He=Ce;do Je[ie++]=Te[Ge++];while(--He);Ge=ie-We,Ke=Je}}}else if(Ge+=Ce-He,He<Ue){Ue-=He;do Je[ie++]=Te[Ge++];while(--He);Ge=ie-We,Ke=Je}for(;Ue>2;)Je[ie++]=Ke[Ge++],Je[ie++]=Ke[Ge++],Je[ie++]=Ke[Ge++],Ue-=3;Ue&&(Je[ie++]=Ke[Ge++],Ue>1&&(Je[ie++]=Ke[Ge++]))}else{Ge=ie-We;do Je[ie++]=Je[Ge++],Je[ie++]=Je[Ge++],Je[ie++]=Je[Ge++],Ue-=3;while(Ue>2);Ue&&(Je[ie++]=Je[Ge++],Ue>1&&(Je[ie++]=Je[Ge++]))}break}if(64&He){e.msg=`invalid distance code`,W.mode=30;break e}Ve=Pe[(65535&Ve)+(Oe&(1<<He)-1)]}}break}}while(Y<X&&ie<le);Y-=Ue=Ae>>3,Oe&=(1<<(Ae-=Ue<<3))-1,e.next_in=Y,e.next_out=ie,e.avail_in=Y<X?X-Y+5:5-(Y-X),e.avail_out=ie<le?le-ie+257:257-(ie-le),W.hold=Oe,W.bits=Ae}},303(e,R,W){var Y=W(411),X=W(805),ie=W(996),ae=W(674),le=W(442),_e=Object.prototype.toString;function l(e){if(!(this instanceof l))return new l(e);this.options=X.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:``},e||{});var R=this.options;R.raw&&R.windowBits>0?R.windowBits=-R.windowBits:R.gzip&&R.windowBits>0&&R.windowBits<16&&(R.windowBits+=16),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new le,this.strm.avail_out=0;var W=Y.deflateInit2(this.strm,R.level,R.method,R.windowBits,R.memLevel,R.strategy);if(W!==0)throw Error(ae[W]);if(R.header&&Y.deflateSetHeader(this.strm,R.header),R.dictionary){var ye;if(ye=typeof R.dictionary==`string`?ie.string2buf(R.dictionary):_e.call(R.dictionary)===`[object ArrayBuffer]`?new Uint8Array(R.dictionary):R.dictionary,(W=Y.deflateSetDictionary(this.strm,ye))!==0)throw Error(ae[W]);this._dict_set=!0}}function c(e,R){var W=new l(R);if(W.push(e,!0),W.err)throw W.msg||ae[W.err];return W.result}l.prototype.push=function(e,R){var W,ae,le=this.strm,ye=this.options.chunkSize;if(this.ended)return!1;ae=R===~~R?R:!0===R?4:0,typeof e==`string`?le.input=ie.string2buf(e):_e.call(e)===`[object ArrayBuffer]`?le.input=new Uint8Array(e):le.input=e,le.next_in=0,le.avail_in=le.input.length;do{if(le.avail_out===0&&(le.output=new X.Buf8(ye),le.next_out=0,le.avail_out=ye),(W=Y.deflate(le,ae))!==1&&W!==0)return this.onEnd(W),this.ended=!0,!1;le.avail_out!==0&&(le.avail_in!==0||ae!==4&&ae!==2)||(this.options.to===`string`?this.onData(ie.buf2binstring(X.shrinkBuf(le.output,le.next_out))):this.onData(X.shrinkBuf(le.output,le.next_out)))}while((le.avail_in>0||le.avail_out===0)&&W!==1);return ae===4?(W=Y.deflateEnd(this.strm),this.onEnd(W),this.ended=!0,W===0):ae!==2||(this.onEnd(0),le.avail_out=0,!0)},l.prototype.onData=function(e){this.chunks.push(e)},l.prototype.onEnd=function(e){e===0&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=X.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},R.Deflate=l,R.deflate=c,R.deflateRaw=function(e,R){return(R||={}).raw=!0,c(e,R)},R.gzip=function(e,R){return(R||={}).gzip=!0,c(e,R)}},371(e){e.exports=Pm},411(e,R,W){var Y,X=W(805),ie=W(665),ae=W(269),le=W(823),_e=W(674),ye=-2,be=258,Ce=262,Te=103,Oe=113,Ae=666;function I(e,R){return e.msg=_e[R],R}function p(e){return(e<<1)-(e>4?9:0)}function f(e){for(var R=e.length;--R>=0;)e[R]=0}function B(e){var R=e.state,W=R.pending;W>e.avail_out&&(W=e.avail_out),W!==0&&(X.arraySet(e.output,R.pending_buf,R.pending_out,W,e.next_out),e.next_out+=W,R.pending_out+=W,e.total_out+=W,e.avail_out-=W,R.pending-=W,R.pending===0&&(R.pending_out=0))}function C(e,R){ie._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,R),e.block_start=e.strstart,B(e.strm)}function E(e,R){e.pending_buf[e.pending++]=R}function Q(e,R){e.pending_buf[e.pending++]=R>>>8&255,e.pending_buf[e.pending++]=255&R}function m(e,R){var W,Y,X=e.max_chain_length,ie=e.strstart,ae=e.prev_length,le=e.nice_match,_e=e.strstart>e.w_size-Ce?e.strstart-(e.w_size-Ce):0,ye=e.window,Te=e.w_mask,Oe=e.prev,Ae=e.strstart+be,Me=ye[ie+ae-1],Pe=ye[ie+ae];e.prev_length>=e.good_match&&(X>>=2),le>e.lookahead&&(le=e.lookahead);do if(ye[(W=R)+ae]===Pe&&ye[W+ae-1]===Me&&ye[W]===ye[ie]&&ye[++W]===ye[ie+1]){ie+=2,W++;do;while(ye[++ie]===ye[++W]&&ye[++ie]===ye[++W]&&ye[++ie]===ye[++W]&&ye[++ie]===ye[++W]&&ye[++ie]===ye[++W]&&ye[++ie]===ye[++W]&&ye[++ie]===ye[++W]&&ye[++ie]===ye[++W]&&ie<Ae);if(Y=be-(Ae-ie),ie=Ae-be,Y>ae){if(e.match_start=R,ae=Y,Y>=le)break;Me=ye[ie+ae-1],Pe=ye[ie+ae]}}while((R=Oe[R&Te])>_e&&--X!=0);return ae<=e.lookahead?ae:e.lookahead}function y(e){var R,W,Y,ie,_e,ye,be,Te,Oe,Ae,Me=e.w_size;do{if(ie=e.window_size-e.lookahead-e.strstart,e.strstart>=Me+(Me-Ce)){X.arraySet(e.window,e.window,Me,Me,0),e.match_start-=Me,e.strstart-=Me,e.block_start-=Me,R=W=e.hash_size;do Y=e.head[--R],e.head[R]=Y>=Me?Y-Me:0;while(--W);R=W=Me;do Y=e.prev[--R],e.prev[R]=Y>=Me?Y-Me:0;while(--W);ie+=Me}if(e.strm.avail_in===0)break;if(ye=e.strm,be=e.window,Te=e.strstart+e.lookahead,Oe=ie,Ae=void 0,(Ae=ye.avail_in)>Oe&&(Ae=Oe),W=Ae===0?0:(ye.avail_in-=Ae,X.arraySet(be,ye.input,ye.next_in,Ae,Te),ye.state.wrap===1?ye.adler=ae(ye.adler,be,Ae,Te):ye.state.wrap===2&&(ye.adler=le(ye.adler,be,Ae,Te)),ye.next_in+=Ae,ye.total_in+=Ae,Ae),e.lookahead+=W,e.lookahead+e.insert>=3)for(_e=e.strstart-e.insert,e.ins_h=e.window[_e],e.ins_h=(e.ins_h<<e.hash_shift^e.window[_e+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[_e+3-1])&e.hash_mask,e.prev[_e&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=_e,_e++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<Ce&&e.strm.avail_in!==0)}function w(e,R){for(var W,Y;;){if(e.lookahead<Ce){if(y(e),e.lookahead<Ce&&R===0)return 1;if(e.lookahead===0)break}if(W=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,W=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),W!==0&&e.strstart-W<=e.w_size-Ce&&(e.match_length=m(e,W)),e.match_length>=3)if(Y=ie._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,W=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!=0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else Y=ie._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(Y&&(C(e,!1),e.strm.avail_out===0))return 1}return e.insert=e.strstart<2?e.strstart:2,R===4?(C(e,!0),e.strm.avail_out===0?3:4):e.last_lit&&(C(e,!1),e.strm.avail_out===0)?1:2}function _(e,R){for(var W,Y,X;;){if(e.lookahead<Ce){if(y(e),e.lookahead<Ce&&R===0)return 1;if(e.lookahead===0)break}if(W=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,W=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,W!==0&&e.prev_length<e.max_lazy_match&&e.strstart-W<=e.w_size-Ce&&(e.match_length=m(e,W),e.match_length<=5&&(e.strategy===1||e.match_length===3&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){X=e.strstart+e.lookahead-3,Y=ie._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=X&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,W=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!=0);if(e.match_available=0,e.match_length=2,e.strstart++,Y&&(C(e,!1),e.strm.avail_out===0))return 1}else if(e.match_available){if((Y=ie._tr_tally(e,0,e.window[e.strstart-1]))&&C(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&=(Y=ie._tr_tally(e,0,e.window[e.strstart-1]),0),e.insert=e.strstart<2?e.strstart:2,R===4?(C(e,!0),e.strm.avail_out===0?3:4):e.last_lit&&(C(e,!1),e.strm.avail_out===0)?1:2}function v(e,R,W,Y,X){this.good_length=e,this.max_lazy=R,this.nice_length=W,this.max_chain=Y,this.func=X}function b(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new X.Buf16(1146),this.dyn_dtree=new X.Buf16(122),this.bl_tree=new X.Buf16(78),f(this.dyn_ltree),f(this.dyn_dtree),f(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new X.Buf16(16),this.heap=new X.Buf16(573),f(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new X.Buf16(573),f(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function k(e){var R;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(R=e.state).pending=0,R.pending_out=0,R.wrap<0&&(R.wrap=-R.wrap),R.status=R.wrap?42:Oe,e.adler=R.wrap===2?0:1,R.last_flush=0,ie._tr_init(R),0):I(e,ye)}function D(e){var R,W=k(e);return W===0&&((R=e.state).window_size=2*R.w_size,f(R.head),R.max_lazy_match=Y[R.level].max_lazy,R.good_match=Y[R.level].good_length,R.nice_match=Y[R.level].nice_length,R.max_chain_length=Y[R.level].max_chain,R.strstart=0,R.block_start=0,R.lookahead=0,R.insert=0,R.match_length=R.prev_length=2,R.match_available=0,R.ins_h=0),W}function S(e,R,W,Y,ie,ae){if(!e)return ye;var le=1;if(R===-1&&(R=6),Y<0?(le=0,Y=-Y):Y>15&&(le=2,Y-=16),ie<1||ie>9||W!==8||Y<8||Y>15||R<0||R>9||ae<0||ae>4)return I(e,ye);Y===8&&(Y=9);var _e=new b;return e.state=_e,_e.strm=e,_e.wrap=le,_e.gzhead=null,_e.w_bits=Y,_e.w_size=1<<_e.w_bits,_e.w_mask=_e.w_size-1,_e.hash_bits=ie+7,_e.hash_size=1<<_e.hash_bits,_e.hash_mask=_e.hash_size-1,_e.hash_shift=~~((_e.hash_bits+3-1)/3),_e.window=new X.Buf8(2*_e.w_size),_e.head=new X.Buf16(_e.hash_size),_e.prev=new X.Buf16(_e.w_size),_e.lit_bufsize=1<<ie+6,_e.pending_buf_size=4*_e.lit_bufsize,_e.pending_buf=new X.Buf8(_e.pending_buf_size),_e.d_buf=1*_e.lit_bufsize,_e.l_buf=3*_e.lit_bufsize,_e.level=R,_e.strategy=ae,_e.method=W,D(e)}Y=[new v(0,0,0,0,(function(e,R){var W=65535;for(W>e.pending_buf_size-5&&(W=e.pending_buf_size-5);;){if(e.lookahead<=1){if(y(e),e.lookahead===0&&R===0)return 1;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var Y=e.block_start+W;if((e.strstart===0||e.strstart>=Y)&&(e.lookahead=e.strstart-Y,e.strstart=Y,C(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-Ce&&(C(e,!1),e.strm.avail_out===0))return 1}return e.insert=0,R===4?(C(e,!0),e.strm.avail_out===0?3:4):(e.strstart>e.block_start&&(C(e,!1),e.strm.avail_out),1)})),new v(4,4,8,4,w),new v(4,5,16,8,w),new v(4,6,32,32,w),new v(4,4,16,16,_),new v(8,16,32,32,_),new v(8,16,128,128,_),new v(8,32,128,256,_),new v(32,128,258,1024,_),new v(32,258,258,4096,_)],R.deflateInit=function(e,R){return S(e,R,8,15,8,0)},R.deflateInit2=S,R.deflateReset=D,R.deflateResetKeep=k,R.deflateSetHeader=function(e,R){return e&&e.state&&e.state.wrap===2?(e.state.gzhead=R,0):ye},R.deflate=function(e,R){var W,X,ae,_e;if(!e||!e.state||R>5||R<0)return e?I(e,ye):ye;if(X=e.state,!e.output||!e.input&&e.avail_in!==0||X.status===Ae&&R!==4)return I(e,e.avail_out===0?-5:ye);if(X.strm=e,W=X.last_flush,X.last_flush=R,X.status===42)if(X.wrap===2)e.adler=0,E(X,31),E(X,139),E(X,8),X.gzhead?(E(X,+!!X.gzhead.text+(X.gzhead.hcrc?2:0)+(X.gzhead.extra?4:0)+(X.gzhead.name?8:0)+(X.gzhead.comment?16:0)),E(X,255&X.gzhead.time),E(X,X.gzhead.time>>8&255),E(X,X.gzhead.time>>16&255),E(X,X.gzhead.time>>24&255),E(X,X.level===9?2:X.strategy>=2||X.level<2?4:0),E(X,255&X.gzhead.os),X.gzhead.extra&&X.gzhead.extra.length&&(E(X,255&X.gzhead.extra.length),E(X,X.gzhead.extra.length>>8&255)),X.gzhead.hcrc&&(e.adler=le(e.adler,X.pending_buf,X.pending,0)),X.gzindex=0,X.status=69):(E(X,0),E(X,0),E(X,0),E(X,0),E(X,0),E(X,X.level===9?2:X.strategy>=2||X.level<2?4:0),E(X,3),X.status=Oe);else{var Ce=8+(X.w_bits-8<<4)<<8;Ce|=(X.strategy>=2||X.level<2?0:X.level<6?1:X.level===6?2:3)<<6,X.strstart!==0&&(Ce|=32),Ce+=31-Ce%31,X.status=Oe,Q(X,Ce),X.strstart!==0&&(Q(X,e.adler>>>16),Q(X,65535&e.adler)),e.adler=1}if(X.status===69)if(X.gzhead.extra){for(ae=X.pending;X.gzindex<(65535&X.gzhead.extra.length)&&(X.pending!==X.pending_buf_size||(X.gzhead.hcrc&&X.pending>ae&&(e.adler=le(e.adler,X.pending_buf,X.pending-ae,ae)),B(e),ae=X.pending,X.pending!==X.pending_buf_size));)E(X,255&X.gzhead.extra[X.gzindex]),X.gzindex++;X.gzhead.hcrc&&X.pending>ae&&(e.adler=le(e.adler,X.pending_buf,X.pending-ae,ae)),X.gzindex===X.gzhead.extra.length&&(X.gzindex=0,X.status=73)}else X.status=73;if(X.status===73)if(X.gzhead.name){ae=X.pending;do{if(X.pending===X.pending_buf_size&&(X.gzhead.hcrc&&X.pending>ae&&(e.adler=le(e.adler,X.pending_buf,X.pending-ae,ae)),B(e),ae=X.pending,X.pending===X.pending_buf_size)){_e=1;break}_e=X.gzindex<X.gzhead.name.length?255&X.gzhead.name.charCodeAt(X.gzindex++):0,E(X,_e)}while(_e!==0);X.gzhead.hcrc&&X.pending>ae&&(e.adler=le(e.adler,X.pending_buf,X.pending-ae,ae)),_e===0&&(X.gzindex=0,X.status=91)}else X.status=91;if(X.status===91)if(X.gzhead.comment){ae=X.pending;do{if(X.pending===X.pending_buf_size&&(X.gzhead.hcrc&&X.pending>ae&&(e.adler=le(e.adler,X.pending_buf,X.pending-ae,ae)),B(e),ae=X.pending,X.pending===X.pending_buf_size)){_e=1;break}_e=X.gzindex<X.gzhead.comment.length?255&X.gzhead.comment.charCodeAt(X.gzindex++):0,E(X,_e)}while(_e!==0);X.gzhead.hcrc&&X.pending>ae&&(e.adler=le(e.adler,X.pending_buf,X.pending-ae,ae)),_e===0&&(X.status=Te)}else X.status=Te;if(X.status===Te&&(X.gzhead.hcrc?(X.pending+2>X.pending_buf_size&&B(e),X.pending+2<=X.pending_buf_size&&(E(X,255&e.adler),E(X,e.adler>>8&255),e.adler=0,X.status=Oe)):X.status=Oe),X.pending!==0){if(B(e),e.avail_out===0)return X.last_flush=-1,0}else if(e.avail_in===0&&p(R)<=p(W)&&R!==4)return I(e,-5);if(X.status===Ae&&e.avail_in!==0)return I(e,-5);if(e.avail_in!==0||X.lookahead!==0||R!==0&&X.status!==Ae){var Me=X.strategy===2?function(e,R){for(var W;;){if(e.lookahead===0&&(y(e),e.lookahead===0)){if(R===0)return 1;break}if(e.match_length=0,W=ie._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,W&&(C(e,!1),e.strm.avail_out===0))return 1}return e.insert=0,R===4?(C(e,!0),e.strm.avail_out===0?3:4):e.last_lit&&(C(e,!1),e.strm.avail_out===0)?1:2}(X,R):X.strategy===3?function(e,R){for(var W,Y,X,ae,le=e.window;;){if(e.lookahead<=be){if(y(e),e.lookahead<=be&&R===0)return 1;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(Y=le[X=e.strstart-1])===le[++X]&&Y===le[++X]&&Y===le[++X]){ae=e.strstart+be;do;while(Y===le[++X]&&Y===le[++X]&&Y===le[++X]&&Y===le[++X]&&Y===le[++X]&&Y===le[++X]&&Y===le[++X]&&Y===le[++X]&&X<ae);e.match_length=be-(ae-X),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(W=ie._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(W=ie._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),W&&(C(e,!1),e.strm.avail_out===0))return 1}return e.insert=0,R===4?(C(e,!0),e.strm.avail_out===0?3:4):e.last_lit&&(C(e,!1),e.strm.avail_out===0)?1:2}(X,R):Y[X.level].func(X,R);if(Me!==3&&Me!==4||(X.status=Ae),Me===1||Me===3)return e.avail_out===0&&(X.last_flush=-1),0;if(Me===2&&(R===1?ie._tr_align(X):R!==5&&(ie._tr_stored_block(X,0,0,!1),R===3&&(f(X.head),X.lookahead===0&&(X.strstart=0,X.block_start=0,X.insert=0))),B(e),e.avail_out===0))return X.last_flush=-1,0}return R===4?X.wrap<=0?1:(X.wrap===2?(E(X,255&e.adler),E(X,e.adler>>8&255),E(X,e.adler>>16&255),E(X,e.adler>>24&255),E(X,255&e.total_in),E(X,e.total_in>>8&255),E(X,e.total_in>>16&255),E(X,e.total_in>>24&255)):(Q(X,e.adler>>>16),Q(X,65535&e.adler)),B(e),X.wrap>0&&(X.wrap=-X.wrap),+(X.pending===0)):0},R.deflateEnd=function(e){var R;return e&&e.state?(R=e.state.status)!==42&&R!==69&&R!==73&&R!==91&&R!==Te&&R!==Oe&&R!==Ae?I(e,ye):(e.state=null,R===Oe?I(e,-3):0):ye},R.deflateSetDictionary=function(e,R){var W,Y,ie,le,_e,be,Ce,Te,Oe=R.length;if(!e||!e.state||(le=(W=e.state).wrap)===2||le===1&&W.status!==42||W.lookahead)return ye;for(le===1&&(e.adler=ae(e.adler,R,Oe,0)),W.wrap=0,Oe>=W.w_size&&(le===0&&(f(W.head),W.strstart=0,W.block_start=0,W.insert=0),Te=new X.Buf8(W.w_size),X.arraySet(Te,R,Oe-W.w_size,W.w_size,0),R=Te,Oe=W.w_size),_e=e.avail_in,be=e.next_in,Ce=e.input,e.avail_in=Oe,e.next_in=0,e.input=R,y(W);W.lookahead>=3;){Y=W.strstart,ie=W.lookahead-2;do W.ins_h=(W.ins_h<<W.hash_shift^W.window[Y+3-1])&W.hash_mask,W.prev[Y&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=Y,Y++;while(--ie);W.strstart=Y,W.lookahead=2,y(W)}return W.strstart+=W.lookahead,W.block_start=W.strstart,W.insert=W.lookahead,W.lookahead=0,W.match_length=W.prev_length=2,W.match_available=0,e.next_in=be,e.input=Ce,e.avail_in=_e,W.wrap=le,0},R.deflateInfo=`pako deflate (from Nodeca project)`},414(e){e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=``,this.comment=``,this.hcrc=0,this.done=!1}},442(e){e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}},447(e,R,W){var Y=W(805),X=W(269),ie=W(823),ae=W(293),le=W(998),_e=-2,ye=12,be=30;function g(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function d(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Y.Buf16(320),this.work=new Y.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function h(e){var R;return e&&e.state?(R=e.state,e.total_in=e.total_out=R.total=0,e.msg=``,R.wrap&&(e.adler=1&R.wrap),R.mode=1,R.last=0,R.havedict=0,R.dmax=32768,R.head=null,R.hold=0,R.bits=0,R.lencode=R.lendyn=new Y.Buf32(852),R.distcode=R.distdyn=new Y.Buf32(592),R.sane=1,R.back=-1,0):_e}function u(e){var R;return e&&e.state?((R=e.state).wsize=0,R.whave=0,R.wnext=0,h(e)):_e}function I(e,R){var W,Y;return e&&e.state?(Y=e.state,R<0?(W=0,R=-R):(W=1+(R>>4),R<48&&(R&=15)),R&&(R<8||R>15)?_e:(Y.window!==null&&Y.wbits!==R&&(Y.window=null),Y.wrap=W,Y.wbits=R,u(e))):_e}function p(e,R){var W,Y;return e?(Y=new d,e.state=Y,Y.window=null,(W=I(e,R))!==0&&(e.state=null),W):_e}var Ce,Te,Oe=!0;function E(e){if(Oe){var R;for(Ce=new Y.Buf32(512),Te=new Y.Buf32(32),R=0;R<144;)e.lens[R++]=8;for(;R<256;)e.lens[R++]=9;for(;R<280;)e.lens[R++]=7;for(;R<288;)e.lens[R++]=8;for(le(1,e.lens,0,288,Ce,0,e.work,{bits:9}),R=0;R<32;)e.lens[R++]=5;le(2,e.lens,0,32,Te,0,e.work,{bits:5}),Oe=!1}e.lencode=Ce,e.lenbits=9,e.distcode=Te,e.distbits=5}function Q(e,R,W,X){var ie,ae=e.state;return ae.window===null&&(ae.wsize=1<<ae.wbits,ae.wnext=0,ae.whave=0,ae.window=new Y.Buf8(ae.wsize)),X>=ae.wsize?(Y.arraySet(ae.window,R,W-ae.wsize,ae.wsize,0),ae.wnext=0,ae.whave=ae.wsize):((ie=ae.wsize-ae.wnext)>X&&(ie=X),Y.arraySet(ae.window,R,W-X,ie,ae.wnext),(X-=ie)?(Y.arraySet(ae.window,R,W-X,X,0),ae.wnext=X,ae.whave=ae.wsize):(ae.wnext+=ie,ae.wnext===ae.wsize&&(ae.wnext=0),ae.whave<ae.wsize&&(ae.whave+=ie))),0}R.inflateReset=u,R.inflateReset2=I,R.inflateResetKeep=h,R.inflateInit=function(e){return p(e,15)},R.inflateInit2=p,R.inflate=function(e,R){var W,Ce,Te,Oe,Ae,Me,Pe,Re,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et,tt,nt=0,rt=new Y.Buf8(4),it=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return _e;(W=e.state).mode===ye&&(W.mode=13),Ae=e.next_out,Te=e.output,Pe=e.avail_out,Oe=e.next_in,Ce=e.input,Me=e.avail_in,Re=W.hold,Be=W.bits,Ve=Me,He=Pe,$e=0;e:for(;;)switch(W.mode){case 1:if(W.wrap===0){W.mode=13;break}for(;Be<16;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}if(2&W.wrap&&Re===35615){W.check=0,rt[0]=255&Re,rt[1]=Re>>>8&255,W.check=ie(W.check,rt,2,0),Re=0,Be=0,W.mode=2;break}if(W.flags=0,W.head&&(W.head.done=!1),!(1&W.wrap)||(((255&Re)<<8)+(Re>>8))%31){e.msg=`incorrect header check`,W.mode=be;break}if((15&Re)!=8){e.msg=`unknown compression method`,W.mode=be;break}if(Be-=4,Qe=8+(15&(Re>>>=4)),W.wbits===0)W.wbits=Qe;else if(Qe>W.wbits){e.msg=`invalid window size`,W.mode=be;break}W.dmax=1<<Qe,e.adler=W.check=1,W.mode=512&Re?10:ye,Re=0,Be=0;break;case 2:for(;Be<16;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}if(W.flags=Re,(255&W.flags)!=8){e.msg=`unknown compression method`,W.mode=be;break}if(57344&W.flags){e.msg=`unknown header flags set`,W.mode=be;break}W.head&&(W.head.text=Re>>8&1),512&W.flags&&(rt[0]=255&Re,rt[1]=Re>>>8&255,W.check=ie(W.check,rt,2,0)),Re=0,Be=0,W.mode=3;case 3:for(;Be<32;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}W.head&&(W.head.time=Re),512&W.flags&&(rt[0]=255&Re,rt[1]=Re>>>8&255,rt[2]=Re>>>16&255,rt[3]=Re>>>24&255,W.check=ie(W.check,rt,4,0)),Re=0,Be=0,W.mode=4;case 4:for(;Be<16;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}W.head&&(W.head.xflags=255&Re,W.head.os=Re>>8),512&W.flags&&(rt[0]=255&Re,rt[1]=Re>>>8&255,W.check=ie(W.check,rt,2,0)),Re=0,Be=0,W.mode=5;case 5:if(1024&W.flags){for(;Be<16;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}W.length=Re,W.head&&(W.head.extra_len=Re),512&W.flags&&(rt[0]=255&Re,rt[1]=Re>>>8&255,W.check=ie(W.check,rt,2,0)),Re=0,Be=0}else W.head&&(W.head.extra=null);W.mode=6;case 6:if(1024&W.flags&&((Ue=W.length)>Me&&(Ue=Me),Ue&&(W.head&&(Qe=W.head.extra_len-W.length,W.head.extra||(W.head.extra=Array(W.head.extra_len)),Y.arraySet(W.head.extra,Ce,Oe,Ue,Qe)),512&W.flags&&(W.check=ie(W.check,Ce,Ue,Oe)),Me-=Ue,Oe+=Ue,W.length-=Ue),W.length))break e;W.length=0,W.mode=7;case 7:if(2048&W.flags){if(Me===0)break e;Ue=0;do Qe=Ce[Oe+ Ue++],W.head&&Qe&&W.length<65536&&(W.head.name+=String.fromCharCode(Qe));while(Qe&&Ue<Me);if(512&W.flags&&(W.check=ie(W.check,Ce,Ue,Oe)),Me-=Ue,Oe+=Ue,Qe)break e}else W.head&&(W.head.name=null);W.length=0,W.mode=8;case 8:if(4096&W.flags){if(Me===0)break e;Ue=0;do Qe=Ce[Oe+ Ue++],W.head&&Qe&&W.length<65536&&(W.head.comment+=String.fromCharCode(Qe));while(Qe&&Ue<Me);if(512&W.flags&&(W.check=ie(W.check,Ce,Ue,Oe)),Me-=Ue,Oe+=Ue,Qe)break e}else W.head&&(W.head.comment=null);W.mode=9;case 9:if(512&W.flags){for(;Be<16;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}if(Re!==(65535&W.check)){e.msg=`header crc mismatch`,W.mode=be;break}Re=0,Be=0}W.head&&(W.head.hcrc=W.flags>>9&1,W.head.done=!0),e.adler=W.check=0,W.mode=ye;break;case 10:for(;Be<32;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}e.adler=W.check=g(Re),Re=0,Be=0,W.mode=11;case 11:if(W.havedict===0)return e.next_out=Ae,e.avail_out=Pe,e.next_in=Oe,e.avail_in=Me,W.hold=Re,W.bits=Be,2;e.adler=W.check=1,W.mode=ye;case ye:if(R===5||R===6)break e;case 13:if(W.last){Re>>>=7&Be,Be-=7&Be,W.mode=27;break}for(;Be<3;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}switch(W.last=1&Re,--Be,3&(Re>>>=1)){case 0:W.mode=14;break;case 1:if(E(W),W.mode=20,R===6){Re>>>=2,Be-=2;break e}break;case 2:W.mode=17;break;case 3:e.msg=`invalid block type`,W.mode=be}Re>>>=2,Be-=2;break;case 14:for(Re>>>=7&Be,Be-=7&Be;Be<32;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}if((65535&Re)!=(Re>>>16^65535)){e.msg=`invalid stored block lengths`,W.mode=be;break}if(W.length=65535&Re,Re=0,Be=0,W.mode=15,R===6)break e;case 15:W.mode=16;case 16:if(Ue=W.length){if(Ue>Me&&(Ue=Me),Ue>Pe&&(Ue=Pe),Ue===0)break e;Y.arraySet(Te,Ce,Oe,Ue,Ae),Me-=Ue,Oe+=Ue,Pe-=Ue,Ae+=Ue,W.length-=Ue;break}W.mode=ye;break;case 17:for(;Be<14;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}if(W.nlen=257+(31&Re),Re>>>=5,Be-=5,W.ndist=1+(31&Re),Re>>>=5,Be-=5,W.ncode=4+(15&Re),Re>>>=4,Be-=4,W.nlen>286||W.ndist>30){e.msg=`too many length or distance symbols`,W.mode=be;break}W.have=0,W.mode=18;case 18:for(;W.have<W.ncode;){for(;Be<3;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}W.lens[it[W.have++]]=7&Re,Re>>>=3,Be-=3}for(;W.have<19;)W.lens[it[W.have++]]=0;if(W.lencode=W.lendyn,W.lenbits=7,et={bits:W.lenbits},$e=le(0,W.lens,0,19,W.lencode,0,W.work,et),W.lenbits=et.bits,$e){e.msg=`invalid code lengths set`,W.mode=be;break}W.have=0,W.mode=19;case 19:for(;W.have<W.nlen+W.ndist;){for(;qe=(nt=W.lencode[Re&(1<<W.lenbits)-1])>>>16&255,Je=65535&nt,!((Ke=nt>>>24)<=Be);){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}if(Je<16)Re>>>=Ke,Be-=Ke,W.lens[W.have++]=Je;else{if(Je===16){for(tt=Ke+2;Be<tt;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}if(Re>>>=Ke,Be-=Ke,W.have===0){e.msg=`invalid bit length repeat`,W.mode=be;break}Qe=W.lens[W.have-1],Ue=3+(3&Re),Re>>>=2,Be-=2}else if(Je===17){for(tt=Ke+3;Be<tt;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}Be-=Ke,Qe=0,Ue=3+(7&(Re>>>=Ke)),Re>>>=3,Be-=3}else{for(tt=Ke+7;Be<tt;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}Be-=Ke,Qe=0,Ue=11+(127&(Re>>>=Ke)),Re>>>=7,Be-=7}if(W.have+Ue>W.nlen+W.ndist){e.msg=`invalid bit length repeat`,W.mode=be;break}for(;Ue--;)W.lens[W.have++]=Qe}}if(W.mode===be)break;if(W.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,W.mode=be;break}if(W.lenbits=9,et={bits:W.lenbits},$e=le(1,W.lens,0,W.nlen,W.lencode,0,W.work,et),W.lenbits=et.bits,$e){e.msg=`invalid literal/lengths set`,W.mode=be;break}if(W.distbits=6,W.distcode=W.distdyn,et={bits:W.distbits},$e=le(2,W.lens,W.nlen,W.ndist,W.distcode,0,W.work,et),W.distbits=et.bits,$e){e.msg=`invalid distances set`,W.mode=be;break}if(W.mode=20,R===6)break e;case 20:W.mode=21;case 21:if(Me>=6&&Pe>=258){e.next_out=Ae,e.avail_out=Pe,e.next_in=Oe,e.avail_in=Me,W.hold=Re,W.bits=Be,ae(e,He),Ae=e.next_out,Te=e.output,Pe=e.avail_out,Oe=e.next_in,Ce=e.input,Me=e.avail_in,Re=W.hold,Be=W.bits,W.mode===ye&&(W.back=-1);break}for(W.back=0;qe=(nt=W.lencode[Re&(1<<W.lenbits)-1])>>>16&255,Je=65535&nt,!((Ke=nt>>>24)<=Be);){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}if(qe&&!(240&qe)){for(Ye=Ke,Xe=qe,Ze=Je;qe=(nt=W.lencode[Ze+((Re&(1<<Ye+Xe)-1)>>Ye)])>>>16&255,Je=65535&nt,!(Ye+(Ke=nt>>>24)<=Be);){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}Re>>>=Ye,Be-=Ye,W.back+=Ye}if(Re>>>=Ke,Be-=Ke,W.back+=Ke,W.length=Je,qe===0){W.mode=26;break}if(32&qe){W.back=-1,W.mode=ye;break}if(64&qe){e.msg=`invalid literal/length code`,W.mode=be;break}W.extra=15&qe,W.mode=22;case 22:if(W.extra){for(tt=W.extra;Be<tt;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}W.length+=Re&(1<<W.extra)-1,Re>>>=W.extra,Be-=W.extra,W.back+=W.extra}W.was=W.length,W.mode=23;case 23:for(;qe=(nt=W.distcode[Re&(1<<W.distbits)-1])>>>16&255,Je=65535&nt,!((Ke=nt>>>24)<=Be);){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}if(!(240&qe)){for(Ye=Ke,Xe=qe,Ze=Je;qe=(nt=W.distcode[Ze+((Re&(1<<Ye+Xe)-1)>>Ye)])>>>16&255,Je=65535&nt,!(Ye+(Ke=nt>>>24)<=Be);){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}Re>>>=Ye,Be-=Ye,W.back+=Ye}if(Re>>>=Ke,Be-=Ke,W.back+=Ke,64&qe){e.msg=`invalid distance code`,W.mode=be;break}W.offset=Je,W.extra=15&qe,W.mode=24;case 24:if(W.extra){for(tt=W.extra;Be<tt;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}W.offset+=Re&(1<<W.extra)-1,Re>>>=W.extra,Be-=W.extra,W.back+=W.extra}if(W.offset>W.dmax){e.msg=`invalid distance too far back`,W.mode=be;break}W.mode=25;case 25:if(Pe===0)break e;if(Ue=He-Pe,W.offset>Ue){if((Ue=W.offset-Ue)>W.whave&&W.sane){e.msg=`invalid distance too far back`,W.mode=be;break}Ue>W.wnext?(Ue-=W.wnext,We=W.wsize-Ue):We=W.wnext-Ue,Ue>W.length&&(Ue=W.length),Ge=W.window}else Ge=Te,We=Ae-W.offset,Ue=W.length;Ue>Pe&&(Ue=Pe),Pe-=Ue,W.length-=Ue;do Te[Ae++]=Ge[We++];while(--Ue);W.length===0&&(W.mode=21);break;case 26:if(Pe===0)break e;Te[Ae++]=W.length,Pe--,W.mode=21;break;case 27:if(W.wrap){for(;Be<32;){if(Me===0)break e;Me--,Re|=Ce[Oe++]<<Be,Be+=8}if(He-=Pe,e.total_out+=He,W.total+=He,He&&(e.adler=W.check=W.flags?ie(W.check,Te,He,Ae-He):X(W.check,Te,He,Ae-He)),He=Pe,(W.flags?Re:g(Re))!==W.check){e.msg=`incorrect data check`,W.mode=be;break}Re=0,Be=0}W.mode=28;case 28:if(W.wrap&&W.flags){for(;Be<32;){if(Me===0)break e;Me--,Re+=Ce[Oe++]<<Be,Be+=8}if(Re!==(4294967295&W.total)){e.msg=`incorrect length check`,W.mode=be;break}Re=0,Be=0}W.mode=29;case 29:$e=1;break e;case be:$e=-3;break e;case 31:return-4;default:return _e}return e.next_out=Ae,e.avail_out=Pe,e.next_in=Oe,e.avail_in=Me,W.hold=Re,W.bits=Be,(W.wsize||He!==e.avail_out&&W.mode<be&&(W.mode<27||R!==4))&&Q(e,e.output,e.next_out,He-e.avail_out)?(W.mode=31,-4):(Ve-=e.avail_in,He-=e.avail_out,e.total_in+=Ve,e.total_out+=He,W.total+=He,W.wrap&&He&&(e.adler=W.check=W.flags?ie(W.check,Te,He,e.next_out-He):X(W.check,Te,He,e.next_out-He)),e.data_type=W.bits+(W.last?64:0)+(W.mode===ye?128:0)+(W.mode===20||W.mode===15?256:0),(Ve===0&&He===0||R===4)&&$e===0&&($e=-5),$e)},R.inflateEnd=function(e){if(!e||!e.state)return _e;var R=e.state;return R.window&&=null,e.state=null,0},R.inflateGetHeader=function(e,R){var W;return e&&e.state&&2&(W=e.state).wrap?(W.head=R,R.done=!1,0):_e},R.inflateSetDictionary=function(e,R){var W,Y=R.length;return e&&e.state?(W=e.state).wrap!==0&&W.mode!==11?_e:W.mode===11&&X(1,R,Y,0)!==W.check?-3:Q(e,R,Y,Y)?(W.mode=31,-4):(W.havedict=1,0):_e},R.inflateInfo=`pako inflate (from Nodeca project)`},665(e,R,W){var Y=W(805);function n(e){for(var R=e.length;--R>=0;)e[R]=0}var X=256,ie=286,ae=30,le=15,_e=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ye=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],be=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Ce=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Te=Array(576);n(Te);var Oe=Array(60);n(Oe);var Ae=Array(512);n(Ae);var Me=Array(256);n(Me);var Pe=Array(29);n(Pe);var Re,Be,Ve,He=Array(ae);function m(e,R,W,Y,X){this.static_tree=e,this.extra_bits=R,this.extra_base=W,this.elems=Y,this.max_length=X,this.has_stree=e&&e.length}function y(e,R){this.dyn_tree=e,this.max_code=0,this.stat_desc=R}function w(e){return e<256?Ae[e]:Ae[256+(e>>>7)]}function _(e,R){e.pending_buf[e.pending++]=255&R,e.pending_buf[e.pending++]=R>>>8&255}function v(e,R,W){e.bi_valid>16-W?(e.bi_buf|=R<<e.bi_valid&65535,_(e,e.bi_buf),e.bi_buf=R>>16-e.bi_valid,e.bi_valid+=W-16):(e.bi_buf|=R<<e.bi_valid&65535,e.bi_valid+=W)}function b(e,R,W){v(e,W[2*R],W[2*R+1])}function k(e,R){var W=0;do W|=1&e,e>>>=1,W<<=1;while(--R>0);return W>>>1}function D(e,R,W){var Y,X,ie=Array(16),ae=0;for(Y=1;Y<=le;Y++)ie[Y]=ae=ae+W[Y-1]<<1;for(X=0;X<=R;X++){var _e=e[2*X+1];_e!==0&&(e[2*X]=k(ie[_e]++,_e))}}function S(e){var R;for(R=0;R<ie;R++)e.dyn_ltree[2*R]=0;for(R=0;R<ae;R++)e.dyn_dtree[2*R]=0;for(R=0;R<19;R++)e.bl_tree[2*R]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function x(e){e.bi_valid>8?_(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function z(e,R,W,Y){var X=2*R,ie=2*W;return e[X]<e[ie]||e[X]===e[ie]&&Y[R]<=Y[W]}function F(e,R,W){for(var Y=e.heap[W],X=W<<1;X<=e.heap_len&&(X<e.heap_len&&z(R,e.heap[X+1],e.heap[X],e.depth)&&X++,!z(R,Y,e.heap[X],e.depth));)e.heap[W]=e.heap[X],W=X,X<<=1;e.heap[W]=Y}function L(e,R,W){var Y,ie,ae,le,be=0;if(e.last_lit!==0)do Y=e.pending_buf[e.d_buf+2*be]<<8|e.pending_buf[e.d_buf+2*be+1],ie=e.pending_buf[e.l_buf+be],be++,Y===0?b(e,ie,R):(b(e,(ae=Me[ie])+X+1,R),(le=_e[ae])!==0&&v(e,ie-=Pe[ae],le),b(e,ae=w(--Y),W),(le=ye[ae])!==0&&v(e,Y-=He[ae],le));while(be<e.last_lit);b(e,256,R)}function N(e,R){var W,Y,X,ie=R.dyn_tree,ae=R.stat_desc.static_tree,_e=R.stat_desc.has_stree,ye=R.stat_desc.elems,be=-1;for(e.heap_len=0,e.heap_max=573,W=0;W<ye;W++)ie[2*W]===0?ie[2*W+1]=0:(e.heap[++e.heap_len]=be=W,e.depth[W]=0);for(;e.heap_len<2;)ie[2*(X=e.heap[++e.heap_len]=be<2?++be:0)]=1,e.depth[X]=0,e.opt_len--,_e&&(e.static_len-=ae[2*X+1]);for(R.max_code=be,W=e.heap_len>>1;W>=1;W--)F(e,ie,W);X=ye;do W=e.heap[1],e.heap[1]=e.heap[e.heap_len--],F(e,ie,1),Y=e.heap[1],e.heap[--e.heap_max]=W,e.heap[--e.heap_max]=Y,ie[2*X]=ie[2*W]+ie[2*Y],e.depth[X]=(e.depth[W]>=e.depth[Y]?e.depth[W]:e.depth[Y])+1,ie[2*W+1]=ie[2*Y+1]=X,e.heap[1]=X++,F(e,ie,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,R){var W,Y,X,ie,ae,_e,ye=R.dyn_tree,be=R.max_code,Ce=R.stat_desc.static_tree,Te=R.stat_desc.has_stree,Oe=R.stat_desc.extra_bits,Ae=R.stat_desc.extra_base,Me=R.stat_desc.max_length,Pe=0;for(ie=0;ie<=le;ie++)e.bl_count[ie]=0;for(ye[2*e.heap[e.heap_max]+1]=0,W=e.heap_max+1;W<573;W++)(ie=ye[2*ye[2*(Y=e.heap[W])+1]+1]+1)>Me&&(ie=Me,Pe++),ye[2*Y+1]=ie,Y>be||(e.bl_count[ie]++,ae=0,Y>=Ae&&(ae=Oe[Y-Ae]),_e=ye[2*Y],e.opt_len+=_e*(ie+ae),Te&&(e.static_len+=_e*(Ce[2*Y+1]+ae)));if(Pe!==0){do{for(ie=Me-1;e.bl_count[ie]===0;)ie--;e.bl_count[ie]--,e.bl_count[ie+1]+=2,e.bl_count[Me]--,Pe-=2}while(Pe>0);for(ie=Me;ie!==0;ie--)for(Y=e.bl_count[ie];Y!==0;)(X=e.heap[--W])>be||(ye[2*X+1]!==ie&&(e.opt_len+=(ie-ye[2*X+1])*ye[2*X],ye[2*X+1]=ie),Y--)}}(e,R),D(ie,be,e.bl_count)}function G(e,R,W){var Y,X,ie=-1,ae=R[1],le=0,_e=7,ye=4;for(ae===0&&(_e=138,ye=3),R[2*(W+1)+1]=65535,Y=0;Y<=W;Y++)X=ae,ae=R[2*(Y+1)+1],++le<_e&&X===ae||(le<ye?e.bl_tree[2*X]+=le:X===0?le<=10?e.bl_tree[34]++:e.bl_tree[36]++:(X!==ie&&e.bl_tree[2*X]++,e.bl_tree[32]++),le=0,ie=X,ae===0?(_e=138,ye=3):X===ae?(_e=6,ye=3):(_e=7,ye=4))}function T(e,R,W){var Y,X,ie=-1,ae=R[1],le=0,_e=7,ye=4;for(ae===0&&(_e=138,ye=3),Y=0;Y<=W;Y++)if(X=ae,ae=R[2*(Y+1)+1],!(++le<_e&&X===ae)){if(le<ye)do b(e,X,e.bl_tree);while(--le!=0);else X===0?le<=10?(b(e,17,e.bl_tree),v(e,le-3,3)):(b(e,18,e.bl_tree),v(e,le-11,7)):(X!==ie&&(b(e,X,e.bl_tree),le--),b(e,16,e.bl_tree),v(e,le-3,2));le=0,ie=X,ae===0?(_e=138,ye=3):X===ae?(_e=6,ye=3):(_e=7,ye=4)}}n(He);var Ue=!1;function M(e,R,W,X){v(e,0+ +!!X,3),function(e,R,W,X){x(e),X&&(_(e,W),_(e,~W)),Y.arraySet(e.pending_buf,e.window,R,W,e.pending),e.pending+=W}(e,R,W,!0)}R._tr_init=function(e){Ue||=(function(){var e,R,W,Y,X,Ce=Array(16);for(W=0,Y=0;Y<28;Y++)for(Pe[Y]=W,e=0;e<1<<_e[Y];e++)Me[W++]=Y;for(Me[W-1]=Y,X=0,Y=0;Y<16;Y++)for(He[Y]=X,e=0;e<1<<ye[Y];e++)Ae[X++]=Y;for(X>>=7;Y<ae;Y++)for(He[Y]=X<<7,e=0;e<1<<ye[Y]-7;e++)Ae[256+ X++]=Y;for(R=0;R<=le;R++)Ce[R]=0;for(e=0;e<=143;)Te[2*e+1]=8,e++,Ce[8]++;for(;e<=255;)Te[2*e+1]=9,e++,Ce[9]++;for(;e<=279;)Te[2*e+1]=7,e++,Ce[7]++;for(;e<=287;)Te[2*e+1]=8,e++,Ce[8]++;for(D(Te,287,Ce),e=0;e<ae;e++)Oe[2*e+1]=5,Oe[2*e]=k(e,5);Re=new m(Te,_e,257,ie,le),Be=new m(Oe,ye,0,ae,le),Ve=new m([],be,0,19,7)}(),!0),e.l_desc=new y(e.dyn_ltree,Re),e.d_desc=new y(e.dyn_dtree,Be),e.bl_desc=new y(e.bl_tree,Ve),e.bi_buf=0,e.bi_valid=0,S(e)},R._tr_stored_block=M,R._tr_flush_block=function(e,R,W,Y){var ie,ae,le=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=function(e){var R,W=4093624447;for(R=0;R<=31;R++,W>>>=1)if(1&W&&e.dyn_ltree[2*R]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(R=32;R<X;R++)if(e.dyn_ltree[2*R]!==0)return 1;return 0}(e)),N(e,e.l_desc),N(e,e.d_desc),le=function(e){var R;for(G(e,e.dyn_ltree,e.l_desc.max_code),G(e,e.dyn_dtree,e.d_desc.max_code),N(e,e.bl_desc),R=18;R>=3&&e.bl_tree[2*Ce[R]+1]===0;R--);return e.opt_len+=3*(R+1)+5+5+4,R}(e),ie=e.opt_len+3+7>>>3,(ae=e.static_len+3+7>>>3)<=ie&&(ie=ae)):ie=ae=W+5,W+4<=ie&&R!==-1?M(e,R,W,Y):e.strategy===4||ae===ie?(v(e,2+ +!!Y,3),L(e,Te,Oe)):(v(e,4+ +!!Y,3),function(e,R,W,Y){var X;for(v(e,R-257,5),v(e,W-1,5),v(e,Y-4,4),X=0;X<Y;X++)v(e,e.bl_tree[2*Ce[X]+1],3);T(e,e.dyn_ltree,R-1),T(e,e.dyn_dtree,W-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,le+1),L(e,e.dyn_ltree,e.dyn_dtree)),S(e),Y&&x(e)},R._tr_tally=function(e,R,W){return e.pending_buf[e.d_buf+2*e.last_lit]=R>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&R,e.pending_buf[e.l_buf+e.last_lit]=255&W,e.last_lit++,R===0?e.dyn_ltree[2*W]++:(e.matches++,R--,e.dyn_ltree[2*(Me[W]+X+1)]++,e.dyn_dtree[2*w(R)]++),e.last_lit===e.lit_bufsize-1},R._tr_align=function(e){v(e,2,3),b(e,256,Te),function(e){e.bi_valid===16?(_(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},668(e,R,W){var Y={};(0,W(805).assign)(Y,W(303),W(83),W(681)),e.exports=Y},674(e){e.exports={2:`need dictionary`,1:`stream end`,0:``,"-1":`file error`,"-2":`stream error`,"-3":`data error`,"-4":`insufficient memory`,"-5":`buffer error`,"-6":`incompatible version`}},681(e){e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},805(e,R){var W=typeof Uint8Array<`u`&&typeof Uint16Array<`u`&&typeof Int32Array<`u`;function i(e,R){return Object.prototype.hasOwnProperty.call(e,R)}R.assign=function(e){for(var R=Array.prototype.slice.call(arguments,1);R.length;){var W=R.shift();if(W){if(typeof W!=`object`)throw TypeError(W+`must be non-object`);for(var Y in W)i(W,Y)&&(e[Y]=W[Y])}}return e},R.shrinkBuf=function(e,R){return e.length===R?e:e.subarray?e.subarray(0,R):(e.length=R,e)};var Y={arraySet:function(e,R,W,Y,X){if(R.subarray&&e.subarray)e.set(R.subarray(W,W+Y),X);else for(var ie=0;ie<Y;ie++)e[X+ie]=R[W+ie]},flattenChunks:function(e){var R,W,Y,X,ie,ae;for(Y=0,R=0,W=e.length;R<W;R++)Y+=e[R].length;for(ae=new Uint8Array(Y),X=0,R=0,W=e.length;R<W;R++)ie=e[R],ae.set(ie,X),X+=ie.length;return ae}},X={arraySet:function(e,R,W,Y,X){for(var ie=0;ie<Y;ie++)e[X+ie]=R[W+ie]},flattenChunks:function(e){return[].concat.apply([],e)}};R.setTyped=function(e){e?(R.Buf8=Uint8Array,R.Buf16=Uint16Array,R.Buf32=Int32Array,R.assign(R,Y)):(R.Buf8=Array,R.Buf16=Array,R.Buf32=Array,R.assign(R,X))},R.setTyped(W)},823(e){var R=function(){for(var e,R=[],W=0;W<256;W++){e=W;for(var Y=0;Y<8;Y++)e=1&e?3988292384^e>>>1:e>>>1;R[W]=e}return R}();e.exports=function(e,W,Y,X){var ie=R,ae=X+Y;e^=-1;for(var le=X;le<ae;le++)e=e>>>8^ie[255&(e^W[le])];return~e}},996(e,R,W){var Y=W(805),X=!0,ie=!0;try{String.fromCharCode.apply(null,[0])}catch{X=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{ie=!1}for(var ae=new Y.Buf8(256),le=0;le<256;le++)ae[le]=le>=252?6:le>=248?5:le>=240?4:le>=224?3:le>=192?2:1;function a(e,R){if(R<65534&&(e.subarray&&ie||!e.subarray&&X))return String.fromCharCode.apply(null,Y.shrinkBuf(e,R));for(var W=``,ae=0;ae<R;ae++)W+=String.fromCharCode(e[ae]);return W}ae[254]=ae[254]=1,R.string2buf=function(e){var R,W,X,ie,ae,le=e.length,_e=0;for(ie=0;ie<le;ie++)(64512&(W=e.charCodeAt(ie)))==55296&&ie+1<le&&(64512&(X=e.charCodeAt(ie+1)))==56320&&(W=65536+(W-55296<<10)+(X-56320),ie++),_e+=W<128?1:W<2048?2:W<65536?3:4;for(R=new Y.Buf8(_e),ae=0,ie=0;ae<_e;ie++)(64512&(W=e.charCodeAt(ie)))==55296&&ie+1<le&&(64512&(X=e.charCodeAt(ie+1)))==56320&&(W=65536+(W-55296<<10)+(X-56320),ie++),W<128?R[ae++]=W:W<2048?(R[ae++]=192|W>>>6,R[ae++]=128|63&W):W<65536?(R[ae++]=224|W>>>12,R[ae++]=128|W>>>6&63,R[ae++]=128|63&W):(R[ae++]=240|W>>>18,R[ae++]=128|W>>>12&63,R[ae++]=128|W>>>6&63,R[ae++]=128|63&W);return R},R.buf2binstring=function(e){return a(e,e.length)},R.binstring2buf=function(e){for(var R=new Y.Buf8(e.length),W=0,X=R.length;W<X;W++)R[W]=e.charCodeAt(W);return R},R.buf2string=function(e,R){var W,Y,X,ie,le=R||e.length,_e=Array(2*le);for(Y=0,W=0;W<le;)if((X=e[W++])<128)_e[Y++]=X;else if((ie=ae[X])>4)_e[Y++]=65533,W+=ie-1;else{for(X&=ie===2?31:ie===3?15:7;ie>1&&W<le;)X=X<<6|63&e[W++],ie--;ie>1?_e[Y++]=65533:X<65536?_e[Y++]=X:(X-=65536,_e[Y++]=55296|X>>10&1023,_e[Y++]=56320|1023&X)}return a(_e,Y)},R.utf8border=function(e,R){var W;for((R||=e.length)>e.length&&(R=e.length),W=R-1;W>=0&&(192&e[W])==128;)W--;return W<0||W===0?R:W+ae[e[W]]>R?W:R}},998(e,R,W){var Y=W(805),X=15,ie=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],ae=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],le=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],_e=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(e,R,W,ye,be,Ce,Te,Oe){var Ae,Me,Pe,Re,Be,Ve,He,Ue,We,Ge=Oe.bits,Ke=0,qe=0,Je=0,Ye=0,Xe=0,Ze=0,Qe=0,$e=0,et=0,tt=0,nt=null,rt=0,it=new Y.Buf16(16),at=new Y.Buf16(16),st=null,ct=0;for(Ke=0;Ke<=X;Ke++)it[Ke]=0;for(qe=0;qe<ye;qe++)it[R[W+qe]]++;for(Xe=Ge,Ye=X;Ye>=1&&it[Ye]===0;Ye--);if(Xe>Ye&&(Xe=Ye),Ye===0)return be[Ce++]=20971520,be[Ce++]=20971520,Oe.bits=1,0;for(Je=1;Je<Ye&&it[Je]===0;Je++);for(Xe<Je&&(Xe=Je),$e=1,Ke=1;Ke<=X;Ke++)if($e<<=1,($e-=it[Ke])<0)return-1;if($e>0&&(e===0||Ye!==1))return-1;for(at[1]=0,Ke=1;Ke<X;Ke++)at[Ke+1]=at[Ke]+it[Ke];for(qe=0;qe<ye;qe++)R[W+qe]!==0&&(Te[at[R[W+qe]]++]=qe);if(e===0?(nt=st=Te,Ve=19):e===1?(nt=ie,rt-=257,st=ae,ct-=257,Ve=256):(nt=le,st=_e,Ve=-1),tt=0,qe=0,Ke=Je,Be=Ce,Ze=Xe,Qe=0,Pe=-1,Re=(et=1<<Xe)-1,e===1&&et>852||e===2&&et>592)return 1;for(;;){He=Ke-Qe,Te[qe]<Ve?(Ue=0,We=Te[qe]):Te[qe]>Ve?(Ue=st[ct+Te[qe]],We=nt[rt+Te[qe]]):(Ue=96,We=0),Ae=1<<Ke-Qe,Je=Me=1<<Ze;do be[Be+(tt>>Qe)+(Me-=Ae)]=He<<24|Ue<<16|We;while(Me!==0);for(Ae=1<<Ke-1;tt&Ae;)Ae>>=1;if(Ae===0?tt=0:(tt&=Ae-1,tt+=Ae),qe++,--it[Ke]==0){if(Ke===Ye)break;Ke=R[W+Te[qe]]}if(Ke>Xe&&(tt&Re)!==Pe){for(Qe===0&&(Qe=Xe),Be+=Je,$e=1<<(Ze=Ke-Qe);Ze+Qe<Ye&&!(($e-=it[Ze+Qe])<=0);)Ze++,$e<<=1;if(et+=1<<Ze,e===1&&et>852||e===2&&et>592)return 1;be[Pe=tt&Re]=Xe<<24|Ze<<16|Be-Ce}}return tt!==0&&(be[Be+tt]=Ke-Qe<<24|64<<16),Oe.bits=Xe,0}}},Lm={};function S(e){var R=Lm[e];if(R!==void 0)return R.exports;var W=Lm[e]={exports:{}};return Im[e](W,W.exports,S),W.exports}S.d=(e,R)=>{for(var W in R)S.o(R,W)&&!S.o(e,W)&&Object.defineProperty(e,W,{enumerable:!0,get:R[W]})},S.o=(e,R)=>Object.prototype.hasOwnProperty.call(e,R),S.r=e=>{typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})};var Rm={};S.r(Rm),S.d(Rm,{base64:()=>Th,base64url:()=>Eh,bigint:()=>Mh,boolean:()=>Fh,browserEmail:()=>bh,cidrv4:()=>Ch,cidrv6:()=>wh,cuid:()=>nh,cuid2:()=>rh,date:()=>jh,datetime:()=>ft,domain:()=>Oh,duration:()=>ch,e164:()=>kh,email:()=>mh,emoji:()=>At,extendedDuration:()=>lh,guid:()=>uh,hex:()=>Bh,hostname:()=>Dh,html5Email:()=>hh,idnEmail:()=>yh,integer:()=>Nh,ipv4:()=>xh,ipv6:()=>Sh,ksuid:()=>oh,lowercase:()=>Rh,mac:()=>ot,md5_base64:()=>Hh,md5_base64url:()=>Uh,md5_hex:()=>Vh,nanoid:()=>sh,null:()=>Ih,number:()=>Ph,rfc5322Email:()=>gh,sha1_base64:()=>Gh,sha1_base64url:()=>Kh,sha1_hex:()=>Wh,sha256_base64:()=>Jh,sha256_base64url:()=>Yh,sha256_hex:()=>qh,sha384_base64:()=>Zh,sha384_base64url:()=>Qh,sha384_hex:()=>Xh,sha512_base64:()=>eg,sha512_base64url:()=>tg,sha512_hex:()=>$h,string:()=>Bt,time:()=>pt,ulid:()=>ih,undefined:()=>Lh,unicodeEmail:()=>vh,uppercase:()=>zh,uuid:()=>je,uuid4:()=>dh,uuid6:()=>fh,uuid7:()=>ph,xid:()=>ah});var zm={};S.r(zm),S.d(zm,{endsWith:()=>Pn,gt:()=>Sn,gte:()=>xn,includes:()=>Yn,length:()=>Jn,lowercase:()=>qn,lt:()=>kn,lte:()=>Dn,maxLength:()=>On,maxSize:()=>Tn,mime:()=>Kn,minLength:()=>Un,minSize:()=>Rn,multipleOf:()=>Gn,negative:()=>Fn,nonnegative:()=>Nn,nonpositive:()=>Ln,normalize:()=>Vn,overwrite:()=>Wn,positive:()=>zn,property:()=>$n,regex:()=>Zn,size:()=>Mn,slugify:()=>Ao,startsWith:()=>Hn,toLowerCase:()=>eo,toUpperCase:()=>to,trim:()=>Xn,uppercase:()=>jn});var Bm={};S.r(Bm),S.d(Bm,{ZodISODate:()=>Z_,ZodISODateTime:()=>X_,ZodISODuration:()=>$_,ZodISOTime:()=>Q_,date:()=>Xo,datetime:()=>Wo,duration:()=>is,time:()=>ts});var Vm={};S.r(Vm),S.d(Vm,{ZodAny:()=>Kv,ZodArray:()=>Zv,ZodBase64:()=>Nv,ZodBase64URL:()=>Pv,ZodBigInt:()=>Vv,ZodBigIntFormat:()=>Hv,ZodBoolean:()=>Bv,ZodCIDRv4:()=>jv,ZodCIDRv6:()=>Mv,ZodCUID:()=>Cv,ZodCUID2:()=>wv,ZodCatch:()=>_y,ZodCodec:()=>by,ZodCustom:()=>Ey,ZodCustomStringFormat:()=>Lv,ZodDate:()=>Xv,ZodDefault:()=>py,ZodDiscriminatedUnion:()=>ty,ZodE164:()=>Fv,ZodEmail:()=>_v,ZodEmoji:()=>xv,ZodEnum:()=>sy,ZodFile:()=>ly,ZodFunction:()=>Ty,ZodGUID:()=>vv,ZodIPv4:()=>Ov,ZodIPv6:()=>Av,ZodIntersection:()=>ny,ZodJWT:()=>Iv,ZodKSUID:()=>Dv,ZodLazy:()=>Cy,ZodLiteral:()=>cy,ZodMAC:()=>kv,ZodMap:()=>ay,ZodNaN:()=>vy,ZodNanoID:()=>Sv,ZodNever:()=>Jv,ZodNonOptional:()=>hy,ZodNull:()=>Gv,ZodNullable:()=>fy,ZodNumber:()=>Rv,ZodNumberFormat:()=>zv,ZodObject:()=>Qv,ZodOptional:()=>dy,ZodPipe:()=>yy,ZodPrefault:()=>my,ZodPromise:()=>wy,ZodReadonly:()=>xy,ZodRecord:()=>iy,ZodSet:()=>oy,ZodString:()=>hv,ZodStringFormat:()=>gv,ZodSuccess:()=>gy,ZodSymbol:()=>Uv,ZodTemplateLiteral:()=>Sy,ZodTransform:()=>uy,ZodTuple:()=>ry,ZodType:()=>pv,ZodULID:()=>Tv,ZodURL:()=>bv,ZodUUID:()=>yv,ZodUndefined:()=>Wv,ZodUnion:()=>$v,ZodUnknown:()=>qv,ZodVoid:()=>Yv,ZodXID:()=>Ev,ZodXor:()=>ey,_ZodString:()=>mv,_default:()=>Na,_function:()=>ol,any:()=>Or,array:()=>Kr,base64:()=>sr,base64url:()=>ar,bigint:()=>Dr,boolean:()=>br,catch:()=>Za,check:()=>rl,cidrv4:()=>Ar,cidrv6:()=>nr,codec:()=>$a,cuid:()=>Os,cuid2:()=>Js,custom:()=>al,date:()=>Pr,describe:()=>gl,discriminatedUnion:()=>ra,e164:()=>cr,email:()=>ws,emoji:()=>Gs,enum:()=>Qa,file:()=>va,float32:()=>mr,float64:()=>yr,function:()=>ol,guid:()=>vs,hash:()=>fr,hex:()=>pr,hostname:()=>Ir,httpUrl:()=>Ls,instanceof:()=>hl,int:()=>Qr,int32:()=>wr,int64:()=>xr,intersection:()=>la,ipv4:()=>Ks,ipv6:()=>er,json:()=>Il,jwt:()=>dr,keyof:()=>Wr,ksuid:()=>Ps,lazy:()=>tl,literal:()=>wa,looseObject:()=>ta,looseRecord:()=>Ia,mac:()=>Vs,map:()=>fa,meta:()=>dl,nan:()=>ja,nanoid:()=>Rs,nativeEnum:()=>ma,never:()=>qr,nonoptional:()=>Ma,null:()=>Rr,nullable:()=>za,nullish:()=>Fa,number:()=>Cr,object:()=>Xr,optional:()=>Sa,partialRecord:()=>ua,pipe:()=>Ha,prefault:()=>Ta,preprocess:()=>pl,promise:()=>il,readonly:()=>Wa,record:()=>ha,refine:()=>ll,set:()=>Ca,strictObject:()=>ea,string:()=>Qs,stringFormat:()=>ur,stringbool:()=>ul,success:()=>Ua,superRefine:()=>cl,symbol:()=>Lr,templateLiteral:()=>Xa,transform:()=>ka,tuple:()=>ga,uint32:()=>_r,uint64:()=>zr,ulid:()=>qs,undefined:()=>Gr,union:()=>ia,unknown:()=>Jr,url:()=>Fs,uuid:()=>ks,uuidv4:()=>Ds,uuidv6:()=>Ss,uuidv7:()=>xs,void:()=>Yr,xid:()=>Ys,xor:()=>oa}),Object.freeze({status:`aborted`});function N(e,R,W){function i(W,Y){if(W._zod||Object.defineProperty(W,"_zod",{value:{def:Y,constr:s,traits:new Set},enumerable:!1}),W._zod.traits.has(e))return;W._zod.traits.add(e),R(W,Y);let X=s.prototype,ie=Object.keys(X);for(let e=0;e<ie.length;e++){let R=ie[e];R in W||(W[R]=X[R].bind(W))}}let Y=W?.Parent??Object;class o extends Y{}function s(e){var R;let Y=W?.Parent?new o:this;i(Y,e),(R=Y._zod).deferred??(R.deferred=[]);for(let e of Y._zod.deferred)e();return Y}return Object.defineProperty(o,"name",{value:e}),Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:R=>!!(W?.Parent&&R instanceof W.Parent)||R?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var G=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},T=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};const Hm={};function M(e){return e&&Object.assign(Hm,e),Hm}function O(e){let R=Object.values(e).filter((e=>typeof e==`number`));return Object.entries(e).filter((([e,W])=>R.indexOf(+e)===-1)).map((([e,R])=>R))}function U(e,R=`|`){return e.map((e=>re(e))).join(R)}function J(e,R){return typeof R==`bigint`?R.toString():R}function Z(e){return{get value(){{let R=e();return Object.defineProperty(this,"value",{value:R}),R}}}}function q(e){return e==null}function j(e){let R=+!!e.startsWith(`^`),W=e.endsWith(`$`)?e.length-1:e.length;return e.slice(R,W)}const Um=Symbol(`evaluating`);function H(e,R,W){let Y;Object.defineProperty(e,R,{get(){if(Y!==Um)return Y===void 0&&(Y=Um,Y=W()),Y},set(W){Object.defineProperty(e,R,{value:W})},configurable:!0})}function P(e,R,W){Object.defineProperty(e,R,{value:W,writable:!0,enumerable:!0,configurable:!0})}function $(...e){let R={};for(let W of e)Object.assign(R,Object.getOwnPropertyDescriptors(W));return Object.defineProperties({},R)}function K(e){return JSON.stringify(e)}const Wm=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Gm=Z((()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}}));function ee(e){if(!1===V(e))return!1;let R=e.constructor;if(R===void 0||typeof R!=`function`)return!0;let W=R.prototype;return!1!==V(W)&&!1!==Object.prototype.hasOwnProperty.call(W,`isPrototypeOf`)}function te(e){return ee(e)?{...e}:Array.isArray(e)?[...e]:e}const Km=new Set([`string`,`number`,`symbol`]),qm=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function ne(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function oe(e,R,W){let Y=new e._zod.constr(R??e._zod.def);return R&&!W?.parent||(Y._zod.parent=e),Y}function se(e){let R=e;if(!R)return{};if(typeof R==`string`)return{error:()=>R};if(R?.message!==void 0){if(R?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");R.error=R.message}return delete R.message,typeof R.error==`string`?{...R,error:()=>R.error}:R}function re(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}const Jm={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ym={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function ce(e,R=0){if(!0===e.aborted)return!0;for(let W=R;W<e.issues.length;W++)if(!0!==e.issues[W]?.continue)return!0;return!1}function ge(e,R){return R.map((R=>{var W;return(W=R).path??(W.path=[]),R.path.unshift(e),R}))}function de(e){return typeof e==`string`?e:e?.message}function he(e,R,W){let Y={...e,path:e.path??[]};return e.message||(Y.message=de(e.inst?._zod.def?.error?.(e))??de(R?.error?.(e))??de(W.customError?.(e))??de(W.localeError?.(e))??`Invalid input`),delete Y.inst,delete Y.continue,R?.reportInput||delete Y.input,Y}function ue(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function Ie(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function pe(...e){let[R,W,Y]=e;return typeof R==`string`?{message:R,code:`custom`,input:W,inst:Y}:{...R}}const fe=(e,R)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:R,enumerable:!1}),e.message=JSON.stringify(R,J,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Xm=N(`$ZodError`,fe),Zm=N(`$ZodError`,fe,{Parent:Error}),Ee=e=>(R,W,Y,X)=>{let ie=Y?Object.assign(Y,{async:!1}):{async:!1},ae=R._zod.run({value:W,issues:[]},ie);if(ae instanceof Promise)throw new G;if(ae.issues.length){let R=new(X?.Err??e)(ae.issues.map((e=>he(e,ie,M()))));throw Wm(R,X?.callee),R}return ae.value},Qm=Ee(Zm),me=e=>async(R,W,Y,X)=>{let ie=Y?Object.assign(Y,{async:!0}):{async:!0},ae=R._zod.run({value:W,issues:[]},ie);if(ae instanceof Promise&&(ae=await ae),ae.issues.length){let R=new(X?.Err??e)(ae.issues.map((e=>he(e,ie,M()))));throw Wm(R,X?.callee),R}return ae.value},$m=me(Zm),we=e=>(R,W,Y)=>{let X=Y?{...Y,async:!1}:{async:!1},ie=R._zod.run({value:W,issues:[]},X);if(ie instanceof Promise)throw new G;return ie.issues.length?{success:!1,error:new(e??Xm)(ie.issues.map((e=>he(e,X,M()))))}:{success:!0,data:ie.value}},eh=we(Zm),ve=e=>async(R,W,Y)=>{let X=Y?Object.assign(Y,{async:!0}):{async:!0},ie=R._zod.run({value:W,issues:[]},X);return ie instanceof Promise&&(ie=await ie),ie.issues.length?{success:!1,error:new e(ie.issues.map((e=>he(e,X,M()))))}:{success:!0,data:ie.value}},th=ve(Zm),ke=e=>(R,W,Y)=>{let X=Y?Object.assign(Y,{direction:`backward`}):{direction:`backward`};return Ee(e)(R,W,X)},De=e=>(R,W,Y)=>Ee(e)(R,W,Y),Se=e=>async(R,W,Y)=>{let X=Y?Object.assign(Y,{direction:`backward`}):{direction:`backward`};return me(e)(R,W,X)},xe=e=>async(R,W,Y)=>me(e)(R,W,Y),ze=e=>(R,W,Y)=>{let X=Y?Object.assign(Y,{direction:`backward`}):{direction:`backward`};return we(e)(R,W,X)},Fe=e=>(R,W,Y)=>we(e)(R,W,Y),Le=e=>async(R,W,Y)=>{let X=Y?Object.assign(Y,{direction:`backward`}):{direction:`backward`};return ve(e)(R,W,X)},Ne=e=>async(R,W,Y)=>ve(e)(R,W,Y),nh=/^[cC][^\s-]{8,}$/,rh=/^[0-9a-z]+$/,ih=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ah=/^[0-9a-vA-V]{20}$/,oh=/^[A-Za-z0-9]{27}$/,sh=/^[a-zA-Z0-9_-]{21}$/,ch=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,lh=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,uh=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,je=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,dh=je(4),fh=je(6),ph=je(7),mh=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,hh=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,gh=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,vh=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,yh=vh,bh=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;function At(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const xh=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Sh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ot=e=>{let R=ne(e??`:`);return RegExp(`^(?:[0-9A-F]{2}${R}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${R}){5}[0-9a-f]{2}$`)},Ch=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,wh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Th=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Eh=/^[A-Za-z0-9_-]*$/,Dh=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Oh=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,kh=/^\+(?:[0-9]){6,14}[0-9]$/,Ah=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,jh=RegExp(`^${Ah}$`);function It(e){let R=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${R}`:e.precision===0?`${R}:[0-5]\\d`:`${R}:[0-5]\\d\\.\\d{${e.precision}}`:`${R}(?::[0-5]\\d(?:\\.\\d+)?)?`}function pt(e){return RegExp(`^${It(e)}$`)}function ft(e){let R=It({precision:e.precision}),W=[`Z`];e.local&&W.push(``),e.offset&&W.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let Y=`${R}(?:${W.join(`|`)})`;return RegExp(`^${Ah}T(?:${Y})$`)}const Bt=e=>RegExp(`^${e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`}$`),Mh=/^-?\d+n?$/,Nh=/^-?\d+$/,Ph=/^-?\d+(?:\.\d+)?/,Fh=/^(?:true|false)$/i,Ih=/^null$/i,Lh=/^undefined$/i,Rh=/^[^A-Z]*$/,zh=/^[^a-z]*$/,Bh=/^[0-9a-fA-F]*$/;function kt(e,R){return RegExp(`^[A-Za-z0-9+/]{${e}}${R}$`)}function Dt(e){return RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const Vh=/^[0-9a-fA-F]{32}$/,Hh=kt(22,`==`),Uh=Dt(22),Wh=/^[0-9a-fA-F]{40}$/,Gh=kt(27,`=`),Kh=Dt(27),qh=/^[0-9a-fA-F]{64}$/,Jh=kt(43,`=`),Yh=Dt(43),Xh=/^[0-9a-fA-F]{96}$/,Zh=kt(64,``),Qh=Dt(64),$h=/^[0-9a-fA-F]{128}$/,eg=kt(86,`==`),tg=Dt(86),rg=N(`$ZodCheck`,((e,R)=>{var W;e._zod??={},e._zod.def=R,(W=e._zod).onattach??(W.onattach=[])})),ag={number:`number`,bigint:`bigint`,object:`date`},og=N(`$ZodCheckLessThan`,((e,R)=>{rg.init(e,R);let W=ag[typeof R.value];e._zod.onattach.push((e=>{let W=e._zod.bag,Y=(R.inclusive?W.maximum:W.exclusiveMaximum)??1/0;R.value<Y&&(R.inclusive?W.maximum=R.value:W.exclusiveMaximum=R.value)})),e._zod.check=Y=>{(R.inclusive?Y.value<=R.value:Y.value<R.value)||Y.issues.push({origin:W,code:`too_big`,maximum:R.value,input:Y.value,inclusive:R.inclusive,inst:e,continue:!R.abort})}})),sg=N(`$ZodCheckGreaterThan`,((e,R)=>{rg.init(e,R);let W=ag[typeof R.value];e._zod.onattach.push((e=>{let W=e._zod.bag,Y=(R.inclusive?W.minimum:W.exclusiveMinimum)??-1/0;R.value>Y&&(R.inclusive?W.minimum=R.value:W.exclusiveMinimum=R.value)})),e._zod.check=Y=>{(R.inclusive?Y.value>=R.value:Y.value>R.value)||Y.issues.push({origin:W,code:`too_small`,minimum:R.value,input:Y.value,inclusive:R.inclusive,inst:e,continue:!R.abort})}})),cg=N(`$ZodCheckMultipleOf`,((e,R)=>{rg.init(e,R),e._zod.onattach.push((e=>{var W;(W=e._zod.bag).multipleOf??(W.multipleOf=R.value)})),e._zod.check=W=>{if(typeof W.value!=typeof R.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof W.value==`bigint`?W.value%R.value===BigInt(0):function(e,R){let W=(e.toString().split(`.`)[1]||``).length,Y=R.toString(),X=(Y.split(`.`)[1]||``).length;if(X===0&&/\d?e-\d?/.test(Y)){let e=Y.match(/\d?e-(\d?)/);e?.[1]&&(X=Number.parseInt(e[1]))}let ie=W>X?W:X;return Number.parseInt(e.toFixed(ie).replace(`.`,``))%Number.parseInt(R.toFixed(ie).replace(`.`,``))/10**ie}(W.value,R.value)===0)||W.issues.push({origin:typeof W.value,code:`not_multiple_of`,divisor:R.value,input:W.value,inst:e,continue:!R.abort})}})),lg=N(`$ZodCheckNumberFormat`,((e,R)=>{rg.init(e,R),R.format=R.format||`float64`;let W=R.format?.includes(`int`),Y=W?`int`:`number`,[X,ie]=Jm[R.format];e._zod.onattach.push((e=>{let Y=e._zod.bag;Y.format=R.format,Y.minimum=X,Y.maximum=ie,W&&(Y.pattern=Nh)})),e._zod.check=ae=>{let le=ae.value;if(W){if(!Number.isInteger(le))return void ae.issues.push({expected:Y,format:R.format,code:`invalid_type`,continue:!1,input:le,inst:e});if(!Number.isSafeInteger(le))return void(le>0?ae.issues.push({input:le,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:Y,continue:!R.abort}):ae.issues.push({input:le,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:Y,continue:!R.abort}))}le<X&&ae.issues.push({origin:`number`,input:le,code:`too_small`,minimum:X,inclusive:!0,inst:e,continue:!R.abort}),le>ie&&ae.issues.push({origin:`number`,input:le,code:`too_big`,maximum:ie,inst:e})}})),ug=N(`$ZodCheckBigIntFormat`,((e,R)=>{rg.init(e,R);let[W,Y]=Ym[R.format];e._zod.onattach.push((e=>{let X=e._zod.bag;X.format=R.format,X.minimum=W,X.maximum=Y})),e._zod.check=X=>{let ie=X.value;ie<W&&X.issues.push({origin:`bigint`,input:ie,code:`too_small`,minimum:W,inclusive:!0,inst:e,continue:!R.abort}),ie>Y&&X.issues.push({origin:`bigint`,input:ie,code:`too_big`,maximum:Y,inst:e})}})),dg=N(`$ZodCheckMaxSize`,((e,R)=>{var W;rg.init(e,R),(W=e._zod.def).when??(W.when=e=>{let R=e.value;return!q(R)&&R.size!==void 0}),e._zod.onattach.push((e=>{let W=e._zod.bag.maximum??1/0;R.maximum<W&&(e._zod.bag.maximum=R.maximum)})),e._zod.check=W=>{let Y=W.value;Y.size<=R.maximum||W.issues.push({origin:ue(Y),code:`too_big`,maximum:R.maximum,inclusive:!0,input:Y,inst:e,continue:!R.abort})}})),fg=N(`$ZodCheckMinSize`,((e,R)=>{var W;rg.init(e,R),(W=e._zod.def).when??(W.when=e=>{let R=e.value;return!q(R)&&R.size!==void 0}),e._zod.onattach.push((e=>{let W=e._zod.bag.minimum??-1/0;R.minimum>W&&(e._zod.bag.minimum=R.minimum)})),e._zod.check=W=>{let Y=W.value;Y.size>=R.minimum||W.issues.push({origin:ue(Y),code:`too_small`,minimum:R.minimum,inclusive:!0,input:Y,inst:e,continue:!R.abort})}})),pg=N(`$ZodCheckSizeEquals`,((e,R)=>{var W;rg.init(e,R),(W=e._zod.def).when??(W.when=e=>{let R=e.value;return!q(R)&&R.size!==void 0}),e._zod.onattach.push((e=>{let W=e._zod.bag;W.minimum=R.size,W.maximum=R.size,W.size=R.size})),e._zod.check=W=>{let Y=W.value,X=Y.size;if(X===R.size)return;let ie=X>R.size;W.issues.push({origin:ue(Y),...ie?{code:`too_big`,maximum:R.size}:{code:`too_small`,minimum:R.size},inclusive:!0,exact:!0,input:W.value,inst:e,continue:!R.abort})}})),mg=N(`$ZodCheckMaxLength`,((e,R)=>{var W;rg.init(e,R),(W=e._zod.def).when??(W.when=e=>{let R=e.value;return!q(R)&&R.length!==void 0}),e._zod.onattach.push((e=>{let W=e._zod.bag.maximum??1/0;R.maximum<W&&(e._zod.bag.maximum=R.maximum)})),e._zod.check=W=>{let Y=W.value;if(Y.length<=R.maximum)return;let X=Ie(Y);W.issues.push({origin:X,code:`too_big`,maximum:R.maximum,inclusive:!0,input:Y,inst:e,continue:!R.abort})}})),hg=N(`$ZodCheckMinLength`,((e,R)=>{var W;rg.init(e,R),(W=e._zod.def).when??(W.when=e=>{let R=e.value;return!q(R)&&R.length!==void 0}),e._zod.onattach.push((e=>{let W=e._zod.bag.minimum??-1/0;R.minimum>W&&(e._zod.bag.minimum=R.minimum)})),e._zod.check=W=>{let Y=W.value;if(Y.length>=R.minimum)return;let X=Ie(Y);W.issues.push({origin:X,code:`too_small`,minimum:R.minimum,inclusive:!0,input:Y,inst:e,continue:!R.abort})}})),gg=N(`$ZodCheckLengthEquals`,((e,R)=>{var W;rg.init(e,R),(W=e._zod.def).when??(W.when=e=>{let R=e.value;return!q(R)&&R.length!==void 0}),e._zod.onattach.push((e=>{let W=e._zod.bag;W.minimum=R.length,W.maximum=R.length,W.length=R.length})),e._zod.check=W=>{let Y=W.value,X=Y.length;if(X===R.length)return;let ie=Ie(Y),ae=X>R.length;W.issues.push({origin:ie,...ae?{code:`too_big`,maximum:R.length}:{code:`too_small`,minimum:R.length},inclusive:!0,exact:!0,input:W.value,inst:e,continue:!R.abort})}})),_g=N(`$ZodCheckStringFormat`,((e,R)=>{var W,Y;rg.init(e,R),e._zod.onattach.push((e=>{let W=e._zod.bag;W.format=R.format,R.pattern&&(W.patterns??=new Set,W.patterns.add(R.pattern))})),R.pattern?(W=e._zod).check??(W.check=W=>{R.pattern.lastIndex=0,R.pattern.test(W.value)||W.issues.push({origin:`string`,code:`invalid_format`,format:R.format,input:W.value,...R.pattern?{pattern:R.pattern.toString()}:{},inst:e,continue:!R.abort})}):(Y=e._zod).check??(Y.check=()=>{})})),vg=N(`$ZodCheckRegex`,((e,R)=>{_g.init(e,R),e._zod.check=W=>{R.pattern.lastIndex=0,R.pattern.test(W.value)||W.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:W.value,pattern:R.pattern.toString(),inst:e,continue:!R.abort})}})),yg=N(`$ZodCheckLowerCase`,((e,R)=>{R.pattern??=Rh,_g.init(e,R)})),bg=N(`$ZodCheckUpperCase`,((e,R)=>{R.pattern??=zh,_g.init(e,R)})),xg=N(`$ZodCheckIncludes`,((e,R)=>{rg.init(e,R);let W=ne(R.includes),Y=new RegExp(typeof R.position==`number`?`^.{${R.position}}${W}`:W);R.pattern=Y,e._zod.onattach.push((e=>{let R=e._zod.bag;R.patterns??=new Set,R.patterns.add(Y)})),e._zod.check=W=>{W.value.includes(R.includes,R.position)||W.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:R.includes,input:W.value,inst:e,continue:!R.abort})}})),Sg=N(`$ZodCheckStartsWith`,((e,R)=>{rg.init(e,R);let W=RegExp(`^${ne(R.prefix)}.*`);R.pattern??=W,e._zod.onattach.push((e=>{let R=e._zod.bag;R.patterns??=new Set,R.patterns.add(W)})),e._zod.check=W=>{W.value.startsWith(R.prefix)||W.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:R.prefix,input:W.value,inst:e,continue:!R.abort})}})),Cg=N(`$ZodCheckEndsWith`,((e,R)=>{rg.init(e,R);let W=RegExp(`.*${ne(R.suffix)}$`);R.pattern??=W,e._zod.onattach.push((e=>{let R=e._zod.bag;R.patterns??=new Set,R.patterns.add(W)})),e._zod.check=W=>{W.value.endsWith(R.suffix)||W.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:R.suffix,input:W.value,inst:e,continue:!R.abort})}}));function gA(e,R,W){e.issues.length&&R.issues.push(...ge(W,e.issues))}const wg=N(`$ZodCheckProperty`,((e,R)=>{rg.init(e,R),e._zod.check=e=>{let W=R.schema._zod.run({value:e.value[R.property],issues:[]},{});if(W instanceof Promise)return W.then((W=>gA(W,e,R.property)));gA(W,e,R.property)}})),Tg=N(`$ZodCheckMimeType`,((e,R)=>{rg.init(e,R);let W=new Set(R.mime);e._zod.onattach.push((e=>{e._zod.bag.mime=R.mime})),e._zod.check=Y=>{W.has(Y.value.type)||Y.issues.push({code:`invalid_value`,values:R.mime,input:Y.value.type,inst:e,continue:!R.abort})}})),Eg=N(`$ZodCheckOverwrite`,((e,R)=>{rg.init(e,R),e._zod.check=e=>{e.value=R.tx(e.value)}}));var IA=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`)return e(this,{execution:`sync`}),void e(this,{execution:`async`});let R=e.split(`
|
|
1104
1104
|
`).filter((e=>e)),W=Math.min(...R.map((e=>e.length-e.trimStart().length))),Y=R.map((e=>e.slice(W))).map((e=>` `.repeat(2*this.indent)+e));for(let e of Y)this.content.push(e)}compile(){let e=Function,R=this?.args;return new e(...R,[...(this?.content??[``]).map((e=>` ${e}`))].join(`
|
|
1105
|
-
`))}};const Dg={major:4,minor:2,patch:1},Og=N(`$ZodType`,((e,R)=>{var W;e??={},e._zod.def=R,e._zod.bag=e._zod.bag||{},e._zod.version=Dg;let Y=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&Y.unshift(e);for(let R of Y)for(let W of R._zod.onattach)W(e);if(Y.length===0)(W=e._zod).deferred??(W.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{let t=(e,R,W)=>{let Y,X=ce(e);for(let ie of R){if(ie._zod.def.when){if(!ie._zod.def.when(e))continue}else if(X)continue;let R=e.issues.length,ae=ie._zod.check(e);if(ae instanceof Promise&&!1===W?.async)throw new G;if(Y||ae instanceof Promise)Y=(Y??Promise.resolve()).then((async()=>{await ae,e.issues.length!==R&&(X||=ce(e,R))}));else{if(e.issues.length===R)continue;X||=ce(e,R)}}return Y?Y.then((()=>e)):e},A=(R,W,X)=>{if(ce(R))return R.aborted=!0,R;let ie=t(W,Y,X);if(ie instanceof Promise){if(!1===X.async)throw new G;return ie.then((R=>e._zod.parse(R,X)))}return e._zod.parse(ie,X)};e._zod.run=(R,W)=>{if(W.skipChecks)return e._zod.parse(R,W);if(W.direction===`backward`){let Y=e._zod.parse({value:R.value,issues:[]},{...W,skipChecks:!0});return Y instanceof Promise?Y.then((e=>A(e,R,W))):A(Y,R,W)}let X=e._zod.parse(R,W);if(X instanceof Promise){if(!1===W.async)throw new G;return X.then((e=>t(e,Y,W)))}return t(X,Y,W)}}e[`~standard`]={validate:R=>{try{let W=eh(e,R);return W.success?{value:W.data}:{issues:W.error?.issues}}catch{return th(e,R).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:`zod`,version:1}})),kg=N(`$ZodString`,((e,R)=>{Og.init(e,R),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Bt(e._zod.bag),e._zod.parse=(W,Y)=>{if(R.coerce)try{W.value=String(W.value)}catch{}return typeof W.value==`string`||W.issues.push({expected:`string`,code:`invalid_type`,input:W.value,inst:e}),W}})),jg=N(`$ZodStringFormat`,((e,R)=>{_g.init(e,R),kg.init(e,R)})),Mg=N(`$ZodGUID`,((e,R)=>{R.pattern??=uh,jg.init(e,R)})),Ng=N(`$ZodUUID`,((e,R)=>{if(R.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[R.version];if(e===void 0)throw Error(`Invalid UUID version: "${R.version}"`);R.pattern??=je(e)}else R.pattern??=je();jg.init(e,R)})),Pg=N(`$ZodEmail`,((e,R)=>{R.pattern??=mh,jg.init(e,R)})),Fg=N(`$ZodURL`,((e,R)=>{jg.init(e,R),e._zod.check=W=>{try{let Y=W.value.trim(),X=new URL(Y);R.hostname&&(R.hostname.lastIndex=0,R.hostname.test(X.hostname)||W.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:R.hostname.source,input:W.value,inst:e,continue:!R.abort})),R.protocol&&(R.protocol.lastIndex=0,R.protocol.test(X.protocol.endsWith(`:`)?X.protocol.slice(0,-1):X.protocol)||W.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:R.protocol.source,input:W.value,inst:e,continue:!R.abort})),R.normalize?W.value=X.href:W.value=Y;return}catch{W.issues.push({code:`invalid_format`,format:`url`,input:W.value,inst:e,continue:!R.abort})}}})),Ig=N(`$ZodEmoji`,((e,R)=>{R.pattern??=At(),jg.init(e,R)})),Lg=N(`$ZodNanoID`,((e,R)=>{R.pattern??=sh,jg.init(e,R)})),Rg=N(`$ZodCUID`,((e,R)=>{R.pattern??=nh,jg.init(e,R)})),zg=N(`$ZodCUID2`,((e,R)=>{R.pattern??=rh,jg.init(e,R)})),Bg=N(`$ZodULID`,((e,R)=>{R.pattern??=ih,jg.init(e,R)})),Vg=N(`$ZodXID`,((e,R)=>{R.pattern??=ah,jg.init(e,R)})),Hg=N(`$ZodKSUID`,((e,R)=>{R.pattern??=oh,jg.init(e,R)})),Ug=N(`$ZodISODateTime`,((e,R)=>{R.pattern??=ft(R),jg.init(e,R)})),Wg=N(`$ZodISODate`,((e,R)=>{R.pattern??=jh,jg.init(e,R)})),Gg=N(`$ZodISOTime`,((e,R)=>{R.pattern??=pt(R),jg.init(e,R)})),Kg=N(`$ZodISODuration`,((e,R)=>{R.pattern??=ch,jg.init(e,R)})),qg=N(`$ZodIPv4`,((e,R)=>{R.pattern??=xh,jg.init(e,R),e._zod.bag.format=`ipv4`})),Jg=N(`$ZodIPv6`,((e,R)=>{R.pattern??=Sh,jg.init(e,R),e._zod.bag.format=`ipv6`,e._zod.check=W=>{try{new URL(`http://[${W.value}]`)}catch{W.issues.push({code:`invalid_format`,format:`ipv6`,input:W.value,inst:e,continue:!R.abort})}}})),Yg=N(`$ZodMAC`,((e,R)=>{R.pattern??=ot(R.delimiter),jg.init(e,R),e._zod.bag.format=`mac`})),Xg=N(`$ZodCIDRv4`,((e,R)=>{R.pattern??=Ch,jg.init(e,R)})),Zg=N(`$ZodCIDRv6`,((e,R)=>{R.pattern??=wh,jg.init(e,R),e._zod.check=W=>{let Y=W.value.split(`/`);try{if(Y.length!==2)throw Error();let[e,R]=Y;if(!R)throw Error();let W=Number(R);if(`${W}`!==R||W<0||W>128)throw Error();new URL(`http://[${e}]`)}catch{W.issues.push({code:`invalid_format`,format:`cidrv6`,input:W.value,inst:e,continue:!R.abort})}}}));function OA(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Qg=N(`$ZodBase64`,((e,R)=>{R.pattern??=Th,jg.init(e,R),e._zod.bag.contentEncoding=`base64`,e._zod.check=W=>{OA(W.value)||W.issues.push({code:`invalid_format`,format:`base64`,input:W.value,inst:e,continue:!R.abort})}})),$g=N(`$ZodBase64URL`,((e,R)=>{R.pattern??=Eh,jg.init(e,R),e._zod.bag.contentEncoding=`base64url`,e._zod.check=W=>{(function(e){if(!Eh.test(e))return!1;let R=e.replace(/[-_]/g,(e=>e===`-`?`+`:`/`));return OA(R.padEnd(4*Math.ceil(R.length/4),`=`))})(W.value)||W.issues.push({code:`invalid_format`,format:`base64url`,input:W.value,inst:e,continue:!R.abort})}})),e_=N(`$ZodE164`,((e,R)=>{R.pattern??=kh,jg.init(e,R)})),t_=N(`$ZodJWT`,((e,R)=>{jg.init(e,R),e._zod.check=W=>{(function(e,R=null){try{let W=e.split(`.`);if(W.length!==3)return!1;let[Y]=W;if(!Y)return!1;let X=JSON.parse(atob(Y));return!(`typ`in X&&X?.typ!==`JWT`||!X.alg||R&&(!(`alg`in X)||X.alg!==R))}catch{return!1}})(W.value,R.alg)||W.issues.push({code:`invalid_format`,format:`jwt`,input:W.value,inst:e,continue:!R.abort})}})),n_=N(`$ZodCustomStringFormat`,((e,R)=>{jg.init(e,R),e._zod.check=W=>{R.fn(W.value)||W.issues.push({code:`invalid_format`,format:R.format,input:W.value,inst:e,continue:!R.abort})}})),r_=N(`$ZodNumber`,((e,R)=>{Og.init(e,R),e._zod.pattern=e._zod.bag.pattern??Ph,e._zod.parse=(W,Y)=>{if(R.coerce)try{W.value=Number(W.value)}catch{}let X=W.value;if(typeof X==`number`&&!Number.isNaN(X)&&Number.isFinite(X))return W;let ie=typeof X==`number`?Number.isNaN(X)?`NaN`:Number.isFinite(X)?void 0:`Infinity`:void 0;return W.issues.push({expected:`number`,code:`invalid_type`,input:X,inst:e,...ie?{received:ie}:{}}),W}})),i_=N(`$ZodNumberFormat`,((e,R)=>{lg.init(e,R),r_.init(e,R)})),a_=N(`$ZodBoolean`,((e,R)=>{Og.init(e,R),e._zod.pattern=Fh,e._zod.parse=(W,Y)=>{if(R.coerce)try{W.value=!!W.value}catch{}let X=W.value;return typeof X==`boolean`||W.issues.push({expected:`boolean`,code:`invalid_type`,input:X,inst:e}),W}})),o_=N(`$ZodBigInt`,((e,R)=>{Og.init(e,R),e._zod.pattern=Mh,e._zod.parse=(W,Y)=>{if(R.coerce)try{W.value=BigInt(W.value)}catch{}return typeof W.value==`bigint`||W.issues.push({expected:`bigint`,code:`invalid_type`,input:W.value,inst:e}),W}})),s_=N(`$ZodBigIntFormat`,((e,R)=>{ug.init(e,R),o_.init(e,R)})),c_=N(`$ZodSymbol`,((e,R)=>{Og.init(e,R),e._zod.parse=(R,W)=>{let Y=R.value;return typeof Y==`symbol`||R.issues.push({expected:`symbol`,code:`invalid_type`,input:Y,inst:e}),R}})),l_=N(`$ZodUndefined`,((e,R)=>{Og.init(e,R),e._zod.pattern=Lh,e._zod.values=new Set([void 0]),e._zod.optin=`optional`,e._zod.optout=`optional`,e._zod.parse=(R,W)=>{let Y=R.value;return Y===void 0||R.issues.push({expected:`undefined`,code:`invalid_type`,input:Y,inst:e}),R}})),u_=N(`$ZodNull`,((e,R)=>{Og.init(e,R),e._zod.pattern=Ih,e._zod.values=new Set([null]),e._zod.parse=(R,W)=>{let Y=R.value;return Y===null||R.issues.push({expected:`null`,code:`invalid_type`,input:Y,inst:e}),R}})),d_=N(`$ZodAny`,((e,R)=>{Og.init(e,R),e._zod.parse=e=>e})),f_=N(`$ZodUnknown`,((e,R)=>{Og.init(e,R),e._zod.parse=e=>e})),p_=N(`$ZodNever`,((e,R)=>{Og.init(e,R),e._zod.parse=(R,W)=>(R.issues.push({expected:`never`,code:`invalid_type`,input:R.value,inst:e}),R)})),m_=N(`$ZodVoid`,((e,R)=>{Og.init(e,R),e._zod.parse=(R,W)=>{let Y=R.value;return Y===void 0||R.issues.push({expected:`void`,code:`invalid_type`,input:Y,inst:e}),R}})),h_=N(`$ZodDate`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{if(R.coerce)try{W.value=new Date(W.value)}catch{}let X=W.value,ie=X instanceof Date;return ie&&!Number.isNaN(X.getTime())||W.issues.push({expected:`date`,code:`invalid_type`,input:X,...ie?{received:`Invalid Date`}:{},inst:e}),W}}));function oi(e,R,W){e.issues.length&&R.issues.push(...ge(W,e.issues)),R.value[W]=e.value}const g_=N(`$ZodArray`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{let X=W.value;if(!Array.isArray(X))return W.issues.push({expected:`array`,code:`invalid_type`,input:X,inst:e}),W;W.value=Array(X.length);let ie=[];for(let e=0;e<X.length;e++){let ae=X[e],le=R.element._zod.run({value:ae,issues:[]},Y);le instanceof Promise?ie.push(le.then((R=>oi(R,W,e)))):oi(le,W,e)}return ie.length?Promise.all(ie).then((()=>W)):W}}));function ri(e,R,W,Y){e.issues.length&&R.issues.push(...ge(W,e.issues)),e.value===void 0?W in Y&&(R.value[W]=void 0):R.value[W]=e.value}function ai(e){let R=Object.keys(e.shape);for(let W of R)if(!e.shape?.[W]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${W}": expected a Zod schema`);let W=(Y=e.shape,Object.keys(Y).filter((e=>Y[e]._zod.optin===`optional`&&Y[e]._zod.optout===`optional`)));var Y;return{...e,keys:R,keySet:new Set(R),numKeys:R.length,optionalKeys:new Set(W)}}function li(e,R,W,Y,X,ie){let ae=[],le=X.keySet,_e=X.catchall._zod,ye=_e.def.type;for(let X in R){if(le.has(X))continue;if(ye===`never`){ae.push(X);continue}let ie=_e.run({value:R[X],issues:[]},Y);ie instanceof Promise?e.push(ie.then((e=>ri(e,W,X,R)))):ri(ie,W,X,R)}return ae.length&&W.issues.push({code:`unrecognized_keys`,keys:ae,input:R,inst:ie}),e.length?Promise.all(e).then((()=>W)):W}const __=N(`$ZodObject`,((e,R)=>{if(Og.init(e,R),!Object.getOwnPropertyDescriptor(R,`shape`)?.get){let e=R.shape;Object.defineProperty(R,"shape",{get:()=>{let W={...e};return Object.defineProperty(R,"shape",{value:W}),W}})}let W=Z((()=>ai(R)));H(e._zod,`propValues`,(()=>{let e=R.shape,W={};for(let R in e){let Y=e[R]._zod;if(Y.values){W[R]??(W[R]=new Set);for(let e of Y.values)W[R].add(e)}}return W}));let Y=V,X=R.catchall,ie;e._zod.parse=(R,ae)=>{ie??=W.value;let le=R.value;if(!Y(le))return R.issues.push({expected:`object`,code:`invalid_type`,input:le,inst:e}),R;R.value={};let _e=[],ye=ie.shape;for(let e of ie.keys){let W=ye[e]._zod.run({value:le[e],issues:[]},ae);W instanceof Promise?_e.push(W.then((W=>ri(W,R,e,le)))):ri(W,R,e,le)}return X?li(_e,le,R,ae,W.value,e):_e.length?Promise.all(_e).then((()=>R)):R}})),v_=N(`$ZodObjectJIT`,((e,R)=>{__.init(e,R);let W=e._zod.parse,Y=Z((()=>ai(R))),X,ie=V,ae=!Hm.jitless,le=ae&&Gm.value,_e=R.catchall,ye;e._zod.parse=(be,Ce)=>{ye??=Y.value;let Te=be.value;return ie(Te)?ae&&le&&!1===Ce?.async&&!0!==Ce.jitless?(X||=(e=>{let R=new IA([`shape`,`payload`,`ctx`]),W=Y.value,n=e=>{let R=K(e);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};R.write(`const input = payload.value;`);let X=Object.create(null),ie=0;for(let e of W.keys)X[e]=`key_`+ ie++;R.write(`const newResult = {};`);for(let e of W.keys){let W=X[e],Y=K(e);R.write(`const ${W} = ${n(e)};`),R.write(`\n if (${W}.issues.length) {\n payload.issues = payload.issues.concat(${W}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${Y}, ...iss.path] : [${Y}]\n })));\n }\n \n \n if (${W}.value === undefined) {\n if (${Y} in input) {\n newResult[${Y}] = undefined;\n }\n } else {\n newResult[${Y}] = ${W}.value;\n }\n \n `)}R.write(`payload.value = newResult;`),R.write(`return payload;`);let ae=R.compile();return(R,W)=>ae(e,R,W)})(R.shape),be=X(be,Ce),_e?li([],Te,be,Ce,ye,e):be):W(be,Ce):(be.issues.push({expected:`object`,code:`invalid_type`,input:Te,inst:e}),be)}}));function di(e,R,W,Y){for(let W of e)if(W.issues.length===0)return R.value=W.value,R;let X=e.filter((e=>!ce(e)));return X.length===1?(R.value=X[0].value,X[0]):(R.issues.push({code:`invalid_union`,input:R.value,inst:W,errors:e.map((e=>e.issues.map((e=>he(e,Y,M())))))}),R)}const y_=N(`$ZodUnion`,((e,R)=>{Og.init(e,R),H(e._zod,`optin`,(()=>R.options.some((e=>e._zod.optin===`optional`))?`optional`:void 0)),H(e._zod,`optout`,(()=>R.options.some((e=>e._zod.optout===`optional`))?`optional`:void 0)),H(e._zod,`values`,(()=>{if(R.options.every((e=>e._zod.values)))return new Set(R.options.flatMap((e=>Array.from(e._zod.values))))})),H(e._zod,`pattern`,(()=>{if(R.options.every((e=>e._zod.pattern))){let e=R.options.map((e=>e._zod.pattern));return RegExp(`^(${e.map((e=>j(e.source))).join(`|`)})$`)}}));let W=R.options.length===1,Y=R.options[0]._zod.run;e._zod.parse=(X,ie)=>{if(W)return Y(X,ie);let ae=!1,le=[];for(let e of R.options){let R=e._zod.run({value:X.value,issues:[]},ie);if(R instanceof Promise)le.push(R),ae=!0;else{if(R.issues.length===0)return R;le.push(R)}}return ae?Promise.all(le).then((R=>di(R,X,e,ie))):di(le,X,e,ie)}}));function ui(e,R,W,Y){let X=e.filter((e=>e.issues.length===0));return X.length===1?(R.value=X[0].value,R):(X.length===0?R.issues.push({code:`invalid_union`,input:R.value,inst:W,errors:e.map((e=>e.issues.map((e=>he(e,Y,M())))))}):R.issues.push({code:`invalid_union`,input:R.value,inst:W,errors:[],inclusive:!1}),R)}const b_=N(`$ZodXor`,((e,R)=>{y_.init(e,R),R.inclusive=!1;let W=R.options.length===1,Y=R.options[0]._zod.run;e._zod.parse=(X,ie)=>{if(W)return Y(X,ie);let ae=!1,le=[];for(let e of R.options){let R=e._zod.run({value:X.value,issues:[]},ie);R instanceof Promise?(le.push(R),ae=!0):le.push(R)}return ae?Promise.all(le).then((R=>ui(R,X,e,ie))):ui(le,X,e,ie)}})),x_=N(`$ZodDiscriminatedUnion`,((e,R)=>{R.inclusive=!1,y_.init(e,R);let W=e._zod.parse;H(e._zod,`propValues`,(()=>{let e={};for(let W of R.options){let Y=W._zod.propValues;if(!Y||Object.keys(Y).length===0)throw Error(`Invalid discriminated union option at index "${R.options.indexOf(W)}"`);for(let[R,W]of Object.entries(Y)){e[R]||(e[R]=new Set);for(let Y of W)e[R].add(Y)}}return e}));let Y=Z((()=>{let e=R.options,W=new Map;for(let Y of e){let e=Y._zod.propValues?.[R.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${R.options.indexOf(Y)}"`);for(let R of e){if(W.has(R))throw Error(`Duplicate discriminator value "${String(R)}"`);W.set(R,Y)}}return W}));e._zod.parse=(X,ie)=>{let ae=X.value;if(!V(ae))return X.issues.push({code:`invalid_type`,expected:`object`,input:ae,inst:e}),X;let le=Y.value.get(ae?.[R.discriminator]);return le?le._zod.run(X,ie):R.unionFallback?W(X,ie):(X.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:R.discriminator,input:ae,path:[R.discriminator],inst:e}),X)}})),S_=N(`$ZodIntersection`,((e,R)=>{Og.init(e,R),e._zod.parse=(e,W)=>{let Y=e.value,X=R.left._zod.run({value:Y,issues:[]},W),ie=R.right._zod.run({value:Y,issues:[]},W);return X instanceof Promise||ie instanceof Promise?Promise.all([X,ie]).then((([R,W])=>Ci(e,R,W))):Ci(e,X,ie)}}));function Bi(e,R){if(e===R||e instanceof Date&&R instanceof Date&&+e==+R)return{valid:!0,data:e};if(ee(e)&&ee(R)){let W=Object.keys(R),Y=Object.keys(e).filter((e=>W.indexOf(e)!==-1)),X={...e,...R};for(let W of Y){let Y=Bi(e[W],R[W]);if(!Y.valid)return{valid:!1,mergeErrorPath:[W,...Y.mergeErrorPath]};X[W]=Y.data}return{valid:!0,data:X}}if(Array.isArray(e)&&Array.isArray(R)){if(e.length!==R.length)return{valid:!1,mergeErrorPath:[]};let W=[];for(let Y=0;Y<e.length;Y++){let X=Bi(e[Y],R[Y]);if(!X.valid)return{valid:!1,mergeErrorPath:[Y,...X.mergeErrorPath]};W.push(X.data)}return{valid:!0,data:W}}return{valid:!1,mergeErrorPath:[]}}function Ci(e,R,W){if(R.issues.length&&e.issues.push(...R.issues),W.issues.length&&e.issues.push(...W.issues),ce(e))return e;let Y=Bi(R.value,W.value);if(!Y.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(Y.mergeErrorPath)}`);return e.value=Y.data,e}const C_=N(`$ZodTuple`,((e,R)=>{Og.init(e,R);let W=R.items;e._zod.parse=(Y,X)=>{let ie=Y.value;if(!Array.isArray(ie))return Y.issues.push({input:ie,inst:e,expected:`tuple`,code:`invalid_type`}),Y;Y.value=[];let ae=[],le=[...W].reverse().findIndex((e=>e._zod.optin!==`optional`)),_e=le===-1?0:W.length-le;if(!R.rest){let R=ie.length>W.length,X=ie.length<_e-1;if(R||X)return Y.issues.push({...R?{code:`too_big`,maximum:W.length}:{code:`too_small`,minimum:W.length},input:ie,inst:e,origin:`array`}),Y}let ye=-1;for(let e of W){if(ye++,ye>=ie.length&&ye>=_e)continue;let R=e._zod.run({value:ie[ye],issues:[]},X);R instanceof Promise?ae.push(R.then((e=>Qi(e,Y,ye)))):Qi(R,Y,ye)}if(R.rest){let e=ie.slice(W.length);for(let W of e){ye++;let e=R.rest._zod.run({value:W,issues:[]},X);e instanceof Promise?ae.push(e.then((e=>Qi(e,Y,ye)))):Qi(e,Y,ye)}}return ae.length?Promise.all(ae).then((()=>Y)):Y}}));function Qi(e,R,W){e.issues.length&&R.issues.push(...ge(W,e.issues)),R.value[W]=e.value}const w_=N(`$ZodRecord`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{let X=W.value;if(!ee(X))return W.issues.push({expected:`record`,code:`invalid_type`,input:X,inst:e}),W;let ie=[],ae=R.keyType._zod.values;if(ae){W.value={};let le=new Set;for(let e of ae)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){le.add(typeof e==`number`?e.toString():e);let ae=R.valueType._zod.run({value:X[e],issues:[]},Y);ae instanceof Promise?ie.push(ae.then((R=>{R.issues.length&&W.issues.push(...ge(e,R.issues)),W.value[e]=R.value}))):(ae.issues.length&&W.issues.push(...ge(e,ae.issues)),W.value[e]=ae.value)}let _e;for(let e in X)le.has(e)||(_e??=[],_e.push(e));_e&&_e.length>0&&W.issues.push({code:`unrecognized_keys`,input:X,inst:e,keys:_e})}else{W.value={};for(let ae of Reflect.ownKeys(X)){if(ae===`__proto__`)continue;let le=R.keyType._zod.run({value:ae,issues:[]},Y);if(le instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(le.issues.length){R.mode===`loose`?W.value[ae]=X[ae]:W.issues.push({code:`invalid_key`,origin:`record`,issues:le.issues.map((e=>he(e,Y,M()))),input:ae,path:[ae],inst:e});continue}let _e=R.valueType._zod.run({value:X[ae],issues:[]},Y);_e instanceof Promise?ie.push(_e.then((e=>{e.issues.length&&W.issues.push(...ge(ae,e.issues)),W.value[le.value]=e.value}))):(_e.issues.length&&W.issues.push(...ge(ae,_e.issues)),W.value[le.value]=_e.value)}}return ie.length?Promise.all(ie).then((()=>W)):W}})),T_=N(`$ZodMap`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{let X=W.value;if(!(X instanceof Map))return W.issues.push({expected:`map`,code:`invalid_type`,input:X,inst:e}),W;let ie=[];W.value=new Map;for(let[ae,le]of X){let _e=R.keyType._zod.run({value:ae,issues:[]},Y),ye=R.valueType._zod.run({value:le,issues:[]},Y);_e instanceof Promise||ye instanceof Promise?ie.push(Promise.all([_e,ye]).then((([R,ie])=>{wi(R,ie,W,ae,X,e,Y)}))):wi(_e,ye,W,ae,X,e,Y)}return ie.length?Promise.all(ie).then((()=>W)):W}}));function wi(e,R,W,Y,X,ie,ae){e.issues.length&&(Km.has(typeof Y)?W.issues.push(...ge(Y,e.issues)):W.issues.push({code:`invalid_key`,origin:`map`,input:X,inst:ie,issues:e.issues.map((e=>he(e,ae,M())))})),R.issues.length&&(Km.has(typeof Y)?W.issues.push(...ge(Y,R.issues)):W.issues.push({origin:`map`,code:`invalid_element`,input:X,inst:ie,key:Y,issues:R.issues.map((e=>he(e,ae,M())))})),W.value.set(e.value,R.value)}const E_=N(`$ZodSet`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{let X=W.value;if(!(X instanceof Set))return W.issues.push({input:X,inst:e,expected:`set`,code:`invalid_type`}),W;let ie=[];W.value=new Set;for(let e of X){let X=R.valueType._zod.run({value:e,issues:[]},Y);X instanceof Promise?ie.push(X.then((e=>vi(e,W)))):vi(X,W)}return ie.length?Promise.all(ie).then((()=>W)):W}}));function vi(e,R){e.issues.length&&R.issues.push(...e.issues),R.value.add(e.value)}const D_=N(`$ZodEnum`,((e,R)=>{Og.init(e,R);let W=O(R.entries),Y=new Set(W);e._zod.values=Y,e._zod.pattern=RegExp(`^(${W.filter((e=>Km.has(typeof e))).map((e=>typeof e==`string`?ne(e):e.toString())).join(`|`)})$`),e._zod.parse=(R,X)=>{let ie=R.value;return Y.has(ie)||R.issues.push({code:`invalid_value`,values:W,input:ie,inst:e}),R}})),O_=N(`$ZodLiteral`,((e,R)=>{if(Og.init(e,R),R.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let W=new Set(R.values);e._zod.values=W,e._zod.pattern=RegExp(`^(${R.values.map((e=>typeof e==`string`?ne(e):e?ne(e.toString()):String(e))).join(`|`)})$`),e._zod.parse=(Y,X)=>{let ie=Y.value;return W.has(ie)||Y.issues.push({code:`invalid_value`,values:R.values,input:ie,inst:e}),Y}})),k_=N(`$ZodFile`,((e,R)=>{Og.init(e,R),e._zod.parse=(R,W)=>{let Y=R.value;return Y instanceof File||R.issues.push({expected:`file`,code:`invalid_type`,input:Y,inst:e}),R}})),A_=N(`$ZodTransform`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{if(Y.direction===`backward`)throw new T(e.constructor.name);let X=R.transform(W.value,W);if(Y.async)return(X instanceof Promise?X:Promise.resolve(X)).then((e=>(W.value=e,W)));if(X instanceof Promise)throw new G;return W.value=X,W}}));function xi(e,R){return e.issues.length&&R===void 0?{issues:[],value:void 0}:e}const j_=N(`$ZodOptional`,((e,R)=>{Og.init(e,R),e._zod.optin=`optional`,e._zod.optout=`optional`,H(e._zod,`values`,(()=>R.innerType._zod.values?new Set([...R.innerType._zod.values,void 0]):void 0)),H(e._zod,`pattern`,(()=>{let e=R.innerType._zod.pattern;return e?RegExp(`^(${j(e.source)})?$`):void 0})),e._zod.parse=(e,W)=>{if(R.innerType._zod.optin===`optional`){let Y=R.innerType._zod.run(e,W);return Y instanceof Promise?Y.then((R=>xi(R,e.value))):xi(Y,e.value)}return e.value===void 0?e:R.innerType._zod.run(e,W)}})),M_=N(`$ZodNullable`,((e,R)=>{Og.init(e,R),H(e._zod,`optin`,(()=>R.innerType._zod.optin)),H(e._zod,`optout`,(()=>R.innerType._zod.optout)),H(e._zod,`pattern`,(()=>{let e=R.innerType._zod.pattern;return e?RegExp(`^(${j(e.source)}|null)$`):void 0})),H(e._zod,`values`,(()=>R.innerType._zod.values?new Set([...R.innerType._zod.values,null]):void 0)),e._zod.parse=(e,W)=>e.value===null?e:R.innerType._zod.run(e,W)})),N_=N(`$ZodDefault`,((e,R)=>{Og.init(e,R),e._zod.optin=`optional`,H(e._zod,`values`,(()=>R.innerType._zod.values)),e._zod.parse=(e,W)=>{if(W.direction===`backward`)return R.innerType._zod.run(e,W);if(e.value===void 0)return e.value=R.defaultValue,e;let Y=R.innerType._zod.run(e,W);return Y instanceof Promise?Y.then((e=>Ni(e,R))):Ni(Y,R)}}));function Ni(e,R){return e.value===void 0&&(e.value=R.defaultValue),e}const P_=N(`$ZodPrefault`,((e,R)=>{Og.init(e,R),e._zod.optin=`optional`,H(e._zod,`values`,(()=>R.innerType._zod.values)),e._zod.parse=(e,W)=>(W.direction===`backward`||e.value===void 0&&(e.value=R.defaultValue),R.innerType._zod.run(e,W))})),F_=N(`$ZodNonOptional`,((e,R)=>{Og.init(e,R),H(e._zod,`values`,(()=>{let e=R.innerType._zod.values;return e?new Set([...e].filter((e=>e!==void 0))):void 0})),e._zod.parse=(W,Y)=>{let X=R.innerType._zod.run(W,Y);return X instanceof Promise?X.then((R=>Ri(R,e))):Ri(X,e)}}));function Ri(e,R){return e.issues.length||e.value!==void 0||e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:R}),e}const I_=N(`$ZodSuccess`,((e,R)=>{Og.init(e,R),e._zod.parse=(e,W)=>{if(W.direction===`backward`)throw new T(`ZodSuccess`);let Y=R.innerType._zod.run(e,W);return Y instanceof Promise?Y.then((R=>(e.value=R.issues.length===0,e))):(e.value=Y.issues.length===0,e)}})),L_=N(`$ZodCatch`,((e,R)=>{Og.init(e,R),H(e._zod,`optin`,(()=>R.innerType._zod.optin)),H(e._zod,`optout`,(()=>R.innerType._zod.optout)),H(e._zod,`values`,(()=>R.innerType._zod.values)),e._zod.parse=(e,W)=>{if(W.direction===`backward`)return R.innerType._zod.run(e,W);let Y=R.innerType._zod.run(e,W);return Y instanceof Promise?Y.then((Y=>(e.value=Y.value,Y.issues.length&&(e.value=R.catchValue({...e,error:{issues:Y.issues.map((e=>he(e,W,M())))},input:e.value}),e.issues=[]),e))):(e.value=Y.value,Y.issues.length&&(e.value=R.catchValue({...e,error:{issues:Y.issues.map((e=>he(e,W,M())))},input:e.value}),e.issues=[]),e)}})),R_=N(`$ZodNaN`,((e,R)=>{Og.init(e,R),e._zod.parse=(R,W)=>(typeof R.value==`number`&&Number.isNaN(R.value)||R.issues.push({input:R.value,inst:e,expected:`nan`,code:`invalid_type`}),R)})),z_=N(`$ZodPipe`,((e,R)=>{Og.init(e,R),H(e._zod,`values`,(()=>R.in._zod.values)),H(e._zod,`optin`,(()=>R.in._zod.optin)),H(e._zod,`optout`,(()=>R.out._zod.optout)),H(e._zod,`propValues`,(()=>R.in._zod.propValues)),e._zod.parse=(e,W)=>{if(W.direction===`backward`){let Y=R.out._zod.run(e,W);return Y instanceof Promise?Y.then((e=>Zi(e,R.in,W))):Zi(Y,R.in,W)}let Y=R.in._zod.run(e,W);return Y instanceof Promise?Y.then((e=>Zi(e,R.out,W))):Zi(Y,R.out,W)}}));function Zi(e,R,W){return e.issues.length?(e.aborted=!0,e):R._zod.run({value:e.value,issues:e.issues},W)}const B_=N(`$ZodCodec`,((e,R)=>{Og.init(e,R),H(e._zod,`values`,(()=>R.in._zod.values)),H(e._zod,`optin`,(()=>R.in._zod.optin)),H(e._zod,`optout`,(()=>R.out._zod.optout)),H(e._zod,`propValues`,(()=>R.in._zod.propValues)),e._zod.parse=(e,W)=>{if((W.direction||`forward`)===`forward`){let Y=R.in._zod.run(e,W);return Y instanceof Promise?Y.then((e=>ji(e,R,W))):ji(Y,R,W)}{let Y=R.out._zod.run(e,W);return Y instanceof Promise?Y.then((e=>ji(e,R,W))):ji(Y,R,W)}}}));function ji(e,R,W){if(e.issues.length)return e.aborted=!0,e;if((W.direction||`forward`)===`forward`){let Y=R.transform(e.value,e);return Y instanceof Promise?Y.then((Y=>Yi(e,Y,R.out,W))):Yi(e,Y,R.out,W)}{let Y=R.reverseTransform(e.value,e);return Y instanceof Promise?Y.then((Y=>Yi(e,Y,R.in,W))):Yi(e,Y,R.in,W)}}function Yi(e,R,W,Y){return e.issues.length?(e.aborted=!0,e):W._zod.run({value:R,issues:e.issues},Y)}const V_=N(`$ZodReadonly`,((e,R)=>{Og.init(e,R),H(e._zod,`propValues`,(()=>R.innerType._zod.propValues)),H(e._zod,`values`,(()=>R.innerType._zod.values)),H(e._zod,`optin`,(()=>R.innerType?._zod?.optin)),H(e._zod,`optout`,(()=>R.innerType?._zod?.optout)),e._zod.parse=(e,W)=>{if(W.direction===`backward`)return R.innerType._zod.run(e,W);let Y=R.innerType._zod.run(e,W);return Y instanceof Promise?Y.then(Pi):Pi(Y)}}));function Pi(e){return e.value=Object.freeze(e.value),e}const H_=N(`$ZodTemplateLiteral`,((e,R)=>{Og.init(e,R);let W=[];for(let e of R.parts)if(typeof e==`object`&&e){if(!e._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);let R=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!R)throw Error(`Invalid template literal part: ${e._zod.traits}`);let Y=+!!R.startsWith(`^`),X=R.endsWith(`$`)?R.length-1:R.length;W.push(R.slice(Y,X))}else{if(e!==null&&!qm.has(typeof e))throw Error(`Invalid template literal part: ${e}`);W.push(ne(`${e}`))}e._zod.pattern=RegExp(`^${W.join(``)}$`),e._zod.parse=(W,Y)=>typeof W.value==`string`?(e._zod.pattern.lastIndex=0,e._zod.pattern.test(W.value)||W.issues.push({input:W.value,inst:e,code:`invalid_format`,format:R.format??`template_literal`,pattern:e._zod.pattern.source}),W):(W.issues.push({input:W.value,inst:e,expected:`template_literal`,code:`invalid_type`}),W)})),U_=N(`$ZodFunction`,((e,R)=>(Og.init(e,R),e._def=R,e._zod.def=R,e.implement=R=>{if(typeof R!=`function`)throw Error(`implement() must be called with a function`);return function(...W){let Y=e._def.input?Qm(e._def.input,W):W,X=Reflect.apply(R,this,Y);return e._def.output?Qm(e._def.output,X):X}},e.implementAsync=R=>{if(typeof R!=`function`)throw Error(`implementAsync() must be called with a function`);return async function(...W){let Y=e._def.input?await $m(e._def.input,W):W,X=await Reflect.apply(R,this,Y);return e._def.output?await $m(e._def.output,X):X}},e._zod.parse=(R,W)=>typeof R.value==`function`?(R.value=e._def.output&&e._def.output._zod.def.type===`promise`?e.implementAsync(R.value):e.implement(R.value),R):(R.issues.push({code:`invalid_type`,expected:`function`,input:R.value,inst:e}),R),e.input=(...R)=>{let W=e.constructor;return Array.isArray(R[0])?new W({type:`function`,input:new C_({type:`tuple`,items:R[0],rest:R[1]}),output:e._def.output}):new W({type:`function`,input:R[0],output:e._def.output})},e.output=R=>new e.constructor({type:`function`,input:e._def.input,output:R}),e))),W_=N(`$ZodPromise`,((e,R)=>{Og.init(e,R),e._zod.parse=(e,W)=>Promise.resolve(e.value).then((e=>R.innerType._zod.run({value:e,issues:[]},W)))})),G_=N(`$ZodLazy`,((e,R)=>{Og.init(e,R),H(e._zod,`innerType`,(()=>R.getter())),H(e._zod,`pattern`,(()=>e._zod.innerType?._zod?.pattern)),H(e._zod,`propValues`,(()=>e._zod.innerType?._zod?.propValues)),H(e._zod,`optin`,(()=>e._zod.innerType?._zod?.optin??void 0)),H(e._zod,`optout`,(()=>e._zod.innerType?._zod?.optout??void 0)),e._zod.parse=(R,W)=>e._zod.innerType._zod.run(R,W)})),K_=N(`$ZodCustom`,((e,R)=>{rg.init(e,R),Og.init(e,R),e._zod.parse=(e,R)=>e,e._zod.check=W=>{let Y=W.value,X=R.fn(Y);if(X instanceof Promise)return X.then((R=>en(R,W,Y,e)));en(X,W,Y,e)}}));function en(e,R,W,Y){if(!e){let e={code:`custom`,input:W,inst:Y,path:[...Y._zod.def.path??[]],continue:!Y._zod.def.abort};Y._zod.def.params&&(e.params=Y._zod.def.params),R.issues.push(pe(e))}}const tn=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`}};function t(R){return e[R]??null}let R={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,jwt:`JWT`,template_literal:`input`};return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${e.expected}, received ${(e=>{let R=typeof e;switch(R){case`number`:return Number.isNaN(e)?`NaN`:`number`;case`object`:if(Array.isArray(e))return`array`;if(e===null)return`null`;if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}return R})(e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${re(e.values[0])}`:`Invalid option: expected one of ${U(e.values,`|`)}`;case`too_big`:{let R=e.inclusive?`<=`:`<`,W=t(e.origin);return W?`Too big: expected ${e.origin??`value`} to have ${R}${e.maximum.toString()} ${W.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${R}${e.maximum.toString()}`}case`too_small`:{let R=e.inclusive?`>=`:`>`,W=t(e.origin);return W?`Too small: expected ${e.origin} to have ${R}${e.minimum.toString()} ${W.unit}`:`Too small: expected ${e.origin} to be ${R}${e.minimum.toString()}`}case`invalid_format`:{let W=e;return W.format===`starts_with`?`Invalid string: must start with "${W.prefix}"`:W.format===`ends_with`?`Invalid string: must end with "${W.suffix}"`:W.format===`includes`?`Invalid string: must include "${W.includes}"`:W.format===`regex`?`Invalid string: must match pattern ${W.pattern}`:`Invalid ${R[W.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${U(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:default:return`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`}}};var q_,nn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...R){let W=R[0];if(this._map.set(e,W),W&&typeof W==`object`&&`id`in W){if(this._idmap.has(W.id))throw Error(`ID ${W.id} already exists in the registry`);this._idmap.set(W.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let R=this._map.get(e);return R&&typeof R==`object`&&`id`in R&&this._idmap.delete(R.id),this._map.delete(e),this}get(e){let R=e._zod.parent;if(R){let W={...this.get(R)??{}};delete W.id;let Y={...W,...this._map.get(e)};return Object.keys(Y).length?Y:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};(q_=globalThis).__zod_globalRegistry??(q_.__zod_globalRegistry=new nn);const J_=globalThis.__zod_globalRegistry;function sn(e,R){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...se(R)})}function rn(e,R){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...se(R)})}function an(e,R){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...se(R)})}function ln(e,R){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...se(R)})}function cn(e,R){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...se(R)})}function gn(e,R){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...se(R)})}function dn(e,R){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...se(R)})}function hn(e,R){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...se(R)})}function un(e,R){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...se(R)})}function In(e,R){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...se(R)})}function pn(e,R){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...se(R)})}function fn(e,R){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...se(R)})}function Bn(e,R){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...se(R)})}function Cn(e,R){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...se(R)})}function En(e,R){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...se(R)})}function Qn(e,R){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...se(R)})}function mn(e,R){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...se(R)})}function yn(e,R){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...se(R)})}function wn(e,R){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...se(R)})}function _n(e,R){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...se(R)})}function vn(e,R){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...se(R)})}function bn(e,R){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...se(R)})}function kn(e,R){return new og({check:`less_than`,...se(R),value:e,inclusive:!1})}function Dn(e,R){return new og({check:`less_than`,...se(R),value:e,inclusive:!0})}function Sn(e,R){return new sg({check:`greater_than`,...se(R),value:e,inclusive:!1})}function xn(e,R){return new sg({check:`greater_than`,...se(R),value:e,inclusive:!0})}function zn(e){return Sn(0,e)}function Fn(e){return kn(0,e)}function Ln(e){return Dn(0,e)}function Nn(e){return xn(0,e)}function Gn(e,R){return new cg({check:`multiple_of`,...se(R),value:e})}function Tn(e,R){return new dg({check:`max_size`,...se(R),maximum:e})}function Rn(e,R){return new fg({check:`min_size`,...se(R),minimum:e})}function Mn(e,R){return new pg({check:`size_equals`,...se(R),size:e})}function On(e,R){return new mg({check:`max_length`,...se(R),maximum:e})}function Un(e,R){return new hg({check:`min_length`,...se(R),minimum:e})}function Jn(e,R){return new gg({check:`length_equals`,...se(R),length:e})}function Zn(e,R){return new vg({check:`string_format`,format:`regex`,...se(R),pattern:e})}function qn(e){return new yg({check:`string_format`,format:`lowercase`,...se(e)})}function jn(e){return new bg({check:`string_format`,format:`uppercase`,...se(e)})}function Yn(e,R){return new xg({check:`string_format`,format:`includes`,...se(R),includes:e})}function Hn(e,R){return new Sg({check:`string_format`,format:`starts_with`,...se(R),prefix:e})}function Pn(e,R){return new Cg({check:`string_format`,format:`ends_with`,...se(R),suffix:e})}function $n(e,R,W){return new wg({check:`property`,property:e,schema:R,...se(W)})}function Kn(e,R){return new Tg({check:`mime_type`,mime:e,...se(R)})}function Wn(e){return new Eg({check:`overwrite`,tx:e})}function Vn(e){return Wn((R=>R.normalize(e)))}function Xn(){return Wn((e=>e.trim()))}function eo(){return Wn((e=>e.toLowerCase()))}function to(){return Wn((e=>e.toUpperCase()))}function Ao(){return Wn((e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}(e)))}function io(e){let R=function(e,R){let W=new rg({check:`custom`,...se(R)});return W._zod.check=e,W}((W=>(W.addIssue=e=>{if(typeof e==`string`)W.issues.push(pe(e,W.value,R._zod.def));else{let Y=e;Y.fatal&&(Y.continue=!1),Y.code??=`custom`,Y.input??=W.value,Y.inst??=R,Y.continue??=!R._zod.def.abort,W.issues.push(pe(Y))}},e(W.value,W))));return R}function no(e,R,W,Y={}){let X=se(Y),ie={...se(Y),check:`string_format`,type:`string`,format:R,fn:typeof W==`function`?W:e=>W.test(e),...X};return W instanceof RegExp&&(ie.pattern=W),new e(ie)}function oo(e){let R=e?.target??`draft-2020-12`;return R===`draft-4`&&(R=`draft-04`),R===`draft-7`&&(R=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??J_,target:R,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function so(e,R,W={path:[],schemaPath:[]}){var Y;let X=e._zod.def,ie=R.seen.get(e);if(ie)return ie.count++,W.schemaPath.includes(e)&&(ie.cycle=W.path),ie.schema;let ae={schema:{},count:1,cycle:void 0,path:W.path};R.seen.set(e,ae);let le=e._zod.toJSONSchema?.();if(le)ae.schema=le;else{let Y={...W,schemaPath:[...W.schemaPath,e],path:W.path},ie=e._zod.parent;if(ie)ae.ref=ie,so(ie,R,Y),R.seen.get(ie).isParent=!0;else if(e._zod.processJSONSchema)e._zod.processJSONSchema(R,ae.schema,Y);else{let W=ae.schema,ie=R.processors[X.type];if(!ie)throw Error(`[toJSONSchema]: Non-representable type encountered: ${X.type}`);ie(e,R,W,Y)}}let _e=R.metadataRegistry.get(e);return _e&&Object.assign(ae.schema,_e),R.io===`input`&&lo(e)&&(delete ae.schema.examples,delete ae.schema.default),R.io===`input`&&ae.schema._prefault&&((Y=ae.schema).default??(Y.default=ae.schema._prefault)),delete ae.schema._prefault,R.seen.get(e).schema}function ro(e,R){let W=e.seen.get(R);if(!W)throw Error(`Unprocessed schema. This is a bug in Zod.`);let i=R=>{if(R[1].schema.$ref)return;let Y=R[1],{ref:X,defId:ie}=(R=>{let Y=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let W=e.external.registry.get(R[0])?.id,X=e.external.uri??(e=>e);if(W)return{ref:X(W)};let ie=R[1].defId??R[1].schema.id??`schema`+ e.counter++;return R[1].defId=ie,{defId:ie,ref:`${X(`__shared`)}#/${Y}/${ie}`}}if(R[1]===W)return{ref:`#`};let X=`#/${Y}/`,ie=R[1].schema.id??`__schema`+ e.counter++;return{defId:ie,ref:X+ie}})(R);Y.def={...Y.schema},ie&&(Y.defId=ie);let ae=Y.schema;for(let e in ae)delete ae[e];ae.$ref=X};if(e.cycles===`throw`)for(let R of e.seen.entries()){let e=R[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let W of e.seen.entries()){let Y=W[1];if(R===W[0]){i(W);continue}if(e.external){let Y=e.external.registry.get(W[0])?.id;if(R!==W[0]&&Y){i(W);continue}}(e.metadataRegistry.get(W[0])?.id||Y.cycle||Y.count>1&&e.reused===`ref`)&&i(W)}}function ao(e,R){let W=e.seen.get(R);if(!W)throw Error(`Unprocessed schema. This is a bug in Zod.`);let i=R=>{let W=e.seen.get(R),Y=W.def??W.schema,X={...Y};if(W.ref===null)return;let ie=W.ref;if(W.ref=null,ie){i(ie);let R=e.seen.get(ie).schema;!R.$ref||e.target!==`draft-07`&&e.target!==`draft-04`&&e.target!==`openapi-3.0`?(Object.assign(Y,R),Object.assign(Y,X)):(Y.allOf=Y.allOf??[],Y.allOf.push(R))}W.isParent||e.override({zodSchema:R,jsonSchema:Y,path:W.path??[]})};for(let R of[...e.seen.entries()].reverse())i(R[0]);let Y={};if(e.target===`draft-2020-12`?Y.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?Y.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?Y.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let W=e.external.registry.get(R)?.id;if(!W)throw Error("Schema is missing an `id` property");Y.$id=e.external.uri(W)}Object.assign(Y,W.def??W.schema);let X=e.external?.defs??{};for(let R of e.seen.entries()){let e=R[1];e.def&&e.defId&&(X[e.defId]=e.def)}e.external||Object.keys(X).length>0&&(e.target===`draft-2020-12`?Y.$defs=X:Y.definitions=X);try{let e=JSON.parse(JSON.stringify(Y));return Object.defineProperty(e,"~standard",{value:{...R[`~standard`],jsonSchema:{input:co(R,`input`),output:co(R,`output`)}},enumerable:!1,writable:!1}),e}catch{throw Error(`Error converting schema to JSON.`)}}function lo(e,R){let W=R??{seen:new Set};if(W.seen.has(e))return!1;W.seen.add(e);let Y=e._zod.def;if(Y.type===`transform`)return!0;if(Y.type===`array`)return lo(Y.element,W);if(Y.type===`set`)return lo(Y.valueType,W);if(Y.type===`lazy`)return lo(Y.getter(),W);if(Y.type===`promise`||Y.type===`optional`||Y.type===`nonoptional`||Y.type===`nullable`||Y.type===`readonly`||Y.type===`default`||Y.type===`prefault`)return lo(Y.innerType,W);if(Y.type===`intersection`)return lo(Y.left,W)||lo(Y.right,W);if(Y.type===`record`||Y.type===`map`)return lo(Y.keyType,W)||lo(Y.valueType,W);if(Y.type===`pipe`)return lo(Y.in,W)||lo(Y.out,W);if(Y.type===`object`){for(let e in Y.shape)if(lo(Y.shape[e],W))return!0;return!1}if(Y.type===`union`){for(let e of Y.options)if(lo(e,W))return!0;return!1}if(Y.type===`tuple`){for(let e of Y.items)if(lo(e,W))return!0;return!(!Y.rest||!lo(Y.rest,W))}return!1}const co=(e,R)=>W=>{let{libraryOptions:Y,target:X}=W??{},ie=oo({...Y??{},target:X,io:R,processors:{}});return so(e,ie),ro(ie,e),ao(ie,e)},Y_={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ho=(e,R,W,Y)=>{let X=W;X.type=`string`;let{minimum:ie,maximum:ae,format:le,patterns:_e,contentEncoding:ye}=e._zod.bag;if(typeof ie==`number`&&(X.minLength=ie),typeof ae==`number`&&(X.maxLength=ae),le&&(X.format=Y_[le]??le,X.format===``&&delete X.format),ye&&(X.contentEncoding=ye),_e&&_e.size>0){let e=[..._e];e.length===1?X.pattern=e[0].source:e.length>1&&(X.allOf=[...e.map((e=>({...R.target===`draft-07`||R.target===`draft-04`||R.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source})))])}},uo=(e,R,W,Y)=>{let X=W,{minimum:ie,maximum:ae,format:le,multipleOf:_e,exclusiveMaximum:ye,exclusiveMinimum:be}=e._zod.bag;typeof le==`string`&&le.includes(`int`)?X.type=`integer`:X.type=`number`,typeof be==`number`&&(R.target===`draft-04`||R.target===`openapi-3.0`?(X.minimum=be,X.exclusiveMinimum=!0):X.exclusiveMinimum=be),typeof ie==`number`&&(X.minimum=ie,typeof be==`number`&&R.target!==`draft-04`&&(be>=ie?delete X.minimum:delete X.exclusiveMinimum)),typeof ye==`number`&&(R.target===`draft-04`||R.target===`openapi-3.0`?(X.maximum=ye,X.exclusiveMaximum=!0):X.exclusiveMaximum=ye),typeof ae==`number`&&(X.maximum=ae,typeof ye==`number`&&R.target!==`draft-04`&&(ye<=ae?delete X.maximum:delete X.exclusiveMaximum)),typeof _e==`number`&&(X.multipleOf=_e)},Io=(e,R,W,Y)=>{W.type=`boolean`},po=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},fo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},Bo=(e,R,W,Y)=>{R.target===`openapi-3.0`?(W.type=`string`,W.nullable=!0,W.enum=[null]):W.type=`null`},Co=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},Eo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},Qo=(e,R,W,Y)=>{W.not={}},mo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},yo=(e,R,W,Y)=>{let X=O(e._zod.def.entries);X.every((e=>typeof e==`number`))&&(W.type=`number`),X.every((e=>typeof e==`string`))&&(W.type=`string`),W.enum=X},wo=(e,R,W,Y)=>{let X=e._zod.def,ie=[];for(let e of X.values)if(e===void 0){if(R.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(R.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);ie.push(Number(e))}else ie.push(e);if(ie.length!==0)if(ie.length===1){let e=ie[0];W.type=e===null?`null`:typeof e,R.target===`draft-04`||R.target===`openapi-3.0`?W.enum=[e]:W.const=e}else ie.every((e=>typeof e==`number`))&&(W.type=`number`),ie.every((e=>typeof e==`string`))&&(W.type=`string`),ie.every((e=>typeof e==`boolean`))&&(W.type=`boolean`),ie.every((e=>e===null))&&(W.type=`null`),W.enum=ie},_o=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},vo=(e,R,W,Y)=>{let X=W,ie=e._zod.pattern;if(!ie)throw Error(`Pattern not found in template literal`);X.type=`string`,X.pattern=ie.source},bo=(e,R,W,Y)=>{let X=W,ie={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:ae,maximum:le,mime:_e}=e._zod.bag;ae!==void 0&&(ie.minLength=ae),le!==void 0&&(ie.maxLength=le),_e?_e.length===1?(ie.contentMediaType=_e[0],Object.assign(X,ie)):X.anyOf=_e.map((e=>({...ie,contentMediaType:e}))):Object.assign(X,ie)},ko=(e,R,W,Y)=>{W.type=`boolean`},Do=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},So=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},xo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},zo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Fo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Lo=(e,R,W,Y)=>{let X=W,ie=e._zod.def,{minimum:ae,maximum:le}=e._zod.bag;typeof ae==`number`&&(X.minItems=ae),typeof le==`number`&&(X.maxItems=le),X.type=`array`,X.items=so(ie.element,R,{...Y,path:[...Y.path,`items`]})},No=(e,R,W,Y)=>{let X=W,ie=e._zod.def;X.type=`object`,X.properties={};let ae=ie.shape;for(let e in ae)X.properties[e]=so(ae[e],R,{...Y,path:[...Y.path,`properties`,e]});let le=new Set(Object.keys(ae)),_e=new Set([...le].filter((e=>{let W=ie.shape[e]._zod;return R.io===`input`?W.optin===void 0:W.optout===void 0})));_e.size>0&&(X.required=Array.from(_e)),ie.catchall?._zod.def.type===`never`?X.additionalProperties=!1:ie.catchall?ie.catchall&&(X.additionalProperties=so(ie.catchall,R,{...Y,path:[...Y.path,`additionalProperties`]})):R.io===`output`&&(X.additionalProperties=!1)},Go=(e,R,W,Y)=>{let X=e._zod.def,ie=!1===X.inclusive,ae=X.options.map(((e,W)=>so(e,R,{...Y,path:[...Y.path,ie?`oneOf`:`anyOf`,W]})));ie?W.oneOf=ae:W.anyOf=ae},To=(e,R,W,Y)=>{let X=e._zod.def,ie=so(X.left,R,{...Y,path:[...Y.path,`allOf`,0]}),ae=so(X.right,R,{...Y,path:[...Y.path,`allOf`,1]}),r=e=>`allOf`in e&&Object.keys(e).length===1;W.allOf=[...r(ie)?ie.allOf:[ie],...r(ae)?ae.allOf:[ae]]},Ro=(e,R,W,Y)=>{let X=W,ie=e._zod.def;X.type=`array`;let ae=R.target===`draft-2020-12`?`prefixItems`:`items`,le=R.target===`draft-2020-12`||R.target===`openapi-3.0`?`items`:`additionalItems`,_e=ie.items.map(((e,W)=>so(e,R,{...Y,path:[...Y.path,ae,W]}))),ye=ie.rest?so(ie.rest,R,{...Y,path:[...Y.path,le,...R.target===`openapi-3.0`?[ie.items.length]:[]]}):null;R.target===`draft-2020-12`?(X.prefixItems=_e,ye&&(X.items=ye)):R.target===`openapi-3.0`?(X.items={anyOf:_e},ye&&X.items.anyOf.push(ye),X.minItems=_e.length,ye||(X.maxItems=_e.length)):(X.items=_e,ye&&(X.additionalItems=ye));let{minimum:be,maximum:Ce}=e._zod.bag;typeof be==`number`&&(X.minItems=be),typeof Ce==`number`&&(X.maxItems=Ce)},Mo=(e,R,W,Y)=>{let X=W,ie=e._zod.def;X.type=`object`,R.target!==`draft-07`&&R.target!==`draft-2020-12`||(X.propertyNames=so(ie.keyType,R,{...Y,path:[...Y.path,`propertyNames`]})),X.additionalProperties=so(ie.valueType,R,{...Y,path:[...Y.path,`additionalProperties`]})},Oo=(e,R,W,Y)=>{let X=e._zod.def,ie=so(X.innerType,R,Y),ae=R.seen.get(e);R.target===`openapi-3.0`?(ae.ref=X.innerType,W.nullable=!0):W.anyOf=[ie,{type:`null`}]},Uo=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType},Jo=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType,W.default=JSON.parse(JSON.stringify(X.defaultValue))},Zo=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType,R.io===`input`&&(W._prefault=JSON.parse(JSON.stringify(X.defaultValue)))},qo=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y);let ie;R.seen.get(e).ref=X.innerType;try{ie=X.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}W.default=ie},jo=(e,R,W,Y)=>{let X=e._zod.def,ie=R.io===`input`?X.in._zod.def.type===`transform`?X.out:X.in:X.out;so(ie,R,Y),R.seen.get(e).ref=ie},Yo=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType,W.readOnly=!0},Ho=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType},Po=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType},$o=(e,R,W,Y)=>{let X=e._zod.innerType;so(X,R,Y),R.seen.get(e).ref=X},X_=N(`ZodISODateTime`,((e,R)=>{Ug.init(e,R),gv.init(e,R)}));function Wo(e){return function(e,R){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...se(R)})}(X_,e)}const Z_=N(`ZodISODate`,((e,R)=>{Wg.init(e,R),gv.init(e,R)}));function Xo(e){return function(e,R){return new e({type:`string`,format:`date`,check:`string_format`,...se(R)})}(Z_,e)}const Q_=N(`ZodISOTime`,((e,R)=>{Gg.init(e,R),gv.init(e,R)}));function ts(e){return function(e,R){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...se(R)})}(Q_,e)}const $_=N(`ZodISODuration`,((e,R)=>{Kg.init(e,R),gv.init(e,R)}));function is(e){return function(e,R){return new e({type:`string`,format:`duration`,check:`string_format`,...se(R)})}($_,e)}const ns=(e,R)=>{Xm.init(e,R),e.name=`ZodError`,Object.defineProperties(e,{format:{value:R=>function(e,R=e=>e.message){let W={_errors:[]},i=e=>{for(let Y of e.issues)if(Y.code===`invalid_union`&&Y.errors.length)Y.errors.map((e=>i({issues:e})));else if(Y.code===`invalid_key`)i({issues:Y.issues});else if(Y.code===`invalid_element`)i({issues:Y.issues});else if(Y.path.length===0)W._errors.push(R(Y));else{let e=W,X=0;for(;X<Y.path.length;){let W=Y.path[X];X===Y.path.length-1?(e[W]=e[W]||{_errors:[]},e[W]._errors.push(R(Y))):e[W]=e[W]||{_errors:[]},e=e[W],X++}}};return i(e),W}(e,R)},flatten:{value:R=>function(e,R=e=>e.message){let W={},Y=[];for(let X of e.issues)X.path.length>0?(W[X.path[0]]=W[X.path[0]]||[],W[X.path[0]].push(R(X))):Y.push(R(X));return{formErrors:Y,fieldErrors:W}}(e,R)},addIssue:{value:R=>{e.issues.push(R),e.message=JSON.stringify(e.issues,J,2)}},addIssues:{value:R=>{e.issues.push(...R),e.message=JSON.stringify(e.issues,J,2)}},isEmpty:{get:()=>e.issues.length===0}})},ev=(N(`ZodError`,ns),N(`ZodError`,ns,{Parent:Error})),tv=Ee(ev),nv=me(ev),rv=we(ev),iv=ve(ev),av=ke(ev),ov=De(ev),sv=Se(ev),cv=xe(ev),lv=ze(ev),uv=Fe(ev),dv=Le(ev),fv=Ne(ev),pv=N(`ZodType`,((e,R)=>(Og.init(e,R),Object.assign(e[`~standard`],{jsonSchema:{input:co(e,`input`),output:co(e,`output`)}}),e.toJSONSchema=((e,R={})=>W=>{let Y=oo({...W,processors:R});return so(e,Y),ro(Y,e),ao(Y,e)})(e,{}),e.def=R,e.type=R.type,Object.defineProperty(e,"_def",{value:R}),e.check=(...W)=>e.clone($(R,{checks:[...R.checks??[],...W.map((e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e))]})),e.clone=(R,W)=>oe(e,R,W),e.brand=()=>e,e.register=(R,W)=>(R.add(e,W),e),e.parse=(R,W)=>tv(e,R,W,{callee:e.parse}),e.safeParse=(R,W)=>rv(e,R,W),e.parseAsync=async(R,W)=>nv(e,R,W,{callee:e.parseAsync}),e.safeParseAsync=async(R,W)=>iv(e,R,W),e.spa=e.safeParseAsync,e.encode=(R,W)=>av(e,R,W),e.decode=(R,W)=>ov(e,R,W),e.encodeAsync=async(R,W)=>sv(e,R,W),e.decodeAsync=async(R,W)=>cv(e,R,W),e.safeEncode=(R,W)=>lv(e,R,W),e.safeDecode=(R,W)=>uv(e,R,W),e.safeEncodeAsync=async(R,W)=>dv(e,R,W),e.safeDecodeAsync=async(R,W)=>fv(e,R,W),e.refine=(R,W)=>e.check(ll(R,W)),e.superRefine=R=>e.check(cl(R)),e.overwrite=R=>e.check(Wn(R)),e.optional=()=>Sa(e),e.nullable=()=>za(e),e.nullish=()=>Sa(za(e)),e.nonoptional=R=>Ma(e,R),e.array=()=>Kr(e),e.or=R=>ia([e,R]),e.and=R=>la(e,R),e.transform=R=>Ha(e,ka(R)),e.default=R=>Na(e,R),e.prefault=R=>Ta(e,R),e.catch=R=>Za(e,R),e.pipe=R=>Ha(e,R),e.readonly=()=>Wa(e),e.describe=R=>{let W=e.clone();return J_.add(W,{description:R}),W},Object.defineProperty(e,"description",{get:()=>J_.get(e)?.description,configurable:!0}),e.meta=(...R)=>{if(R.length===0)return J_.get(e);let W=e.clone();return J_.add(W,R[0]),W},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e))),mv=N(`_ZodString`,((e,R)=>{kg.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>ho(e,R,W);let W=e._zod.bag;e.format=W.format??null,e.minLength=W.minimum??null,e.maxLength=W.maximum??null,e.regex=(...R)=>e.check(Zn(...R)),e.includes=(...R)=>e.check(Yn(...R)),e.startsWith=(...R)=>e.check(Hn(...R)),e.endsWith=(...R)=>e.check(Pn(...R)),e.min=(...R)=>e.check(Un(...R)),e.max=(...R)=>e.check(On(...R)),e.length=(...R)=>e.check(Jn(...R)),e.nonempty=(...R)=>e.check(Un(1,...R)),e.lowercase=R=>e.check(qn(R)),e.uppercase=R=>e.check(jn(R)),e.trim=()=>e.check(Xn()),e.normalize=(...R)=>e.check(Vn(...R)),e.toLowerCase=()=>e.check(eo()),e.toUpperCase=()=>e.check(to()),e.slugify=()=>e.check(Ao())})),hv=N(`ZodString`,((e,R)=>{kg.init(e,R),mv.init(e,R),e.email=R=>e.check(sn(_v,R)),e.url=R=>e.check(dn(bv,R)),e.jwt=R=>e.check(bn(Iv,R)),e.emoji=R=>e.check(hn(xv,R)),e.guid=R=>e.check(rn(vv,R)),e.uuid=R=>e.check(an(yv,R)),e.uuidv4=R=>e.check(ln(yv,R)),e.uuidv6=R=>e.check(cn(yv,R)),e.uuidv7=R=>e.check(gn(yv,R)),e.nanoid=R=>e.check(un(Sv,R)),e.guid=R=>e.check(rn(vv,R)),e.cuid=R=>e.check(In(Cv,R)),e.cuid2=R=>e.check(pn(wv,R)),e.ulid=R=>e.check(fn(Tv,R)),e.base64=R=>e.check(wn(Nv,R)),e.base64url=R=>e.check(_n(Pv,R)),e.xid=R=>e.check(Bn(Ev,R)),e.ksuid=R=>e.check(Cn(Dv,R)),e.ipv4=R=>e.check(En(Ov,R)),e.ipv6=R=>e.check(Qn(Av,R)),e.cidrv4=R=>e.check(mn(jv,R)),e.cidrv6=R=>e.check(yn(Mv,R)),e.e164=R=>e.check(vn(Fv,R)),e.datetime=R=>e.check(Wo(R)),e.date=R=>e.check(Xo(R)),e.time=R=>e.check(ts(R)),e.duration=R=>e.check(is(R))}));function Qs(e){return function(e,R){return new e({type:`string`,...se(R)})}(hv,e)}const gv=N(`ZodStringFormat`,((e,R)=>{jg.init(e,R),mv.init(e,R)})),_v=N(`ZodEmail`,((e,R)=>{Pg.init(e,R),gv.init(e,R)}));function ws(e){return sn(_v,e)}const vv=N(`ZodGUID`,((e,R)=>{Mg.init(e,R),gv.init(e,R)}));function vs(e){return rn(vv,e)}const yv=N(`ZodUUID`,((e,R)=>{Ng.init(e,R),gv.init(e,R)}));function ks(e){return an(yv,e)}function Ds(e){return ln(yv,e)}function Ss(e){return cn(yv,e)}function xs(e){return gn(yv,e)}const bv=N(`ZodURL`,((e,R)=>{Fg.init(e,R),gv.init(e,R)}));function Fs(e){return dn(bv,e)}function Ls(e){return dn(bv,{protocol:/^https?$/,hostname:Oh,...se(e)})}const xv=N(`ZodEmoji`,((e,R)=>{Ig.init(e,R),gv.init(e,R)}));function Gs(e){return hn(xv,e)}const Sv=N(`ZodNanoID`,((e,R)=>{Lg.init(e,R),gv.init(e,R)}));function Rs(e){return un(Sv,e)}const Cv=N(`ZodCUID`,((e,R)=>{Rg.init(e,R),gv.init(e,R)}));function Os(e){return In(Cv,e)}const wv=N(`ZodCUID2`,((e,R)=>{zg.init(e,R),gv.init(e,R)}));function Js(e){return pn(wv,e)}const Tv=N(`ZodULID`,((e,R)=>{Bg.init(e,R),gv.init(e,R)}));function qs(e){return fn(Tv,e)}const Ev=N(`ZodXID`,((e,R)=>{Vg.init(e,R),gv.init(e,R)}));function Ys(e){return Bn(Ev,e)}const Dv=N(`ZodKSUID`,((e,R)=>{Hg.init(e,R),gv.init(e,R)}));function Ps(e){return Cn(Dv,e)}const Ov=N(`ZodIPv4`,((e,R)=>{qg.init(e,R),gv.init(e,R)}));function Ks(e){return En(Ov,e)}const kv=N(`ZodMAC`,((e,R)=>{Yg.init(e,R),gv.init(e,R)}));function Vs(e){return function(e,R){return new e({type:`string`,format:`mac`,check:`string_format`,abort:!1,...se(R)})}(kv,e)}const Av=N(`ZodIPv6`,((e,R)=>{Jg.init(e,R),gv.init(e,R)}));function er(e){return Qn(Av,e)}const jv=N(`ZodCIDRv4`,((e,R)=>{Xg.init(e,R),gv.init(e,R)}));function Ar(e){return mn(jv,e)}const Mv=N(`ZodCIDRv6`,((e,R)=>{Zg.init(e,R),gv.init(e,R)}));function nr(e){return yn(Mv,e)}const Nv=N(`ZodBase64`,((e,R)=>{Qg.init(e,R),gv.init(e,R)}));function sr(e){return wn(Nv,e)}const Pv=N(`ZodBase64URL`,((e,R)=>{$g.init(e,R),gv.init(e,R)}));function ar(e){return _n(Pv,e)}const Fv=N(`ZodE164`,((e,R)=>{e_.init(e,R),gv.init(e,R)}));function cr(e){return vn(Fv,e)}const Iv=N(`ZodJWT`,((e,R)=>{t_.init(e,R),gv.init(e,R)}));function dr(e){return bn(Iv,e)}const Lv=N(`ZodCustomStringFormat`,((e,R)=>{n_.init(e,R),gv.init(e,R)}));function ur(e,R,W={}){return no(Lv,e,R,W)}function Ir(e){return no(Lv,`hostname`,Dh,e)}function pr(e){return no(Lv,`hex`,Bh,e)}function fr(e,R){let W=`${e}_${R?.enc??`hex`}`,Y=Rm[W];if(!Y)throw Error(`Unrecognized hash format: ${W}`);return no(Lv,W,Y,R)}const Rv=N(`ZodNumber`,((e,R)=>{r_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>uo(e,R,W),e.gt=(R,W)=>e.check(Sn(R,W)),e.gte=(R,W)=>e.check(xn(R,W)),e.min=(R,W)=>e.check(xn(R,W)),e.lt=(R,W)=>e.check(kn(R,W)),e.lte=(R,W)=>e.check(Dn(R,W)),e.max=(R,W)=>e.check(Dn(R,W)),e.int=R=>e.check(Qr(R)),e.safe=R=>e.check(Qr(R)),e.positive=R=>e.check(Sn(0,R)),e.nonnegative=R=>e.check(xn(0,R)),e.negative=R=>e.check(kn(0,R)),e.nonpositive=R=>e.check(Dn(0,R)),e.multipleOf=(R,W)=>e.check(Gn(R,W)),e.step=(R,W)=>e.check(Gn(R,W)),e.finite=()=>e;let W=e._zod.bag;e.minValue=Math.max(W.minimum??-1/0,W.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(W.maximum??1/0,W.exclusiveMaximum??1/0)??null,e.isInt=(W.format??``).includes(`int`)||Number.isSafeInteger(W.multipleOf??.5),e.isFinite=!0,e.format=W.format??null}));function Cr(e){return function(e,R){return new e({type:`number`,checks:[],...se(R)})}(Rv,e)}const zv=N(`ZodNumberFormat`,((e,R)=>{i_.init(e,R),Rv.init(e,R)}));function Qr(e){return function(e,R){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...se(R)})}(zv,e)}function mr(e){return function(e,R){return new e({type:`number`,check:`number_format`,abort:!1,format:`float32`,...se(R)})}(zv,e)}function yr(e){return function(e,R){return new e({type:`number`,check:`number_format`,abort:!1,format:`float64`,...se(R)})}(zv,e)}function wr(e){return function(e,R){return new e({type:`number`,check:`number_format`,abort:!1,format:`int32`,...se(R)})}(zv,e)}function _r(e){return function(e,R){return new e({type:`number`,check:`number_format`,abort:!1,format:`uint32`,...se(R)})}(zv,e)}const Bv=N(`ZodBoolean`,((e,R)=>{a_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Io(0,0,R)}));function br(e){return function(e,R){return new e({type:`boolean`,...se(R)})}(Bv,e)}const Vv=N(`ZodBigInt`,((e,R)=>{o_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>po(0,e),e.gte=(R,W)=>e.check(xn(R,W)),e.min=(R,W)=>e.check(xn(R,W)),e.gt=(R,W)=>e.check(Sn(R,W)),e.gte=(R,W)=>e.check(xn(R,W)),e.min=(R,W)=>e.check(xn(R,W)),e.lt=(R,W)=>e.check(kn(R,W)),e.lte=(R,W)=>e.check(Dn(R,W)),e.max=(R,W)=>e.check(Dn(R,W)),e.positive=R=>e.check(Sn(BigInt(0),R)),e.negative=R=>e.check(kn(BigInt(0),R)),e.nonpositive=R=>e.check(Dn(BigInt(0),R)),e.nonnegative=R=>e.check(xn(BigInt(0),R)),e.multipleOf=(R,W)=>e.check(Gn(R,W));let W=e._zod.bag;e.minValue=W.minimum??null,e.maxValue=W.maximum??null,e.format=W.format??null}));function Dr(e){return function(e,R){return new e({type:`bigint`,...se(R)})}(Vv,e)}const Hv=N(`ZodBigIntFormat`,((e,R)=>{s_.init(e,R),Vv.init(e,R)}));function xr(e){return function(e,R){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`int64`,...se(R)})}(Hv,e)}function zr(e){return function(e,R){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`uint64`,...se(R)})}(Hv,e)}const Uv=N(`ZodSymbol`,((e,R)=>{c_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>fo(0,e)}));function Lr(e){return function(e,R){return new e({type:`symbol`,...se(R)})}(Uv,e)}const Wv=N(`ZodUndefined`,((e,R)=>{l_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Co(0,e)}));function Gr(e){return function(e,R){return new e({type:`undefined`,...se(R)})}(Wv,e)}const Gv=N(`ZodNull`,((e,R)=>{u_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Bo(0,e,R)}));function Rr(e){return function(e,R){return new e({type:`null`,...se(R)})}(Gv,e)}const Kv=N(`ZodAny`,((e,R)=>{d_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>{}}));function Or(){return function(e){return new e({type:`any`})}(Kv)}const qv=N(`ZodUnknown`,((e,R)=>{f_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>{}}));function Jr(){return function(e){return new e({type:`unknown`})}(qv)}const Jv=N(`ZodNever`,((e,R)=>{p_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Qo(0,0,R)}));function qr(e){return function(e,R){return new e({type:`never`,...se(R)})}(Jv,e)}const Yv=N(`ZodVoid`,((e,R)=>{m_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Eo(0,e)}));function Yr(e){return function(e,R){return new e({type:`void`,...se(R)})}(Yv,e)}const Xv=N(`ZodDate`,((e,R)=>{h_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>mo(0,e),e.min=(R,W)=>e.check(xn(R,W)),e.max=(R,W)=>e.check(Dn(R,W));let W=e._zod.bag;e.minDate=W.minimum?new Date(W.minimum):null,e.maxDate=W.maximum?new Date(W.maximum):null}));function Pr(e){return function(e,R){return new e({type:`date`,...se(R)})}(Xv,e)}const Zv=N(`ZodArray`,((e,R)=>{g_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Lo(e,R,W,Y),e.element=R.element,e.min=(R,W)=>e.check(Un(R,W)),e.nonempty=R=>e.check(Un(1,R)),e.max=(R,W)=>e.check(On(R,W)),e.length=(R,W)=>e.check(Jn(R,W)),e.unwrap=()=>e.element}));function Kr(e,R){return function(e,R,W){return new e({type:`array`,element:R,...se(W)})}(Zv,e,R)}function Wr(e){let R=e._zod.def.shape;return Qa(Object.keys(R))}const Qv=N(`ZodObject`,((e,R)=>{v_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>No(e,R,W,Y),H(e,`shape`,(()=>R.shape)),e.keyof=()=>Qa(Object.keys(e._zod.def.shape)),e.catchall=R=>e.clone({...e._zod.def,catchall:R}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Jr()}),e.loose=()=>e.clone({...e._zod.def,catchall:Jr()}),e.strict=()=>e.clone({...e._zod.def,catchall:qr()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=R=>function(e,R){if(!ee(R))throw Error(`Invalid input to extend: expected a plain object`);let W=e._zod.def.checks;if(W&&W.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return oe(e,$(e._zod.def,{get shape(){let W={...e._zod.def.shape,...R};return P(this,`shape`,W),W},checks:[]}))}(e,R),e.safeExtend=R=>function(e,R){if(!ee(R))throw Error(`Invalid input to safeExtend: expected a plain object`);return oe(e,{...e._zod.def,get shape(){let W={...e._zod.def.shape,...R};return P(this,`shape`,W),W},checks:e._zod.def.checks})}(e,R),e.merge=R=>function(e,R){return oe(e,$(e._zod.def,{get shape(){let W={...e._zod.def.shape,...R._zod.def.shape};return P(this,`shape`,W),W},get catchall(){return R._zod.def.catchall},checks:[]}))}(e,R),e.pick=R=>function(e,R){let W=e._zod.def;return oe(e,$(e._zod.def,{get shape(){let e={};for(let Y in R){if(!(Y in W.shape))throw Error(`Unrecognized key: "${Y}"`);R[Y]&&(e[Y]=W.shape[Y])}return P(this,`shape`,e),e},checks:[]}))}(e,R),e.omit=R=>function(e,R){let W=e._zod.def;return oe(e,$(e._zod.def,{get shape(){let Y={...e._zod.def.shape};for(let e in R){if(!(e in W.shape))throw Error(`Unrecognized key: "${e}"`);R[e]&&delete Y[e]}return P(this,`shape`,Y),Y},checks:[]}))}(e,R),e.partial=(...R)=>function(e,R,W){return oe(R,$(R._zod.def,{get shape(){let Y=R._zod.def.shape,X={...Y};if(W)for(let R in W){if(!(R in Y))throw Error(`Unrecognized key: "${R}"`);W[R]&&(X[R]=e?new e({type:`optional`,innerType:Y[R]}):Y[R])}else for(let R in Y)X[R]=e?new e({type:`optional`,innerType:Y[R]}):Y[R];return P(this,`shape`,X),X},checks:[]}))}(dy,e,R[0]),e.required=(...R)=>function(e,R,W){return oe(R,$(R._zod.def,{get shape(){let Y=R._zod.def.shape,X={...Y};if(W)for(let R in W){if(!(R in X))throw Error(`Unrecognized key: "${R}"`);W[R]&&(X[R]=new e({type:`nonoptional`,innerType:Y[R]}))}else for(let R in Y)X[R]=new e({type:`nonoptional`,innerType:Y[R]});return P(this,`shape`,X),X},checks:[]}))}(hy,e,R[0])}));function Xr(e,R){return new Qv({type:`object`,shape:e??{},...se(R)})}function ea(e,R){return new Qv({type:`object`,shape:e,catchall:qr(),...se(R)})}function ta(e,R){return new Qv({type:`object`,shape:e,catchall:Jr(),...se(R)})}const $v=N(`ZodUnion`,((e,R)=>{y_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Go(e,R,W,Y),e.options=R.options}));function ia(e,R){return new $v({type:`union`,options:e,...se(R)})}const ey=N(`ZodXor`,((e,R)=>{$v.init(e,R),b_.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Go(e,R,W,Y),e.options=R.options}));function oa(e,R){return new ey({type:`union`,options:e,inclusive:!1,...se(R)})}const ty=N(`ZodDiscriminatedUnion`,((e,R)=>{$v.init(e,R),x_.init(e,R)}));function ra(e,R,W){return new ty({type:`union`,options:R,discriminator:e,...se(W)})}const ny=N(`ZodIntersection`,((e,R)=>{S_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>To(e,R,W,Y)}));function la(e,R){return new ny({type:`intersection`,left:e,right:R})}const ry=N(`ZodTuple`,((e,R)=>{C_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Ro(e,R,W,Y),e.rest=R=>e.clone({...e._zod.def,rest:R})}));function ga(e,R,W){let Y=R instanceof Og;return new ry({type:`tuple`,items:e,rest:Y?R:null,...se(Y?W:R)})}const iy=N(`ZodRecord`,((e,R)=>{w_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Mo(e,R,W,Y),e.keyType=R.keyType,e.valueType=R.valueType}));function ha(e,R,W){return new iy({type:`record`,keyType:e,valueType:R,...se(W)})}function ua(e,R,W){let Y=oe(e);return Y._zod.values=void 0,new iy({type:`record`,keyType:Y,valueType:R,...se(W)})}function Ia(e,R,W){return new iy({type:`record`,keyType:e,valueType:R,mode:`loose`,...se(W)})}const ay=N(`ZodMap`,((e,R)=>{T_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>zo(0,e),e.keyType=R.keyType,e.valueType=R.valueType}));function fa(e,R,W){return new ay({type:`map`,keyType:e,valueType:R,...se(W)})}const oy=N(`ZodSet`,((e,R)=>{E_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Fo(0,e),e.min=(...R)=>e.check(Rn(...R)),e.nonempty=R=>e.check(Rn(1,R)),e.max=(...R)=>e.check(Tn(...R)),e.size=(...R)=>e.check(Mn(...R))}));function Ca(e,R){return new oy({type:`set`,valueType:e,...se(R)})}const sy=N(`ZodEnum`,((e,R)=>{D_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>yo(e,0,W),e.enum=R.entries,e.options=Object.values(R.entries);let W=new Set(Object.keys(R.entries));e.extract=(e,Y)=>{let X={};for(let Y of e){if(!W.has(Y))throw Error(`Key ${Y} not found in enum`);X[Y]=R.entries[Y]}return new sy({...R,checks:[],...se(Y),entries:X})},e.exclude=(e,Y)=>{let X={...R.entries};for(let R of e){if(!W.has(R))throw Error(`Key ${R} not found in enum`);delete X[R]}return new sy({...R,checks:[],...se(Y),entries:X})}}));function Qa(e,R){return new sy({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e,...se(R)})}function ma(e,R){return new sy({type:`enum`,entries:e,...se(R)})}const cy=N(`ZodLiteral`,((e,R)=>{O_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>wo(e,R,W),e.values=new Set(R.values),Object.defineProperty(e,"value",{get(){if(R.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return R.values[0]}})}));function wa(e,R){return new cy({type:`literal`,values:Array.isArray(e)?e:[e],...se(R)})}const ly=N(`ZodFile`,((e,R)=>{k_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>bo(e,0,W),e.min=(R,W)=>e.check(Rn(R,W)),e.max=(R,W)=>e.check(Tn(R,W)),e.mime=(R,W)=>e.check(Kn(Array.isArray(R)?R:[R],W))}));function va(e){return function(e,R){return new e({type:`file`,...se(R)})}(ly,e)}const uy=N(`ZodTransform`,((e,R)=>{A_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>xo(0,e),e._zod.parse=(W,Y)=>{if(Y.direction===`backward`)throw new T(e.constructor.name);W.addIssue=Y=>{if(typeof Y==`string`)W.issues.push(pe(Y,W.value,R));else{let R=Y;R.fatal&&(R.continue=!1),R.code??=`custom`,R.input??=W.value,R.inst??=e,W.issues.push(pe(R))}};let X=R.transform(W.value,W);return X instanceof Promise?X.then((e=>(W.value=e,W))):(W.value=X,W)}}));function ka(e){return new uy({type:`transform`,transform:e})}const dy=N(`ZodOptional`,((e,R)=>{j_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Po(e,R,0,Y),e.unwrap=()=>e._zod.def.innerType}));function Sa(e){return new dy({type:`optional`,innerType:e})}const fy=N(`ZodNullable`,((e,R)=>{M_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Oo(e,R,W,Y),e.unwrap=()=>e._zod.def.innerType}));function za(e){return new fy({type:`nullable`,innerType:e})}function Fa(e){return Sa(za(e))}const py=N(`ZodDefault`,((e,R)=>{N_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Jo(e,R,W,Y),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));function Na(e,R){return new py({type:`default`,innerType:e,get defaultValue(){return typeof R==`function`?R():te(R)}})}const my=N(`ZodPrefault`,((e,R)=>{P_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Zo(e,R,W,Y),e.unwrap=()=>e._zod.def.innerType}));function Ta(e,R){return new my({type:`prefault`,innerType:e,get defaultValue(){return typeof R==`function`?R():te(R)}})}const hy=N(`ZodNonOptional`,((e,R)=>{F_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Uo(e,R,0,Y),e.unwrap=()=>e._zod.def.innerType}));function Ma(e,R){return new hy({type:`nonoptional`,innerType:e,...se(R)})}const gy=N(`ZodSuccess`,((e,R)=>{I_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>ko(0,0,R),e.unwrap=()=>e._zod.def.innerType}));function Ua(e){return new gy({type:`success`,innerType:e})}const _y=N(`ZodCatch`,((e,R)=>{L_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>qo(e,R,W,Y),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));function Za(e,R){return new _y({type:`catch`,innerType:e,catchValue:typeof R==`function`?R:()=>R})}const vy=N(`ZodNaN`,((e,R)=>{R_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>_o(0,e)}));function ja(e){return function(e,R){return new e({type:`nan`,...se(R)})}(vy,e)}const yy=N(`ZodPipe`,((e,R)=>{z_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>jo(e,R,0,Y),e.in=R.in,e.out=R.out}));function Ha(e,R){return new yy({type:`pipe`,in:e,out:R})}const by=N(`ZodCodec`,((e,R)=>{yy.init(e,R),B_.init(e,R)}));function $a(e,R,W){return new by({type:`pipe`,in:e,out:R,transform:W.decode,reverseTransform:W.encode})}const xy=N(`ZodReadonly`,((e,R)=>{V_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Yo(e,R,W,Y),e.unwrap=()=>e._zod.def.innerType}));function Wa(e){return new xy({type:`readonly`,innerType:e})}const Sy=N(`ZodTemplateLiteral`,((e,R)=>{H_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>vo(e,0,W)}));function Xa(e,R){return new Sy({type:`template_literal`,parts:e,...se(R)})}const Cy=N(`ZodLazy`,((e,R)=>{G_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>$o(e,R,0,Y),e.unwrap=()=>e._zod.def.getter()}));function tl(e){return new Cy({type:`lazy`,getter:e})}const wy=N(`ZodPromise`,((e,R)=>{W_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Ho(e,R,0,Y),e.unwrap=()=>e._zod.def.innerType}));function il(e){return new wy({type:`promise`,innerType:e})}const Ty=N(`ZodFunction`,((e,R)=>{U_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>So(0,e)}));function ol(e){return new Ty({type:`function`,input:Array.isArray(e?.input)?ga(e?.input):e?.input??Kr(Jr()),output:e?.output??Jr()})}const Ey=N(`ZodCustom`,((e,R)=>{K_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Do(0,e)}));function rl(e){let R=new rg({check:`custom`});return R._zod.check=e,R}function al(e,R){return function(e,R,W){let Y=se(W);return Y.abort??=!0,new e({type:`custom`,check:`custom`,fn:R,...Y})}(Ey,e??(()=>!0),R)}function ll(e,R={}){return function(e,R,W){return new e({type:`custom`,check:`custom`,fn:R,...se(W)})}(Ey,e,R)}function cl(e){return io(e)}const gl=function(e){let R=new rg({check:`describe`});return R._zod.onattach=[R=>{let W=J_.get(R)??{};J_.add(R,{...W,description:e})}],R._zod.check=()=>{},R},dl=function(e){let R=new rg({check:`meta`});return R._zod.onattach=[R=>{let W=J_.get(R)??{};J_.add(R,{...W,...e})}],R._zod.check=()=>{},R};function hl(e,R={error:`Input not instance of ${e.name}`}){let W=new Ey({type:`custom`,check:`custom`,fn:R=>R instanceof e,abort:!0,...se(R)});return W._zod.bag.Class=e,W}const ul=(...e)=>function(e,R){let W=se(R),Y=W.truthy??[`true`,`1`,`yes`,`on`,`y`,`enabled`],X=W.falsy??[`false`,`0`,`no`,`off`,`n`,`disabled`];W.case!==`sensitive`&&(Y=Y.map((e=>typeof e==`string`?e.toLowerCase():e)),X=X.map((e=>typeof e==`string`?e.toLowerCase():e)));let ie=new Set(Y),ae=new Set(X),le=e.Codec??B_,_e=e.Boolean??a_,ye=new le({type:`pipe`,in:new(e.String??kg)({type:`string`,error:W.error}),out:new _e({type:`boolean`,error:W.error}),transform:(e,R)=>{let Y=e;return W.case!==`sensitive`&&(Y=Y.toLowerCase()),!!ie.has(Y)||!ae.has(Y)&&(R.issues.push({code:`invalid_value`,expected:`stringbool`,values:[...ie,...ae],input:R.value,inst:ye,continue:!1}),{})},reverseTransform:(e,R)=>!0===e?Y[0]||`true`:X[0]||`false`,error:W.error});return ye}({Codec:by,Boolean:Bv,String:hv},...e);function Il(e){let R=tl((()=>ia([Qs(e),Cr(),br(),Rr(),Kr(R),ha(Qs(),R)])));return R}function pl(e,R){return Ha(ka(e),R)}var Dy;Dy||={},M({localeError:tn()});const Oy=ra(`type`,[Xr({name:Qs(),type:wa(`int`),value:Cr().int()}),Xr({name:Qs(),type:wa(`bool`),value:br()}),Xr({name:Qs(),type:wa(`float`),value:Cr()}),Xr({name:Qs(),type:wa(`string`),value:Qs()}),Xr({name:Qs(),type:wa(`file`),value:Qs()}),Xr({name:Qs(),type:wa(`color`),value:Qs()}),Xr({name:Qs(),type:wa(`object`),value:Cr()})]),ky=Xr({name:Qs(),type:wa(`tilelayer`),class:Qs().optional(),height:Cr(),width:Cr(),x:Cr(),y:Cr(),id:Cr(),opacity:Cr(),properties:Kr(Oy).optional(),visible:br(),tintcolor:Qs().optional(),parallaxx:Cr().optional(),parallaxy:Cr().optional(),offsetx:Cr().optional(),offsety:Cr().optional()}),Ay=ky.extend({data:Kr(Cr()),encoding:wa(`csv`)}),jy=ky.extend({data:Kr(Cr()),encoding:wa(`base64`),compression:wa(`gzip`)}),My=ky.extend({data:Kr(Cr()),encoding:wa(`base64`),compression:wa(`zlib`)}),Ny=ky.extend({data:Kr(Cr()),encoding:wa(`base64`),compression:wa(`zstandard`)}),Py=ky.extend({data:Qs(),encoding:wa(`base64`),compression:Qs().optional()}),Fy=ia([Xr({x:Cr(),y:Cr(),width:Cr(),height:Cr(),data:Qs()}),Xr({x:Cr(),y:Cr(),width:Cr(),height:Cr(),data:Kr(Cr())})]),Iy=ia([Py,Ay,jy,My,Ny,ky.extend({startx:Cr(),starty:Cr(),chunks:Kr(Fy),encoding:Qs().optional(),compression:Qs().optional(),data:Gr()})]);function kl(e){return e.encoding===`base64`}function Dl(e){return e.encoding===`csv`||Array.isArray(e.data)}const Ly=Xr({x:Cr(),y:Cr()}),Ry=Kr(Ly),zy=Xr({text:Qs(),color:Qs().optional(),fontfamily:Qs().optional(),pixelsize:Cr().optional(),wrap:br().optional(),halign:ia([wa(`left`),wa(`center`),wa(`right`),wa(`justify`)]).optional(),valign:ia([wa(`top`),wa(`center`),wa(`bottom`)]).optional()}),By=Xr({id:Cr().optional(),name:Qs().optional(),type:Qs().optional(),x:Cr().optional(),y:Cr().optional(),rotation:Cr().optional(),height:Cr().optional(),width:Cr().optional(),visible:br().optional(),gid:Cr().optional(),text:zy.optional(),point:br().optional(),ellipse:br().optional(),polyline:Kr(Ly).optional(),polygon:Ry.optional(),template:Qs().optional(),properties:Kr(Oy).optional()}),Vy=Xr({duration:Cr(),tileid:Cr()}),Hy=Xr({name:Qs(),draworder:Qs(),type:wa(`objectgroup`),class:Qs().optional(),x:Cr(),y:Cr(),id:Cr(),color:Qs().optional(),tintcolor:Qs().optional(),parallaxx:Cr().optional(),parallaxy:Cr().optional(),offsetx:Cr().optional(),offsety:Cr().optional(),opacity:Cr(),properties:Kr(Oy).optional(),visible:br(),objects:Kr(By)}),Uy=ia([Iy,Xr({name:Qs(),x:Cr(),y:Cr(),id:Cr(),type:wa(`imagelayer`),class:Qs().optional(),image:Qs().optional(),opacity:Cr(),properties:Kr(Oy).optional(),visible:br(),tintcolor:Qs().optional(),repeatx:br().optional(),repeaty:br().optional(),parallaxx:Cr().optional(),parallaxy:Cr().optional(),offsetx:Cr().optional(),offsety:Cr().optional(),transparentcolor:Qs().optional()}),Hy]),Wy=Xr({draworder:Qs(),id:Cr().optional(),name:Qs(),x:Cr(),y:Cr(),opacity:Cr(),tintcolor:Qs().optional(),type:wa(`objectgroup`),visible:br(),objects:Kr(By),properties:Kr(Oy).optional()}),Gy=Xr({id:Cr(),type:Qs().optional(),animation:Kr(Vy).optional(),objectgroup:Wy.optional(),probability:Cr().optional(),properties:Kr(Oy).optional(),image:Qs().optional(),imageheight:Cr().optional(),imagewidth:Cr().optional()}),Ky=Xr({name:Qs(),firstgid:Cr().optional(),class:Qs().optional(),objectalignment:ia([wa(`topleft`),wa(`top`),wa(`topright`),wa(`left`),wa(`center`),wa(`right`),wa(`bottomleft`),wa(`bottom`),wa(`bottomright`)]).optional(),image:Qs().optional(),imagewidth:Cr().optional(),imageheight:Cr().optional(),columns:Cr(),tileheight:Cr(),tilewidth:Cr(),tilecount:Cr(),grid:Xr({height:Cr(),width:Cr(),orientation:ia([wa(`isometric`),wa(`orthogonal`)])}).optional(),tileoffset:Ly.optional(),spacing:Cr(),margin:Cr(),tiles:Kr(Gy).optional(),properties:Kr(Oy).optional()});function Ol(e){return!!e.image}function Ul(e){return!e.image}const qy=Ky.extend({tiledversion:Qs().optional(),type:wa(`tileset`),version:Qs().optional()}),Jy=Xr({firstgid:Cr(),source:Qs()}),Yy=ia([Ky,Jy]),Xy=Xr({object:By.extend({id:Cr().optional()}),tileset:Jy.optional(),type:wa(`template`)}),Zy=Xr({type:Qs(),class:Qs().optional(),tiledversion:Qs(),version:Qs(),width:Cr(),height:Cr(),tilewidth:Cr(),tileheight:Cr(),compressionlevel:Cr().optional(),infinite:br(),nextlayerid:Cr(),nextobjectid:Cr(),parallaxoriginx:Cr().optional(),parallaxoriginy:Cr().optional(),hexsidelength:Cr().optional(),staggeraxis:wa(`y`).or(wa(`x`)).optional(),staggerindex:wa(`odd`).or(wa(`even`)).optional(),orientation:ia([wa(`isometric`),wa(`orthogonal`),wa(`staggered`),wa(`hexagonal`)]),renderorder:ia([wa(`right-down`),wa(`right-up`),wa(`left-down`),wa(`left-up`)]),backgroundcolor:Qs().optional(),layers:Kr(Uy),tilesets:Kr(Yy),properties:Kr(Oy).optional()});function Hl(e){return!!e.chunks}function Pl(e){return!e.source}function $l(e){return!!e.source}var Qy=class Kl{constructor(e,R,W,Y){this.x=e,this.y=R,this.width=W,this.height=Y}combine(e){let R=this.x+this.width,W=this.y+this.height,Y=e.x+e.width,X=e.y+e.height,ie=Math.max(R,Y),ae=Math.max(W,X);return new Kl(Math.min(this.x,e.x),Math.min(this.y,e.y),ie-Math.min(this.x,e.x),ae-Math.min(this.y,e.y))}},Wl=class{constructor(){this._largestBounds=new Qy(0,0,0,0)}_coerceNumber(e){return+e}_coerceBoolean(e){switch(e){case`0`:case`false`:return!1;case`true`:return!0;default:return!!e}}_coerceType(e,R){return e===`bool`?this._coerceBoolean(R):e===`int`||e===`float`||e===`object`?this._coerceNumber(R):R}_parsePropertiesNode(e,R){let W=[];if(e)for(let R of e.children){let e=R.getAttribute(`type`)??`string`,Y=R.getAttribute(`value`);Y||=R.innerHTML,W.push({name:R.getAttribute(`name`),type:e,value:this._coerceType(e,Y)})}R.properties=W}_parseAttributes(e,R){let W=`width.height.columns.firstgid.spacing.margin.tilecount.tilewidth.tileheight.opacity.compressionlevel.nextlayerid.nextobjectid.parallaxoriginx.parallaxoriginy.parallaxx.parallaxy.hexsidelength.offsetx.offsety.id.gid.x.y.rotation.probability`.split(`.`),Y=[`infinite`,`visible`,`repeatx`,`repeaty`];for(let X of e.attributes)W.indexOf(X.name)>-1?R[X.name]=this._coerceNumber(X.value):Y.indexOf(X.name)>-1?R[X.name]=this._coerceBoolean(X.value):R[X.name]=X.value}_parseToDocument(e){if(typeof DOMParser<`u`)return new DOMParser().parseFromString(e,`application/xml`);try{let{JSDOM:R}=S(371);return new R(e,{contentType:`application/xml`,encoding:`utf-8`}).window.document}catch{}let R=Error(`Could not find DOM parser`);throw bt.error(R.message,R),R}parseObject(e,R=!0){let W={type:``,x:0,y:0};e.getAttribute(`template`)||(W.visible=!0,W.name=``,W.rotation=0,W.height=0,W.width=0),this._parseAttributes(e,W);let Y=e.querySelector(`properties`);Y&&this._parsePropertiesNode(Y,W);let X=e.querySelector(`text`);if(X){W.text={text:X.textContent};let e=X.getAttribute(`fontfamily`);e&&(W.text.fontfamily=e);let R=X.getAttribute(`color`);R&&(W.text.color=R);let Y=X.getAttribute(`pixelsize`);Y&&(W.text.pixelsize=this._coerceNumber(Y));let ie=X.getAttribute(`wrap`);ie&&(W.text.wrap=this._coerceBoolean(ie));let ae=X.getAttribute(`valign`);ae&&(W.text.valign=ae);let le=X.getAttribute(`halign`);le&&(W.text.halign=le)}e.querySelector(`point`)&&(W.point=!0),e.querySelector(`ellipse`)&&(W.ellipse=!0);let ie=e.querySelector(`polygon`);if(ie){let e=ie.getAttribute(`points`)?.split(` `);W.polygon=[],e&&e.forEach((e=>{let R=e.split(`,`);W.polygon.push({x:+R[0],y:+R[1]})}))}let ae=e.querySelector(`polyline`);if(ae){let e=ae.getAttribute(`points`)?.split(` `);W.polyline=[],e&&e.forEach((e=>{let R=e.split(`,`);W.polyline.push({x:+R[0],y:+R[1]})}))}if(R)try{return By.parse(W)}catch(e){throw bt.error(`Could not parse object`,W,e),e}return W}parseTileset(e,R=!0){let W={spacing:0,margin:0};if(this._parseAttributes(e,W),W.source)try{return Yy.parse(W)}catch(e){bt.error(`Could not parse external tileset`,W,e)}for(let Y of e.children)switch(Y.tagName){case`properties`:this._parsePropertiesNode(Y,W);break;case`tileoffset`:{let e={};this._parseAttributes(Y,e),W.tileoffset=e;break}case`grid`:{let e={};this._parseAttributes(Y,e),W.grid=e;break}case`image`:W.image=Y.getAttribute(`source`),W.imagewidth=this._coerceNumber(Y.getAttribute(`width`)),W.imageheight=this._coerceNumber(Y.getAttribute(`height`));break;case`tile`:{W.tiles||=[];let e={};this._parseAttributes(Y,e);for(let W of Y.children)switch(W.tagName){case`image`:e.image=W.getAttribute(`source`),e.imagewidth=this._coerceNumber(W.getAttribute(`width`)),e.imageheight=this._coerceNumber(W.getAttribute(`height`));break;case`objectgroup`:{let Y={type:`objectgroup`,name:``,visible:!0,x:0,y:0,opacity:1,objects:[]};this._parseAttributes(W,Y),e.objectgroup=Y;for(let e of W.children){let W=this.parseObject(e,R);Y.objects.push(W)}break}case`animation`:{let R=[];for(let e of W.children)R.push({duration:this._coerceNumber(e.getAttribute(`duration`)),tileid:this._coerceNumber(e.getAttribute(`tileid`))});e.animation=R;break}case`properties`:this._parsePropertiesNode(W,e)}if(R)try{W.tiles.push(Gy.parse(e))}catch(R){throw bt.error(`Could not parse Tile`,e,R),R}else W.tiles.push(e);break}}if(R)try{return Yy.parse(W)}catch(e){throw bt.error(`Could not parse Tileset`,W,e),e}return W}parseTileLayer(e,R,W=!0){let Y={type:`tilelayer`,x:0,y:0,opacity:1,visible:!0};this._parseAttributes(e,Y);for(let W of e.children)switch(W.tagName){case`properties`:this._parsePropertiesNode(W,Y);break;case`data`:{let e=W.getAttribute(`encoding`);e&&(Y.encoding=e);let X=W.getAttribute(`compression`);if(X&&(Y.compression=X),R){Y.width=0,Y.height=0,Y.chunks=[];let e=new Qy(0,0,0,0);for(let R of W.children)if(R.tagName===`chunk`){let W={};switch(this._parseAttributes(R,W),Y.encoding){case`base64`:W.data=R.textContent?.trim();break;case`csv`:W.data=R.textContent?.split(`,`).map((e=>+e))}let X=new Qy(W.x,W.y,W.width,W.height);e=e.combine(X),Y.chunks.push(W)}Y.width=e.width,Y.height=e.height,Y.startx=e.x,Y.starty=e.y,this._largestBounds=this._largestBounds.combine(new Qy(Y.startx,Y.starty,Y.width,Y.height))}else switch(Y.encoding){case`base64`:Y.data=W.textContent?.trim();break;case`csv`:Y.data=W.textContent?.split(`,`).map((e=>+e))}}}if(W)try{return Uy.parse(Y)}catch(e){throw bt.error(`Could not parse tiled tile layer`,Y,e),e}return Y}parseObjectGroup(e,R=!0){let W={type:`objectgroup`,draworder:`topdown`,visible:!0,x:0,y:0,opacity:1,objects:[]};this._parseAttributes(e,W);for(let Y of e.children)switch(Y.tagName){case`properties`:this._parsePropertiesNode(Y,W);break;case`object`:{let e=this.parseObject(Y,R);W.objects.push(e);break}}if(R)try{return Uy.parse(W)}catch(e){throw bt.error(`Could not parse object group`,W,e),e}return W}parseImageLayer(e,R=!0){let W={type:`imagelayer`,visible:!0,x:0,y:0,opacity:1},Y=e.querySelector(`image`);W.image=Y?.getAttribute(`source`);let X=e.querySelector(`properties`);X&&this._parsePropertiesNode(X,W);let ie=Y?.getAttribute(`trans`);if(ie&&(W.transparentcolor=`#`+ie),this._parseAttributes(e,W),R)try{return Uy.parse(W)}catch(e){throw bt.error(`Could not parse layer`,W,e),e}return W}parseExternalTemplate(e,R=!0){let W=this._parseToDocument(e).querySelector(`template`),Y={type:`template`},X=W.querySelector(`object`);X&&(Y.object=this.parseObject(X,R));let ie=W.querySelector(`tileset`);if(ie&&(Y.tileset=this.parseTileset(ie,R)),R)try{return Xy.parse(Y)}catch(e){throw bt.error(`Could not parse template`,Y,e),e}return Y}parseExternalTileset(e,R=!0){let W=this._parseToDocument(e).querySelector(`tileset`),Y=this.parseTileset(W,R);if(Y.type=`tileset`,this._parseAttributes(W,Y),R)try{return qy.parse(Y)}catch(e){throw bt.error(`Could not parse tileset file`,Y,e),e}return Y}parse(e,R=!0){let W=this._parseToDocument(e).querySelector(`map`),Y={type:`map`,compressionlevel:-1,layers:[],tilesets:[]};this._parseAttributes(W,Y);let n=(e,R=!0)=>{switch(e.tagName){case`group`:for(let W of e.children)n(W,R);break;case`layer`:{let W=this.parseTileLayer(e,Y.infinite,R);Y.layers.push(W);break}case`properties`:this._parsePropertiesNode(e,Y);break;case`tileset`:{let W=this.parseTileset(e,R);Y.tilesets.push(W);break}case`objectgroup`:{let W=this.parseObjectGroup(e,R);Y.layers.push(W);break}case`imagelayer`:{let W=this.parseImageLayer(e,R);Y.layers.push(W);break}}};for(let e of W.children)n(e,R);if(R)try{return Zy.parse(Y)}catch(e){throw bt.error(`Could not parse Tiled map`,e),e}return Y}},$y=S(668);let eb,tb,nb;const rb={env:{emscripten_notify_memory_growth:function(e){nb=new Uint8Array(tb.exports.memory.buffer)}}};var ic=class{init(){return eb||(eb=typeof fetch<`u`?fetch(`data:application/wasm;base64,`+ib).then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,rb))).then(this._init):WebAssembly.instantiate(Buffer.from(ib,`base64`),rb).then(this._init),eb)}_init(e){tb=e.instance,rb.env.emscripten_notify_memory_growth(0)}decode(e,R=0){if(!tb)throw Error(`ZSTDDecoder: Await .init() before decoding.`);let W=e.byteLength,Y=tb.exports.malloc(W);nb.set(e,Y),R||=Number(tb.exports.ZSTD_findDecompressedSize(Y,W));let X=tb.exports.malloc(R),ie=tb.exports.ZSTD_decompress(X,R,Y,W),ae=nb.slice(X,X+ie);return tb.exports.free(Y),tb.exports.free(X),ae}};const ib=`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IAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQh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ASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdB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IAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY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wOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEE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`;var oc=class{static decode(e,R){var W,Y,X,ie,ae,le;if(e.length%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var _e=43,ye=47,be=48,Ce=97,Te=65,Oe=45,Ae=95;function I(e){var R=e.charCodeAt(0);if(R===_e||R===Oe)return 62;if(R===ye||R===Ae)return 63;if(R<be)return-1;if(R<be+10)return R-be+26+26;if(R<Te+26)return R-Te;if(R<Ce+26)return R-Ce+26;throw Error(`Could not decode elt`)}var Me=e.length;ae=e.charAt(Me-2)===`=`?2:+(e.charAt(Me-1)===`=`),le=new Uint8Array(3*e.length/4-ae),X=ae>0?e.length-4:e.length;var Pe=0;function B(e){le[Pe++]=e}for(W=0,Y=0;W<X;W+=4,Y+=3)B((16711680&(ie=I(e.charAt(W))<<18|I(e.charAt(W+1))<<12|I(e.charAt(W+2))<<6|I(e.charAt(W+3))))>>16),B((65280&ie)>>8),B(255&ie);return ae===2?B(255&(ie=I(e.charAt(W))<<2|I(e.charAt(W+1))>>4)):ae===1&&(B((ie=I(e.charAt(W))<<10|I(e.charAt(W+1))<<4|I(e.charAt(W+2))>>2)>>8&255),B(255&ie)),new Promise((e=>{let i=function(e){for(var R=0,W=e.length-1;W>=0;W--)R=256*R+1*e[W];return R};if(R===`zlib`||R===`gzip`){var Y=(le=(0,$y.inflate)(le)).length/4,X=Array(Y);for(W=0;W<Y;W++)X[W]=i(le.slice(4*W,4*W+4));e(X)}if(R===`zstd`){let R=new ic;R.init().then((()=>{var Y=(le=R.decode(le)).length/4,X=Array(Y);for(W=0;W<Y;W++)X[W]=i(le.slice(4*W,4*W+4));e(X)}))}if(!R){for(Y=le.length/4,X=Array(Y),W=0;W<Y;W++)X[W]=i(le.slice(4*W,4*W+4));e(X)}}))}};const ab={TileData:{Tiled:`ex-tiled`},ZIndex:{ZIndex:`zindex`},Camera:{Camera:`camera`,Zoom:`zoom`},Animation:{Strategy:`animationstrategy`},Layer:{Solid:`solid`},Collision:{Type:`collisiontype`}},rc=async(e,R)=>{let W=await fetch(e);switch(R.toLowerCase()){case`xml`:default:return await W.text();case`json`:return await W.json()}},ac=e=>R=>R?.name&&e?R.name.toLocaleLowerCase().localeCompare(e.toLocaleLowerCase())===0:R?.name===e,lc=e=>R=>R?.class&&e?R.class.toLocaleLowerCase().localeCompare(e.toLocaleLowerCase())===0:R?.class===e,cc=e=>{let R=new Map;for(let[W,Y]of e)R.set(W.toLocaleLowerCase(),Y);return R},gc=(e,R,W=!0)=>Y=>{let X=cc(Y.properties);if(R!==void 0){let Y=R;typeof R==`string`&&(Y=W?R.toLocaleLowerCase():R);let ie=X.get(e.toLocaleLowerCase());return typeof ie==`string`?(W?ie.toLocaleLowerCase():ie)===Y:X.get(e.toLocaleLowerCase())===Y}return X.has(e.toLocaleLowerCase())},dc=(e,R)=>W=>R(cc(W.properties).get(e.toLocaleLowerCase())),pc=e=>!!(e&2147483648),fc=e=>!!(e&1073741824),Bc=e=>!!(e&536870912),Cc=e=>536870911&e;var Ec=class{constructor(e){this.type=e,this._loaded=!1,this.cache=new Map}getOrAdd(...e){let R=this.cache.get(e.join(`+`));return R||(R=new this.type(...e),this.cache.set(e.join(`+`),R),R)}values(){if(this._loaded)return Array.from(this.cache.values());throw Error(`Read through cache not yet loaded! No values to return!`)}async load(){let e=Array.from(this.cache.entries()),R=await Promise.allSettled(e.map((e=>e[1].load()))),W=0;for(let Y=0;Y<R.length;Y++){let X=R[Y];X.status===`rejected`&&(bt.error(`Error loading resource at ${e[Y][0]}, is your pathMap correct? or your Tiled map corrupted?`,X.reason),W++)}if(W)throw Error(`Error loading ${W} resources`);this._loaded=!0}};function Qc(e,R){try{if(R)for(let W of R){let R=W.value;typeof W.value==`string`&&(R=W.value.toLocaleLowerCase()),e.properties.set(W.name.toLocaleLowerCase(),R)}}catch(R){bt.error(`Unable to map properties onto ${e}`,R)}}function mc(e){let R=e.match(/[^/\\&\?]+\.\w{2,4}(?=([\#\?&].*$|$))/gi);if(R)return R[0];throw Error(`Could not locate filename from path: ${e}`)}function yc(e,R){for(let{path:W,output:Y}of R)if(typeof W==`string`){if(e.includes(W))return Y}else{let R=e.match(W);if(R)return Y.replace(`[match]`,R[0])}return e}function wc(e,R){if(!R)return!1;for(let{path:W,output:Y}of R)if(typeof W==`string`){if(e.includes(W))return!0}else if(e.match(W))return!0;return!1}function _c(e,R,W){if(wc(R,W)&&W)return yc(R,W);if(R.indexOf(`/`)===0)return R;let Y=e.split(`/`),X=R.split(`/`);return Y[Y.length-1].includes(`.`)&&Y.pop(),Y.concat(X).join(`/`)}var vc=class{constructor(e){this.properties=new Map,this.tiledObject=e.tiledObject,this.name=this.tiledObject.name,this.class=this.tiledObject.type,this.id=this.tiledObject.id??-1,this.x=this.tiledObject.x??0,this.y=this.tiledObject.y??0,this.rotation=this.tiledObject.rotation??0}},bc=class extends vc{constructor(e,R){if(super({tiledObject:e}),!e.template)throw Error(`Invalid template`);if(this.source=e.template,this.gid=e.gid,this.instanceObject=e,this.template=R,R.object){this.name=this.name||R.object.name,this.class=this.class||R.object.class;for(let[e,W]of R.object.properties.entries())this.properties.has(e)||this.properties.set(e,W)}if(R.tileset&&R.object.tiledObject.gid){let e=R.tileset.getTileByGid(R.object.tiledObject.gid);if(e){this.class=this.class||e.class;for(let[R,W]of e.properties.entries())this.properties.has(R)||this.properties.set(R,W)}}}},kc=class extends vc{constructor(e,R,W,Y){super({tiledObject:e}),this.gid=R,this.width=W,this.height=Y}},Dc=class extends vc{},Sc=class extends vc{constructor(e,R,W,Y){var X;super({tiledObject:e}),this.font=new Kp({family:R.fontfamily??`sans-serif`,color:R.color?gf.fromHex(R.color):gf.Black,size:R.pixelsize??16,unit:cp.Px,textAlign:this._textAlignFromTiled(R.halign),baseAlign:this._textBaselineFromTiled(R.valign),quality:Y});let ie=(X=R.wrap)!=null&&X;this.text=new qp({text:R.text,font:this.font,...ie?{maxWidth:W+10}:{}})}_textBaselineFromTiled(e){switch(e){case`bottom`:return up.Bottom;case`center`:return up.Middle;default:return up.Top}}_textAlignFromTiled(e){switch(e){case`left`:default:return lp.Left;case`center`:return lp.Center;case`right`:return lp.Right;case`justify`:return lp.Start}}},xc=class extends vc{constructor(e,R,W){super({tiledObject:e}),this.width=R,this.height=W}},zc=class extends vc{constructor(e,R,W,Y){super({tiledObject:e}),this.width=R,this.height=W,this.anchor=Y}},Fc=class extends vc{constructor(e,R){super({tiledObject:e}),this.points=[],this.localPoints=[],this.localPoints=R.map((e=>vec(e.x,e.y))),this.points=R.map((e=>vec(e.x,e.y).rotate(toRadians(this.rotation)).add(vec(this.x,this.y))))}},Lc=class extends vc{constructor(e,R){super({tiledObject:e}),this.points=[],this.points=R.map((e=>vec(e.x,e.y)))}};function Nc(e,R){let W;if(e.point)W=new Dc({tiledObject:e});else if(e.ellipse)e.width&&e.height?(W=new xc(e,e.width,e.height),W.x+=e.width/2,W.y+=e.height/2):W=new xc(e,20,20);else if(e.polygon)W=new Fc(e,e.polygon);else if(e.polyline)W=new Lc(e,e.polyline);else if(e.text)W=new Sc(e,e.text,e.width??0,R?.textQuality??4);else if(e.gid&&!e.template){W=new kc(e,e.gid,e.width??0,e.height??0);let Y=R?.getTilesetForTileGid(e.gid),X=e.type;if(Y){let R=Y?.getTileByGid(e.gid);if(X||=R?.class,R?.properties)for(let[e,Y]of R.properties.entries())W.properties.has(e)||W.properties.set(e,Y)}W.class=X}else if(e.template&&R){let Y=R.templates.find((R=>mc(R.templatePath)===mc(e.template)));if(!Y)throw Error(`Template object id ${e.id} with name ${e.name} is missing a loaded template file, there should be one loaded from ${e.template}! Is your tiled map or template corrupted?`);W=new bc(e,Y)}else W=e.width&&e.height?new zc(e,e.width,e.height,sf.Zero):new zc(e,20,20,sf.Half);return Qc(W,e.properties),W}function Gc(e,R){let W=[];for(let Y of e.objects){let e=Nc(Y,R);W.push(e)}return W}var Tc=class{constructor(e){let{templatePath:R,object:W,tiledTemplate:Y,tileset:X}=e;this.templatePath=R,this.object=W,this.tiledTemplate=Y,this.tileset=X}},Rc=class{constructor(e){this.objects=[],this.colliders=[],this.animation=[],this.properties=new Map;let{id:R,tileset:W,tiledTile:Y}=e;this.id=R,this.tileset=W,this.tiledTile=Y,this.class=Y.type,Qc(this,Y.properties),Y.objectgroup&&Y.objectgroup.objects&&(this.objects=Gc(Y.objectgroup)),Y.animation&&(this.animation=Y.animation)}},Mc=class{constructor(e){this.firstGid=-1,this.tileCount=0,this.tileWidth=0,this.tileHeight=0,this.tileOffset=vec(0,0),this.tiles=[],this.objectalignment=`bottomleft`,this.orientation=`orthogonal`,this.properties=new Map;let{name:R,tiledTileset:W,image:Y,tileToImage:X,firstGid:ie}=e;if(this.name=R,this.tiledTileset=W,this.firstGid=ie,Ol(W)){Qc(this,W.properties);let e=W.spacing,R=Math.floor((W.imagewidth+e)/(W.tilewidth+e)),X=Math.floor((W.imageheight+e)/(W.tileheight+e));if(this.class=W.class,this.orientation=W.grid?.orientation??`orthogonal`,this.horizontalFlipTransform=lf.identity().translate(W.tilewidth,0).scale(-1,1),this.verticalFlipTransform=lf.identity().translate(0,W.tileheight).scale(1,-1),this.diagonalFlipTransform=lf.identity().translate(0,0).rotate(-Math.PI/2).scale(-1,1),this.objectalignment=W.objectalignment??(this.orientation===`orthogonal`?`bottomleft`:`bottom`),Y&&(this.spritesheet=Sp.fromImageSource({image:Y,grid:{rows:X,columns:R,spriteWidth:W.tilewidth,spriteHeight:W.tileheight},spacing:{originOffset:{x:W.margin??0,y:W.margin??0},margin:{x:W.spacing??0,y:W.spacing??0}}})),this.tileCount=W.tilecount,this.tileWidth=W.tilewidth,this.tileHeight=W.tileheight,W.tileoffset&&(this.tileOffset=vec(W.tileoffset.x,W.tileoffset.y)),W.tiles)for(let e of W.tiles)this.tiles.push(new Rc({id:e.id,tileset:this,tiledTile:e,image:Y}))}if(Ul(W)&&W.firstgid!==void 0){this.horizontalFlipTransform=lf.identity().translate(W.tilewidth,0).scale(-1,1),this.verticalFlipTransform=lf.identity().translate(0,W.tileheight).scale(1,-1),this.diagonalFlipTransform=lf.identity().translate(0,0).rotate(-Math.PI/2).scale(-1,1),this.objectalignment=W.objectalignment??(this.orientation===`orthogonal`?`bottomleft`:`bottom`),this.orientation=W.grid?.orientation??`orthogonal`,this.tileCount=W.tilecount,this.tileWidth=W.tilewidth,this.tileHeight=W.tileheight,W.tileoffset&&(this.tileOffset=vec(W.tileoffset.x,W.tileoffset.y));let e=[];if(W.tiles)for(let R of W.tiles){let W=X?.get(R);W&&e.push(W.toSprite()),this.tiles.push(new Rc({id:R.id,tileset:this,tiledTile:R,image:W}))}X&&(this.spritesheet=new Sp({sprites:e}))}}getTilesetAlignmentAnchor(e){switch(e??this.objectalignment){case`topleft`:return vec(0,0);case`top`:return vec(.5,0);case`topright`:return vec(1,0);case`left`:return vec(0,.5);case`center`:return vec(.5,.5);case`right`:return vec(1,.5);case`bottomleft`:default:return vec(0,1);case`bottom`:return vec(.5,1);case`bottomright`:return vec(1,1)}}getTileByGid(e){let R=Cc(e)-this.firstGid;return this.tiles.find((e=>e.id===R))}getTilesByClassName(e){return this.tiles.filter(lc(e))}getTilesByProperty(e,R,W=!0){return this.tiles.filter(gc(e,R,W))}getTilesByPropertyValueMatcher(e,R){return this.tiles.filter(dc(e,R))}getSpriteForGid(e){let R=pc(e),W=fc(e),Y=Bc(e),X=Cc(e),ie=X-this.firstGid;if(this.spritesheet){let e=this.spritesheet.sprites[ie];return(Y||R||W)&&(e=e.clone()),Y&&(e.rotation=-Math.PI/2,e.scale=vec(-1,1)),R&&(e.scale=vec((Y?1:-1)*e.scale.x,(Y?-1:1)*e.scale.y)),W&&(e.scale=vec((Y?-1:1)*e.scale.x,(Y?1:-1)*e.scale.y)),e}throw Error(`Tileset: [${this.name}] Could not find sprite for gid: [${e}] normalized gid: [${X}]`)}_isometricTiledCoordToWorld(e){let R=this.tileWidth,W=this.tileHeight/2,Y=e.y/W,X=e.x/W;return vec((X-Y)*R/2+0,(X+Y)*W/2)}getCollidersForGid(e,R){let{anchor:W,scale:Y,orientationOverride:X,offset:ie}={anchor:sf.Zero,scale:sf.One,offset:sf.Zero,orientationOverride:void 0,...R},ae=X??this.orientation,le=this.getTileByGid(e),_e=[];if(le&&le.objects)for(let R of le.objects){if(R instanceof Fc){let W=R.points.map((e=>e.scale(Y)));W=this._applyFlipsToPoints(W,e),ae===`isometric`&&(W=W.map((e=>this._isometricTiledCoordToWorld(e)))),W=W.map((e=>e.add(ie)));let X=tp.Polygon(W,sf.Zero,!0);X.isConvex()?_e.push(X):_e.push(X.triangulate())}if(R instanceof zc){let W=R.width,X=R.height,le=R.anchor,ye=Pf.fromDimension(W*Y.x,X*Y.y,le).getPoints().map((e=>e.rotate(toRadians(R.rotation)).add(vec(R.x,R.y))));ae===`isometric`&&(ye=ye.map((e=>this._isometricTiledCoordToWorld(e)))),ye=this._applyFlipsToPoints(ye,e),ye=ye.map((e=>e.add(ie)));let be=tp.Polygon(ye);_e.push(be)}if(R instanceof xc){let e=vec(R.x,R.y);ae===`isometric`&&(e=this._isometricTiledCoordToWorld(e)),e=e.add(ie);let W=Math.min(R.width/2,R.height/2),X=tp.Circle(W,e.scale(Y));_e.push(X)}}return _e}_applyFlipsToPoints(e,R){let W=pc(R),Y=fc(R);return Bc(R)&&(e=e.map((e=>this.diagonalFlipTransform.multiply(e)))),W&&(e=e.map((e=>this.horizontalFlipTransform.multiply(e)))),Y&&(e=e.map((e=>this.verticalFlipTransform.multiply(e)))),e}getAnimationForGid(e){let R=this.getTileByGid(e);if(R&&R.animation?.length){let e=[];for(let W of R.animation)e.push({graphic:this.getSpriteForGid(W.tileid+this.firstGid),duration:W.duration});return new op({frames:e,strategy:ip.Loop})}return null}},Oc=class{constructor(e,R,W){this.path=e,this.strict=!0,this.headless=!1,this.orientation=`orthogonal`,this.fileLoader=rc;let{fileLoader:Y,parser:X,pathMap:ie,imageLoader:ae,strict:le,headless:_e,orientation:ye}={...W};this.headless=_e??this.headless,this.orientation=ye??this.orientation,this.strict=le??this.strict,this.fileLoader=Y??this.fileLoader,this.imageLoader=ae??new Ec(yp),this.parser=X??new Wl,this.firstGid=R,this.pathMap=ie}async load(){let e=this.path.includes(`.tsx`)?`xml`:`json`;try{let R=await this.fileLoader(this.path,e),W;if(W=e===`json`?this.strict?qy.parse(R):R:this.parser.parseExternalTileset(R,this.strict),Ol(W)){let e=_c(this.path,W.image,this.pathMap),R=this.headless?void 0:this.imageLoader.getOrAdd(e);this.data=new Mc({name:W.name,tiledTileset:W,firstGid:this.firstGid,image:R})}if(Ul(W)){let e=this.headless?void 0:new Map;if(e){let R=[];if(W.tiles){for(let Y of W.tiles)if(Y.image){let W=_c(this.path,Y.image,this.pathMap),X=this.imageLoader.getOrAdd(W);e.set(Y,X),R.push(X)}}}W.firstgid=this.firstGid,this.data=new Mc({name:W.name,tiledTileset:W,firstGid:this.firstGid,tileToImage:e})}if(this.headless||await this.imageLoader.load(),this.data)return this.data}catch(e){throw bt.error(`Could not load tileset at path ${this.path}`),e}throw Error(`No tileset at path ${this.path}`)}isLoaded(){return!!this.data}},Uc=class{constructor(e,R){this.templatePath=e,this.headless=!1,this.strict=!0,this.fileLoader=rc;let{fileLoader:W,parser:Y,pathMap:X,imageLoader:ie,strict:ae,headless:le}={...R};this.headless=le??this.headless,this.strict=ae??this.strict,this.fileLoader=W??this.fileLoader,this.imageLoader=ie??new Ec(yp),this.parser=Y??new Wl,this.pathMap=X}isLoaded(){return!!this.data}async load(){let e=this.templatePath.includes(`.tx`)?`xml`:`json`;try{let R=await this.fileLoader(this.templatePath,e),W;W=e===`xml`?this.parser.parseExternalTemplate(R,this.strict):this.strict?Xy.parse(R):R;let Y=W,X=Nc(W.object),ie;return W.tileset&&(ie=await new Oc(_c(this.templatePath,W.tileset.source,this.pathMap),W.tileset.firstgid,{headless:this.headless,strict:this.strict,fileLoader:this.fileLoader,imageLoader:this.imageLoader,parser:this.parser,pathMap:this.pathMap}).load()),this.data=new Tc({templatePath:this.templatePath,tiledTemplate:Y,object:X,tileset:ie})}catch(e){throw bt.error(`Could not load template at ${this.templatePath}, check to see if your pathMap is correct or if you're Tiled map is corrupted`),e}}},Jc=class extends Component{constructor(e){super();let{tiledObject:R}=e;this.tiledObject=R}},Zc=class extends Component{constructor(e){super();let{tiledTileLayer:R}=e;this.tiledTileLayer=R}},qc=class{get isInfinite(){return this._isInfinite}constructor(e,R,W){this.tiledTileLayer=e,this.resource=R,this.order=W,this.logger=bf.getInstance(),this.width=0,this.height=0,this.properties=new Map,this.data=[],this._isInfinite=!1,this._tileToChunkData=new WeakMap,this._tileToChunkIndex=new WeakMap,this._gidToTileInfo=new Map,this.name=e.name,this.id=e.id,this.class=e.class,this.width=e.width,this.height=e.height,this.visible=!!e.visible,Qc(this,e.properties)}getTilesByProperty(e,R,W=!0){return this.isometricMap.tiles.filter((Y=>{let X=Y.data.get(ab.TileData.Tiled);return!!X&&gc(e,R,W)(X)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}getTilesByPropertyValueMatcher(e,R){return this.isometricMap.tiles.filter((W=>{let Y=W.data.get(ab.TileData.Tiled);return!!Y&&dc(e,R)(Y)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}getTilesByGid(e){return this._gidToTileInfo.get(e)??[]}getTilesByClassName(e){return this.isometricMap.tiles.filter((R=>{let W=R.data.get(ab.TileData.Tiled);return!!W&&lc(e)(W)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}_getGidForTile(e){let R=0;if(this._isInfinite){let W=this._tileToChunkData.get(e);if(W===void 0)throw Error(`Missing chunk data for excalibur tile`);let Y=this._tileToChunkIndex.get(e);if(Y===void 0)throw Error(`Missing chunk index for excalibur tile`);R=Cc(W[Y])}else{let W=this.isometricMap.tiles.indexOf(e);R=Cc(this.data[W])}return R}getTileByPoint(e){if(!this.isometricMap)return this.logger.warn(`IsometricMap has not yet been loaded! getTileByPoint() will only return null`),null;if(this.isometricMap){let R=this.isometricMap.getTileByPoint(e);if(!R)return null;let W=this._getGidForTile(R),Y;return W>0&&(Y=this.resource.getTilesetForTileGid(W).getTileByGid(W)),{tiledTile:Y,exTile:R}}return null}getTileByCoordinate(e,R){if(!this.isometricMap)return this.logger.warn(`IsometricMap has not yet been loaded! getTileByCoordinate() will only return null`),null;if(this.isometricMap){let W=this.isometricMap.getTile(e,R),Y=this._getGidForTile(W),X;return Y>0&&(X=this.resource.getTilesetForTileGid(Y).getTileByGid(Y)),{tiledTile:X,exTile:W}}return null}_recordTileData(e,R){let W=this._gidToTileInfo.get(e),Y=this.resource.getTilesetForTileGid(e).getTileByGid(e);W?W.push({exTile:R,tiledTile:Y}):W=[{exTile:R,tiledTile:Y}],this._gidToTileInfo.set(e,W),R.data.set(ab.TileData.Tiled,Y)}updateTile(e,R,W,Y,X){this._recordTileData(R,e);let ie=this.resource.getLayerConfig(this.name)||this.resource.getLayerConfig(this.id);ie?.isSolid!==void 0&&(X=ie.isSolid),this.resource.useExcaliburWiring&&X&&(e.solid=!0);let ae=e.get(IsometricEntityComponent);ae&&(ae.elevation=this.order);let le=this.resource.getTilesetForTileGid(R),_e=le.getSpriteForGid(R);W&&(_e=_e.clone(),_e.tint=Y),e.addGraphic(_e,{offset:le.tileOffset});let ye=e.pos;if(le.orientation===`orthogonal`)ye=vec(0,0);else{let e=this.resource.map.tilewidth/2,R=this.resource.map.tileheight;ye=vec(e,R)}let be=le.getCollidersForGid(R,{offset:ye});for(let R of be)e.addCollider(R);ie!=null&&ie.useTileColliders&&be.length>0&&this.visible&&(e.solid=!0),ie!=null&&ie.useTileCollidersWhenInvisible&&be.length>0&&(e.solid=!0);let Ce=le.getAnimationForGid(R);if(Ce&&(W&&(Ce=Ce.clone(),Ce.tint=Y),e.clearGraphics(),e.addGraphic(Ce,{offset:le.tileOffset}),this.resource.useExcaliburWiring)){let e=le.getTileByGid(R)?.properties.get(ab.Animation.Strategy);if(e&&typeof e==`string`)switch(e.toLowerCase()){case ip.End.toLowerCase():Ce.strategy=ip.End;break;case ip.Freeze.toLowerCase():Ce.strategy=ip.Freeze;break;case ip.Loop.toLowerCase():Ce.strategy=ip.Loop;break;case ip.PingPong.toLowerCase():Ce.strategy=ip.PingPong;break;default:this.logger.warn(`Unknown animation strategy in tileset ${le.name} on tile gid ${R}: ${e}`)}}}async load(){let e=this.resource.getLayerConfig(this.name)||this.resource.getLayerConfig(this.id),R=this.tiledTileLayer,W=!!this.properties.get(ab.Layer.Solid),Y=(this.tiledTileLayer.opacity,!!this.tiledTileLayer.tintcolor),X=this.tiledTileLayer.tintcolor?gf.fromHex(this.tiledTileLayer.tintcolor):gf.Transparent,ie=vec(R.offsetx??0,R.offsety??0);this.tiledTileLayer.data&&kl(this.tiledTileLayer)?this.data=await oc.decode(this.tiledTileLayer.data,this.tiledTileLayer.compression):this.tiledTileLayer.data&&Dl(this.tiledTileLayer)&&(this.data=this.tiledTileLayer.data);let ae=this.order,le=this.properties.get(ab.ZIndex.ZIndex);if(typeof le==`number`&&(ae=le),this.resource.map.infinite&&Hl(this.tiledTileLayer)){let W=this.resource.isometricTiledCoordToWorld(this.tiledTileLayer.startx,this.tiledTileLayer.starty),Y=vec(W.x*this.resource.map.tilewidth,W.y*this.resource.map.tileheight);this.isometricMap=new IsometricMap({name:this.name,pos:ie.add(Y),tileHeight:this.resource.map.tileheight,tileWidth:this.resource.map.tilewidth,columns:R.width,rows:R.height,elevation:ae}),e?.collisionGroup&&(this.isometricMap.get(rm).group=e.collisionGroup)}else this.isometricMap=new IsometricMap({name:this.name,pos:ie,tileWidth:this.resource.map.tilewidth,tileHeight:this.resource.map.tileheight,columns:R.width,rows:R.height,elevation:ae}),e?.collisionGroup&&(this.isometricMap.get(rm).group=e.collisionGroup);if(this.isometricMap.visible=this.tiledTileLayer.visible,this.isometricMap.opacity=this.tiledTileLayer.opacity,this.isometricMap.addComponent(new Zc({tiledTileLayer:R})),R.parallaxx||R.parallaxy){let e=vec(R.parallaxx??1,R.parallaxy??1);this.isometricMap.addComponent(new ParallaxComponent(e))}if(this.resource.map.infinite&&Hl(this.tiledTileLayer)){this._isInfinite=!0;let e=this.tiledTileLayer;for(let ie of this.tiledTileLayer.chunks){let ae=[];kl(this.tiledTileLayer)?ae=await oc.decode(ie.data,e.compression):Dl(this.tiledTileLayer)&&(ae=ie.data);for(let e=0;e<ae.length;e++){let le=ae[e],_e=e%ie.width+(ie.x-this.tiledTileLayer.startx),ye=Math.floor(e/ie.width)+(ie.y-this.tiledTileLayer.starty),be=this.isometricMap.tiles[_e+ye*R.width];this._tileToChunkData.set(be,ae),this._tileToChunkIndex.set(be,e),le!=0&&this.updateTile(be,le,Y,X,W)}}}else for(let e=0;e<this.data.length;e++){let R=this.data[e];if(R!==0){let ie=this.isometricMap.tiles[e];this.updateTile(ie,R,Y,X,W)}}}},jc=class{get isInfinite(){return this._isInfinite}getTilesByProperty(e,R,W=!0){return this.tilemap.tiles.filter((Y=>{let X=Y.data.get(ab.TileData.Tiled);return!!X&&gc(e,R,W)(X)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}getTilesByPropertyValueMatcher(e,R){return this.tilemap.tiles.filter((W=>{let Y=W.data.get(ab.TileData.Tiled);return!!Y&&dc(e,R)(Y)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}getTilesByGid(e){return this._gidToTileInfo.get(e)??[]}getTilesByClassName(e){return this.tilemap.tiles.filter((R=>{let W=R.data.get(ab.TileData.Tiled);return!!W&&lc(e)(W)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}_getGidForTile(e){let R=0;if(this._isInfinite){let W=this._tileToChunkData.get(e);if(W===void 0)throw Error(`Missing chunk data for excalibur tile (${e.x}, ${e.y})`);let Y=this._tileToChunkIndex.get(e);if(Y===void 0)throw Error(`Missing chunk index for excalibur tile (${e.x}, ${e.y})`);R=Cc(W[Y])}else{let W=this.tilemap.tiles.indexOf(e);R=Cc(this.data[W])}return R}getTileByPoint(e){if(!this.tilemap)return this.logger.warn(`Tilemap has not yet been loaded! getTileByPoint() will only return null`),null;if(this.tilemap){let R=this.tilemap.getTileByPoint(e);if(!R)return null;let W=this._getGidForTile(R),Y;return W>0&&(Y=this.resource.getTilesetForTileGid(W).getTileByGid(W)),{tiledTile:Y,exTile:R}}return null}getTileByCoordinate(e,R){if(!this.tilemap)return this.logger.warn(`Tilemap has not yet been loaded! getTileByCoordinate() will only return null`),null;if(this.tilemap){let W=this.tilemap.getTile(e,R),Y=this._getGidForTile(W),X;return Y>0&&(X=this.resource.getTilesetForTileGid(Y).getTileByGid(Y)),{tiledTile:X,exTile:W}}return null}constructor(e,R,W){this.tiledTileLayer=e,this.resource=R,this.order=W,this.logger=bf.getInstance(),this.width=0,this.height=0,this.properties=new Map,this.data=[],this._gidToTileInfo=new Map,this._isInfinite=!1,this._tileToChunkData=new Map,this._tileToChunkIndex=new Map,this.name=e.name,this.id=e.id,this.class=e.class,this.width=e.width,this.height=e.height,this.visible=!!e.visible,Qc(this,e.properties)}_recordTileData(e,R){let W=this._gidToTileInfo.get(e),Y=this.resource.getTilesetForTileGid(e).getTileByGid(e);W?W.push({exTile:R,tiledTile:Y}):W=[{exTile:R,tiledTile:Y}],this._gidToTileInfo.set(e,W),R.data.set(ab.TileData.Tiled,Y)}updateTile(e,R,W,Y,X){this._recordTileData(R,e);let ie=this.resource.getLayerConfig(this.name)||this.resource.getLayerConfig(this.id);ie?.isSolid!==void 0&&(X=ie.isSolid),this.resource.useExcaliburWiring&&X&&this.visible&&(e.solid=!0);let ae=this.resource.getTilesetForTileGid(R),le=this.resource.headless;if(!le){let X=ae.getSpriteForGid(R);W&&(X=X.clone(),X.tint=Y),e.addGraphic(X,{offset:ae.tileOffset})}let _e=ae.getCollidersForGid(R);for(let R of _e)e.addCollider(R);ie!=null&&ie.useTileColliders&&_e.length>0&&this.visible&&(e.solid=!0),ie!=null&&ie.useTileCollidersWhenInvisible&&_e.length>0&&(e.solid=!0);let ye=le?null:ae.getAnimationForGid(R);if(ye&&(W&&(ye=ye.clone(),ye.tint=Y),e.clearGraphics(),e.addGraphic(ye,{offset:ae.tileOffset}),this.resource.useExcaliburWiring)){let e=ae.getTileByGid(R)?.properties.get(ab.Animation.Strategy);if(e&&typeof e==`string`)switch(e.toLowerCase()){case ip.End.toLowerCase():ye.strategy=ip.End;break;case ip.Freeze.toLowerCase():ye.strategy=ip.Freeze;break;case ip.Loop.toLowerCase():ye.strategy=ip.Loop;break;case ip.PingPong.toLowerCase():ye.strategy=ip.PingPong;break;default:this.logger.warn(`Unknown animation strategy in tileset ${ae.name} on tile gid ${R}: ${e}`)}}}async load(){let e=this.resource.getLayerConfig(this.name)||this.resource.getLayerConfig(this.id),R=this.tiledTileLayer.opacity,W=!!this.tiledTileLayer.tintcolor,Y=this.tiledTileLayer.tintcolor?gf.fromHex(this.tiledTileLayer.tintcolor):gf.Transparent,X=!!this.properties.get(ab.Layer.Solid),ie=this.tiledTileLayer,ae=vec(ie.offsetx??0,ie.offsety??0);if(this.tiledTileLayer.data&&kl(this.tiledTileLayer)?this.data=await oc.decode(this.tiledTileLayer.data,this.tiledTileLayer.compression):this.tiledTileLayer.data&&Dl(this.tiledTileLayer)&&(this.data=this.tiledTileLayer.data),this.resource.map.infinite&&Hl(this.tiledTileLayer)){let R=vec(this.tiledTileLayer.startx*this.resource.map.tilewidth,this.tiledTileLayer.starty*this.resource.map.tileheight);this.tilemap=new TileMap({name:this.name,pos:ae.add(R),tileHeight:this.resource.map.tileheight,tileWidth:this.resource.map.tilewidth,columns:ie.width,rows:ie.height}),e?.collisionGroup&&(this.tilemap.get(rm).group=e.collisionGroup)}else this.tilemap=new TileMap({name:this.name,pos:ae,tileWidth:this.resource.map.tilewidth,tileHeight:this.resource.map.tileheight,columns:ie.width,rows:ie.height}),e?.collisionGroup&&(this.tilemap.get(rm).group=e.collisionGroup);this.tilemap.addComponent(new Zc({tiledTileLayer:ie}));let le=this.tilemap.get(Sf);if(le){le.z=this.order;let e=this.properties.get(ab.ZIndex.ZIndex);typeof e==`number`&&(le.z=e)}let _e=this.tilemap.get(Jp);if(_e&&(_e.isVisible=this.tiledTileLayer.visible,_e.opacity=R),ie.parallaxx||ie.parallaxy){let e=vec(ie.parallaxx??1,ie.parallaxy??1);this.tilemap.addComponent(new ParallaxComponent(e))}if(this.resource.map.infinite&&Hl(this.tiledTileLayer)){this._isInfinite=!0;let e=this.tiledTileLayer;for(let R of this.tiledTileLayer.chunks){let ae=[];kl(this.tiledTileLayer)?ae=await oc.decode(R.data,e.compression):Dl(this.tiledTileLayer)&&(ae=R.data);for(let e=0;e<ae.length;e++){let le=ae[e],_e=e%R.width+(R.x-this.tiledTileLayer.startx),ye=Math.floor(e/R.width)+(R.y-this.tiledTileLayer.starty),be=this.tilemap.tiles[_e+ye*ie.width];this._tileToChunkData.set(be,ae),this._tileToChunkIndex.set(be,e),le!==0&&this.updateTile(be,le,W,Y,X)}}}else for(let e=0;e<this.data.length;e++){let R=this.data[e];if(R!==0){let ie=this.tilemap.tiles[e];this.updateTile(ie,R,W,Y,X)}}}},Yc=class{constructor(e,R,W){this.tiledObjectLayer=e,this.resource=R,this.order=W,this.logger=bf.getInstance(),this.properties=new Map,this.objects=[],this.entities=[],this._objectToEntity=new Map,this._entityToObject=new Map,this._loaded=!1,this.name=e.name,this.class=e.class,Qc(this,e.properties)}_logLoadedWarning(e){this.logger.warn(`ObjectLayer ${this.name} is not yet loaded, ${e}() will always be empty!`)}getObjectsByName(e){return this._loaded||this._logLoadedWarning(`getObjectsByName`),this.objects.filter(ac(e))}getEntitiesByName(e){return this._loaded||this._logLoadedWarning(`getEntitiesByName`),this.entities.filter(ac(e))}getEntityByObject(e){return this._loaded||this._logLoadedWarning(`getEntityByObject`),this._objectToEntity.get(e)}getObjectByEntity(e){return this._loaded||this._logLoadedWarning(`getObjectByEntity`),this._entityToObject.get(e)}getObjectsByProperty(e,R,W=!0){return this._loaded||this._logLoadedWarning(`getObjectsByProperty`),this.objects.filter(gc(e,R,W))}getObjectsByPropertyValueMatcher(e,R){return this._loaded||this._logLoadedWarning(`getObjectsByPropertyValueMatcher`),this.objects.filter(dc(e,R))}getEntitiesByProperty(e,R,W=!0){return this._loaded||this._logLoadedWarning(`getEntitiesByProperty`),this.getObjectsByProperty(e,R,W).map((e=>this._objectToEntity.get(e))).filter((e=>!!e))}getEntitiesByPropertyValueMatcher(e,R){return this._loaded||this._logLoadedWarning(`getEntitiesByPropertyValueMatcher`),this.getObjectsByProperty(e,R).map((e=>this._objectToEntity.get(e))).filter((e=>!!e))}getObjectsByClassName(e){return this._loaded||this._logLoadedWarning(`getObjectsByClassName`),this.objects.filter(lc(e))}getEntitiesByClassName(e){return this._loaded||this._logLoadedWarning(`getEntitiesByClassName`),this.getObjectsByClassName(e).map((e=>this._objectToEntity.get(e))).filter((e=>!!e))}getTemplates(){return this._loaded||this._logLoadedWarning(`getTemplates`),this.objects.filter((e=>e instanceof bc))}runFactory(e){let R=vec(this.tiledObjectLayer.offsetx??0,this.tiledObjectLayer.offsety??0),W=this.objects.slice();for(let Y of W){let W=Y.class;if(Y instanceof bc&&(W||=Y.template.object.class),e!==W)continue;let X=vec((Y.x??0)+R.x,(Y.y??0)+R.y);this.resource.map.orientation===`isometric`&&(X=this.resource.isometricTiledCoordToWorld(X.x,X.y));let ie=this.resource.factories.get(e);if(ie){let e=ie({worldPos:X,name:Y.name,class:W,layer:this,object:Y,properties:Y.properties});e&&this._recordObjectEntityMapping(Y,e)}}}_actorFromObject(e,R,W){let Y=this.resource.headless,X=!!this.tiledObjectLayer.tintcolor,ie=this.tiledObjectLayer.tintcolor?gf.fromHex(this.tiledObjectLayer.tintcolor):gf.White;if(e instanceof kc&&W){let ae=this.resource.map.orientation===`isometric`&&W.orientation===`orthogonal`?`bottom`:void 0,le=W.getTilesetAlignmentAnchor(ae);R.anchor=le;let _e=vec((e.tiledObject.width??W.tileWidth)/W.tileWidth,(e.tiledObject.width??W.tileWidth)/W.tileWidth);if(!Y){let Y=W.getSpriteForGid(e.gid).clone();Y.destSize.width=e.tiledObject.width??Y.width,Y.destSize.height=e.tiledObject.height??Y.height,X&&(Y.tint=ie),R.graphics.use(Y),R.graphics.offset=W.tileOffset;let ae=W.getAnimationForGid(e.gid);if(ae){let e=ae.clone();e.scale=_e,X&&(e.tint=ie),R.graphics.use(e),R.graphics.offset=W.tileOffset}}let ye=e.tiledObject.width??0,be=e.tiledObject.height??0,Ce=-ye*le.x,Te=-be*le.y,Oe=this.resource.map.tilewidth/2,Ae=this.resource.map.tileheight,Me=vec(Ce,Te);this.resource.map.orientation===`isometric`&&(Me=vec(Ce+Oe,Te+Ae),W.orientation===`orthogonal`&&(Me=Me.sub(vec(Oe,Ae))));let Pe=W.getCollidersForGid(e.gid,{anchor:sf.Zero,scale:_e,offset:Me});if(Pe.length)R.collider.useCompositeCollider(Pe);else{let W=e.width,Y=e.height;if(this.resource.map.orientation===`isometric`){let R=e.height/2;W=R,Y=R}let X=tp.Box(W,Y,this.resource.map.orientation===`isometric`?vec(1,1):vec(0,1));this.resource.map.orientation===`isometric`&&(X.points=X.points.map((e=>this.resource.isometricTiledCoordToWorld(e.x,e.y)))),R.collider.set(X)}}if(e instanceof Sc&&R.graphics.use(e.text),e instanceof Fc){let W=vec(e.x,e.y),Y=e.localPoints;this.resource.map.orientation===`isometric`&&(W=this.resource.isometricTiledCoordToWorld(W.x,W.y),Y=Y.map((e=>this.resource.isometricTiledCoordToWorld(e.x,e.y)))),R.anchor=vec(0,1),R.pos=W;let X=tp.Polygon(Y,sf.Zero,!0);X.isConvex()?R.collider.set(X):R.collider.set(X.triangulate())}if(e instanceof zc){R.anchor=e.anchor;let W=tp.Box(e.width,e.height,e.anchor);this.resource.map.orientation===`isometric`&&(W.points=W.points.map((e=>this.resource.isometricTiledCoordToWorld(e.x,e.y)))),R.collider.set(W)}e instanceof xc&&R.collider.useCircleCollider(Math.min(e.width,e.height)/2)}async load(){let e=this.tiledObjectLayer.opacity,R=vec(this.tiledObjectLayer.offsetx??0,this.tiledObjectLayer.offsety??0),W=Gc(this.tiledObjectLayer,this.resource);for(let Y of W){let W=vec((Y.x??0)+R.x,(Y.y??0)+R.y);this.resource.map.orientation===`isometric`&&(W=this.resource.isometricTiledCoordToWorld(W.x,W.y));let X,ie=Y.class;if(Y instanceof bc&&(ie||=Y.template.object.class),ie){let e=this.resource.factories.get(ie);if(e){let R=e({worldPos:W,name:Y.name,class:ie,layer:this,object:Y,properties:Y.properties});R&&this._recordObjectEntityMapping(Y,R);continue}}let ae=this.properties.get(ab.ZIndex.ZIndex);typeof ae==`number`&&(X=ae);let le=new $p({name:Y.tiledObject.name,pos:W,anchor:sf.Zero,rotation:toRadians(Y.tiledObject.rotation??0),z:X}),_e=le.get(Jp);if(_e&&(_e.visible=this.tiledObjectLayer.visible&&(Y.tiledObject.visible===void 0||!!Y.tiledObject.visible),_e.opacity=e),this.resource.map.orientation===`isometric`){let e=new IsometricEntityComponent({rows:this.resource.map.height,columns:this.resource.map.width,tileWidth:this.resource.map.tilewidth,tileHeight:this.resource.map.tileheight});e.elevation=X??this.order,le.addComponent(e)}if(this.resource.useExcaliburWiring){let e=Y.properties.get(ab.Collision.Type);if(e&&typeof e==`string`)switch(e.toLowerCase()){case xf.Active.toLowerCase():le.body.collisionType=xf.Active;break;case xf.Fixed.toLowerCase():le.body.collisionType=xf.Fixed;break;case xf.Passive.toLowerCase():le.body.collisionType=xf.Passive;break;case xf.PreventCollision.toLowerCase():le.body.collisionType=xf.PreventCollision;break;default:this.logger.warn(`Unknown collision type in layer ${this.name}, for object id ${Y.id} and name ${Y.name}: ${e}`)}}if(Y instanceof bc){let e=Y.template.tileset,R=Y.template.object;R&&(Y.gid&&R instanceof kc&&(e=this.resource.getTilesetForTileGid(Y.gid),R=new kc(R.tiledObject,Y.gid,R.width,R.height)),this._actorFromObject(R,le,e))}else{let e;Y instanceof kc&&(e=this.resource.getTilesetForTileGid(Y.gid)),this._actorFromObject(Y,le,e)}this._recordObjectEntityMapping(Y,le)}this._loaded=!0}_recordObjectEntityMapping(e,R){R.addComponent(new Jc({tiledObject:e})),this.objects.push(e),this.entities.push(R),this._objectToEntity.set(e,R),this._entityToObject.set(R,e)}};const ob=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Pc=e=>{if(typeof e!=`string`)throw TypeError(`Invalid argument expected string`);let R=e.match(ob);if(!R)throw Error(`Invalid argument not valid semver ('${e}' received)`);return R.shift(),R},$c=e=>e===`*`||e===`x`||e===`X`,Kc=e=>{let R=parseInt(e,10);return isNaN(R)?e:R},Wc=(e,R)=>{if($c(e)||$c(R))return 0;let[W,Y]=((e,R)=>typeof e==typeof R?[e,R]:[String(e),String(R)])(Kc(e),Kc(R));return W>Y?1:W<Y?-1:0},Vc=(e,R)=>{for(let W=0;W<Math.max(e.length,R.length);W++){let Y=Wc(e[W]||`0`,R[W]||`0`);if(Y!==0)return Y}return 0},Xc=(e,R,W)=>{Ag(W);let Y=((e,R)=>{let W=Pc(e),Y=Pc(R),X=W.pop(),ie=Y.pop(),ae=Vc(W,Y);return ae===0?X&&ie?Vc(X.split(`.`),ie.split(`.`)):X||ie?X?-1:1:0:ae})(e,R);return sb[W].includes(Y)},sb={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},lb=Object.keys(sb),Ag=e=>{if(typeof e!=`string`)throw TypeError(`Invalid operator type, expected string but got `+typeof e);if(lb.indexOf(e)===-1)throw Error(`Invalid operator, expected one of ${lb.join(`|`)}`)};var ig=class{constructor(e,R,W){this.tiledImageLayer=e,this.resource=R,this.order=W,this.properties=new Map,this.image=null,this.imageActor=null,this.name=e.name,this.class=e.class,Qc(this,e.properties),e.image&&(this.image=new yp(_c(this.resource.path,e.image,this.resource.pathMap)))}async load(){let e=this.tiledImageLayer.opacity,R=!!this.tiledImageLayer.tintcolor,W=this.tiledImageLayer.tintcolor?gf.fromHex(this.tiledImageLayer.tintcolor):gf.White,Y=vec(this.tiledImageLayer.offsetx??0,this.tiledImageLayer.offsety??0),X=this.tiledImageLayer.parallaxx??1,ie=this.tiledImageLayer.parallaxy??1;if(this.image){this.resource.headless||await this.image.load(),this.imageActor=new $p({name:this.tiledImageLayer.name,pos:Y,anchor:sf.Zero,z:this.order}),this.imageActor.addComponent(new ParallaxComponent(vec(X,ie)));let ae=this.image.toSprite();this.imageActor.graphics.use(ae),this.imageActor.graphics.visible=this.tiledImageLayer.visible,this.imageActor.graphics.opacity=e,R&&(ae.tint=W)}}},ub=class ng{constructor(e,R){this.path=e,this.logger=bf.getInstance(),this.tilesets=[],this.templates=[],this.layers=[],this.mapFormat=`TMX`,this.strict=!0,this.factories=new Map,this.parser=new Wl,this.fileLoader=rc,this.startZIndex=0,this.textQuality=4,this.useExcaliburWiring=!0,this.useMapBackgroundColor=!1,this.useTilemapCameraStrategy=!1,this.headless=!1,this.layerConfig={},this._imageLoader=new Ec(yp),this._tilesetLoader=new Ec(Oc),this._templateLoader=new Ec(Uc);let{mapFormatOverride:W,textQuality:Y,entityClassNameFactories:X,useExcaliburWiring:ie,useTilemapCameraStrategy:ae,useMapBackgroundColor:le,layerConfig:_e,pathMap:ye,fileLoader:be,strict:Ce,headless:Te,startZIndex:Oe}={...R};this.strict=Ce??this.strict,this.headless=Te??this.headless,this.useExcaliburWiring=ie??this.useExcaliburWiring,this.useTilemapCameraStrategy=ae??this.useTilemapCameraStrategy,this.useMapBackgroundColor=le??this.useMapBackgroundColor,this.layerConfig=_e??this.layerConfig,this.textQuality=Y??this.textQuality,this.startZIndex=Oe??this.startZIndex,this.fileLoader=be??this.fileLoader,this.pathMap=ye;for(let e in X)this.registerEntityFactory(e,X[e]);this.mapFormat=W??(e.includes(`.tmx`)?`TMX`:`TMJ`)}registerEntityFactory(e,R){if(this.factories.has(e)&&bt.warn(`Another factory has already been registered for tiled class/type "${e}", this is probably a bug.`),this.factories.set(e,R),this.isLoaded())for(let R of this.getObjectLayers())R.runFactory(e)}unregisterEntityFactory(e){this.factories.has(e)||bt.warn(`No factory has been registered for tiled class/type "${e}", cannot unregister!`),this.factories.delete(e)}getLayerConfig(e){return this.layerConfig[e]}getTilesetForTileGid(e){let R=Cc(e);if(this.tilesets){for(let e of this.tilesets)if(R>=e.firstGid&&R<=e.firstGid+e.tileCount-1)return e}throw Error(`No tileset exists for tiled gid [${e}] normalized [${R}]!`)}getTilesetByName(e){return this.tilesets.filter(ac(e))}getTilesetByClassName(e){return this.tilesets.filter(lc(e))}getTilesetByProperty(e,R){return this.tilesets.filter(gc(e,R))}getTileMetadataByClassName(e){let R=[];for(let W of this.tilesets)R=R.concat(W.tiles.filter(lc(e)));return R}getTileMetadataByProperty(e,R){let W=[];for(let Y of this.tilesets)W=W.concat(Y.tiles.filter(gc(e,R)));return W}getTilesByGid(e){if(this.map.orientation===`orthogonal`){let R=[];for(let W of this.getTileLayers())R=R.concat(W.getTilesByGid(e));return R}{let R=[];for(let W of this.getIsoTileLayers())R=R.concat(W.getTilesByGid(e));return R}}getTilesByClassName(e){if(this.map.orientation===`orthogonal`){let R=[];for(let W of this.getTileLayers())R=R.concat(W.getTilesByClassName(e));return R}{let R=[];for(let W of this.getIsoTileLayers())R=R.concat(W.getTilesByClassName(e));return R}}getTilesByProperty(e,R){if(this.map.orientation===`orthogonal`){let W=[];for(let Y of this.getTileLayers())W=W.concat(Y.getTilesByProperty(e,R));return W}{let W=[];for(let Y of this.getIsoTileLayers())W=W.concat(Y.getTilesByProperty(e,R));return W}}getTileByPoint(e,R){if(this.map.orientation===`isometric`){let W=this.getIsoTileLayers().find(ac(e));if(W)return W.getTileByPoint(R)}else{let W=this.getTileLayers().find(ac(e));if(W)return W.getTileByPoint(R)}return null}getTileByCoordinate(e,R,W){if(this.map.orientation===`isometric`){let Y=this.getIsoTileLayers().find(ac(e));if(Y)return Y.getTileByCoordinate(R,W)}else{let Y=this.getTileLayers().find(ac(e));if(Y)return Y.getTileByCoordinate(R,W)}return null}getTilesByPoint(e){if(this.map.orientation===`orthogonal`){let R=[];for(let W of this.getTileLayers()){let Y=W.getTileByPoint(e);Y&&R.push(Y)}return R}{let R=[];for(let W of this.getIsoTileLayers()){let Y=W.getTileByPoint(e);Y&&R.push(Y)}return R}}getTilesByCoordinate(e,R){if(this.map.orientation===`orthogonal`){let W=[];for(let Y of this.getTileLayers()){let X=Y.getTileByCoordinate(e,R);X&&W.push(X)}return W}{let W=[];for(let Y of this.getIsoTileLayers()){let X=Y.getTileByCoordinate(e,R);X&&W.push(X)}return W}}getObjectsByName(e){let R=[];for(let W of this.getObjectLayers())R=R.concat(W.getObjectsByName(e));return R}getEntitiesByName(e){let R=[];for(let W of this.getObjectLayers())R=R.concat(W.getEntitiesByName(e));return R}getEntityByObject(e){for(let R of this.getObjectLayers()){let W=R.getEntityByObject(e);if(W)return W}}getObjectByEntity(e){for(let R of this.getObjectLayers()){let W=R.getObjectByEntity(e);if(W)return W}}getObjectsByProperty(e,R){let W=[];for(let Y of this.getObjectLayers())W=W.concat(Y.getObjectsByProperty(e,R));return W}getEntitiesByProperty(e,R){let W=[];for(let Y of this.getObjectLayers())W=W.concat(Y.getEntitiesByProperty(e,R));return W}getObjectsByClassName(e){let R=[];for(let W of this.getObjectLayers())R=R.concat(W.getObjectsByClassName(e));return R}getEntitiesByClassName(e){let R=[];for(let W of this.getObjectLayers())R=R.concat(W.getEntitiesByClassName(e));return R}getImageLayers(e){let R=this.layers.filter((e=>e instanceof ig));return e?R.filter(ac(e)):R}getTileLayers(e){let R=this.layers.filter((e=>e instanceof jc));return e?R.filter(ac(e)):R}getIsoTileLayers(e){let R=this.layers.filter((e=>e instanceof qc));return e?R.filter(ac(e)):R}getObjectLayers(e){let R=this.layers.filter((e=>e instanceof Yc));return e?R.filter(ac(e)):R}getLayersByName(e){return this.layers.filter(ac(e))}getLayersByClassName(e){return this.layers.filter(lc(e))}getLayersByProperty(e,R){return this.layers.filter(gc(e,R))}_parseMap(e){return this.mapFormat===`TMX`?this.parser.parse(e,this.strict):e}async load(){let e=await this.fileLoader(this.path,this.mapFormat===`TMX`?`xml`:`json`),R;if(this.strict)try{R=this._parseMap(e)}catch(e){throw bt.error(`Could not parse tiled map from location ${this.path}, attempted to interpret as ${this.mapFormat}.\nExcalibur only supports the latest version of Tiled formats as of the plugin's release.`),bt.error(`Is your map file corrupted or being interpreted as the wrong type?`),e}else R=this._parseMap(e);Xc(ng.supportedTiledVersion,R.tiledversion??`0.0.0`,`>`)&&bt.warn(`The excalibur tiled plugin officially supports ${ng.supportedTiledVersion}+, the current map has tiled version ${R.tiledversion}`),this.map=R,this._collectTilesets(),this._collectTemplates(),await Promise.all([this._tilesetLoader.load(),this.headless?Promise.resolve():this._imageLoader.load(),this._templateLoader.load()]),this.tilesets=[...this.tilesets,...this._tilesetLoader.values().map((e=>e.data))],this.templates=this._templateLoader.values().map((e=>e.data));let W=[],Y=this.startZIndex;for(let e of this.map.layers){if(e.type===`tilelayer`){if(this.map.orientation===`isometric`){let R=new qc(e,this,Y);W.push(R)}if(this.map.orientation===`orthogonal`){let R=new jc(e,this,Y);W.push(R)}}if(e.type===`objectgroup`){let R=new Yc(e,this,Y);W.push(R)}if(e.type===`imagelayer`){let R=new ig(e,this,Y);W.push(R)}Y++}await Promise.all(W.map((e=>e.load()))),this.layers=W}_collectTilesets(){for(let e of this.map.tilesets){if(Pl(e)){if(Ol(e)){let R=_c(this.path,e.image,this.pathMap),W=this._imageLoader.getOrAdd(R),Y=new Mc({name:e.name,tiledTileset:e,image:W,firstGid:e.firstgid});this.tilesets.push(Y)}if(Ul(e)){let R=new Map;if(e.tiles){for(let W of e.tiles)if(W.image){let e=_c(this.path,W.image,this.pathMap),Y=this._imageLoader.getOrAdd(e);R.set(W,Y)}}let W=new Mc({name:e.name,tiledTileset:e,tileToImage:R,firstGid:e.firstgid});this.tilesets.push(W)}}if($l(e)){let R=_c(this.path,e.source,this.pathMap);this._tilesetLoader.getOrAdd(R,e.firstgid,{strict:this.strict,headless:this.headless,parser:this.parser,fileLoader:this.fileLoader,imageLoader:this._imageLoader,pathMap:this.pathMap})}}}_collectTemplates(){let e=[];for(let R of this.map.layers)if(R.type===`objectgroup`){let W=R.objects.filter((e=>e.template)).map((e=>e.template));e=e.concat(W)}let R=e.filter(((e,R,W)=>W.findIndex((R=>R===e))===R));for(let e of R){let R=_c(this.path,e,this.pathMap);this._templateLoader.getOrAdd(R,{strict:this.strict,headless:this.headless,parser:this.parser,fileLoader:this.fileLoader,imageLoader:this._imageLoader,pathMap:this.pathMap})}}addToScene(e,R){if(!this.isLoaded())return void this.logger.warn(`TiledResource ${this.path} is not loaded! Nothing will be wired into excalibur!`);let{pos:W}={pos:vec(0,0),...R};for(let R of this.layers){if(R instanceof jc&&(R.tilemap.pos=R.tilemap.pos.add(W),e.add(R.tilemap)),R instanceof qc&&e.add(R.isometricMap),R instanceof Yc)for(let Y of R.entities){let R=Y.get(Sf);R&&(R.pos=R.pos.add(W)),e.add(Y)}R instanceof ig&&R.imageActor&&(R.imageActor.pos=R.imageActor.pos.add(W),e.add(R.imageActor))}if(this.useExcaliburWiring){let R=this.getObjectsByProperty(ab.Camera.Camera,!0);if(R&&R.length){let W=R[0],Y=1,X=W.properties.get(ab.Camera.Zoom);X&&typeof X==`number`&&(Y=X),this.map.orientation===`isometric`?e.camera.pos=this.isometricTiledCoordToWorld(W.x,W.y):e.camera.pos=vec(W.x,W.y),e.camera.zoom=Y}}if(this.useTilemapCameraStrategy){let R=this.getTileLayers()[0];if(R){let Y=Pf.fromDimension(this.map.width*this.map.tilewidth,this.map.height*this.map.tileheight,sf.Zero,W.add(R.tilemap.pos));e.camera.strategy.limitCameraBounds(Y)}}this.useMapBackgroundColor&&this.map.backgroundcolor&&(e.backgroundColor=gf.fromHex(this.map.backgroundcolor))}isometricTiledCoordToWorld(e,R){let W=this.map.tilewidth,Y=this.map.tileheight,X=R/Y,ie=e/Y;return vec((ie-X)*W/2+0,(ie+X)*Y/2)}isLoaded(){return!!this.map}};ub.supportedTiledVersion=`1.10.1`;const db={img:{player:new yp(`/res/images/Player.png`),level1Background:new yp(`/res/images/Forest_Background_0.png`),spiderGreen:new yp(`/res/images/Spider_1.png`),spiderGray:new yp(`/res/images/Spider_2.png`),birdPurple:new yp(`/res/images/Bird_1.png`),birdOrange:new yp(`/res/images/Bird_2.png`),platform:new yp(`/res/images/Platform.png`),bouncepadGreen:new yp(`/res/images/Bouncepad_Green.png`),bouncepadRed:new yp(`/res/images/Bouncepad_Red.png`),bouncepadWood:new yp(`/res/images/Bouncepad_Wood.png`),axe:new yp(`/res/images/Axe_Trap.png`),circularSaw:new yp(`/res/images/Circular_Saw.png`),smokePuff:new yp(`/res/images/Smoke_Puff.png`),smokeLand:new yp(`/res/images/Smoke_Land.png`),coin:new yp(`/res/images/Coin.png`),coinsUi:new yp(`/res/images/Coins_Ui.png`)},fonts:{round:new FontSource(`/res/fonts/Round9x13.ttf`,`Round9x13`,{filtering:pp.Pixel,quality:4})},music:{stage1:new Sound(`/res/music/stage1.mp3`),stage2:new Sound(`/res/music/stage2.mp3`)},sfx:{jump:new Sound(`/res/sfx/jump.wav`),jumpSpring:new Sound(`/res/sfx/jump-spring.wav`),land:new Sound(`/res/sfx/land.wav`),turnAround:new Sound(`/res/sfx/turn-around.wav`),stomp:new Sound(`/res/sfx/stomp.wav`),damage:new Sound(`/res/sfx/damage.wav`),collectCoin:new Sound(`/res/sfx/coin.wav`)},tiled:{level1:new ub(`/res/tilemaps/level1.tmx`,{useTilemapCameraStrategy:!0})}};var DevLoader=class extends dm{showPlayButton(){return Promise.resolve()}draw(){}dispose(){}static __type=[()=>dm,`showPlayButton`,`draw`,`dispose`,`DevLoader`,`P7!P"0"P"0#P"0$5w%`]};const fb=new DevLoader;for(let e of Object.values(db))for(let R of Object.values(e))fb.addResource(R);function __assignType$19(e,R){return e.__type=R,e}__name$1(__assignType$19,`__assignType`);var OneWayCollisionComponent=class extends Component{type=`one-way-collision`;onAdd(e){let R=e.onPreCollisionResolve.bind(e);e.onPreCollisionResolve=__assignType$19((...e)=>{this.onPreCollisionResolve(...e),R(...e)},[`args`,``,`P"@2!"/"`])}onPreCollisionResolve(e,R,W,Y){if(!(R.owner instanceof $p))return;let X=R.owner.pos.sub(R.owner.oldPos),ie=R.bounds.bottom-X.y<e.bounds.top+1;if(W!==Mf.Top||!ie){Y.cancel();return}}static __type=[()=>Component,`type`,function(){return`one-way-collision`},`owner`,`onAdd`,`self`,`other`,`side`,`contact`,`onPreCollisionResolve`,`OneWayCollisionComponent`,`P7!&3">#P!2$$0%P!2&!2'!2(!2)$0*5w+`]};function __assignType$18(e,R){return e.__type=R,e}__name$1(__assignType$18,`__assignType`);const pb=[`Ground`,()=>1,`Player`,()=>2,`Enemy`,()=>4,`Item`,()=>8,`PhysicalItem`,()=>16,`Hazard`,()=>32,`Climbable`,()=>64,`Category`,`PC!>"C#>$C%>&C'>(C)>*C+>,C->.Bw/`],mb={Ground:new Ef(`ground`,1,collideWith(2,4,16)),Player:new Ef(`player`,2,collideWith(1,4,8,32,16,64)),Enemy:new Ef(`enemy`,4,collideWith(1,2)),Hazard:new Ef(`hazard`,32,collideWith(2)),Item:new Ef(`item`,8,collideWith(2)),PhysicalItem:new Ef(`phys-item`,16,collideWith(1,2)),Climbable:new Ef(`climbable`,64,collideWith(2))};function collideWith(...e){return e.reduce(__assignType$18((e,R)=>e|R,[`acc`,`cat`,``,`P"2!"2""/#`]),0)}collideWith.__type=[()=>pb,`categories`,`collideWith`,`Pn!@2""/#`];var OneWayPlatform=class extends $p{constructor(e){super({...e,collisionType:xf.Fixed,collisionGroup:mb.Ground,anchor:vec(0,0),height:16}),this.addComponent(new OneWayCollisionComponent)}static __type=[()=>$p,`args`,`constructor`,`OneWayPlatform`,`P7!P!2""0#5w$`]};const hb=[`K`,`T`,`Record`,`l'e#"Rb!b"Pde"!N#!w#y`];function __assignType$17(e,R){return e.__type=R,e}__name$1(__assignType$17,`__assignType`);var AnimationComponent=class extends Component{type=`animation`;_animations;_speed=1;_frameDurations=(WeakMap.Ω=[[`!`],[`'`]],new WeakMap);constructor(e){super(),this._animations=e}set(e,R=0,W){let Y=this.owner.graphics.current,X=this._animations[e];this.is(e)||(R?X.goToFrame(R,W):X.reset(),Y&&(X.scale.setTo(Y.scale.x,Y.scale.y),X.opacity=Y.opacity),this.owner.graphics.use(X))}get(e){return this._animations[e]}set speed(e){this._speed=e,e!==0&&this.current.frames.forEach(__assignType$17(R=>{this._frameDurations.has(R)||this._frameDurations.set(R,R.duration??0),R.duration=this._frameDurations.get(R)/e},[`frame`,``,`P"2!"/"`]))}get speed(){return this._speed}get current(){return this.owner.graphics.current}is(e){return this.current===this.get(e)}static __type=[`Keys`,()=>Component,`graphics`,`owner`,`type`,function(){return`animation`},()=>hb,`_animations`,`_speed`,function(){return 1},`_frameDurations`,function(){return WeakMap.Ω=[[`!`],[`'`]],new WeakMap},()=>hb,`animations`,`constructor`,`name`,`startFromFrame`,`durationLeft`,`set`,`get`,`animation`,`is`,`AnimationComponent`,`b!P7"P!P!4#MK3$&3%>&e!!!o'#3(;'3);>*!3+;>,Pe"!!o-#2."0/Pe"!20"21'228"03Pe"!20"04!!Pe"!25"065w7`]};function __assignType$16(e,R){return e.__type=R,e}__name$1(__assignType$16,`__assignType`);var ControlsComponent=class extends Component{type=`input`;controls={Left:[gm.Left,hm.DpadLeft],Right:[gm.Right,hm.DpadRight],Up:[gm.Up,hm.DpadUp],Down:[gm.Down,hm.DpadDown],Jump:[gm.A,hm.Face1],Run:[gm.S,hm.Face3]};isHeld(e){let R=this.owner.scene.engine,[W,Y]=this.controls[e];return!!(R.input.keyboard.isHeld(W)||this.getGamepad()?.isButtonHeld(Y))}wasPressed(e){let R=this.owner.scene.engine,[W,Y]=this.controls[e];return!!(R.input.keyboard.wasPressed(W)||this.getGamepad()?.wasButtonPressed(Y))}wasReleased(e){let R=this.owner.scene.engine,[W,Y]=this.controls[e];return!!(R.input.keyboard.wasReleased(W)||this.getGamepad()?.wasButtonReleased(Y))}getGamepad(){let e=this.owner.scene.engine;return[e.input.gamepads.at(0),e.input.gamepads.at(1),e.input.gamepads.at(2),e.input.gamepads.at(3)].find(__assignType$16(e=>e.connected,[`g`,``,`P"2!"/"`]))}getHeldXDirection(){let e=this.owner.scene.engine;for(let R of e.input.keyboard.getKeys().slice().reverse()){if(this.controls.Left.includes(R))return`Left`;if(this.controls.Right.includes(R))return`Right`}if(this.getGamepad()){if(this.isHeld(`Left`))return`Left`;if(this.isHeld(`Right`))return`Right`}}getHeldYDirection(){let e=this.owner.scene.engine;for(let R of e.input.keyboard.getKeys().slice().reverse()){if(this.controls.Up.includes(R))return`Up`;if(this.controls.Down.includes(R))return`Down`}if(this.getGamepad()){if(this.isHeld(`Up`))return`Up`;if(this.isHeld(`Down`))return`Down`}}static __type=[()=>Component,`owner`,`type`,function(){return`input`},`controls`,function(){return{Left:[gm.Left,hm.DpadLeft],Right:[gm.Right,hm.DpadRight],Up:[gm.Up,hm.DpadUp],Down:[gm.Down,hm.DpadDown],Jump:[gm.A,hm.Face1],Run:[gm.S,hm.Face3]}},()=>this.controls,`control`,`isHeld`,()=>this.controls,`wasPressed`,()=>this.controls,`wasReleased`,`getGamepad`,`Left`,`Right`,`getHeldXDirection`,`Up`,`Down`,`getHeldYDirection`,`ControlsComponent`,`P7!!3"&3#>$!3%>&Pi'g2("0)Pi*g2("0+Pi,g2("0-P"0.PP./.0-J01PP.2.3-J045w5`]},ClimbableComponent=class extends Component{static __type=[()=>Component,`ClimbableComponent`,`P7!5w"`]};function __assignType$15(e,R){return e.__type=R,e}__name$1(__assignType$15,`__assignType`);const gb=[`left`,`right`,`top`,`bottom`,`Side`,`P.!.".#.$Jw%y`];var TouchingComponent=class extends Component{type=`touching`;contacts=(Map.Ω=[[`&`],[`contact`,`actor`,()=>gb,`side`,`P!4!!4"n#4$M`]],new Map);left=(Set.Ω=[[`!`]],new Set);right=(Set.Ω=[[`!`]],new Set);top=(Set.Ω=[[`!`]],new Set);bottom=(Set.Ω=[[`!`]],new Set);passives=(Set.Ω=[[`!`]],new Set);onAdd(e){e.on(`collisionstart`,__assignType$15(e=>{let R=e.other.owner;if(R)if(R.get(rm)?.collisionType===xf.Passive)this.passives.add(R);else{let W=e.side.toLowerCase();this.contacts.set(e.contact.id,{contact:e.contact,actor:R,side:W}),this.updateSides()}},[`ev`,``,`P"2!"/"`])),e.on(`collisionend`,__assignType$15(e=>{let R=e.other.owner;R?.get(rm)?.collisionType===xf.Passive?this.passives.delete(R):(this.contacts.delete(e.lastContact.id),this.updateSides())},[`ev`,``,`P"2!"/"`]))}updateSides(){this.left.clear(),this.right.clear(),this.top.clear(),this.bottom.clear();for(let{side:e,actor:R}of this.contacts.values())this[e].add(R)}get ladders(){return new Set(Array.from(this.passives).filter(__assignType$15(e=>e.has(ClimbableComponent),[`e`,``,`P"2!"/"`])))}static __type=[()=>Component,`type`,function(){return`touching`},`contacts`,function(){return Map.Ω=[[`&`],[`contact`,`actor`,()=>gb,`side`,`P!4!!4"n#4$M`]],new Map},`left`,function(){return Set.Ω=[[`!`]],new Set},`right`,function(){return Set.Ω=[[`!`]],new Set},`top`,function(){return Set.Ω=[[`!`]],new Set},`bottom`,function(){return Set.Ω=[[`!`]],new Set},`passives`,function(){return Set.Ω=[[`!`]],new Set},`owner`,`onAdd`,`updateSides`,`TouchingComponent`,`P7!&3">#!3$;>%!3&>'!3(>)!3*>+!3,>-!3.>/P!20$01P"02;!5w3`]},CarrierComponent=class extends Component{type=`carrier`;onAdd(e){e.on(`collisionstart`,this.onCollisionStart.bind(this)),e.on(`collisionend`,this.onCollisionEnd.bind(this)),e.on(`initialize`,this.onInitialize.bind(this))}onInitialize(){let e=this.owner;e.once(`postupdate`,()=>{--e.pos.y,e.once(`preupdate`,()=>{e.pos.y+=1})})}onCollisionStart(e){let R=e.other.owner;R.get(CarriableComponent)?.canBeCarried&&e.side===Mf.Top&&!this.owner.children.includes(R)&&this.addChild(R)}onCollisionEnd(e){let R=e.other.owner;this.owner.children.includes(R)&&this.removeChild(R)}addChild(e){this.owner.addChild(e),e.pos.x-=this.owner.pos.x,e.pos.y-=this.owner.pos.y}removeChild(e){this.owner.removeChild(e),this.owner.scene.add(e),e.pos.x+=this.owner.pos.x,e.pos.y+=this.owner.pos.y}static __type=[()=>Component,`owner`,`type`,function(){return`carrier`},`onAdd`,`onInitialize`,`event`,`onCollisionStart`,`onCollisionEnd`,`actor`,`addChild`,`removeChild`,`CarrierComponent`,`P7!!3"&3#>$P!2"$0%P$0&P!2'$0(P!2'$0)P!2*"0+P!2*"0,5w-`]},CarriableComponent=class extends Component{canBeCarried=!0;static __type=[()=>Component,`owner`,`canBeCarried`,function(){return!0},`CarriableComponent`,`P7!!3")3#>$5w%`]};const _b=[`T`,`K`,()=>vb,()=>yb,`Omit`,`b!b"e!!e!!ge!"o$#o##w%y`],vb=[`T`,`K`,`Pick`,`l+e#!e"!fRb!b"Pde""N#!w#y`],yb=[`T`,`U`,`Exclude`,`l6!Re$!RPe#!e$"qk#%QRb!b"Pde"!p)w#y`];function __assignType$14(e,R){return e.__type=R,e}__name$1(__assignType$14,`__assignType`);var PhysicsActor=class extends $p{touching=new TouchingComponent;isOnGround=!1;_oldPosGlobal=vec(0,0);_ray1=new Ray(vec(0,0),vec(1,0));_ray2=new Ray(vec(0,0),vec(1,0));constructor(e){super(e),this.addComponent(new CarriableComponent)}onInitialize(e){this.addComponent(this.touching),this.on(`preupdate`,()=>{this.isOnGround=this.touching.bottom.size>0}),this.on(`postupdate`,()=>{let e=this.getGlobalPos();this._oldPosGlobal.setTo(e.x,e.y)})}get canBeCarried(){return this.get(CarriableComponent).canBeCarried}set canBeCarried(e){this.get(CarriableComponent).canBeCarried=e}raycast(e,R,W){return this.scene.physics.rayCast(e,{maxDistance:R,searchAllColliders:!0,...W}).filter(__assignType$14(e=>e.body!==this.body,[`hit`,``,`P"2!"/"`])).sort(__assignType$14((e,R)=>e.distance-R.distance,[`a`,`b`,``,`P"2!"2""/#`]))}raycastSide(e,R,W){let Y=this.collider.bounds,X=Math.round(Y.left)+1,ie=Math.round(Y.right)-1,ae=Math.round(Y.top)+1,le=Math.round(Y.bottom)-1;if(e===`left`||e===`right`){let R=e===`left`?X:ie,W=e===`left`?-1:1;this._ray1.pos.setTo(R,ae),this._ray1.dir.setTo(W,0),this._ray2.pos.setTo(R,le),this._ray2.dir.setTo(W,0)}else{let R=e===`top`?ae:le,W=e===`top`?-1:1;this._ray1.pos.setTo(X,R),this._ray1.dir.setTo(0,W),this._ray2.pos.setTo(ie,R),this._ray2.dir.setTo(0,W)}let _e=this.raycast(this._ray1,R,W),ye=this.raycast(this._ray2,R,W);if(ye.length===0)return _e;if(_e.length===0)return ye;let be=_e.slice();for(let e of ye)_e.indexOf(e)===-1&&be.push(e);return be}getGlobalOldPos(){return this._oldPosGlobal}static __type=[()=>$p,`touching`,function(){return new TouchingComponent},`isOnGround`,function(){return!1},`_oldPosGlobal`,function(){return vec(0,0)},`_ray1`,function(){return new Ray(vec(0,0),vec(1,0))},`_ray2`,function(){return new Ray(vec(0,0),vec(1,0))},`args`,`constructor`,`_engine`,`onInitialize`,`ray`,`distance`,()=>_b,`maxDistance`,`opts`,`raycast`,`left`,`right`,`top`,`bottom`,`side`,()=>_b,`maxDistance`,`raycastSide`,`getGlobalOldPos`,`PhysicsActor`,`P7!!3">#)3$>%!3&;>'!3(;>)!3*;>+P!2,"0-P!2.$0/!P!20'21!.3o2#248"05PP.6.7.8.9J2:'21!.<o;#248"0=P"0>5w?`]};let bb=null,xb=!1;var Sb=class AudioManager{static levels=(Map.Ω=[[`!`],[`'`]],new Map([[db.music.stage1,.1],[db.music.stage2,.1],[db.sfx.jump,.25],[db.sfx.jumpSpring,.25],[db.sfx.land,.25],[db.sfx.turnAround,.25],[db.sfx.stomp,.25],[db.sfx.damage,.25],[db.sfx.collectCoin,.25]]));static get isMuted(){return xb}static init(e=!1){xb=e;for(let e of Object.values(db))for(let R of Object.values(e))R instanceof Sound&&(R.volume=xb?0:AudioManager.levels.get(R)??1)}static muteAll(){xb=!0;for(let e of Object.values(db))for(let R of Object.values(e))R instanceof Sound&&(R.stop(),R.volume=0)}static unmuteAll(){xb=!1;for(let e of Object.values(db))for(let R of Object.values(e))R instanceof Sound&&(R.volume=AudioManager.levels.get(R)??1);bb&&(bb.play(),bb.loop=!0)}static playSong(e){bb&&bb.stop(),bb=e,xb||bb.play(),bb.loop=!0}static playSfx(e,R={}){if(xb)return;let{volume:W=AudioManager.levels.get(e),force:Y=!1}=R;(Y||!e.isPlaying())&&e.play(W)}static __type=[`levels`,function(){return Map.Ω=[[`!`],[`'`]],new Map([[db.music.stage1,.1],[db.music.stage2,.1],[db.sfx.jump,.25],[db.sfx.jumpSpring,.25],[db.sfx.land,.25],[db.sfx.turnAround,.25],[db.sfx.stomp,.25],[db.sfx.damage,.25],[db.sfx.collectCoin,.25]])},`startMuted`,`init`,`muteAll`,`unmuteAll`,`song`,`playSong`,`sfx`,()=>Cb,`opts`,()=>({}),`playSfx`,`AudioManager`,`!3!s>"!P"2#"0$sP"0%sP"0&sP!2'"0(sP!2)n*2+>,"0-s5w.`]};const Cb=[`volume`,`force`,`PlaySfxOptions`,`P'4!8)4"8Mw#y`],wb=new sf(0,1450),Tb={rows:1,columns:3,spriteWidth:48,spriteHeight:48},Eb={green:{force:500,spritesheet:Sp.fromImageSource({image:db.img.bouncepadGreen,grid:Tb})},red:{force:700,spritesheet:Sp.fromImageSource({image:db.img.bouncepadRed,grid:Tb})}},Db=[()=>Eb,`type`,`BouncepadArgs`,`P!Pi!g4"8MKw#y`];var Bouncepad=class extends $p{COMPRESS_TIME=250;COMPRESS_DISTANCE=2;spritesheet;force;animation;touching=new TouchingComponent;colliderShape;constructor({type:e=`green`,...R}){super({...R,name:`bouncepad`,anchor:vec(.5,1),width:16,height:16,collisionType:xf.Fixed}),this.graphics.offset=vec(0,16),this.pos.x+=this.width*this.anchor.x,this.pos.y+=this.height*this.anchor.y,this.spritesheet=Eb[e].spritesheet,this.force=Eb[e].force,this.animation=new AnimationComponent({neutral:op.fromSpriteSheet(this.spritesheet,[2],0),compressed:op.fromSpriteSheet(this.spritesheet,[1],this.COMPRESS_TIME),released:op.fromSpriteSheet(this.spritesheet,[0,0,0,0,1],150)}),this.colliderShape=tp.Box(16,16,this.anchor),this.collider.set(this.colliderShape),this.addTag(`bouncepad`),this.addComponent(this.animation),this.addComponent(this.touching),this.addComponent(new OneWayCollisionComponent)}onInitialize(e){this.graphics.use(this.animation.get(`neutral`)),this.animation.get(`compressed`).events.on(`loop`,()=>{this.release()}),this.animation.get(`released`).events.on(`loop`,()=>{this.animation.set(`neutral`)})}compress(){if(this.animation.current===this.animation.get(`compressed`))return;this.graphics.use(this.animation.get(`compressed`));let e=this.colliderShape.points[0],R=this.colliderShape.points[1];e.y+=this.COMPRESS_DISTANCE,R.y+=this.COMPRESS_DISTANCE,this.colliderShape.points=this.colliderShape.points;for(let e of this.touching.top)e instanceof $p&&(e.pos.y+=this.COMPRESS_DISTANCE)}release(){if(this.animation.current!==this.animation.get(`compressed`))return;this.graphics.use(this.animation.get(`released`));let e=this.colliderShape.points[0],R=this.colliderShape.points[1];e.y-=this.COMPRESS_DISTANCE,R.y-=this.COMPRESS_DISTANCE,this.colliderShape.points=this.colliderShape.points;for(let e of this.touching.top)e instanceof $p&&(e.pos.y-=this.COMPRESS_DISTANCE,e.vel.y=-this.force,Sb.playSfx(db.sfx.jumpSpring))}onCollisionStart(e,R,W,Y){W===Mf.Top&&R.owner instanceof $p&&this.compress()}static __type=[()=>$p,`COMPRESS_TIME`,function(){return 250},`COMPRESS_DISTANCE`,function(){return 2},`spritesheet`,`force`,`neutral`,`compressed`,`released`,()=>AnimationComponent,`animation`,`touching`,function(){return new TouchingComponent},`colliderShape`,()=>Db,`param0`,`constructor`,`_engine`,`onInitialize`,`compress`,`release`,`self`,`other`,`side`,`_contact`,`onCollisionStart`,`Bouncepad`,`P7!'3">#'3$>%!3&'3'PP.(.).*J7+3,!3->.!3/;Pn021"02P!23$04P"05P"06P!27!28!29!2:$0;5w<`]},StompableComponent=class extends Component{stomped=!1;stomp(){this.stomped||(this.stomped=!0,this.owner.graphics.current.scale=vec(1,.25))}isBeingStomped(e){let R=e.getGlobalPos().sub(e.getGlobalOldPos());return e.collider.bounds.bottom-R.y<this.owner.collider.bounds.top+1}static __type=[()=>Component,`owner`,`stomped`,function(){return!1},`stomp`,`PhysicsActor`,`other`,`isBeingStomped`,`StompableComponent`,`P7!!3")3#>$P"0%P"w&2'"0(5w)`]};const Ob=[`instant`,`stomp`,`KillMethod`,`P.!."Jw#y`],kb=[`stompDuration`,`KillableComponentArgs`,`P'4!8Mw"y`];var KillableComponent=class extends Component{dead=!1;events=(EventEmitter.Ω=[[()=>Ob,`method`,`kill`,`PPn!4"M4#M`]],new EventEmitter);stompDuration=700;constructor({stompDuration:e}={}){super(),this.stompDuration=e??700}kill(e){if(e===`stomp`&&!this.owner.has(StompableComponent))throw Error(`Cannot kill with stomp method: actor does not have a StompableComponent`);if(!this.dead){if(this.dead=!0,this.events.emit(`kill`,{method:e}),e===`instant`)this.owner.kill();else if(e===`stomp`){let e=this.owner.get(StompableComponent);this.owner.actions.callMethod(()=>{e.stomp()}).delay(this.stompDuration*.8).fade(0,this.stompDuration*.2).callMethod(()=>{this.owner.kill()})}}}static __type=[()=>Component,`owner`,`dead`,function(){return!1},`events`,function(){return EventEmitter.Ω=[[()=>Ob,`method`,`kill`,`PPn!4"M4#M`]],new EventEmitter},`stompDuration`,function(){return 700},()=>kb,`param0`,()=>({}),`constructor`,()=>Ob,`method`,`kill`,`KillableComponent`,`P7!!3")3#>$!3%>&'3';>(Pn)2*>+"0,Pn-2."0/5w0`]};const Ab={puff:{spritesheet:Sp.fromImageSource({image:db.img.smokePuff,grid:{rows:1,columns:8,spriteWidth:32,spriteHeight:32}}),get animation(){return op.fromSpriteSheet(this.spritesheet,[0,1,2,3,4,5,6,7],50,ip.End)}},land:{spritesheet:Sp.fromImageSource({image:db.img.smokeLand,grid:{rows:1,columns:3,spriteWidth:32,spriteHeight:32}}),get animation(){return op.fromSpriteSheet(this.spritesheet,[0,0,0,1,1,2],60,ip.End)}}},jb=[`puff`,`land`,`type`,`SmokeArgs`,`P!PP.!."J4#MKw$y`];var Smoke=class extends $p{constructor({type:e,...R}){super({anchor:vec(.5,.5),...R});let W=Ab[e].animation;W.events.on(`end`,()=>{this.kill()}),this.graphics.use(W),e===`puff`&&(this.vel.y=-20)}static __type=[()=>$p,()=>jb,`param0`,`constructor`,`Smoke`,`P7!Pn"2#"0$5w%`]},HealthComponent=class extends Component{_amount;_max;events=(EventEmitter.Ω=[[`die`,`amount`,`change`,`P$4!P'4"M4#M`]],new EventEmitter);constructor({amount:e}){super(),this._max=e,this._amount=e}get max(){return this._max}get amount(){return this._amount}set amount(e){this._amount=e,this.events.emit(`change`,{amount:e}),this._amount<=0&&this.events.emit(`die`)}static __type=[()=>Component,`_amount`,`_max`,`events`,function(){return EventEmitter.Ω=[[`die`,`amount`,`change`,`P$4!P'4"M4#M`]],new EventEmitter},`amount`,`param0`,`constructor`,`HealthComponent`,`P7!'3";'3#;!3$>%PP'4&M2'"0(!!5w)`]};const Mb=[`T`,`args`,``,`ReturnType`,`l>e"!R"RPde#!P"@2"h"!/#qk#'QRb!Pde"!p)w$y`];function __assignType$13(e,R){return e.__type=R,e}__name$1(__assignType$13,`__assignType`);var Nb=class DamageableComponent extends Component{events=(EventEmitter.Ω=[[`amount`,`left`,`right`,`knockback`,`damage`,`PP'4!P.".#J4$8M4%M`]],new EventEmitter);INVINCIBILITY_DURATION=2e3;KNOCKBACK_DURATION=200;isInvincible=!1;isBeingKnockedBack=!1;damage(e,R){if(this.isInvincible)return;let W=this.owner.get(HealthComponent);if(this.events.emit(`damage`,{amount:e,knockback:R}),this.isInvincible=!0,Sb.playSfx(db.sfx.damage),W&&(W.amount-=e),R){let e=100*(R===`left`?-1:1);this.owner.vel=vec(e,-300),this.owner.acc=vec(0,0),this.isBeingKnockedBack=!0}coroutine(this.owner.scene.engine,__assignType$13(function*(){let e=0;for(;e<Math.max(this.KNOCKBACK_DURATION,this.INVINCIBILITY_DURATION);)if(e+=yield 1,this.isBeingKnockedBack&&e>=this.KNOCKBACK_DURATION&&(this.isBeingKnockedBack=!1,this.owner.vel.x=0),e>=this.INVINCIBILITY_DURATION&&(this.isInvincible=!1),this.owner.graphics.current){let R=Math.floor(e/100)%2==0;this.owner.graphics.current.opacity=R?.35:1}this.owner.graphics.current&&(this.owner.graphics.current.opacity=1)},[()=>DamageableComponent,`this`,()=>Mb,``,`PP7!2"!o#"/$`]).bind(this))}static __type=[()=>Component,`owner`,`events`,function(){return EventEmitter.Ω=[[`amount`,`left`,`right`,`knockback`,`damage`,`PP'4!P.".#J4$8M4%M`]],new EventEmitter},`INVINCIBILITY_DURATION`,function(){return 2e3},`KNOCKBACK_DURATION`,function(){return 200},`isInvincible`,function(){return!1},`isBeingKnockedBack`,function(){return!1},`amount`,`left`,`right`,`knockback`,`damage`,`DamageableComponent`,`P7!!3"!3#>$'3%>&'3'>()3)>*)3+>,P'2-P.../J208"015w2`]},CollectableComponent=class extends Component{isCollected=!1;isCollectable=!0;static __type=[()=>Component,`isCollected`,function(){return!1},`isCollectable`,function(){return!0},`CollectableComponent`,`P7!)3">#)3$>%5w&`]};let Pb=3;var Fb=class GameManager{static events=(EventEmitter.Ω=[[()=>Ib,`n!`]],new EventEmitter);static get coins(){return Pb}static set coins(e){e<0&&(e=0),Pb=e,GameManager.events.emit(`coinchange`,{coins:Pb})}static __type=[`events`,function(){return EventEmitter.Ω=[[()=>Ib,`n!`]],new EventEmitter},`GameManager`,`!3!s>"!5w#`]};const Ib=[`coins`,`coinchange`,`GameManagerEvents`,`PP'4!M4"Mw#y`];function __assignType$12(e,R){return e.__type=R,e}__name$1(__assignType$12,`__assignType`);var CoinItem=class extends $p{elapsedMs=0;collected=!1;constructor(e){super({anchor:vec(.5,.75),collisionType:xf.Passive,collisionGroup:mb.Item,width:8,height:8,...e}),this.pos.x+=this.width*this.anchor.x,this.pos.y-=this.height*this.anchor.y,this.addComponent(new CollectableComponent),this.graphics.use(db.img.coin.toSprite())}get collectable(){return this.get(CollectableComponent)}onPreUpdate(e,R){this.elapsedMs+=R,this.pos.y-=Math.sin(this.elapsedMs/200)/10}collect(){!this.collectable.isCollectable||this.collectable.isCollected||(Sb.playSfx(db.sfx.collectCoin,{force:!0}),Fb.coins+=1,this.collectable.isCollected=!0,this.actions.clearActions(),this.actions.runAction(new ParallelActions([new Am(this,__assignType$12(e=>e.moveBy(vec(0,-16),150),[`ctx`,``,`P"2!"/"`])),new Am(this,__assignType$12(e=>e.fade(0,150),[`ctx`,``,`P"2!"/"`]))])).callMethod(()=>{this.kill()}))}onPreCollisionResolve(e,R,W,Y){R.owner instanceof Bb&&(this.collect(),Y.cancel())}static __type=[()=>$p,`elapsedMs`,function(){return 0},`collected`,function(){return!1},`args`,`constructor`,`engine`,`elapsed`,`onPreUpdate`,`collect`,`self`,`other`,`side`,`contact`,`onPreCollisionResolve`,`CoinItem`,`P7!'3">#)3$>%P!2&"0'!P!2('2)$0*P"0+P!2,!2-!2.!2/$005w1`]};function __assignType$11(e,R){return e.__type=R,e}__name$1(__assignType$11,`__assignType`);var LostCoin=class extends CoinItem{touching=new TouchingComponent;LIFETIME=3e3;TIME_UNTIL_COLLECTABLE=500;BOUNCE=1;FRICTION=.1;constructor(e){super({anchor:vec(.5,.5),collisionType:xf.Active,collisionGroup:mb.PhysicalItem,width:8,height:8,z:500,...e}),this.pos.x+=this.width*this.anchor.x,this.pos.y-=this.height*this.anchor.y,this.addComponent(this.touching),this.addComponent(new CarriableComponent),this.graphics.use(db.img.coin.toSprite()),this.collectable.isCollectable=!1}onInitialize(e){this.actions.runAction(new ParallelActions([new Am(this,__assignType$11(e=>e.delay(this.TIME_UNTIL_COLLECTABLE).callMethod(()=>{this.collectable.isCollectable=!0}),[`ctx`,``,`P"2!"/"`])),new Am(this,__assignType$11(e=>e.delay(this.LIFETIME).callMethod(()=>this.kill()),[`ctx`,``,`P"2!"/"`]))]))}onPreUpdate(e,R){this.elapsedMs+=R;let W=Math.floor(this.elapsedMs/50)%2==0;this.graphics.current&&(this.graphics.current.opacity=W?.35:.65)}onPreCollisionResolve(e,R,W,Y){if(R.owner instanceof Bb&&!this.collectable.isCollectable)return Y.cancel();super.onPreCollisionResolve(e,R,W,Y)}onPostCollisionResolve(e,R,W,Y){W===Mf.Bottom||W===Mf.Top?this.vel.x=this.oldVel.x*(1-this.FRICTION):(W==Mf.Left||W==Mf.Right)&&(this.vel.y=this.oldVel.y*(1-this.FRICTION))}onCollisionStart(e,R,W,Y){R.owner instanceof Bb?super.onCollisionStart(e,R,W,Y):W===Mf.Bottom||W===Mf.Top?this.vel.y=this.oldVel.y*-this.BOUNCE:(W==Mf.Left||W==Mf.Right)&&(this.vel.x=this.oldVel.x*-this.BOUNCE)}static __type=[()=>CoinItem,`touching`,function(){return new TouchingComponent},`LIFETIME`,function(){return 3e3},`TIME_UNTIL_COLLECTABLE`,function(){return 500},`BOUNCE`,function(){return 1},`FRICTION`,function(){return .1},`args`,`constructor`,`_engine`,`onInitialize`,`engine`,`elapsed`,`onPreUpdate`,`self`,`other`,`side`,`contact`,`onPreCollisionResolve`,`_contact`,`onPostCollisionResolve`,`onCollisionStart`,`LostCoin`,`P7!!3">#'3$>%'3&>''3(>)'3*>+P!2,"0-P!2.$0/P!20'21$02P!23!24!25!26$07P!23!24!25!28$09P!23!24!25!26$0:5w;`]};const Lb=[`K`,`T`,`Record`,`l'e#"Rb!b"Pde"!N#!w#y`];var CoyoteComponent=class extends Component{actions;counter={};constructor(e){super(),this.actions=e}onAdd(e){e.on(`preupdate`,this.onPreUpdate.bind(this))}onPreUpdate(e){for(let R in this.actions){let W=this.actions[R];W.condition(e.elapsed)?this.counter[R]=W.time:this.counter[R]=Math.max(0,this.counter[R]-e.elapsed)}}allow(e){return this.counter[e]>0}reset(e){this.counter[e]=0}static __type=[`T`,()=>Component,`actions`,()=>Lb,`counter`,function(){return{}},`constructor`,`owner`,`onAdd`,`ev`,`onPreUpdate`,`action`,`allow`,`reset`,`CoyoteComponent`,`b!P7"e!!3#e!!g'o$#3%>&Pe"!2#"0'P!2($0)P!2*"0+Pe"!g2,"0-Pe"!g2,"0.5w/`]},FakeDie=class extends $p{constructor(e){super({...e,collisionType:xf.Active,z:9999}),this.body.useGravity=!1,this.acc.y=wb.y/2,this.graphics.use(new qp({text:`// TODO: die`,color:gf.White,font:new Kp({size:10,family:`sans-serif`})})),this.vel.y=-300,this.vel.x=randomInRange(-100,100)}onPreUpdate(e,R){this.isOffScreen&&this.kill()}static __type=[()=>$p,`args`,`constructor`,`_engine`,`_elapsed`,`onPreUpdate`,`FakeDie`,`P7!P!2""0#P!2$'2%$0&5w'`]};const Rb=[`T`,`args`,``,`ReturnType`,`l>e"!R"RPde#!P"@2"h"!/#qk#'QRb!Pde"!p)w$y`];function __assignType$10(e,R){return e.__type=R,e}__name$1(__assignType$10,`__assignType`);const zb=Sp.fromImageSource({image:db.img.player,grid:{columns:4,rows:7,spriteWidth:48,spriteHeight:48}});var Bb=class Player extends PhysicsActor{JUMP_GRAVITY=wb.y*.5;APEX_GRAVITY=wb.y*.3;MAX_FALL_SPEED=270;WALL_SLIDE_SPEED=80;LADDER_CLIMB_SPEED=75;ACCELERATION=300;STOP_DECELERATION=this.ACCELERATION;GROUND_TURN_DECELERATION=this.ACCELERATION*4;AIR_TURN_DECELERATION=this.ACCELERATION*7;WALK_MAX_VELOCITY=90;RUN_MAX_VELOCITY=150;SPRINT_MAX_VELOCITY=210;SPRINT_TRIGGER_TIME=1e3;JUMP_FORCE=300;RUN_JUMP_FORCE=this.JUMP_FORCE*1.1;SPRINT_JUMP_FORCE=this.JUMP_FORCE*1.2;WALL_JUMP_X_DISTANCE=4;WALL_JUMP_DURATION=70;FX_SQUISH_AMOUNT=8/48;animation=new AnimationComponent({idle:op.fromSpriteSheet(zb,[0,1,2,3],140),run:op.fromSpriteSheet(zb,[4,5,6,7],140),sprint:op.fromSpriteSheet(zb,[8,9,10,11],140),jump:op.fromSpriteSheet(zb,[12],140),fall:op.fromSpriteSheet(zb,[13],140),turn:op.fromSpriteSheet(zb,[16],140),ladder_climb:op.fromSpriteSheet(zb,[20,21],140),wall_slide:op.fromSpriteSheet(zb,[16],100,ip.Loop)});controls=new PlayerControlsComponent;coyote=new CoyoteComponent({jump:{time:70,condition:()=>this.isOnGround}});isUsingJumpGravity=!1;facing=`right`;isClimbingLadder=!1;isSlidingOnWall=!1;isWallJumping=!1;get maxXVelocity(){switch(!0){case this.controls.isSprinting:return this.SPRINT_MAX_VELOCITY;case this.controls.isRunning:return this.RUN_MAX_VELOCITY;default:return this.WALK_MAX_VELOCITY}}get maxFallingVelocity(){switch(!0){case this.isSlidingOnWall:return this.WALL_SLIDE_SPEED;default:return this.MAX_FALL_SPEED}}get bouncepad(){for(let e of this.touching.bottom)if(e.hasTag(`bouncepad`))return e}get isTouchingLadder(){return this.touching.ladders.size>0}get isAboveLadder(){return this.raycastSide(`bottom`,1,{searchAllColliders:!0}).filter(__assignType$10(e=>e.body.owner?.has(ClimbableComponent),[`hit`,``,`P"2!"/"`])).length>0}get isXMovementAllowed(){let{isBeingKnockedBack:e}=this.get(Nb);return!this.isClimbingLadder&&!this.bouncepad&&!this.isWallJumping&&!e}constructor(e){super({...e,name:`player`,anchor:new sf(.5,1),width:16,height:16,collisionType:xf.Active,collisionGroup:mb.Player,collider:tp.Box(12,12,vec(.5,1))}),this.body.useGravity=!1;let R=new Nb;this.addComponent(this.animation),this.addComponent(this.controls),this.addComponent(this.coyote),this.addComponent(R),this.addComponent(new HealthComponent({amount:3})),R.events.on(`damage`,__assignType$10(({amount:e})=>{if(Fb.coins===0)this.scene?.entities.find(__assignType$10(e=>e instanceof FakeDie,[`e`,``,`P"2!"/"`]))||this.scene?.add(new FakeDie({x:this.getGlobalPos().x,y:this.getGlobalPos().y}));else{let R=Fb.coins-e<0?Fb.coins:e;Fb.coins-=R;for(let e=0;e<R;e++)this.scene?.add(new LostCoin({pos:vec(this.facing===`left`?this.collider.bounds.right:this.collider.bounds.left,this.collider.bounds.top),vel:vec(100*(this.facing===`right`?-1:1),-200)}))}},[`param0`,``,`P"2!"/"`])),this.animation.get(`turn`).events.on(`frame`,__assignType$10(e=>{e.frameIndex===0&&Sb.playSfx(db.sfx.turnAround)},[`frame`,``,`P"2!"/"`])),this.animation.get(`sprint`).events.on(`frame`,__assignType$10(e=>{e.frameIndex%2==0&&this.spawnSmokePuffAtFeet(this.facing===`left`?`right`:`left`,vec(-2,0))},[`frame`,``,`P"2!"/"`])),this.animation.get(`turn`).events.on(`frame`,__assignType$10(e=>{this.spawnSmokePuffAtFeet(this.facing===`left`?`right`:`left`)},[`_frame`,``,`P"2!"/"`])),this.animation.get(`wall_slide`).events.on(`loop`,__assignType$10(e=>{this.spawnSmokePuffAtHands(this.facing,vec(randomIntInRange(-1,1),0))},[`_frame`,``,`P"2!"/"`])),this.addTag(`player`),globalThis.player=this}onInitialize(e){super.onInitialize(e),this.graphics.offset=new sf(0,16),this.animation.set(`idle`)}onPreUpdate(e,R){this.isOnGround&&(this.isUsingJumpGravity=!1,this.isWallJumping=!1,this.isSlidingOnWall=!1),this.isTouchingLadder||(this.isClimbingLadder=!1),!this.isOnWall(`right`)&&!this.isOnWall(`left`)&&(this.isSlidingOnWall=!1),this.handleInput(e,R)}update(e,R){let W=!1;this.vel.y<0&&(this.isUsingJumpGravity=this.controls.isHeld(`Jump`)),this.isUsingJumpGravity&&this.vel.y>-10&&this.vel.y<10&&(W=!0),W?this.acc.setTo(0,this.APEX_GRAVITY):this.isUsingJumpGravity?this.acc.setTo(0,this.JUMP_GRAVITY):this.acc.setTo(0,wb.y),this.isClimbingLadder&&(this.acc.setTo(0,0),this.vel.setTo(0,0)),this.vel.y>=this.maxFallingVelocity&&(this.vel.y=this.maxFallingVelocity,this.acc.y=0),super.update(e,R)}onPostUpdate(e,R){let{isBeingKnockedBack:W}=this.get(Nb);this.animation.speed=Math.min(1+(Math.abs(this.vel.x)/200)**2*3,3),this.handleAnimation(),!this.isWallJumping&&!W&&this.applyDeceleration()}onPreCollisionResolve(e,R,W,Y){super.onPreCollisionResolve(e,R,W,Y);let X=R.owner.has(StompableComponent)?R.owner.get(StompableComponent):void 0;X&&X&&!X.stomped&&X.isBeingStomped(this)&&(this.stomp(R.owner),Y.cancel())}onCollisionStart(e,R,W,Y){if(Y.isCanceled())return;let X=R.owner.get(rm);if(X?.collisionType===xf.Fixed||X?.collisionType===xf.Active){let e=this.oldVel.y>0;W===Mf.Bottom&&e&&(R.owner instanceof Bouncepad&&(this.vel.x=0),this.land())}}handleInput(e,R){let W=this.controls.wasPressed(`Jump`),Y=this.controls.isHeld(`Jump`),X=this.controls.getHeldXDirection(),ie=this.controls.getHeldYDirection(),ae=this.isOnWall(`left`,4),le=this.isOnWall(`right`,4);if(X&&this.isXMovementAllowed){let e=X===`Left`?-1:1,R=this.ACCELERATION*e;if(this.facing=e===-1?`left`:`right`,this.acc.x+=R,!this.isOnGround&&this.vel.y>0){let e=this.isOnWall(`right`),R=this.isOnWall(`left`);e&&X===`Right`||R&&X===`Left`?this.isSlidingOnWall=!0:this.isSlidingOnWall=!1}}else this.isSlidingOnWall=!1;ie&&this.climbLadder(),W?this.isClimbingLadder?(this.isClimbingLadder=!1,ie!==`Down`&&this.jump()):this.isOnGround||this.coyote.allow(`jump`)?this.jump():(ae||le)&&this.wallJump(ae?`left`:`right`):!Y&&this.vel.y<0&&this.vel.y>-200&&!this.isClimbingLadder&&(this.vel.y*=.5,this.isUsingJumpGravity=!1)}handleAnimation(){let e=this.animation.current.currentFrameIndex,R=this.animation.current.currentFrameTimeLeft,W=this.controls.getHeldXDirection();if(this.graphics.flipHorizontal=this.facing===`left`,this.isSlidingOnWall)this.animation.is(`wall_slide`)||Sb.playSfx(db.sfx.land),this.animation.set(`wall_slide`);else if(this.isClimbingLadder)this.animation.set(`ladder_climb`),this.vel.y===0&&this.animation.current.goToFrame(0);else if(this.isOnGround){if(this.controls.isTurning)this.animation.set(`turn`);else if(!W||W===`Left`&&this.vel.x<0||W===`Right`&&this.vel.x>0){if(this.controls.isSprinting&&Math.abs(this.vel.x)>this.RUN_MAX_VELOCITY){let W=this.animation.is(`run`);this.animation.set(`sprint`,W?e:0,W?R:0)}else if(this.vel.x!==0){let W=this.animation.is(`sprint`);this.animation.set(`run`,W?e:0,W?R:0)}}else this.animation.set(`idle`);Math.round(this.vel.x)===0&&this.animation.set(`idle`)}else this.vel.y!==0&&(this.vel.y<0?this.animation.set(`jump`):this.animation.set(`fall`));this.animation.is(`jump`)&&this.oldVel.y>=0&&this.vel.y<0&&coroutine(this.scene.engine,__assignType$10(function*(){let e=1+1*this.FX_SQUISH_AMOUNT,R=Xp.EaseOutCubic,W=this.vel.y,Y=0;for(;this.vel.y<W*.25;)Y+=yield 1,Y<70&&this.squishGraphic(R(Math.min(Y,70),1,e,70));for(Y=0;!this.touching.bottom.size;)Y+=yield 1,Y<70&&this.squishGraphic(R(Math.min(Y,70),e,1,140));this.squishGraphic(1)},[()=>Player,`this`,()=>Rb,``,`PP7!2"!o#"/$`]).bind(this))}land(){this.isOnGround=!0,Sb.playSfx(db.sfx.land),this.spawnSmoke(`land`,{pos:vec(this.center.x,this.collider.bounds.bottom-8),scale:vec(.5,.5)});let e=1-this.FX_SQUISH_AMOUNT,R=Xp.EaseOutCubic;coroutine(this.scene.engine,__assignType$10(function*(){let W=0;for(;W<70&&this.isOnGround;)W+=yield 1,this.squishGraphic(R(Math.min(W,70),1,e,70));for(this.squishGraphic(e),W=0;W<70&&this.isOnGround;)W+=yield 1,this.squishGraphic(R(Math.min(W,70),e,1,70));this.squishGraphic(1)},[()=>Player,`this`,()=>Rb,``,`PP7!2"!o#"/$`]).bind(this))}climbLadder(){let e=this.controls.getHeldYDirection();if(this.isTouchingLadder){let R=Array.from(this.touching.ladders).sort(__assignType$10((e,R)=>Math.abs(this.collider.bounds.bottom-e.collider.bounds.bottom)-Math.abs(this.collider.bounds.bottom-R.collider.bounds.bottom),[`a`,`b`,``,`P"2!"2""/#`])).at(0),W=e===`Up`?-1:1,Y=Math.abs(this.pos.x-R.center.x)<8,X=__assignType$10(e=>Math.floor(Math.round(e)/16),[`n`,``,`P'2!"/"`]),ie=X(this.collider.bounds.bottom)===X(R.collider.bounds.bottom);e===`Up`&&!this.isClimbingLadder&&ie&&Y&&(this.isClimbingLadder=!0),this.isClimbingLadder&&(this.pos.x=R.center.x,this.vel.y=this.LADDER_CLIMB_SPEED*W,this.vel.x=0,this.isOnGround&&e===`Down`&&(this.isClimbingLadder=!1))}else this.isAboveLadder&&e===`Down`&&(this.isClimbingLadder=!0,this.pos.y=Math.ceil(this.pos.y)+1)}jump(e,R=!0){if(this.isOnGround=!1,this.coyote.reset(`jump`),this.bouncepad){this.bouncepad.release();return}e===void 0&&(e=this.JUMP_FORCE,this.controls.isSprinting?e=this.SPRINT_JUMP_FORCE:this.controls.isRunning&&(e=this.RUN_JUMP_FORCE)),this.vel.y=-e,R&&Sb.playSfx(db.sfx.jump)}wallJump(e){this.isWallJumping||(this.jump(),this.isWallJumping=!0,this.spawnSmokePuffAtFeet(e,vec(0,-4)),coroutine(this.scene.engine,__assignType$10(function*(){let R=0,W=e===`left`?1:-1,Y=this.WALL_JUMP_X_DISTANCE/(this.WALL_JUMP_DURATION/1e3)*W;for(;R<this.WALL_JUMP_DURATION&&this.isWallJumping;)R+=yield 1,this.vel.x=Y;this.isWallJumping&&(this.controls.getHeldXDirection()||(this.vel.x=0)),this.isWallJumping=!1},[()=>Player,`this`,()=>Rb,``,`PP7!2"!o#"/$`]).bind(this)))}stomp(e){let R=e.get(KillableComponent);if(R.dead)return;this.land(),R.kill(`stomp`),Sb.playSfx(db.sfx.stomp);let W=this.controls.isSprinting?this.SPRINT_JUMP_FORCE:this.RUN_JUMP_FORCE;this.jump(W,!1)}isOnWall(e,R=1){return this.raycastSide(e,R,{filter:__assignType$10(e=>e.body.group===mb.Ground,[`hit`,``,`P"2!"/"`])}).length>0}applyDeceleration(){let e=this.isOnGround,R=Math.abs(this.vel.x)>this.maxXVelocity;e?this.controls.isTurning?this.acc.x=-this.GROUND_TURN_DECELERATION*Math.sign(this.vel.x):(!this.controls.isMoving||R)&&this.vel.x!==0&&(this.acc.x=-this.STOP_DECELERATION*Math.sign(this.vel.x)):this.controls.isTurning?this.acc.x=-this.AIR_TURN_DECELERATION*Math.sign(this.vel.x):R&&(this.vel.x=clamp(this.vel.x,-this.maxXVelocity,this.maxXVelocity),this.acc.x=0),Math.sign(this.vel.x)!==0&&Math.sign(this.vel.x)!==Math.sign(this.acc.x)&&Math.abs(this.vel.x)<1&&(this.vel.x=0,this.acc.x=0)}squishGraphic(e){let R=e,W=2-R;this.graphics.current.scale=vec(W,R)}spawnSmoke(e,R){this.scene?.add(new Smoke({type:e,z:this.z+1,...R}))}spawnSmokePuffAtFeet(e,R=vec(0,0)){this.spawnSmoke(`puff`,{pos:vec(e===`left`?this.collider.bounds.left+R.x:this.collider.bounds.right-R.x,this.collider.bounds.bottom+R.y),scale:vec(.35,.35)})}spawnSmokePuffAtHands(e,R=vec(0,0)){this.spawnSmoke(`puff`,{pos:vec(e===`left`?this.collider.bounds.left+R.x:this.collider.bounds.right-R.x,this.center.y+R.y),scale:vec(.35,.35)})}static __type=[()=>PhysicsActor,`JUMP_GRAVITY`,function(){return wb.y*.5},`APEX_GRAVITY`,function(){return wb.y*.3},`MAX_FALL_SPEED`,function(){return 270},`WALL_SLIDE_SPEED`,function(){return 80},`LADDER_CLIMB_SPEED`,function(){return 75},`ACCELERATION`,function(){return 300},`STOP_DECELERATION`,function(){return this.ACCELERATION},`GROUND_TURN_DECELERATION`,function(){return this.ACCELERATION*4},`AIR_TURN_DECELERATION`,function(){return this.ACCELERATION*7},`WALK_MAX_VELOCITY`,function(){return 90},`RUN_MAX_VELOCITY`,function(){return 150},`SPRINT_MAX_VELOCITY`,function(){return 210},`SPRINT_TRIGGER_TIME`,function(){return 1e3},`JUMP_FORCE`,function(){return 300},`RUN_JUMP_FORCE`,function(){return this.JUMP_FORCE*1.1},`SPRINT_JUMP_FORCE`,function(){return this.JUMP_FORCE*1.2},`WALL_JUMP_X_DISTANCE`,function(){return 4},`WALL_JUMP_DURATION`,function(){return 70},`FX_SQUISH_AMOUNT`,function(){return 8/48},`animation`,function(){return new AnimationComponent({idle:op.fromSpriteSheet(zb,[0,1,2,3],140),run:op.fromSpriteSheet(zb,[4,5,6,7],140),sprint:op.fromSpriteSheet(zb,[8,9,10,11],140),jump:op.fromSpriteSheet(zb,[12],140),fall:op.fromSpriteSheet(zb,[13],140),turn:op.fromSpriteSheet(zb,[16],140),ladder_climb:op.fromSpriteSheet(zb,[20,21],140),wall_slide:op.fromSpriteSheet(zb,[16],100,ip.Loop)})},`controls`,function(){return new PlayerControlsComponent},`coyote`,function(){return new CoyoteComponent({jump:{time:70,condition:()=>this.isOnGround}})},`isUsingJumpGravity`,function(){return!1},`left`,`right`,`facing`,function(){return`right`},`isClimbingLadder`,function(){return!1},`isSlidingOnWall`,function(){return!1},`isWallJumping`,function(){return!1},`x`,`y`,`z`,`args`,`constructor`,`engine`,`onInitialize`,`elapsed`,`onPreUpdate`,`update`,`_engine`,`_elapsed`,`onPostUpdate`,`self`,`other`,`side`,`contact`,`onPreCollisionResolve`,`onCollisionStart`,`handleInput`,`handleAnimation`,`land`,`climbLadder`,`force`,`playSfx`,`jump`,`left`,`right`,`wallJump`,`stomp`,`left`,`right`,`distance`,`isOnWall`,`applyDeceleration`,`scale`,`squishGraphic`,`puff`,`land`,`type`,`pos`,`spawnSmoke`,`left`,`right`,`offset`,`spawnSmokePuffAtFeet`,`left`,`right`,`spawnSmokePuffAtHands`,`Player`,`P7!!3">#!3$>%'3&>''3(>)'3*>+'3,>-!3.>/!30>1!32>3'34>5'36>7'38>9'3:>;'3<>=!3>>?!3@>A'3B>C'3D>E!3F>G!3H>I!3J>K!3L>M)3N>OP.P.QJ3R>S)3T>U)3V>W)3X>Y!!!!!!PP'4Z'4['4\\8M2]"0^P!2_"0\`P!2_'2a$0bP!2_'2a$0cP!2d'2e$0fP!2g!2h!2i!2j$0kP!2g!2h!2i!2j$0lP!2d'2e"0mP"0nP"0oP"0pP'2q8"2r"0sPP.t.uJ2i"0vP!2h"0wPP.x.yJ2i"2z"0{P"0|P'2}"0~PP..J2P!4!4}8M2]"0PP..
J2i"2"0PP..J2i"2"05w`]},PlayerControlsComponent=class extends ControlsComponent{sprintTimer=0;onAdd(e){super.onAdd?.(e),e.on(`postupdate`,__assignType$10(({elapsed:e})=>{let R=this.owner.isOnGround,W=!R&&!this.isSprinting,Y=this.isTurning&&R;this.isRunning&&R&&!Y?this.sprintTimer=Math.min(this.sprintTimer+e,this.owner.SPRINT_TRIGGER_TIME):(!this.isRunning||Y||W)&&(this.sprintTimer=0)},[`param0`,``,`P"2!"/"`]))}get isMoving(){return this.getHeldXDirection()!==void 0}get isRunning(){return this.isMoving&&this.isHeld(`Run`)}get isSprinting(){return this.isRunning&&this.sprintTimer>=this.owner.SPRINT_TRIGGER_TIME}get isTurning(){let e=this.getHeldXDirection(),{isBeingKnockedBack:R}=this.owner.get(Nb);return R?!1:e===`Left`&&this.owner.vel.x>0||e===`Right`&&this.owner.vel.x<0}static __type=[()=>ControlsComponent,()=>Bb,`owner`,`sprintTimer`,function(){return 0},()=>Bb,`onAdd`,`PlayerControlsComponent`,`P7!P7"3#'3$>%PP7&2#$0'!!!!5w(`]};function __assignType$9(e,R){return e.__type=R,e}__name$1(__assignType$9,`__assignType`);var ScrollingBackground=class extends Of{xSpeed;ySpeed;image;graphics=new Jp;transform=new Sf;constructor(e){let{xSpeed:R=.25,ySpeed:W=.1,z:Y=-100,image:X}=e;super(),this.addComponent(this.graphics),this.addComponent(this.transform),this.image=X,this.xSpeed=R,this.ySpeed=W,this.graphics.anchor=vec(.5,.5),this.transform.pos=vec(0,0),this.transform.z=Y}onInitialize(e){let R=this.image.toSprite(),W=this.scene.camera.viewport.width,Y=this.scene.camera.viewport.height,X=Math.ceil(W/R.width)+1,ie=Math.ceil(Y/R.height)+1;this.graphics.use(new sp({members:Array.from({length:X*ie}).map(__assignType$9((e,W)=>{let Y=W%X,ae=Math.floor(W/ie);return{graphic:R,offset:vec(R.width*Y,R.height*ae)}},[`_`,`i`,``,`P"2!"2""/#`]))})),this.on(`pretransformdraw`,()=>{let W=this.scene.camera,Y=W.drawPos.x-e.halfDrawWidth,X=W.drawPos.y-e.halfDrawHeight;this.transform.pos.x=Y,this.transform.pos.y=X;let ie=Y*-this.xSpeed%R.width+R.width,ae=X*-this.ySpeed%R.height+R.height;this.graphics.offset.setTo(ie,ae)})}static __type=[()=>Of,`xSpeed`,`ySpeed`,`image`,`graphics`,function(){return new Jp},`transform`,function(){return new Sf},`z`,`args`,`constructor`,`_engine`,`onInitialize`,`ScrollingBackground`,`P7!'3"'3#!3$!3%>&!3'>(PP!4$'4"8'4#8'4)8M2*"0+P!2,$0-5w.`]};function __assignType$8(e,R){return e.__type=R,e}__name$1(__assignType$8,`__assignType`);var Tween=class{engine;value;_startValue=0;_targetValue=0;_easing;_duration=0;_elapsed=0;constructor(e,R,W){let{easing:Y=Xp.Linear,duration:X=1e3}=W;this.engine=e,this.value=R,this._startValue=R,this._targetValue=R,this._easing=Y,this._duration=X,e.on(`preupdate`,this.onUpdate)}onUpdate=__assignType$8(e=>{this._elapsed<this._duration&&(this._elapsed=Math.min(this._duration,this._elapsed+e.elapsed),this.value=this._easing(this._elapsed,this._startValue,this._targetValue,this._duration))},[`ev`,``,`P!2!"/"`]);set(e,R=!1){this._elapsed=0,R?(this.value=e,this._startValue=e,this._targetValue=e):(this._startValue=this.value,this._targetValue=e)}destroy(){this.engine.off(`preupdate`,this.onUpdate)}static __type=[`engine`,`value`,`_startValue`,function(){return 0},`_targetValue`,function(){return 0},`_easing`,`_duration`,function(){return 0},`_elapsed`,function(){return 0},`easing`,`duration`,`opts`,`constructor`,`onUpdate`,function(){return __assignType$8(e=>{this._elapsed<this._duration&&(this._elapsed=Math.min(this._duration,this._elapsed+e.elapsed),this.value=this._easing(this._elapsed,this._startValue,this._targetValue,this._duration))},[`ev`,``,`P!2!"/"`])},`immediately`,`set`,`destroy`,`Tween`,`!3!'3"'3#;>$'3%;>&!3';'3(;>)'3*;>+P!2!'2"P!4,8'4-8M2."0/!30>1P'2""22"03P"045w5`]},LockToPlayerStrategy=class{FOLLOW_DAMPING=.5;TURN_TWEEN_DURATION=400;X_EDGE_BUFFER=20;Y_EDGE_BUFFER=40;target;xOffset;facing=`right`;isFirstUpdate=!0;constructor(e){this.target=e,this.xOffset=new Tween(this.target.scene.engine,0,{easing:Xp.Linear,duration:this.TURN_TWEEN_DURATION}),this.turn(`right`,!0)}action(e,R,W,Y){let X=e.getGlobalPos(),ie=X.x-R.pos.x+this.xOffset.value,ae=X.y-R.pos.y,le=ie<-this.X_EDGE_BUFFER,_e=ie>this.X_EDGE_BUFFER,ye=ae<-this.Y_EDGE_BUFFER,be=ae>this.Y_EDGE_BUFFER,Ce=R.pos.x,Te=R.pos.y;if((le&&this.facing!==`left`||_e&&this.facing!==`right`)&&this.turn(le?`left`:`right`),le?Ce=X.x+this.X_EDGE_BUFFER+this.xOffset.value:_e&&(Ce=X.x-this.X_EDGE_BUFFER+this.xOffset.value),(ye||be)&&(Te=ye?X.y+this.Y_EDGE_BUFFER:X.y-this.Y_EDGE_BUFFER),this.isFirstUpdate)return this.isFirstUpdate=!1,vec(Ce,Te);if(le||_e){let e=Ce-R.pos.x,W=Te-R.pos.y;Math.abs(e)>.1&&(Ce-=e*this.FOLLOW_DAMPING),Math.abs(W)>.1&&(Te-=W*this.FOLLOW_DAMPING)}return vec(Ce,Te)}turn(e,R=!1){this.facing=e,e===`left`?this.xOffset.set(-this.X_EDGE_BUFFER*4,R):this.xOffset.set(this.X_EDGE_BUFFER*4,R)}static __type=[`FOLLOW_DAMPING`,function(){return .5},`TURN_TWEEN_DURATION`,function(){return 400},`X_EDGE_BUFFER`,function(){return 20},`Y_EDGE_BUFFER`,function(){return 40},`Player`,`target`,()=>Tween,`xOffset`,`left`,`right`,`facing`,function(){return`right`},`isFirstUpdate`,function(){return!0},`constructor`,`camera`,`_engine`,`_elapsed`,`action`,`left`,`right`,`direction`,`immediately`,`turn`,`LockToPlayerStrategy`,`'3!>"'3#>$'3%>&'3'>("w)3*P7+3,P.-..J3/>0)31;>2P"w)2*"03P"w)2*!24!25'26"07PP.8.9J2:"2;"0<5"x"w=`]},DamageComponent=class extends Component{amount;cancelContactOnDamage;constructor({amount:e,cancelContactOnDamage:R}){super(),this.amount=e,this.cancelContactOnDamage=R??!0}onAdd(e){e.on(`precollision`,this.onPreCollisionResolve.bind(this))}onPreCollisionResolve(e){let R=this.owner.get(KillableComponent),W=this.owner.get(StompableComponent),Y=R?.dead??!1,X=e.other.owner,ie=X.get(Nb),ae=X instanceof PhysicsActor&&W?.isBeingStomped(X);ie&&(this.cancelContactOnDamage&&e.contact.cancel(),!Y&&!ae&&ie.damage(this.amount,X.center.x<this.owner.center.x?`left`:`right`))}static __type=[()=>Component,`owner`,`amount`,`cancelContactOnDamage`,`param0`,`constructor`,`onAdd`,`event`,`onPreCollisionResolve`,`DamageComponent`,`P7!!3"'3#)3$PP'4#)4$8M2%"0&P!2"$0'P!2("0)5w*`]};const Vb=[`stompDuration`,`EnemyActorArgs`,`P!P'4!8MKw"y`];var Hb=class EnemyActor extends PhysicsActor{killable;stompable;constructor({stompDuration:e,...R}){super({collisionType:xf.Active,collisionGroup:mb.Enemy,...R}),this.killable=new KillableComponent({stompDuration:e}),this.stompable=new StompableComponent,this.addComponent(new DamageComponent({amount:1})),this.addComponent(this.stompable),this.addComponent(this.killable),this.killable.events.on(`kill`,this.onKill.bind(this))}get dead(){return this.killable.dead}set dead(e){this.killable.dead=e}onPreCollisionResolve(e,R,W,Y){R.owner instanceof EnemyActor&&Y.cancel()}onKill(){}static __type=[()=>PhysicsActor,()=>KillableComponent,`killable`,()=>StompableComponent,`stompable`,()=>Vb,`param0`,`constructor`,`self`,`other`,`side`,`contact`,`onPreCollisionResolve`,`onKill`,`EnemyActor`,`P7!P7"3#<P7$3%<Pn&2'"0(!P!2)!2*!2+!2,$0-P"0.5w/`]};const Ub={rows:1,columns:3,spriteWidth:64,spriteHeight:48},Wb={green:{speed:20,spritesheet:Sp.fromImageSource({image:db.img.spiderGreen,grid:Ub})},gray:{speed:30,spritesheet:Sp.fromImageSource({image:db.img.spiderGray,grid:Ub})}},Gb=[()=>Wb,`type`,`SpiderEnemyArgs`,`P!Pi!g4"MKw#y`];var SpiderEnemy=class extends Hb{spritesheet;speed;direction=`left`;constructor(e){super({...e,anchor:vec(.5,32/48),collider:tp.Box(24,4,vec(.5,1))}),this.spritesheet=Wb[e.type].spritesheet,this.speed=Wb[e.type].speed,this.graphics.use(op.fromSpriteSheet(this.spritesheet,[0,1,2],2500/this.speed))}onPreUpdate(e,R){if(this.dead)return;let W=this.raycast(new Ray(vec(this.collider.bounds.left+1,Math.round(this.collider.bounds.bottom)-1),sf.Down),1),Y=this.raycast(new Ray(vec(this.collider.bounds.right-1,Math.round(this.collider.bounds.bottom)-1),sf.Down),1),X=this.direction===`left`&&W.length===0,ie=this.direction===`right`&&Y.length===0;(X||ie)&&(this.direction=this.direction===`left`?`right`:`left`),this.graphics.flipHorizontal=this.direction===`right`,this.direction===`left`?this.vel.x=-this.speed:this.vel.x=this.speed}onCollisionStart(e,R,W,Y){R.owner instanceof Bb||R.owner instanceof $p&&R.owner.body.collisionType===xf.Passive||(W===Mf.Left||W===Mf.Right)&&(this.direction=this.direction===`left`?`right`:`left`)}onKill(){this.graphics.current.pause(),this.vel.x=0,this.vel.y=0,this.body.useGravity=!1}static __type=[()=>Hb,`spritesheet`,`speed`,`left`,`right`,`direction`,function(){return`left`},()=>Gb,`args`,`constructor`,`_engine`,`_elapsed`,`onPreUpdate`,`self`,`other`,`side`,`_contact`,`onCollisionStart`,`onKill`,`SpiderEnemy`,`P7!!3"'3#P.$.%J3&>'Pn(2)"0*P!2+'2,$0-P!2.!2/!20!21$02P"035w4`]};function __assignType$7(e,R){return e.__type=R,e}__name$1(__assignType$7,`__assignType`);const Kb=db.img.platform.toSprite(),qb=new mp({image:Kb.image,destSize:{height:16,width:16},sourceView:{x:0,y:0,width:16,height:16}}),Jb=new mp({image:Kb.image,destSize:{height:16,width:16},sourceView:{x:32,y:0,width:16,height:16}}),Yb=new mp({image:Kb.image,destSize:{height:16,width:16},sourceView:{x:16,y:0,width:16,height:16}}),Xb=[`oneWay`,`MovingPlatformArgs`,`P!P)4!8MKw"y`];var MovingPlatform=class extends $p{constructor({oneWay:e=!0,...R},W){super({color:gf.Green,anchor:vec(0,0),collisionType:xf.Fixed,collisionGroup:mb.Ground,...R});let Y=this.width-32;this.graphics.use(new sp({members:[{graphic:qb,offset:vec(0,0)},...Array.from({length:Y/16},__assignType$7((e,R)=>({graphic:Yb,offset:vec(16+R*16,0)}),[`_`,`i`,``,`P"2!"2""/#`])),{graphic:Jb,offset:vec(this.width-16,0)}]})),W(this.actions),this.addComponent(new CarrierComponent),e&&this.addComponent(new OneWayCollisionComponent)}static __type=[()=>$p,()=>Xb,`param0`,`actions`,``,`cb`,`constructor`,`MovingPlatform`,`P7!Pn"2#P!2$#/%2&"0'5w(`]};const Zb=[`x`,`y`,`pos`,`EnemyActor`,``,`spawn`,`EnemySpawnerArgs`,`P'4!'4"P!2#"w$/%4&Mw'y`];var EnemySpawner=class extends $p{OFFSCREEN_BUFFER=100;spawnedInstance=null;canSpawn=!0;spawn;constructor({x:e,y:R,spawn:W}){super({x:e,y:R}),this.spawn=W,this.on(`enterviewport`,()=>{this.spawnInstance()})}spawnInstance(){this.spawnedInstance||!this.canSpawn||(this.canSpawn=!1,this.spawnedInstance=this.spawn(this.pos),this.spawnedInstance.on(`kill`,()=>{this.spawnedInstance=null}),this.scene.engine.add(this.spawnedInstance))}onPreUpdate(e,R){let W=e.currentScene.camera.viewport,Y=this.OFFSCREEN_BUFFER,X=W.left-Y,ie=W.top-Y,ae=W.right+Y,le=W.bottom+Y,{x:_e,y:ye}=this.pos;if(_e<X||_e>ae||ye<ie||ye>le?this.spawnedInstance||(this.canSpawn=!0):this.spawnInstance(),this.spawnedInstance){let e=this.spawnedInstance.getGlobalPos();(e.x<X||e.x>ae||e.y<ie||e.y>le)&&(this.spawnedInstance.kill(),this.spawnedInstance=null)}}static __type=[()=>$p,`OFFSCREEN_BUFFER`,function(){return 100},`EnemyActor`,`spawnedInstance`,function(){return null},`canSpawn`,function(){return!0},`pos`,``,`spawn`,()=>Zb,`param0`,`constructor`,`spawnInstance`,`engine`,`_elapsed`,`onPreUpdate`,`EnemySpawner`,`P7!'3">#P"w$,J3%;>&)3';>(P!2)"w$/*3+Pn,2-"0.P"0/P!20'21$025w3`]};const Qb={rows:1,columns:3,spriteWidth:48,spriteHeight:48},$b={purple:{speed:20,distance:60,spritesheet:Sp.fromImageSource({image:db.img.birdPurple,grid:Qb})},orange:{speed:30,distance:100,spritesheet:Sp.fromImageSource({image:db.img.birdOrange,grid:Qb})}},ex=[()=>$b,`type`,`BirdEnemyArgs`,`P!Pi!g4"MKw#y`];var BirdEnemy=class extends Hb{spritesheet;speed;distance;direction=`left`;elapsedMs=0;deathPosition=null;initialPos;constructor(e){super({...e,stompDuration:1500,anchor:vec(.5,.6),collider:tp.Box(16,5,vec(.5,1)),collisionType:xf.Passive}),this.spritesheet=$b[e.type].spritesheet,this.speed=$b[e.type].speed,this.distance=$b[e.type].distance,this.body.useGravity=!1,this.graphics.use(op.fromSpriteSheet(this.spritesheet,[0,1,2],3e3/this.speed)),this.initialPos=this.pos.clone(),this.canBeCarried=!1}onPreUpdate(e,R){this.elapsedMs+=R,this.dead&&this.deathPosition?(this.vel.y=10,this.pos.x+=Math.sin((this.pos.y-this.deathPosition.y)/2),this.rotation=-Math.sin((this.pos.x-this.deathPosition.x)/50)):(this.graphics.flipHorizontal=this.direction===`right`,this.direction===`left`?this.vel.x=-this.speed:this.vel.x=this.speed,this.pos.y+=Math.sin(this.elapsedMs/(this.speed*10)*Math.PI)*.3),this.pos.x<this.initialPos.x-this.distance?this.direction=`right`:this.pos.x>this.initialPos.x&&(this.direction=`left`)}onKill(){this.deathPosition=this.pos.clone(),this.graphics.current.pause(),this.vel.x=0,this.vel.y=0,this.body.useGravity=!1}static __type=[()=>Hb,`spritesheet`,`speed`,`distance`,`left`,`right`,`direction`,function(){return`left`},`elapsedMs`,function(){return 0},`deathPosition`,function(){return null},`initialPos`,()=>ex,`args`,`constructor`,`engine`,`elapsed`,`onPreUpdate`,`onKill`,`BirdEnemy`,`P7!!3"'3#'3$P.%.&J3'>('3);>*P!,J3+;>,!3-;Pn.2/"00P!21'22$03P"045w5`]},AxeHazard=class extends $p{elapsedMs=0;constructor(e){super({...e,anchor:vec(.5,0),width:12,height:48,rotation:0,collisionType:xf.Passive,collisionGroup:mb.Enemy,collider:tp.Box(28,12,vec(.5,.5),vec(0,42))}),this.body.useGravity=!1,this.graphics.offset=vec(0,-8),this.graphics.use(db.img.axe.toSprite()),this.addComponent(new DamageComponent({amount:1}))}onPreUpdate(e,R){this.elapsedMs+=R;let W=Math.PI/2,Y=this.elapsedMs/1e3;this.rotation=W*Math.cos(Math.sqrt(wb.y/600)*Y)}static __type=[()=>$p,`elapsedMs`,function(){return 0},`args`,`constructor`,`_engine`,`elapsed`,`onPreUpdate`,`AxeHazard`,`P7!'3";>#P!2$"0%P!2&'2'"0(5w)`]};function __assignType$6(e,R){return e.__type=R,e}__name$1(__assignType$6,`__assignType`);var CircularSawHazard=class extends PhysicsActor{direction=1;speed=25;bladeSize={width:24,height:12};lastGroundHit=null;constructor(e){super({...e,name:`circular-saw`,anchor:vec(.5,.5),width:4,height:4,collisionType:xf.Passive,collisionGroup:mb.Enemy}),this.pos.x+=this.width*this.anchor.x,this.pos.y-=this.height*this.anchor.y,this.body.useGravity=!1,this.graphics.use(db.img.circularSaw.toSprite()),this.graphics.offset=vec(0,2);let R=new $p({pos:vec(0,0),anchor:vec(.5,1),width:this.bladeSize.width,height:this.bladeSize.height,collisionType:xf.Passive,collisionGroup:mb.Enemy});R.addComponent(new DamageComponent({amount:1})),this.addChild(R),this.addComponent(new CarriableComponent)}onInitialize(e){this.graphics.material=new RenderTopHalfMaterial(e.graphicsContext,this)}onPreUpdate(e,R){let W=this.direction===1?this.collider.bounds.right+this.bladeSize.width/2:this.collider.bounds.left-this.bladeSize.width/2,Y=this.collider.bounds.bottom-1,[X]=this.raycast(new Ray(vec(W,Y),sf.Down),1,{collisionGroup:mb.Ground}),[ie]=this.raycast(new Ray(vec(W,Y),this.direction===1?sf.Right:sf.Left),1,{collisionGroup:mb.Ground});(!X&&this.lastGroundHit||ie)&&(this.direction*=-1);let ae=this.graphics.current;ae.rotation=(ae.rotation+toRadians(this.speed*5/R))%(Math.PI*2),this.vel.x=this.speed*this.direction,X&&(this.lastGroundHit=X)}static __type=[()=>PhysicsActor,`direction`,function(){return 1},`speed`,function(){return 25},`bladeSize`,function(){return{width:24,height:12}},`lastGroundHit`,function(){return null},`args`,`constructor`,`engine`,`onInitialize`,`_engine`,`elapsed`,`onPreUpdate`,`CircularSawHazard`,`P7!'3">#'3$>%!3&>'P!,J3(>)P!2*"0+P!2,$0-P!2.'2/"005w1`]},RenderTopHalfMaterial=class extends Up{constructor(e,R){super({name:`render-top-half-material`,fragmentSource:`#version 300 es
|
|
1105
|
+
`))}};const Dg={major:4,minor:2,patch:1},Og=N(`$ZodType`,((e,R)=>{var W;e??={},e._zod.def=R,e._zod.bag=e._zod.bag||{},e._zod.version=Dg;let Y=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&Y.unshift(e);for(let R of Y)for(let W of R._zod.onattach)W(e);if(Y.length===0)(W=e._zod).deferred??(W.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{let t=(e,R,W)=>{let Y,X=ce(e);for(let ie of R){if(ie._zod.def.when){if(!ie._zod.def.when(e))continue}else if(X)continue;let R=e.issues.length,ae=ie._zod.check(e);if(ae instanceof Promise&&!1===W?.async)throw new G;if(Y||ae instanceof Promise)Y=(Y??Promise.resolve()).then((async()=>{await ae,e.issues.length!==R&&(X||=ce(e,R))}));else{if(e.issues.length===R)continue;X||=ce(e,R)}}return Y?Y.then((()=>e)):e},A=(R,W,X)=>{if(ce(R))return R.aborted=!0,R;let ie=t(W,Y,X);if(ie instanceof Promise){if(!1===X.async)throw new G;return ie.then((R=>e._zod.parse(R,X)))}return e._zod.parse(ie,X)};e._zod.run=(R,W)=>{if(W.skipChecks)return e._zod.parse(R,W);if(W.direction===`backward`){let Y=e._zod.parse({value:R.value,issues:[]},{...W,skipChecks:!0});return Y instanceof Promise?Y.then((e=>A(e,R,W))):A(Y,R,W)}let X=e._zod.parse(R,W);if(X instanceof Promise){if(!1===W.async)throw new G;return X.then((e=>t(e,Y,W)))}return t(X,Y,W)}}e[`~standard`]={validate:R=>{try{let W=eh(e,R);return W.success?{value:W.data}:{issues:W.error?.issues}}catch{return th(e,R).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:`zod`,version:1}})),kg=N(`$ZodString`,((e,R)=>{Og.init(e,R),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Bt(e._zod.bag),e._zod.parse=(W,Y)=>{if(R.coerce)try{W.value=String(W.value)}catch{}return typeof W.value==`string`||W.issues.push({expected:`string`,code:`invalid_type`,input:W.value,inst:e}),W}})),jg=N(`$ZodStringFormat`,((e,R)=>{_g.init(e,R),kg.init(e,R)})),Mg=N(`$ZodGUID`,((e,R)=>{R.pattern??=uh,jg.init(e,R)})),Ng=N(`$ZodUUID`,((e,R)=>{if(R.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[R.version];if(e===void 0)throw Error(`Invalid UUID version: "${R.version}"`);R.pattern??=je(e)}else R.pattern??=je();jg.init(e,R)})),Pg=N(`$ZodEmail`,((e,R)=>{R.pattern??=mh,jg.init(e,R)})),Fg=N(`$ZodURL`,((e,R)=>{jg.init(e,R),e._zod.check=W=>{try{let Y=W.value.trim(),X=new URL(Y);R.hostname&&(R.hostname.lastIndex=0,R.hostname.test(X.hostname)||W.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:R.hostname.source,input:W.value,inst:e,continue:!R.abort})),R.protocol&&(R.protocol.lastIndex=0,R.protocol.test(X.protocol.endsWith(`:`)?X.protocol.slice(0,-1):X.protocol)||W.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:R.protocol.source,input:W.value,inst:e,continue:!R.abort})),R.normalize?W.value=X.href:W.value=Y;return}catch{W.issues.push({code:`invalid_format`,format:`url`,input:W.value,inst:e,continue:!R.abort})}}})),Ig=N(`$ZodEmoji`,((e,R)=>{R.pattern??=At(),jg.init(e,R)})),Lg=N(`$ZodNanoID`,((e,R)=>{R.pattern??=sh,jg.init(e,R)})),Rg=N(`$ZodCUID`,((e,R)=>{R.pattern??=nh,jg.init(e,R)})),zg=N(`$ZodCUID2`,((e,R)=>{R.pattern??=rh,jg.init(e,R)})),Bg=N(`$ZodULID`,((e,R)=>{R.pattern??=ih,jg.init(e,R)})),Vg=N(`$ZodXID`,((e,R)=>{R.pattern??=ah,jg.init(e,R)})),Hg=N(`$ZodKSUID`,((e,R)=>{R.pattern??=oh,jg.init(e,R)})),Ug=N(`$ZodISODateTime`,((e,R)=>{R.pattern??=ft(R),jg.init(e,R)})),Wg=N(`$ZodISODate`,((e,R)=>{R.pattern??=jh,jg.init(e,R)})),Gg=N(`$ZodISOTime`,((e,R)=>{R.pattern??=pt(R),jg.init(e,R)})),Kg=N(`$ZodISODuration`,((e,R)=>{R.pattern??=ch,jg.init(e,R)})),qg=N(`$ZodIPv4`,((e,R)=>{R.pattern??=xh,jg.init(e,R),e._zod.bag.format=`ipv4`})),Jg=N(`$ZodIPv6`,((e,R)=>{R.pattern??=Sh,jg.init(e,R),e._zod.bag.format=`ipv6`,e._zod.check=W=>{try{new URL(`http://[${W.value}]`)}catch{W.issues.push({code:`invalid_format`,format:`ipv6`,input:W.value,inst:e,continue:!R.abort})}}})),Yg=N(`$ZodMAC`,((e,R)=>{R.pattern??=ot(R.delimiter),jg.init(e,R),e._zod.bag.format=`mac`})),Xg=N(`$ZodCIDRv4`,((e,R)=>{R.pattern??=Ch,jg.init(e,R)})),Zg=N(`$ZodCIDRv6`,((e,R)=>{R.pattern??=wh,jg.init(e,R),e._zod.check=W=>{let Y=W.value.split(`/`);try{if(Y.length!==2)throw Error();let[e,R]=Y;if(!R)throw Error();let W=Number(R);if(`${W}`!==R||W<0||W>128)throw Error();new URL(`http://[${e}]`)}catch{W.issues.push({code:`invalid_format`,format:`cidrv6`,input:W.value,inst:e,continue:!R.abort})}}}));function OA(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Qg=N(`$ZodBase64`,((e,R)=>{R.pattern??=Th,jg.init(e,R),e._zod.bag.contentEncoding=`base64`,e._zod.check=W=>{OA(W.value)||W.issues.push({code:`invalid_format`,format:`base64`,input:W.value,inst:e,continue:!R.abort})}})),$g=N(`$ZodBase64URL`,((e,R)=>{R.pattern??=Eh,jg.init(e,R),e._zod.bag.contentEncoding=`base64url`,e._zod.check=W=>{(function(e){if(!Eh.test(e))return!1;let R=e.replace(/[-_]/g,(e=>e===`-`?`+`:`/`));return OA(R.padEnd(4*Math.ceil(R.length/4),`=`))})(W.value)||W.issues.push({code:`invalid_format`,format:`base64url`,input:W.value,inst:e,continue:!R.abort})}})),e_=N(`$ZodE164`,((e,R)=>{R.pattern??=kh,jg.init(e,R)})),t_=N(`$ZodJWT`,((e,R)=>{jg.init(e,R),e._zod.check=W=>{(function(e,R=null){try{let W=e.split(`.`);if(W.length!==3)return!1;let[Y]=W;if(!Y)return!1;let X=JSON.parse(atob(Y));return!(`typ`in X&&X?.typ!==`JWT`||!X.alg||R&&(!(`alg`in X)||X.alg!==R))}catch{return!1}})(W.value,R.alg)||W.issues.push({code:`invalid_format`,format:`jwt`,input:W.value,inst:e,continue:!R.abort})}})),n_=N(`$ZodCustomStringFormat`,((e,R)=>{jg.init(e,R),e._zod.check=W=>{R.fn(W.value)||W.issues.push({code:`invalid_format`,format:R.format,input:W.value,inst:e,continue:!R.abort})}})),r_=N(`$ZodNumber`,((e,R)=>{Og.init(e,R),e._zod.pattern=e._zod.bag.pattern??Ph,e._zod.parse=(W,Y)=>{if(R.coerce)try{W.value=Number(W.value)}catch{}let X=W.value;if(typeof X==`number`&&!Number.isNaN(X)&&Number.isFinite(X))return W;let ie=typeof X==`number`?Number.isNaN(X)?`NaN`:Number.isFinite(X)?void 0:`Infinity`:void 0;return W.issues.push({expected:`number`,code:`invalid_type`,input:X,inst:e,...ie?{received:ie}:{}}),W}})),i_=N(`$ZodNumberFormat`,((e,R)=>{lg.init(e,R),r_.init(e,R)})),a_=N(`$ZodBoolean`,((e,R)=>{Og.init(e,R),e._zod.pattern=Fh,e._zod.parse=(W,Y)=>{if(R.coerce)try{W.value=!!W.value}catch{}let X=W.value;return typeof X==`boolean`||W.issues.push({expected:`boolean`,code:`invalid_type`,input:X,inst:e}),W}})),o_=N(`$ZodBigInt`,((e,R)=>{Og.init(e,R),e._zod.pattern=Mh,e._zod.parse=(W,Y)=>{if(R.coerce)try{W.value=BigInt(W.value)}catch{}return typeof W.value==`bigint`||W.issues.push({expected:`bigint`,code:`invalid_type`,input:W.value,inst:e}),W}})),s_=N(`$ZodBigIntFormat`,((e,R)=>{ug.init(e,R),o_.init(e,R)})),c_=N(`$ZodSymbol`,((e,R)=>{Og.init(e,R),e._zod.parse=(R,W)=>{let Y=R.value;return typeof Y==`symbol`||R.issues.push({expected:`symbol`,code:`invalid_type`,input:Y,inst:e}),R}})),l_=N(`$ZodUndefined`,((e,R)=>{Og.init(e,R),e._zod.pattern=Lh,e._zod.values=new Set([void 0]),e._zod.optin=`optional`,e._zod.optout=`optional`,e._zod.parse=(R,W)=>{let Y=R.value;return Y===void 0||R.issues.push({expected:`undefined`,code:`invalid_type`,input:Y,inst:e}),R}})),u_=N(`$ZodNull`,((e,R)=>{Og.init(e,R),e._zod.pattern=Ih,e._zod.values=new Set([null]),e._zod.parse=(R,W)=>{let Y=R.value;return Y===null||R.issues.push({expected:`null`,code:`invalid_type`,input:Y,inst:e}),R}})),d_=N(`$ZodAny`,((e,R)=>{Og.init(e,R),e._zod.parse=e=>e})),f_=N(`$ZodUnknown`,((e,R)=>{Og.init(e,R),e._zod.parse=e=>e})),p_=N(`$ZodNever`,((e,R)=>{Og.init(e,R),e._zod.parse=(R,W)=>(R.issues.push({expected:`never`,code:`invalid_type`,input:R.value,inst:e}),R)})),m_=N(`$ZodVoid`,((e,R)=>{Og.init(e,R),e._zod.parse=(R,W)=>{let Y=R.value;return Y===void 0||R.issues.push({expected:`void`,code:`invalid_type`,input:Y,inst:e}),R}})),h_=N(`$ZodDate`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{if(R.coerce)try{W.value=new Date(W.value)}catch{}let X=W.value,ie=X instanceof Date;return ie&&!Number.isNaN(X.getTime())||W.issues.push({expected:`date`,code:`invalid_type`,input:X,...ie?{received:`Invalid Date`}:{},inst:e}),W}}));function oi(e,R,W){e.issues.length&&R.issues.push(...ge(W,e.issues)),R.value[W]=e.value}const g_=N(`$ZodArray`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{let X=W.value;if(!Array.isArray(X))return W.issues.push({expected:`array`,code:`invalid_type`,input:X,inst:e}),W;W.value=Array(X.length);let ie=[];for(let e=0;e<X.length;e++){let ae=X[e],le=R.element._zod.run({value:ae,issues:[]},Y);le instanceof Promise?ie.push(le.then((R=>oi(R,W,e)))):oi(le,W,e)}return ie.length?Promise.all(ie).then((()=>W)):W}}));function ri(e,R,W,Y){e.issues.length&&R.issues.push(...ge(W,e.issues)),e.value===void 0?W in Y&&(R.value[W]=void 0):R.value[W]=e.value}function ai(e){let R=Object.keys(e.shape);for(let W of R)if(!e.shape?.[W]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${W}": expected a Zod schema`);let W=(Y=e.shape,Object.keys(Y).filter((e=>Y[e]._zod.optin===`optional`&&Y[e]._zod.optout===`optional`)));var Y;return{...e,keys:R,keySet:new Set(R),numKeys:R.length,optionalKeys:new Set(W)}}function li(e,R,W,Y,X,ie){let ae=[],le=X.keySet,_e=X.catchall._zod,ye=_e.def.type;for(let X in R){if(le.has(X))continue;if(ye===`never`){ae.push(X);continue}let ie=_e.run({value:R[X],issues:[]},Y);ie instanceof Promise?e.push(ie.then((e=>ri(e,W,X,R)))):ri(ie,W,X,R)}return ae.length&&W.issues.push({code:`unrecognized_keys`,keys:ae,input:R,inst:ie}),e.length?Promise.all(e).then((()=>W)):W}const __=N(`$ZodObject`,((e,R)=>{if(Og.init(e,R),!Object.getOwnPropertyDescriptor(R,`shape`)?.get){let e=R.shape;Object.defineProperty(R,"shape",{get:()=>{let W={...e};return Object.defineProperty(R,"shape",{value:W}),W}})}let W=Z((()=>ai(R)));H(e._zod,`propValues`,(()=>{let e=R.shape,W={};for(let R in e){let Y=e[R]._zod;if(Y.values){W[R]??(W[R]=new Set);for(let e of Y.values)W[R].add(e)}}return W}));let Y=V,X=R.catchall,ie;e._zod.parse=(R,ae)=>{ie??=W.value;let le=R.value;if(!Y(le))return R.issues.push({expected:`object`,code:`invalid_type`,input:le,inst:e}),R;R.value={};let _e=[],ye=ie.shape;for(let e of ie.keys){let W=ye[e]._zod.run({value:le[e],issues:[]},ae);W instanceof Promise?_e.push(W.then((W=>ri(W,R,e,le)))):ri(W,R,e,le)}return X?li(_e,le,R,ae,W.value,e):_e.length?Promise.all(_e).then((()=>R)):R}})),v_=N(`$ZodObjectJIT`,((e,R)=>{__.init(e,R);let W=e._zod.parse,Y=Z((()=>ai(R))),X,ie=V,ae=!Hm.jitless,le=ae&&Gm.value,_e=R.catchall,ye;e._zod.parse=(be,Ce)=>{ye??=Y.value;let Te=be.value;return ie(Te)?ae&&le&&!1===Ce?.async&&!0!==Ce.jitless?(X||=(e=>{let R=new IA([`shape`,`payload`,`ctx`]),W=Y.value,n=e=>{let R=K(e);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};R.write(`const input = payload.value;`);let X=Object.create(null),ie=0;for(let e of W.keys)X[e]=`key_`+ ie++;R.write(`const newResult = {};`);for(let e of W.keys){let W=X[e],Y=K(e);R.write(`const ${W} = ${n(e)};`),R.write(`\n if (${W}.issues.length) {\n payload.issues = payload.issues.concat(${W}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${Y}, ...iss.path] : [${Y}]\n })));\n }\n \n \n if (${W}.value === undefined) {\n if (${Y} in input) {\n newResult[${Y}] = undefined;\n }\n } else {\n newResult[${Y}] = ${W}.value;\n }\n \n `)}R.write(`payload.value = newResult;`),R.write(`return payload;`);let ae=R.compile();return(R,W)=>ae(e,R,W)})(R.shape),be=X(be,Ce),_e?li([],Te,be,Ce,ye,e):be):W(be,Ce):(be.issues.push({expected:`object`,code:`invalid_type`,input:Te,inst:e}),be)}}));function di(e,R,W,Y){for(let W of e)if(W.issues.length===0)return R.value=W.value,R;let X=e.filter((e=>!ce(e)));return X.length===1?(R.value=X[0].value,X[0]):(R.issues.push({code:`invalid_union`,input:R.value,inst:W,errors:e.map((e=>e.issues.map((e=>he(e,Y,M())))))}),R)}const y_=N(`$ZodUnion`,((e,R)=>{Og.init(e,R),H(e._zod,`optin`,(()=>R.options.some((e=>e._zod.optin===`optional`))?`optional`:void 0)),H(e._zod,`optout`,(()=>R.options.some((e=>e._zod.optout===`optional`))?`optional`:void 0)),H(e._zod,`values`,(()=>{if(R.options.every((e=>e._zod.values)))return new Set(R.options.flatMap((e=>Array.from(e._zod.values))))})),H(e._zod,`pattern`,(()=>{if(R.options.every((e=>e._zod.pattern))){let e=R.options.map((e=>e._zod.pattern));return RegExp(`^(${e.map((e=>j(e.source))).join(`|`)})$`)}}));let W=R.options.length===1,Y=R.options[0]._zod.run;e._zod.parse=(X,ie)=>{if(W)return Y(X,ie);let ae=!1,le=[];for(let e of R.options){let R=e._zod.run({value:X.value,issues:[]},ie);if(R instanceof Promise)le.push(R),ae=!0;else{if(R.issues.length===0)return R;le.push(R)}}return ae?Promise.all(le).then((R=>di(R,X,e,ie))):di(le,X,e,ie)}}));function ui(e,R,W,Y){let X=e.filter((e=>e.issues.length===0));return X.length===1?(R.value=X[0].value,R):(X.length===0?R.issues.push({code:`invalid_union`,input:R.value,inst:W,errors:e.map((e=>e.issues.map((e=>he(e,Y,M())))))}):R.issues.push({code:`invalid_union`,input:R.value,inst:W,errors:[],inclusive:!1}),R)}const b_=N(`$ZodXor`,((e,R)=>{y_.init(e,R),R.inclusive=!1;let W=R.options.length===1,Y=R.options[0]._zod.run;e._zod.parse=(X,ie)=>{if(W)return Y(X,ie);let ae=!1,le=[];for(let e of R.options){let R=e._zod.run({value:X.value,issues:[]},ie);R instanceof Promise?(le.push(R),ae=!0):le.push(R)}return ae?Promise.all(le).then((R=>ui(R,X,e,ie))):ui(le,X,e,ie)}})),x_=N(`$ZodDiscriminatedUnion`,((e,R)=>{R.inclusive=!1,y_.init(e,R);let W=e._zod.parse;H(e._zod,`propValues`,(()=>{let e={};for(let W of R.options){let Y=W._zod.propValues;if(!Y||Object.keys(Y).length===0)throw Error(`Invalid discriminated union option at index "${R.options.indexOf(W)}"`);for(let[R,W]of Object.entries(Y)){e[R]||(e[R]=new Set);for(let Y of W)e[R].add(Y)}}return e}));let Y=Z((()=>{let e=R.options,W=new Map;for(let Y of e){let e=Y._zod.propValues?.[R.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${R.options.indexOf(Y)}"`);for(let R of e){if(W.has(R))throw Error(`Duplicate discriminator value "${String(R)}"`);W.set(R,Y)}}return W}));e._zod.parse=(X,ie)=>{let ae=X.value;if(!V(ae))return X.issues.push({code:`invalid_type`,expected:`object`,input:ae,inst:e}),X;let le=Y.value.get(ae?.[R.discriminator]);return le?le._zod.run(X,ie):R.unionFallback?W(X,ie):(X.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:R.discriminator,input:ae,path:[R.discriminator],inst:e}),X)}})),S_=N(`$ZodIntersection`,((e,R)=>{Og.init(e,R),e._zod.parse=(e,W)=>{let Y=e.value,X=R.left._zod.run({value:Y,issues:[]},W),ie=R.right._zod.run({value:Y,issues:[]},W);return X instanceof Promise||ie instanceof Promise?Promise.all([X,ie]).then((([R,W])=>Ci(e,R,W))):Ci(e,X,ie)}}));function Bi(e,R){if(e===R||e instanceof Date&&R instanceof Date&&+e==+R)return{valid:!0,data:e};if(ee(e)&&ee(R)){let W=Object.keys(R),Y=Object.keys(e).filter((e=>W.indexOf(e)!==-1)),X={...e,...R};for(let W of Y){let Y=Bi(e[W],R[W]);if(!Y.valid)return{valid:!1,mergeErrorPath:[W,...Y.mergeErrorPath]};X[W]=Y.data}return{valid:!0,data:X}}if(Array.isArray(e)&&Array.isArray(R)){if(e.length!==R.length)return{valid:!1,mergeErrorPath:[]};let W=[];for(let Y=0;Y<e.length;Y++){let X=Bi(e[Y],R[Y]);if(!X.valid)return{valid:!1,mergeErrorPath:[Y,...X.mergeErrorPath]};W.push(X.data)}return{valid:!0,data:W}}return{valid:!1,mergeErrorPath:[]}}function Ci(e,R,W){if(R.issues.length&&e.issues.push(...R.issues),W.issues.length&&e.issues.push(...W.issues),ce(e))return e;let Y=Bi(R.value,W.value);if(!Y.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(Y.mergeErrorPath)}`);return e.value=Y.data,e}const C_=N(`$ZodTuple`,((e,R)=>{Og.init(e,R);let W=R.items;e._zod.parse=(Y,X)=>{let ie=Y.value;if(!Array.isArray(ie))return Y.issues.push({input:ie,inst:e,expected:`tuple`,code:`invalid_type`}),Y;Y.value=[];let ae=[],le=[...W].reverse().findIndex((e=>e._zod.optin!==`optional`)),_e=le===-1?0:W.length-le;if(!R.rest){let R=ie.length>W.length,X=ie.length<_e-1;if(R||X)return Y.issues.push({...R?{code:`too_big`,maximum:W.length}:{code:`too_small`,minimum:W.length},input:ie,inst:e,origin:`array`}),Y}let ye=-1;for(let e of W){if(ye++,ye>=ie.length&&ye>=_e)continue;let R=e._zod.run({value:ie[ye],issues:[]},X);R instanceof Promise?ae.push(R.then((e=>Qi(e,Y,ye)))):Qi(R,Y,ye)}if(R.rest){let e=ie.slice(W.length);for(let W of e){ye++;let e=R.rest._zod.run({value:W,issues:[]},X);e instanceof Promise?ae.push(e.then((e=>Qi(e,Y,ye)))):Qi(e,Y,ye)}}return ae.length?Promise.all(ae).then((()=>Y)):Y}}));function Qi(e,R,W){e.issues.length&&R.issues.push(...ge(W,e.issues)),R.value[W]=e.value}const w_=N(`$ZodRecord`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{let X=W.value;if(!ee(X))return W.issues.push({expected:`record`,code:`invalid_type`,input:X,inst:e}),W;let ie=[],ae=R.keyType._zod.values;if(ae){W.value={};let le=new Set;for(let e of ae)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){le.add(typeof e==`number`?e.toString():e);let ae=R.valueType._zod.run({value:X[e],issues:[]},Y);ae instanceof Promise?ie.push(ae.then((R=>{R.issues.length&&W.issues.push(...ge(e,R.issues)),W.value[e]=R.value}))):(ae.issues.length&&W.issues.push(...ge(e,ae.issues)),W.value[e]=ae.value)}let _e;for(let e in X)le.has(e)||(_e??=[],_e.push(e));_e&&_e.length>0&&W.issues.push({code:`unrecognized_keys`,input:X,inst:e,keys:_e})}else{W.value={};for(let ae of Reflect.ownKeys(X)){if(ae===`__proto__`)continue;let le=R.keyType._zod.run({value:ae,issues:[]},Y);if(le instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(le.issues.length){R.mode===`loose`?W.value[ae]=X[ae]:W.issues.push({code:`invalid_key`,origin:`record`,issues:le.issues.map((e=>he(e,Y,M()))),input:ae,path:[ae],inst:e});continue}let _e=R.valueType._zod.run({value:X[ae],issues:[]},Y);_e instanceof Promise?ie.push(_e.then((e=>{e.issues.length&&W.issues.push(...ge(ae,e.issues)),W.value[le.value]=e.value}))):(_e.issues.length&&W.issues.push(...ge(ae,_e.issues)),W.value[le.value]=_e.value)}}return ie.length?Promise.all(ie).then((()=>W)):W}})),T_=N(`$ZodMap`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{let X=W.value;if(!(X instanceof Map))return W.issues.push({expected:`map`,code:`invalid_type`,input:X,inst:e}),W;let ie=[];W.value=new Map;for(let[ae,le]of X){let _e=R.keyType._zod.run({value:ae,issues:[]},Y),ye=R.valueType._zod.run({value:le,issues:[]},Y);_e instanceof Promise||ye instanceof Promise?ie.push(Promise.all([_e,ye]).then((([R,ie])=>{wi(R,ie,W,ae,X,e,Y)}))):wi(_e,ye,W,ae,X,e,Y)}return ie.length?Promise.all(ie).then((()=>W)):W}}));function wi(e,R,W,Y,X,ie,ae){e.issues.length&&(Km.has(typeof Y)?W.issues.push(...ge(Y,e.issues)):W.issues.push({code:`invalid_key`,origin:`map`,input:X,inst:ie,issues:e.issues.map((e=>he(e,ae,M())))})),R.issues.length&&(Km.has(typeof Y)?W.issues.push(...ge(Y,R.issues)):W.issues.push({origin:`map`,code:`invalid_element`,input:X,inst:ie,key:Y,issues:R.issues.map((e=>he(e,ae,M())))})),W.value.set(e.value,R.value)}const E_=N(`$ZodSet`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{let X=W.value;if(!(X instanceof Set))return W.issues.push({input:X,inst:e,expected:`set`,code:`invalid_type`}),W;let ie=[];W.value=new Set;for(let e of X){let X=R.valueType._zod.run({value:e,issues:[]},Y);X instanceof Promise?ie.push(X.then((e=>vi(e,W)))):vi(X,W)}return ie.length?Promise.all(ie).then((()=>W)):W}}));function vi(e,R){e.issues.length&&R.issues.push(...e.issues),R.value.add(e.value)}const D_=N(`$ZodEnum`,((e,R)=>{Og.init(e,R);let W=O(R.entries),Y=new Set(W);e._zod.values=Y,e._zod.pattern=RegExp(`^(${W.filter((e=>Km.has(typeof e))).map((e=>typeof e==`string`?ne(e):e.toString())).join(`|`)})$`),e._zod.parse=(R,X)=>{let ie=R.value;return Y.has(ie)||R.issues.push({code:`invalid_value`,values:W,input:ie,inst:e}),R}})),O_=N(`$ZodLiteral`,((e,R)=>{if(Og.init(e,R),R.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let W=new Set(R.values);e._zod.values=W,e._zod.pattern=RegExp(`^(${R.values.map((e=>typeof e==`string`?ne(e):e?ne(e.toString()):String(e))).join(`|`)})$`),e._zod.parse=(Y,X)=>{let ie=Y.value;return W.has(ie)||Y.issues.push({code:`invalid_value`,values:R.values,input:ie,inst:e}),Y}})),k_=N(`$ZodFile`,((e,R)=>{Og.init(e,R),e._zod.parse=(R,W)=>{let Y=R.value;return Y instanceof File||R.issues.push({expected:`file`,code:`invalid_type`,input:Y,inst:e}),R}})),A_=N(`$ZodTransform`,((e,R)=>{Og.init(e,R),e._zod.parse=(W,Y)=>{if(Y.direction===`backward`)throw new T(e.constructor.name);let X=R.transform(W.value,W);if(Y.async)return(X instanceof Promise?X:Promise.resolve(X)).then((e=>(W.value=e,W)));if(X instanceof Promise)throw new G;return W.value=X,W}}));function xi(e,R){return e.issues.length&&R===void 0?{issues:[],value:void 0}:e}const j_=N(`$ZodOptional`,((e,R)=>{Og.init(e,R),e._zod.optin=`optional`,e._zod.optout=`optional`,H(e._zod,`values`,(()=>R.innerType._zod.values?new Set([...R.innerType._zod.values,void 0]):void 0)),H(e._zod,`pattern`,(()=>{let e=R.innerType._zod.pattern;return e?RegExp(`^(${j(e.source)})?$`):void 0})),e._zod.parse=(e,W)=>{if(R.innerType._zod.optin===`optional`){let Y=R.innerType._zod.run(e,W);return Y instanceof Promise?Y.then((R=>xi(R,e.value))):xi(Y,e.value)}return e.value===void 0?e:R.innerType._zod.run(e,W)}})),M_=N(`$ZodNullable`,((e,R)=>{Og.init(e,R),H(e._zod,`optin`,(()=>R.innerType._zod.optin)),H(e._zod,`optout`,(()=>R.innerType._zod.optout)),H(e._zod,`pattern`,(()=>{let e=R.innerType._zod.pattern;return e?RegExp(`^(${j(e.source)}|null)$`):void 0})),H(e._zod,`values`,(()=>R.innerType._zod.values?new Set([...R.innerType._zod.values,null]):void 0)),e._zod.parse=(e,W)=>e.value===null?e:R.innerType._zod.run(e,W)})),N_=N(`$ZodDefault`,((e,R)=>{Og.init(e,R),e._zod.optin=`optional`,H(e._zod,`values`,(()=>R.innerType._zod.values)),e._zod.parse=(e,W)=>{if(W.direction===`backward`)return R.innerType._zod.run(e,W);if(e.value===void 0)return e.value=R.defaultValue,e;let Y=R.innerType._zod.run(e,W);return Y instanceof Promise?Y.then((e=>Ni(e,R))):Ni(Y,R)}}));function Ni(e,R){return e.value===void 0&&(e.value=R.defaultValue),e}const P_=N(`$ZodPrefault`,((e,R)=>{Og.init(e,R),e._zod.optin=`optional`,H(e._zod,`values`,(()=>R.innerType._zod.values)),e._zod.parse=(e,W)=>(W.direction===`backward`||e.value===void 0&&(e.value=R.defaultValue),R.innerType._zod.run(e,W))})),F_=N(`$ZodNonOptional`,((e,R)=>{Og.init(e,R),H(e._zod,`values`,(()=>{let e=R.innerType._zod.values;return e?new Set([...e].filter((e=>e!==void 0))):void 0})),e._zod.parse=(W,Y)=>{let X=R.innerType._zod.run(W,Y);return X instanceof Promise?X.then((R=>Ri(R,e))):Ri(X,e)}}));function Ri(e,R){return e.issues.length||e.value!==void 0||e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:R}),e}const I_=N(`$ZodSuccess`,((e,R)=>{Og.init(e,R),e._zod.parse=(e,W)=>{if(W.direction===`backward`)throw new T(`ZodSuccess`);let Y=R.innerType._zod.run(e,W);return Y instanceof Promise?Y.then((R=>(e.value=R.issues.length===0,e))):(e.value=Y.issues.length===0,e)}})),L_=N(`$ZodCatch`,((e,R)=>{Og.init(e,R),H(e._zod,`optin`,(()=>R.innerType._zod.optin)),H(e._zod,`optout`,(()=>R.innerType._zod.optout)),H(e._zod,`values`,(()=>R.innerType._zod.values)),e._zod.parse=(e,W)=>{if(W.direction===`backward`)return R.innerType._zod.run(e,W);let Y=R.innerType._zod.run(e,W);return Y instanceof Promise?Y.then((Y=>(e.value=Y.value,Y.issues.length&&(e.value=R.catchValue({...e,error:{issues:Y.issues.map((e=>he(e,W,M())))},input:e.value}),e.issues=[]),e))):(e.value=Y.value,Y.issues.length&&(e.value=R.catchValue({...e,error:{issues:Y.issues.map((e=>he(e,W,M())))},input:e.value}),e.issues=[]),e)}})),R_=N(`$ZodNaN`,((e,R)=>{Og.init(e,R),e._zod.parse=(R,W)=>(typeof R.value==`number`&&Number.isNaN(R.value)||R.issues.push({input:R.value,inst:e,expected:`nan`,code:`invalid_type`}),R)})),z_=N(`$ZodPipe`,((e,R)=>{Og.init(e,R),H(e._zod,`values`,(()=>R.in._zod.values)),H(e._zod,`optin`,(()=>R.in._zod.optin)),H(e._zod,`optout`,(()=>R.out._zod.optout)),H(e._zod,`propValues`,(()=>R.in._zod.propValues)),e._zod.parse=(e,W)=>{if(W.direction===`backward`){let Y=R.out._zod.run(e,W);return Y instanceof Promise?Y.then((e=>Zi(e,R.in,W))):Zi(Y,R.in,W)}let Y=R.in._zod.run(e,W);return Y instanceof Promise?Y.then((e=>Zi(e,R.out,W))):Zi(Y,R.out,W)}}));function Zi(e,R,W){return e.issues.length?(e.aborted=!0,e):R._zod.run({value:e.value,issues:e.issues},W)}const B_=N(`$ZodCodec`,((e,R)=>{Og.init(e,R),H(e._zod,`values`,(()=>R.in._zod.values)),H(e._zod,`optin`,(()=>R.in._zod.optin)),H(e._zod,`optout`,(()=>R.out._zod.optout)),H(e._zod,`propValues`,(()=>R.in._zod.propValues)),e._zod.parse=(e,W)=>{if((W.direction||`forward`)===`forward`){let Y=R.in._zod.run(e,W);return Y instanceof Promise?Y.then((e=>ji(e,R,W))):ji(Y,R,W)}{let Y=R.out._zod.run(e,W);return Y instanceof Promise?Y.then((e=>ji(e,R,W))):ji(Y,R,W)}}}));function ji(e,R,W){if(e.issues.length)return e.aborted=!0,e;if((W.direction||`forward`)===`forward`){let Y=R.transform(e.value,e);return Y instanceof Promise?Y.then((Y=>Yi(e,Y,R.out,W))):Yi(e,Y,R.out,W)}{let Y=R.reverseTransform(e.value,e);return Y instanceof Promise?Y.then((Y=>Yi(e,Y,R.in,W))):Yi(e,Y,R.in,W)}}function Yi(e,R,W,Y){return e.issues.length?(e.aborted=!0,e):W._zod.run({value:R,issues:e.issues},Y)}const V_=N(`$ZodReadonly`,((e,R)=>{Og.init(e,R),H(e._zod,`propValues`,(()=>R.innerType._zod.propValues)),H(e._zod,`values`,(()=>R.innerType._zod.values)),H(e._zod,`optin`,(()=>R.innerType?._zod?.optin)),H(e._zod,`optout`,(()=>R.innerType?._zod?.optout)),e._zod.parse=(e,W)=>{if(W.direction===`backward`)return R.innerType._zod.run(e,W);let Y=R.innerType._zod.run(e,W);return Y instanceof Promise?Y.then(Pi):Pi(Y)}}));function Pi(e){return e.value=Object.freeze(e.value),e}const H_=N(`$ZodTemplateLiteral`,((e,R)=>{Og.init(e,R);let W=[];for(let e of R.parts)if(typeof e==`object`&&e){if(!e._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);let R=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!R)throw Error(`Invalid template literal part: ${e._zod.traits}`);let Y=+!!R.startsWith(`^`),X=R.endsWith(`$`)?R.length-1:R.length;W.push(R.slice(Y,X))}else{if(e!==null&&!qm.has(typeof e))throw Error(`Invalid template literal part: ${e}`);W.push(ne(`${e}`))}e._zod.pattern=RegExp(`^${W.join(``)}$`),e._zod.parse=(W,Y)=>typeof W.value==`string`?(e._zod.pattern.lastIndex=0,e._zod.pattern.test(W.value)||W.issues.push({input:W.value,inst:e,code:`invalid_format`,format:R.format??`template_literal`,pattern:e._zod.pattern.source}),W):(W.issues.push({input:W.value,inst:e,expected:`template_literal`,code:`invalid_type`}),W)})),U_=N(`$ZodFunction`,((e,R)=>(Og.init(e,R),e._def=R,e._zod.def=R,e.implement=R=>{if(typeof R!=`function`)throw Error(`implement() must be called with a function`);return function(...W){let Y=e._def.input?Qm(e._def.input,W):W,X=Reflect.apply(R,this,Y);return e._def.output?Qm(e._def.output,X):X}},e.implementAsync=R=>{if(typeof R!=`function`)throw Error(`implementAsync() must be called with a function`);return async function(...W){let Y=e._def.input?await $m(e._def.input,W):W,X=await Reflect.apply(R,this,Y);return e._def.output?await $m(e._def.output,X):X}},e._zod.parse=(R,W)=>typeof R.value==`function`?(R.value=e._def.output&&e._def.output._zod.def.type===`promise`?e.implementAsync(R.value):e.implement(R.value),R):(R.issues.push({code:`invalid_type`,expected:`function`,input:R.value,inst:e}),R),e.input=(...R)=>{let W=e.constructor;return Array.isArray(R[0])?new W({type:`function`,input:new C_({type:`tuple`,items:R[0],rest:R[1]}),output:e._def.output}):new W({type:`function`,input:R[0],output:e._def.output})},e.output=R=>new e.constructor({type:`function`,input:e._def.input,output:R}),e))),W_=N(`$ZodPromise`,((e,R)=>{Og.init(e,R),e._zod.parse=(e,W)=>Promise.resolve(e.value).then((e=>R.innerType._zod.run({value:e,issues:[]},W)))})),G_=N(`$ZodLazy`,((e,R)=>{Og.init(e,R),H(e._zod,`innerType`,(()=>R.getter())),H(e._zod,`pattern`,(()=>e._zod.innerType?._zod?.pattern)),H(e._zod,`propValues`,(()=>e._zod.innerType?._zod?.propValues)),H(e._zod,`optin`,(()=>e._zod.innerType?._zod?.optin??void 0)),H(e._zod,`optout`,(()=>e._zod.innerType?._zod?.optout??void 0)),e._zod.parse=(R,W)=>e._zod.innerType._zod.run(R,W)})),K_=N(`$ZodCustom`,((e,R)=>{rg.init(e,R),Og.init(e,R),e._zod.parse=(e,R)=>e,e._zod.check=W=>{let Y=W.value,X=R.fn(Y);if(X instanceof Promise)return X.then((R=>en(R,W,Y,e)));en(X,W,Y,e)}}));function en(e,R,W,Y){if(!e){let e={code:`custom`,input:W,inst:Y,path:[...Y._zod.def.path??[]],continue:!Y._zod.def.abort};Y._zod.def.params&&(e.params=Y._zod.def.params),R.issues.push(pe(e))}}const tn=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`}};function t(R){return e[R]??null}let R={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,jwt:`JWT`,template_literal:`input`};return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${e.expected}, received ${(e=>{let R=typeof e;switch(R){case`number`:return Number.isNaN(e)?`NaN`:`number`;case`object`:if(Array.isArray(e))return`array`;if(e===null)return`null`;if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}return R})(e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${re(e.values[0])}`:`Invalid option: expected one of ${U(e.values,`|`)}`;case`too_big`:{let R=e.inclusive?`<=`:`<`,W=t(e.origin);return W?`Too big: expected ${e.origin??`value`} to have ${R}${e.maximum.toString()} ${W.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${R}${e.maximum.toString()}`}case`too_small`:{let R=e.inclusive?`>=`:`>`,W=t(e.origin);return W?`Too small: expected ${e.origin} to have ${R}${e.minimum.toString()} ${W.unit}`:`Too small: expected ${e.origin} to be ${R}${e.minimum.toString()}`}case`invalid_format`:{let W=e;return W.format===`starts_with`?`Invalid string: must start with "${W.prefix}"`:W.format===`ends_with`?`Invalid string: must end with "${W.suffix}"`:W.format===`includes`?`Invalid string: must include "${W.includes}"`:W.format===`regex`?`Invalid string: must match pattern ${W.pattern}`:`Invalid ${R[W.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${U(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:default:return`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`}}};var q_,nn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...R){let W=R[0];if(this._map.set(e,W),W&&typeof W==`object`&&`id`in W){if(this._idmap.has(W.id))throw Error(`ID ${W.id} already exists in the registry`);this._idmap.set(W.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let R=this._map.get(e);return R&&typeof R==`object`&&`id`in R&&this._idmap.delete(R.id),this._map.delete(e),this}get(e){let R=e._zod.parent;if(R){let W={...this.get(R)??{}};delete W.id;let Y={...W,...this._map.get(e)};return Object.keys(Y).length?Y:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};(q_=globalThis).__zod_globalRegistry??(q_.__zod_globalRegistry=new nn);const J_=globalThis.__zod_globalRegistry;function sn(e,R){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...se(R)})}function rn(e,R){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...se(R)})}function an(e,R){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...se(R)})}function ln(e,R){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...se(R)})}function cn(e,R){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...se(R)})}function gn(e,R){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...se(R)})}function dn(e,R){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...se(R)})}function hn(e,R){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...se(R)})}function un(e,R){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...se(R)})}function In(e,R){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...se(R)})}function pn(e,R){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...se(R)})}function fn(e,R){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...se(R)})}function Bn(e,R){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...se(R)})}function Cn(e,R){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...se(R)})}function En(e,R){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...se(R)})}function Qn(e,R){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...se(R)})}function mn(e,R){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...se(R)})}function yn(e,R){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...se(R)})}function wn(e,R){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...se(R)})}function _n(e,R){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...se(R)})}function vn(e,R){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...se(R)})}function bn(e,R){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...se(R)})}function kn(e,R){return new og({check:`less_than`,...se(R),value:e,inclusive:!1})}function Dn(e,R){return new og({check:`less_than`,...se(R),value:e,inclusive:!0})}function Sn(e,R){return new sg({check:`greater_than`,...se(R),value:e,inclusive:!1})}function xn(e,R){return new sg({check:`greater_than`,...se(R),value:e,inclusive:!0})}function zn(e){return Sn(0,e)}function Fn(e){return kn(0,e)}function Ln(e){return Dn(0,e)}function Nn(e){return xn(0,e)}function Gn(e,R){return new cg({check:`multiple_of`,...se(R),value:e})}function Tn(e,R){return new dg({check:`max_size`,...se(R),maximum:e})}function Rn(e,R){return new fg({check:`min_size`,...se(R),minimum:e})}function Mn(e,R){return new pg({check:`size_equals`,...se(R),size:e})}function On(e,R){return new mg({check:`max_length`,...se(R),maximum:e})}function Un(e,R){return new hg({check:`min_length`,...se(R),minimum:e})}function Jn(e,R){return new gg({check:`length_equals`,...se(R),length:e})}function Zn(e,R){return new vg({check:`string_format`,format:`regex`,...se(R),pattern:e})}function qn(e){return new yg({check:`string_format`,format:`lowercase`,...se(e)})}function jn(e){return new bg({check:`string_format`,format:`uppercase`,...se(e)})}function Yn(e,R){return new xg({check:`string_format`,format:`includes`,...se(R),includes:e})}function Hn(e,R){return new Sg({check:`string_format`,format:`starts_with`,...se(R),prefix:e})}function Pn(e,R){return new Cg({check:`string_format`,format:`ends_with`,...se(R),suffix:e})}function $n(e,R,W){return new wg({check:`property`,property:e,schema:R,...se(W)})}function Kn(e,R){return new Tg({check:`mime_type`,mime:e,...se(R)})}function Wn(e){return new Eg({check:`overwrite`,tx:e})}function Vn(e){return Wn((R=>R.normalize(e)))}function Xn(){return Wn((e=>e.trim()))}function eo(){return Wn((e=>e.toLowerCase()))}function to(){return Wn((e=>e.toUpperCase()))}function Ao(){return Wn((e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}(e)))}function io(e){let R=function(e,R){let W=new rg({check:`custom`,...se(R)});return W._zod.check=e,W}((W=>(W.addIssue=e=>{if(typeof e==`string`)W.issues.push(pe(e,W.value,R._zod.def));else{let Y=e;Y.fatal&&(Y.continue=!1),Y.code??=`custom`,Y.input??=W.value,Y.inst??=R,Y.continue??=!R._zod.def.abort,W.issues.push(pe(Y))}},e(W.value,W))));return R}function no(e,R,W,Y={}){let X=se(Y),ie={...se(Y),check:`string_format`,type:`string`,format:R,fn:typeof W==`function`?W:e=>W.test(e),...X};return W instanceof RegExp&&(ie.pattern=W),new e(ie)}function oo(e){let R=e?.target??`draft-2020-12`;return R===`draft-4`&&(R=`draft-04`),R===`draft-7`&&(R=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??J_,target:R,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function so(e,R,W={path:[],schemaPath:[]}){var Y;let X=e._zod.def,ie=R.seen.get(e);if(ie)return ie.count++,W.schemaPath.includes(e)&&(ie.cycle=W.path),ie.schema;let ae={schema:{},count:1,cycle:void 0,path:W.path};R.seen.set(e,ae);let le=e._zod.toJSONSchema?.();if(le)ae.schema=le;else{let Y={...W,schemaPath:[...W.schemaPath,e],path:W.path},ie=e._zod.parent;if(ie)ae.ref=ie,so(ie,R,Y),R.seen.get(ie).isParent=!0;else if(e._zod.processJSONSchema)e._zod.processJSONSchema(R,ae.schema,Y);else{let W=ae.schema,ie=R.processors[X.type];if(!ie)throw Error(`[toJSONSchema]: Non-representable type encountered: ${X.type}`);ie(e,R,W,Y)}}let _e=R.metadataRegistry.get(e);return _e&&Object.assign(ae.schema,_e),R.io===`input`&&lo(e)&&(delete ae.schema.examples,delete ae.schema.default),R.io===`input`&&ae.schema._prefault&&((Y=ae.schema).default??(Y.default=ae.schema._prefault)),delete ae.schema._prefault,R.seen.get(e).schema}function ro(e,R){let W=e.seen.get(R);if(!W)throw Error(`Unprocessed schema. This is a bug in Zod.`);let i=R=>{if(R[1].schema.$ref)return;let Y=R[1],{ref:X,defId:ie}=(R=>{let Y=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let W=e.external.registry.get(R[0])?.id,X=e.external.uri??(e=>e);if(W)return{ref:X(W)};let ie=R[1].defId??R[1].schema.id??`schema`+ e.counter++;return R[1].defId=ie,{defId:ie,ref:`${X(`__shared`)}#/${Y}/${ie}`}}if(R[1]===W)return{ref:`#`};let X=`#/${Y}/`,ie=R[1].schema.id??`__schema`+ e.counter++;return{defId:ie,ref:X+ie}})(R);Y.def={...Y.schema},ie&&(Y.defId=ie);let ae=Y.schema;for(let e in ae)delete ae[e];ae.$ref=X};if(e.cycles===`throw`)for(let R of e.seen.entries()){let e=R[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let W of e.seen.entries()){let Y=W[1];if(R===W[0]){i(W);continue}if(e.external){let Y=e.external.registry.get(W[0])?.id;if(R!==W[0]&&Y){i(W);continue}}(e.metadataRegistry.get(W[0])?.id||Y.cycle||Y.count>1&&e.reused===`ref`)&&i(W)}}function ao(e,R){let W=e.seen.get(R);if(!W)throw Error(`Unprocessed schema. This is a bug in Zod.`);let i=R=>{let W=e.seen.get(R),Y=W.def??W.schema,X={...Y};if(W.ref===null)return;let ie=W.ref;if(W.ref=null,ie){i(ie);let R=e.seen.get(ie).schema;!R.$ref||e.target!==`draft-07`&&e.target!==`draft-04`&&e.target!==`openapi-3.0`?(Object.assign(Y,R),Object.assign(Y,X)):(Y.allOf=Y.allOf??[],Y.allOf.push(R))}W.isParent||e.override({zodSchema:R,jsonSchema:Y,path:W.path??[]})};for(let R of[...e.seen.entries()].reverse())i(R[0]);let Y={};if(e.target===`draft-2020-12`?Y.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?Y.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?Y.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let W=e.external.registry.get(R)?.id;if(!W)throw Error("Schema is missing an `id` property");Y.$id=e.external.uri(W)}Object.assign(Y,W.def??W.schema);let X=e.external?.defs??{};for(let R of e.seen.entries()){let e=R[1];e.def&&e.defId&&(X[e.defId]=e.def)}e.external||Object.keys(X).length>0&&(e.target===`draft-2020-12`?Y.$defs=X:Y.definitions=X);try{let e=JSON.parse(JSON.stringify(Y));return Object.defineProperty(e,"~standard",{value:{...R[`~standard`],jsonSchema:{input:co(R,`input`),output:co(R,`output`)}},enumerable:!1,writable:!1}),e}catch{throw Error(`Error converting schema to JSON.`)}}function lo(e,R){let W=R??{seen:new Set};if(W.seen.has(e))return!1;W.seen.add(e);let Y=e._zod.def;if(Y.type===`transform`)return!0;if(Y.type===`array`)return lo(Y.element,W);if(Y.type===`set`)return lo(Y.valueType,W);if(Y.type===`lazy`)return lo(Y.getter(),W);if(Y.type===`promise`||Y.type===`optional`||Y.type===`nonoptional`||Y.type===`nullable`||Y.type===`readonly`||Y.type==="default"||Y.type===`prefault`)return lo(Y.innerType,W);if(Y.type===`intersection`)return lo(Y.left,W)||lo(Y.right,W);if(Y.type===`record`||Y.type===`map`)return lo(Y.keyType,W)||lo(Y.valueType,W);if(Y.type===`pipe`)return lo(Y.in,W)||lo(Y.out,W);if(Y.type===`object`){for(let e in Y.shape)if(lo(Y.shape[e],W))return!0;return!1}if(Y.type===`union`){for(let e of Y.options)if(lo(e,W))return!0;return!1}if(Y.type===`tuple`){for(let e of Y.items)if(lo(e,W))return!0;return!(!Y.rest||!lo(Y.rest,W))}return!1}const co=(e,R)=>W=>{let{libraryOptions:Y,target:X}=W??{},ie=oo({...Y??{},target:X,io:R,processors:{}});return so(e,ie),ro(ie,e),ao(ie,e)},Y_={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ho=(e,R,W,Y)=>{let X=W;X.type=`string`;let{minimum:ie,maximum:ae,format:le,patterns:_e,contentEncoding:ye}=e._zod.bag;if(typeof ie==`number`&&(X.minLength=ie),typeof ae==`number`&&(X.maxLength=ae),le&&(X.format=Y_[le]??le,X.format===``&&delete X.format),ye&&(X.contentEncoding=ye),_e&&_e.size>0){let e=[..._e];e.length===1?X.pattern=e[0].source:e.length>1&&(X.allOf=[...e.map((e=>({...R.target===`draft-07`||R.target===`draft-04`||R.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source})))])}},uo=(e,R,W,Y)=>{let X=W,{minimum:ie,maximum:ae,format:le,multipleOf:_e,exclusiveMaximum:ye,exclusiveMinimum:be}=e._zod.bag;typeof le==`string`&&le.includes(`int`)?X.type=`integer`:X.type=`number`,typeof be==`number`&&(R.target===`draft-04`||R.target===`openapi-3.0`?(X.minimum=be,X.exclusiveMinimum=!0):X.exclusiveMinimum=be),typeof ie==`number`&&(X.minimum=ie,typeof be==`number`&&R.target!==`draft-04`&&(be>=ie?delete X.minimum:delete X.exclusiveMinimum)),typeof ye==`number`&&(R.target===`draft-04`||R.target===`openapi-3.0`?(X.maximum=ye,X.exclusiveMaximum=!0):X.exclusiveMaximum=ye),typeof ae==`number`&&(X.maximum=ae,typeof ye==`number`&&R.target!==`draft-04`&&(ye<=ae?delete X.maximum:delete X.exclusiveMaximum)),typeof _e==`number`&&(X.multipleOf=_e)},Io=(e,R,W,Y)=>{W.type=`boolean`},po=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},fo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},Bo=(e,R,W,Y)=>{R.target===`openapi-3.0`?(W.type=`string`,W.nullable=!0,W.enum=[null]):W.type=`null`},Co=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},Eo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},Qo=(e,R,W,Y)=>{W.not={}},mo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},yo=(e,R,W,Y)=>{let X=O(e._zod.def.entries);X.every((e=>typeof e==`number`))&&(W.type=`number`),X.every((e=>typeof e==`string`))&&(W.type=`string`),W.enum=X},wo=(e,R,W,Y)=>{let X=e._zod.def,ie=[];for(let e of X.values)if(e===void 0){if(R.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(R.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);ie.push(Number(e))}else ie.push(e);if(ie.length!==0)if(ie.length===1){let e=ie[0];W.type=e===null?`null`:typeof e,R.target===`draft-04`||R.target===`openapi-3.0`?W.enum=[e]:W.const=e}else ie.every((e=>typeof e==`number`))&&(W.type=`number`),ie.every((e=>typeof e==`string`))&&(W.type=`string`),ie.every((e=>typeof e==`boolean`))&&(W.type=`boolean`),ie.every((e=>e===null))&&(W.type=`null`),W.enum=ie},_o=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},vo=(e,R,W,Y)=>{let X=W,ie=e._zod.pattern;if(!ie)throw Error(`Pattern not found in template literal`);X.type=`string`,X.pattern=ie.source},bo=(e,R,W,Y)=>{let X=W,ie={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:ae,maximum:le,mime:_e}=e._zod.bag;ae!==void 0&&(ie.minLength=ae),le!==void 0&&(ie.maxLength=le),_e?_e.length===1?(ie.contentMediaType=_e[0],Object.assign(X,ie)):X.anyOf=_e.map((e=>({...ie,contentMediaType:e}))):Object.assign(X,ie)},ko=(e,R,W,Y)=>{W.type=`boolean`},Do=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},So=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},xo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},zo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Fo=(e,R,W,Y)=>{if(R.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Lo=(e,R,W,Y)=>{let X=W,ie=e._zod.def,{minimum:ae,maximum:le}=e._zod.bag;typeof ae==`number`&&(X.minItems=ae),typeof le==`number`&&(X.maxItems=le),X.type=`array`,X.items=so(ie.element,R,{...Y,path:[...Y.path,`items`]})},No=(e,R,W,Y)=>{let X=W,ie=e._zod.def;X.type=`object`,X.properties={};let ae=ie.shape;for(let e in ae)X.properties[e]=so(ae[e],R,{...Y,path:[...Y.path,`properties`,e]});let le=new Set(Object.keys(ae)),_e=new Set([...le].filter((e=>{let W=ie.shape[e]._zod;return R.io===`input`?W.optin===void 0:W.optout===void 0})));_e.size>0&&(X.required=Array.from(_e)),ie.catchall?._zod.def.type===`never`?X.additionalProperties=!1:ie.catchall?ie.catchall&&(X.additionalProperties=so(ie.catchall,R,{...Y,path:[...Y.path,`additionalProperties`]})):R.io===`output`&&(X.additionalProperties=!1)},Go=(e,R,W,Y)=>{let X=e._zod.def,ie=!1===X.inclusive,ae=X.options.map(((e,W)=>so(e,R,{...Y,path:[...Y.path,ie?`oneOf`:`anyOf`,W]})));ie?W.oneOf=ae:W.anyOf=ae},To=(e,R,W,Y)=>{let X=e._zod.def,ie=so(X.left,R,{...Y,path:[...Y.path,`allOf`,0]}),ae=so(X.right,R,{...Y,path:[...Y.path,`allOf`,1]}),r=e=>`allOf`in e&&Object.keys(e).length===1;W.allOf=[...r(ie)?ie.allOf:[ie],...r(ae)?ae.allOf:[ae]]},Ro=(e,R,W,Y)=>{let X=W,ie=e._zod.def;X.type=`array`;let ae=R.target===`draft-2020-12`?`prefixItems`:`items`,le=R.target===`draft-2020-12`||R.target===`openapi-3.0`?`items`:`additionalItems`,_e=ie.items.map(((e,W)=>so(e,R,{...Y,path:[...Y.path,ae,W]}))),ye=ie.rest?so(ie.rest,R,{...Y,path:[...Y.path,le,...R.target===`openapi-3.0`?[ie.items.length]:[]]}):null;R.target===`draft-2020-12`?(X.prefixItems=_e,ye&&(X.items=ye)):R.target===`openapi-3.0`?(X.items={anyOf:_e},ye&&X.items.anyOf.push(ye),X.minItems=_e.length,ye||(X.maxItems=_e.length)):(X.items=_e,ye&&(X.additionalItems=ye));let{minimum:be,maximum:Ce}=e._zod.bag;typeof be==`number`&&(X.minItems=be),typeof Ce==`number`&&(X.maxItems=Ce)},Mo=(e,R,W,Y)=>{let X=W,ie=e._zod.def;X.type=`object`,R.target!==`draft-07`&&R.target!==`draft-2020-12`||(X.propertyNames=so(ie.keyType,R,{...Y,path:[...Y.path,`propertyNames`]})),X.additionalProperties=so(ie.valueType,R,{...Y,path:[...Y.path,`additionalProperties`]})},Oo=(e,R,W,Y)=>{let X=e._zod.def,ie=so(X.innerType,R,Y),ae=R.seen.get(e);R.target===`openapi-3.0`?(ae.ref=X.innerType,W.nullable=!0):W.anyOf=[ie,{type:`null`}]},Uo=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType},Jo=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType,W.default=JSON.parse(JSON.stringify(X.defaultValue))},Zo=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType,R.io===`input`&&(W._prefault=JSON.parse(JSON.stringify(X.defaultValue)))},qo=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y);let ie;R.seen.get(e).ref=X.innerType;try{ie=X.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}W.default=ie},jo=(e,R,W,Y)=>{let X=e._zod.def,ie=R.io===`input`?X.in._zod.def.type===`transform`?X.out:X.in:X.out;so(ie,R,Y),R.seen.get(e).ref=ie},Yo=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType,W.readOnly=!0},Ho=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType},Po=(e,R,W,Y)=>{let X=e._zod.def;so(X.innerType,R,Y),R.seen.get(e).ref=X.innerType},$o=(e,R,W,Y)=>{let X=e._zod.innerType;so(X,R,Y),R.seen.get(e).ref=X},X_=N(`ZodISODateTime`,((e,R)=>{Ug.init(e,R),gv.init(e,R)}));function Wo(e){return function(e,R){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...se(R)})}(X_,e)}const Z_=N(`ZodISODate`,((e,R)=>{Wg.init(e,R),gv.init(e,R)}));function Xo(e){return function(e,R){return new e({type:`string`,format:`date`,check:`string_format`,...se(R)})}(Z_,e)}const Q_=N(`ZodISOTime`,((e,R)=>{Gg.init(e,R),gv.init(e,R)}));function ts(e){return function(e,R){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...se(R)})}(Q_,e)}const $_=N(`ZodISODuration`,((e,R)=>{Kg.init(e,R),gv.init(e,R)}));function is(e){return function(e,R){return new e({type:`string`,format:`duration`,check:`string_format`,...se(R)})}($_,e)}const ns=(e,R)=>{Xm.init(e,R),e.name=`ZodError`,Object.defineProperties(e,{format:{value:R=>function(e,R=e=>e.message){let W={_errors:[]},i=e=>{for(let Y of e.issues)if(Y.code===`invalid_union`&&Y.errors.length)Y.errors.map((e=>i({issues:e})));else if(Y.code===`invalid_key`)i({issues:Y.issues});else if(Y.code===`invalid_element`)i({issues:Y.issues});else if(Y.path.length===0)W._errors.push(R(Y));else{let e=W,X=0;for(;X<Y.path.length;){let W=Y.path[X];X===Y.path.length-1?(e[W]=e[W]||{_errors:[]},e[W]._errors.push(R(Y))):e[W]=e[W]||{_errors:[]},e=e[W],X++}}};return i(e),W}(e,R)},flatten:{value:R=>function(e,R=e=>e.message){let W={},Y=[];for(let X of e.issues)X.path.length>0?(W[X.path[0]]=W[X.path[0]]||[],W[X.path[0]].push(R(X))):Y.push(R(X));return{formErrors:Y,fieldErrors:W}}(e,R)},addIssue:{value:R=>{e.issues.push(R),e.message=JSON.stringify(e.issues,J,2)}},addIssues:{value:R=>{e.issues.push(...R),e.message=JSON.stringify(e.issues,J,2)}},isEmpty:{get:()=>e.issues.length===0}})},ev=(N(`ZodError`,ns),N(`ZodError`,ns,{Parent:Error})),tv=Ee(ev),nv=me(ev),rv=we(ev),iv=ve(ev),av=ke(ev),ov=De(ev),sv=Se(ev),cv=xe(ev),lv=ze(ev),uv=Fe(ev),dv=Le(ev),fv=Ne(ev),pv=N(`ZodType`,((e,R)=>(Og.init(e,R),Object.assign(e[`~standard`],{jsonSchema:{input:co(e,`input`),output:co(e,`output`)}}),e.toJSONSchema=((e,R={})=>W=>{let Y=oo({...W,processors:R});return so(e,Y),ro(Y,e),ao(Y,e)})(e,{}),e.def=R,e.type=R.type,Object.defineProperty(e,"_def",{value:R}),e.check=(...W)=>e.clone($(R,{checks:[...R.checks??[],...W.map((e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e))]})),e.clone=(R,W)=>oe(e,R,W),e.brand=()=>e,e.register=(R,W)=>(R.add(e,W),e),e.parse=(R,W)=>tv(e,R,W,{callee:e.parse}),e.safeParse=(R,W)=>rv(e,R,W),e.parseAsync=async(R,W)=>nv(e,R,W,{callee:e.parseAsync}),e.safeParseAsync=async(R,W)=>iv(e,R,W),e.spa=e.safeParseAsync,e.encode=(R,W)=>av(e,R,W),e.decode=(R,W)=>ov(e,R,W),e.encodeAsync=async(R,W)=>sv(e,R,W),e.decodeAsync=async(R,W)=>cv(e,R,W),e.safeEncode=(R,W)=>lv(e,R,W),e.safeDecode=(R,W)=>uv(e,R,W),e.safeEncodeAsync=async(R,W)=>dv(e,R,W),e.safeDecodeAsync=async(R,W)=>fv(e,R,W),e.refine=(R,W)=>e.check(ll(R,W)),e.superRefine=R=>e.check(cl(R)),e.overwrite=R=>e.check(Wn(R)),e.optional=()=>Sa(e),e.nullable=()=>za(e),e.nullish=()=>Sa(za(e)),e.nonoptional=R=>Ma(e,R),e.array=()=>Kr(e),e.or=R=>ia([e,R]),e.and=R=>la(e,R),e.transform=R=>Ha(e,ka(R)),e.default=R=>Na(e,R),e.prefault=R=>Ta(e,R),e.catch=R=>Za(e,R),e.pipe=R=>Ha(e,R),e.readonly=()=>Wa(e),e.describe=R=>{let W=e.clone();return J_.add(W,{description:R}),W},Object.defineProperty(e,"description",{get:()=>J_.get(e)?.description,configurable:!0}),e.meta=(...R)=>{if(R.length===0)return J_.get(e);let W=e.clone();return J_.add(W,R[0]),W},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e))),mv=N(`_ZodString`,((e,R)=>{kg.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>ho(e,R,W);let W=e._zod.bag;e.format=W.format??null,e.minLength=W.minimum??null,e.maxLength=W.maximum??null,e.regex=(...R)=>e.check(Zn(...R)),e.includes=(...R)=>e.check(Yn(...R)),e.startsWith=(...R)=>e.check(Hn(...R)),e.endsWith=(...R)=>e.check(Pn(...R)),e.min=(...R)=>e.check(Un(...R)),e.max=(...R)=>e.check(On(...R)),e.length=(...R)=>e.check(Jn(...R)),e.nonempty=(...R)=>e.check(Un(1,...R)),e.lowercase=R=>e.check(qn(R)),e.uppercase=R=>e.check(jn(R)),e.trim=()=>e.check(Xn()),e.normalize=(...R)=>e.check(Vn(...R)),e.toLowerCase=()=>e.check(eo()),e.toUpperCase=()=>e.check(to()),e.slugify=()=>e.check(Ao())})),hv=N(`ZodString`,((e,R)=>{kg.init(e,R),mv.init(e,R),e.email=R=>e.check(sn(_v,R)),e.url=R=>e.check(dn(bv,R)),e.jwt=R=>e.check(bn(Iv,R)),e.emoji=R=>e.check(hn(xv,R)),e.guid=R=>e.check(rn(vv,R)),e.uuid=R=>e.check(an(yv,R)),e.uuidv4=R=>e.check(ln(yv,R)),e.uuidv6=R=>e.check(cn(yv,R)),e.uuidv7=R=>e.check(gn(yv,R)),e.nanoid=R=>e.check(un(Sv,R)),e.guid=R=>e.check(rn(vv,R)),e.cuid=R=>e.check(In(Cv,R)),e.cuid2=R=>e.check(pn(wv,R)),e.ulid=R=>e.check(fn(Tv,R)),e.base64=R=>e.check(wn(Nv,R)),e.base64url=R=>e.check(_n(Pv,R)),e.xid=R=>e.check(Bn(Ev,R)),e.ksuid=R=>e.check(Cn(Dv,R)),e.ipv4=R=>e.check(En(Ov,R)),e.ipv6=R=>e.check(Qn(Av,R)),e.cidrv4=R=>e.check(mn(jv,R)),e.cidrv6=R=>e.check(yn(Mv,R)),e.e164=R=>e.check(vn(Fv,R)),e.datetime=R=>e.check(Wo(R)),e.date=R=>e.check(Xo(R)),e.time=R=>e.check(ts(R)),e.duration=R=>e.check(is(R))}));function Qs(e){return function(e,R){return new e({type:`string`,...se(R)})}(hv,e)}const gv=N(`ZodStringFormat`,((e,R)=>{jg.init(e,R),mv.init(e,R)})),_v=N(`ZodEmail`,((e,R)=>{Pg.init(e,R),gv.init(e,R)}));function ws(e){return sn(_v,e)}const vv=N(`ZodGUID`,((e,R)=>{Mg.init(e,R),gv.init(e,R)}));function vs(e){return rn(vv,e)}const yv=N(`ZodUUID`,((e,R)=>{Ng.init(e,R),gv.init(e,R)}));function ks(e){return an(yv,e)}function Ds(e){return ln(yv,e)}function Ss(e){return cn(yv,e)}function xs(e){return gn(yv,e)}const bv=N(`ZodURL`,((e,R)=>{Fg.init(e,R),gv.init(e,R)}));function Fs(e){return dn(bv,e)}function Ls(e){return dn(bv,{protocol:/^https?$/,hostname:Oh,...se(e)})}const xv=N(`ZodEmoji`,((e,R)=>{Ig.init(e,R),gv.init(e,R)}));function Gs(e){return hn(xv,e)}const Sv=N(`ZodNanoID`,((e,R)=>{Lg.init(e,R),gv.init(e,R)}));function Rs(e){return un(Sv,e)}const Cv=N(`ZodCUID`,((e,R)=>{Rg.init(e,R),gv.init(e,R)}));function Os(e){return In(Cv,e)}const wv=N(`ZodCUID2`,((e,R)=>{zg.init(e,R),gv.init(e,R)}));function Js(e){return pn(wv,e)}const Tv=N(`ZodULID`,((e,R)=>{Bg.init(e,R),gv.init(e,R)}));function qs(e){return fn(Tv,e)}const Ev=N(`ZodXID`,((e,R)=>{Vg.init(e,R),gv.init(e,R)}));function Ys(e){return Bn(Ev,e)}const Dv=N(`ZodKSUID`,((e,R)=>{Hg.init(e,R),gv.init(e,R)}));function Ps(e){return Cn(Dv,e)}const Ov=N(`ZodIPv4`,((e,R)=>{qg.init(e,R),gv.init(e,R)}));function Ks(e){return En(Ov,e)}const kv=N(`ZodMAC`,((e,R)=>{Yg.init(e,R),gv.init(e,R)}));function Vs(e){return function(e,R){return new e({type:`string`,format:`mac`,check:`string_format`,abort:!1,...se(R)})}(kv,e)}const Av=N(`ZodIPv6`,((e,R)=>{Jg.init(e,R),gv.init(e,R)}));function er(e){return Qn(Av,e)}const jv=N(`ZodCIDRv4`,((e,R)=>{Xg.init(e,R),gv.init(e,R)}));function Ar(e){return mn(jv,e)}const Mv=N(`ZodCIDRv6`,((e,R)=>{Zg.init(e,R),gv.init(e,R)}));function nr(e){return yn(Mv,e)}const Nv=N(`ZodBase64`,((e,R)=>{Qg.init(e,R),gv.init(e,R)}));function sr(e){return wn(Nv,e)}const Pv=N(`ZodBase64URL`,((e,R)=>{$g.init(e,R),gv.init(e,R)}));function ar(e){return _n(Pv,e)}const Fv=N(`ZodE164`,((e,R)=>{e_.init(e,R),gv.init(e,R)}));function cr(e){return vn(Fv,e)}const Iv=N(`ZodJWT`,((e,R)=>{t_.init(e,R),gv.init(e,R)}));function dr(e){return bn(Iv,e)}const Lv=N(`ZodCustomStringFormat`,((e,R)=>{n_.init(e,R),gv.init(e,R)}));function ur(e,R,W={}){return no(Lv,e,R,W)}function Ir(e){return no(Lv,`hostname`,Dh,e)}function pr(e){return no(Lv,`hex`,Bh,e)}function fr(e,R){let W=`${e}_${R?.enc??`hex`}`,Y=Rm[W];if(!Y)throw Error(`Unrecognized hash format: ${W}`);return no(Lv,W,Y,R)}const Rv=N(`ZodNumber`,((e,R)=>{r_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>uo(e,R,W),e.gt=(R,W)=>e.check(Sn(R,W)),e.gte=(R,W)=>e.check(xn(R,W)),e.min=(R,W)=>e.check(xn(R,W)),e.lt=(R,W)=>e.check(kn(R,W)),e.lte=(R,W)=>e.check(Dn(R,W)),e.max=(R,W)=>e.check(Dn(R,W)),e.int=R=>e.check(Qr(R)),e.safe=R=>e.check(Qr(R)),e.positive=R=>e.check(Sn(0,R)),e.nonnegative=R=>e.check(xn(0,R)),e.negative=R=>e.check(kn(0,R)),e.nonpositive=R=>e.check(Dn(0,R)),e.multipleOf=(R,W)=>e.check(Gn(R,W)),e.step=(R,W)=>e.check(Gn(R,W)),e.finite=()=>e;let W=e._zod.bag;e.minValue=Math.max(W.minimum??-1/0,W.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(W.maximum??1/0,W.exclusiveMaximum??1/0)??null,e.isInt=(W.format??``).includes(`int`)||Number.isSafeInteger(W.multipleOf??.5),e.isFinite=!0,e.format=W.format??null}));function Cr(e){return function(e,R){return new e({type:`number`,checks:[],...se(R)})}(Rv,e)}const zv=N(`ZodNumberFormat`,((e,R)=>{i_.init(e,R),Rv.init(e,R)}));function Qr(e){return function(e,R){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...se(R)})}(zv,e)}function mr(e){return function(e,R){return new e({type:`number`,check:`number_format`,abort:!1,format:`float32`,...se(R)})}(zv,e)}function yr(e){return function(e,R){return new e({type:`number`,check:`number_format`,abort:!1,format:`float64`,...se(R)})}(zv,e)}function wr(e){return function(e,R){return new e({type:`number`,check:`number_format`,abort:!1,format:`int32`,...se(R)})}(zv,e)}function _r(e){return function(e,R){return new e({type:`number`,check:`number_format`,abort:!1,format:`uint32`,...se(R)})}(zv,e)}const Bv=N(`ZodBoolean`,((e,R)=>{a_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Io(0,0,R)}));function br(e){return function(e,R){return new e({type:`boolean`,...se(R)})}(Bv,e)}const Vv=N(`ZodBigInt`,((e,R)=>{o_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>po(0,e),e.gte=(R,W)=>e.check(xn(R,W)),e.min=(R,W)=>e.check(xn(R,W)),e.gt=(R,W)=>e.check(Sn(R,W)),e.gte=(R,W)=>e.check(xn(R,W)),e.min=(R,W)=>e.check(xn(R,W)),e.lt=(R,W)=>e.check(kn(R,W)),e.lte=(R,W)=>e.check(Dn(R,W)),e.max=(R,W)=>e.check(Dn(R,W)),e.positive=R=>e.check(Sn(BigInt(0),R)),e.negative=R=>e.check(kn(BigInt(0),R)),e.nonpositive=R=>e.check(Dn(BigInt(0),R)),e.nonnegative=R=>e.check(xn(BigInt(0),R)),e.multipleOf=(R,W)=>e.check(Gn(R,W));let W=e._zod.bag;e.minValue=W.minimum??null,e.maxValue=W.maximum??null,e.format=W.format??null}));function Dr(e){return function(e,R){return new e({type:`bigint`,...se(R)})}(Vv,e)}const Hv=N(`ZodBigIntFormat`,((e,R)=>{s_.init(e,R),Vv.init(e,R)}));function xr(e){return function(e,R){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`int64`,...se(R)})}(Hv,e)}function zr(e){return function(e,R){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`uint64`,...se(R)})}(Hv,e)}const Uv=N(`ZodSymbol`,((e,R)=>{c_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>fo(0,e)}));function Lr(e){return function(e,R){return new e({type:`symbol`,...se(R)})}(Uv,e)}const Wv=N(`ZodUndefined`,((e,R)=>{l_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Co(0,e)}));function Gr(e){return function(e,R){return new e({type:`undefined`,...se(R)})}(Wv,e)}const Gv=N(`ZodNull`,((e,R)=>{u_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Bo(0,e,R)}));function Rr(e){return function(e,R){return new e({type:`null`,...se(R)})}(Gv,e)}const Kv=N(`ZodAny`,((e,R)=>{d_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>{}}));function Or(){return function(e){return new e({type:`any`})}(Kv)}const qv=N(`ZodUnknown`,((e,R)=>{f_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>{}}));function Jr(){return function(e){return new e({type:`unknown`})}(qv)}const Jv=N(`ZodNever`,((e,R)=>{p_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Qo(0,0,R)}));function qr(e){return function(e,R){return new e({type:`never`,...se(R)})}(Jv,e)}const Yv=N(`ZodVoid`,((e,R)=>{m_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Eo(0,e)}));function Yr(e){return function(e,R){return new e({type:`void`,...se(R)})}(Yv,e)}const Xv=N(`ZodDate`,((e,R)=>{h_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>mo(0,e),e.min=(R,W)=>e.check(xn(R,W)),e.max=(R,W)=>e.check(Dn(R,W));let W=e._zod.bag;e.minDate=W.minimum?new Date(W.minimum):null,e.maxDate=W.maximum?new Date(W.maximum):null}));function Pr(e){return function(e,R){return new e({type:`date`,...se(R)})}(Xv,e)}const Zv=N(`ZodArray`,((e,R)=>{g_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Lo(e,R,W,Y),e.element=R.element,e.min=(R,W)=>e.check(Un(R,W)),e.nonempty=R=>e.check(Un(1,R)),e.max=(R,W)=>e.check(On(R,W)),e.length=(R,W)=>e.check(Jn(R,W)),e.unwrap=()=>e.element}));function Kr(e,R){return function(e,R,W){return new e({type:`array`,element:R,...se(W)})}(Zv,e,R)}function Wr(e){let R=e._zod.def.shape;return Qa(Object.keys(R))}const Qv=N(`ZodObject`,((e,R)=>{v_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>No(e,R,W,Y),H(e,`shape`,(()=>R.shape)),e.keyof=()=>Qa(Object.keys(e._zod.def.shape)),e.catchall=R=>e.clone({...e._zod.def,catchall:R}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Jr()}),e.loose=()=>e.clone({...e._zod.def,catchall:Jr()}),e.strict=()=>e.clone({...e._zod.def,catchall:qr()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=R=>function(e,R){if(!ee(R))throw Error(`Invalid input to extend: expected a plain object`);let W=e._zod.def.checks;if(W&&W.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return oe(e,$(e._zod.def,{get shape(){let W={...e._zod.def.shape,...R};return P(this,`shape`,W),W},checks:[]}))}(e,R),e.safeExtend=R=>function(e,R){if(!ee(R))throw Error(`Invalid input to safeExtend: expected a plain object`);return oe(e,{...e._zod.def,get shape(){let W={...e._zod.def.shape,...R};return P(this,`shape`,W),W},checks:e._zod.def.checks})}(e,R),e.merge=R=>function(e,R){return oe(e,$(e._zod.def,{get shape(){let W={...e._zod.def.shape,...R._zod.def.shape};return P(this,`shape`,W),W},get catchall(){return R._zod.def.catchall},checks:[]}))}(e,R),e.pick=R=>function(e,R){let W=e._zod.def;return oe(e,$(e._zod.def,{get shape(){let e={};for(let Y in R){if(!(Y in W.shape))throw Error(`Unrecognized key: "${Y}"`);R[Y]&&(e[Y]=W.shape[Y])}return P(this,`shape`,e),e},checks:[]}))}(e,R),e.omit=R=>function(e,R){let W=e._zod.def;return oe(e,$(e._zod.def,{get shape(){let Y={...e._zod.def.shape};for(let e in R){if(!(e in W.shape))throw Error(`Unrecognized key: "${e}"`);R[e]&&delete Y[e]}return P(this,`shape`,Y),Y},checks:[]}))}(e,R),e.partial=(...R)=>function(e,R,W){return oe(R,$(R._zod.def,{get shape(){let Y=R._zod.def.shape,X={...Y};if(W)for(let R in W){if(!(R in Y))throw Error(`Unrecognized key: "${R}"`);W[R]&&(X[R]=e?new e({type:`optional`,innerType:Y[R]}):Y[R])}else for(let R in Y)X[R]=e?new e({type:`optional`,innerType:Y[R]}):Y[R];return P(this,`shape`,X),X},checks:[]}))}(dy,e,R[0]),e.required=(...R)=>function(e,R,W){return oe(R,$(R._zod.def,{get shape(){let Y=R._zod.def.shape,X={...Y};if(W)for(let R in W){if(!(R in X))throw Error(`Unrecognized key: "${R}"`);W[R]&&(X[R]=new e({type:`nonoptional`,innerType:Y[R]}))}else for(let R in Y)X[R]=new e({type:`nonoptional`,innerType:Y[R]});return P(this,`shape`,X),X},checks:[]}))}(hy,e,R[0])}));function Xr(e,R){return new Qv({type:`object`,shape:e??{},...se(R)})}function ea(e,R){return new Qv({type:`object`,shape:e,catchall:qr(),...se(R)})}function ta(e,R){return new Qv({type:`object`,shape:e,catchall:Jr(),...se(R)})}const $v=N(`ZodUnion`,((e,R)=>{y_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Go(e,R,W,Y),e.options=R.options}));function ia(e,R){return new $v({type:`union`,options:e,...se(R)})}const ey=N(`ZodXor`,((e,R)=>{$v.init(e,R),b_.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Go(e,R,W,Y),e.options=R.options}));function oa(e,R){return new ey({type:`union`,options:e,inclusive:!1,...se(R)})}const ty=N(`ZodDiscriminatedUnion`,((e,R)=>{$v.init(e,R),x_.init(e,R)}));function ra(e,R,W){return new ty({type:`union`,options:R,discriminator:e,...se(W)})}const ny=N(`ZodIntersection`,((e,R)=>{S_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>To(e,R,W,Y)}));function la(e,R){return new ny({type:`intersection`,left:e,right:R})}const ry=N(`ZodTuple`,((e,R)=>{C_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Ro(e,R,W,Y),e.rest=R=>e.clone({...e._zod.def,rest:R})}));function ga(e,R,W){let Y=R instanceof Og;return new ry({type:`tuple`,items:e,rest:Y?R:null,...se(Y?W:R)})}const iy=N(`ZodRecord`,((e,R)=>{w_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Mo(e,R,W,Y),e.keyType=R.keyType,e.valueType=R.valueType}));function ha(e,R,W){return new iy({type:`record`,keyType:e,valueType:R,...se(W)})}function ua(e,R,W){let Y=oe(e);return Y._zod.values=void 0,new iy({type:`record`,keyType:Y,valueType:R,...se(W)})}function Ia(e,R,W){return new iy({type:`record`,keyType:e,valueType:R,mode:`loose`,...se(W)})}const ay=N(`ZodMap`,((e,R)=>{T_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>zo(0,e),e.keyType=R.keyType,e.valueType=R.valueType}));function fa(e,R,W){return new ay({type:`map`,keyType:e,valueType:R,...se(W)})}const oy=N(`ZodSet`,((e,R)=>{E_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Fo(0,e),e.min=(...R)=>e.check(Rn(...R)),e.nonempty=R=>e.check(Rn(1,R)),e.max=(...R)=>e.check(Tn(...R)),e.size=(...R)=>e.check(Mn(...R))}));function Ca(e,R){return new oy({type:`set`,valueType:e,...se(R)})}const sy=N(`ZodEnum`,((e,R)=>{D_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>yo(e,0,W),e.enum=R.entries,e.options=Object.values(R.entries);let W=new Set(Object.keys(R.entries));e.extract=(e,Y)=>{let X={};for(let Y of e){if(!W.has(Y))throw Error(`Key ${Y} not found in enum`);X[Y]=R.entries[Y]}return new sy({...R,checks:[],...se(Y),entries:X})},e.exclude=(e,Y)=>{let X={...R.entries};for(let R of e){if(!W.has(R))throw Error(`Key ${R} not found in enum`);delete X[R]}return new sy({...R,checks:[],...se(Y),entries:X})}}));function Qa(e,R){return new sy({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e,...se(R)})}function ma(e,R){return new sy({type:`enum`,entries:e,...se(R)})}const cy=N(`ZodLiteral`,((e,R)=>{O_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>wo(e,R,W),e.values=new Set(R.values),Object.defineProperty(e,"value",{get(){if(R.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return R.values[0]}})}));function wa(e,R){return new cy({type:`literal`,values:Array.isArray(e)?e:[e],...se(R)})}const ly=N(`ZodFile`,((e,R)=>{k_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>bo(e,0,W),e.min=(R,W)=>e.check(Rn(R,W)),e.max=(R,W)=>e.check(Tn(R,W)),e.mime=(R,W)=>e.check(Kn(Array.isArray(R)?R:[R],W))}));function va(e){return function(e,R){return new e({type:`file`,...se(R)})}(ly,e)}const uy=N(`ZodTransform`,((e,R)=>{A_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>xo(0,e),e._zod.parse=(W,Y)=>{if(Y.direction===`backward`)throw new T(e.constructor.name);W.addIssue=Y=>{if(typeof Y==`string`)W.issues.push(pe(Y,W.value,R));else{let R=Y;R.fatal&&(R.continue=!1),R.code??=`custom`,R.input??=W.value,R.inst??=e,W.issues.push(pe(R))}};let X=R.transform(W.value,W);return X instanceof Promise?X.then((e=>(W.value=e,W))):(W.value=X,W)}}));function ka(e){return new uy({type:`transform`,transform:e})}const dy=N(`ZodOptional`,((e,R)=>{j_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Po(e,R,0,Y),e.unwrap=()=>e._zod.def.innerType}));function Sa(e){return new dy({type:`optional`,innerType:e})}const fy=N(`ZodNullable`,((e,R)=>{M_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Oo(e,R,W,Y),e.unwrap=()=>e._zod.def.innerType}));function za(e){return new fy({type:`nullable`,innerType:e})}function Fa(e){return Sa(za(e))}const py=N(`ZodDefault`,((e,R)=>{N_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Jo(e,R,W,Y),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));function Na(e,R){return new py({type:`default`,innerType:e,get defaultValue(){return typeof R==`function`?R():te(R)}})}const my=N(`ZodPrefault`,((e,R)=>{P_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Zo(e,R,W,Y),e.unwrap=()=>e._zod.def.innerType}));function Ta(e,R){return new my({type:`prefault`,innerType:e,get defaultValue(){return typeof R==`function`?R():te(R)}})}const hy=N(`ZodNonOptional`,((e,R)=>{F_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Uo(e,R,0,Y),e.unwrap=()=>e._zod.def.innerType}));function Ma(e,R){return new hy({type:`nonoptional`,innerType:e,...se(R)})}const gy=N(`ZodSuccess`,((e,R)=>{I_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>ko(0,0,R),e.unwrap=()=>e._zod.def.innerType}));function Ua(e){return new gy({type:`success`,innerType:e})}const _y=N(`ZodCatch`,((e,R)=>{L_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>qo(e,R,W,Y),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));function Za(e,R){return new _y({type:`catch`,innerType:e,catchValue:typeof R==`function`?R:()=>R})}const vy=N(`ZodNaN`,((e,R)=>{R_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>_o(0,e)}));function ja(e){return function(e,R){return new e({type:`nan`,...se(R)})}(vy,e)}const yy=N(`ZodPipe`,((e,R)=>{z_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>jo(e,R,0,Y),e.in=R.in,e.out=R.out}));function Ha(e,R){return new yy({type:`pipe`,in:e,out:R})}const by=N(`ZodCodec`,((e,R)=>{yy.init(e,R),B_.init(e,R)}));function $a(e,R,W){return new by({type:`pipe`,in:e,out:R,transform:W.decode,reverseTransform:W.encode})}const xy=N(`ZodReadonly`,((e,R)=>{V_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Yo(e,R,W,Y),e.unwrap=()=>e._zod.def.innerType}));function Wa(e){return new xy({type:`readonly`,innerType:e})}const Sy=N(`ZodTemplateLiteral`,((e,R)=>{H_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>vo(e,0,W)}));function Xa(e,R){return new Sy({type:`template_literal`,parts:e,...se(R)})}const Cy=N(`ZodLazy`,((e,R)=>{G_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>$o(e,R,0,Y),e.unwrap=()=>e._zod.def.getter()}));function tl(e){return new Cy({type:`lazy`,getter:e})}const wy=N(`ZodPromise`,((e,R)=>{W_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(R,W,Y)=>Ho(e,R,0,Y),e.unwrap=()=>e._zod.def.innerType}));function il(e){return new wy({type:`promise`,innerType:e})}const Ty=N(`ZodFunction`,((e,R)=>{U_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>So(0,e)}));function ol(e){return new Ty({type:`function`,input:Array.isArray(e?.input)?ga(e?.input):e?.input??Kr(Jr()),output:e?.output??Jr()})}const Ey=N(`ZodCustom`,((e,R)=>{K_.init(e,R),pv.init(e,R),e._zod.processJSONSchema=(e,R,W)=>Do(0,e)}));function rl(e){let R=new rg({check:`custom`});return R._zod.check=e,R}function al(e,R){return function(e,R,W){let Y=se(W);return Y.abort??=!0,new e({type:`custom`,check:`custom`,fn:R,...Y})}(Ey,e??(()=>!0),R)}function ll(e,R={}){return function(e,R,W){return new e({type:`custom`,check:`custom`,fn:R,...se(W)})}(Ey,e,R)}function cl(e){return io(e)}const gl=function(e){let R=new rg({check:`describe`});return R._zod.onattach=[R=>{let W=J_.get(R)??{};J_.add(R,{...W,description:e})}],R._zod.check=()=>{},R},dl=function(e){let R=new rg({check:`meta`});return R._zod.onattach=[R=>{let W=J_.get(R)??{};J_.add(R,{...W,...e})}],R._zod.check=()=>{},R};function hl(e,R={error:`Input not instance of ${e.name}`}){let W=new Ey({type:`custom`,check:`custom`,fn:R=>R instanceof e,abort:!0,...se(R)});return W._zod.bag.Class=e,W}const ul=(...e)=>function(e,R){let W=se(R),Y=W.truthy??[`true`,`1`,`yes`,`on`,`y`,`enabled`],X=W.falsy??[`false`,`0`,`no`,`off`,`n`,`disabled`];W.case!==`sensitive`&&(Y=Y.map((e=>typeof e==`string`?e.toLowerCase():e)),X=X.map((e=>typeof e==`string`?e.toLowerCase():e)));let ie=new Set(Y),ae=new Set(X),le=e.Codec??B_,_e=e.Boolean??a_,ye=new le({type:`pipe`,in:new(e.String??kg)({type:`string`,error:W.error}),out:new _e({type:`boolean`,error:W.error}),transform:(e,R)=>{let Y=e;return W.case!==`sensitive`&&(Y=Y.toLowerCase()),!!ie.has(Y)||!ae.has(Y)&&(R.issues.push({code:`invalid_value`,expected:`stringbool`,values:[...ie,...ae],input:R.value,inst:ye,continue:!1}),{})},reverseTransform:(e,R)=>!0===e?Y[0]||`true`:X[0]||`false`,error:W.error});return ye}({Codec:by,Boolean:Bv,String:hv},...e);function Il(e){let R=tl((()=>ia([Qs(e),Cr(),br(),Rr(),Kr(R),ha(Qs(),R)])));return R}function pl(e,R){return Ha(ka(e),R)}var Dy;Dy||={},M({localeError:tn()});const Oy=ra(`type`,[Xr({name:Qs(),type:wa(`int`),value:Cr().int()}),Xr({name:Qs(),type:wa(`bool`),value:br()}),Xr({name:Qs(),type:wa(`float`),value:Cr()}),Xr({name:Qs(),type:wa(`string`),value:Qs()}),Xr({name:Qs(),type:wa(`file`),value:Qs()}),Xr({name:Qs(),type:wa(`color`),value:Qs()}),Xr({name:Qs(),type:wa(`object`),value:Cr()})]),ky=Xr({name:Qs(),type:wa(`tilelayer`),class:Qs().optional(),height:Cr(),width:Cr(),x:Cr(),y:Cr(),id:Cr(),opacity:Cr(),properties:Kr(Oy).optional(),visible:br(),tintcolor:Qs().optional(),parallaxx:Cr().optional(),parallaxy:Cr().optional(),offsetx:Cr().optional(),offsety:Cr().optional()}),Ay=ky.extend({data:Kr(Cr()),encoding:wa(`csv`)}),jy=ky.extend({data:Kr(Cr()),encoding:wa(`base64`),compression:wa(`gzip`)}),My=ky.extend({data:Kr(Cr()),encoding:wa(`base64`),compression:wa(`zlib`)}),Ny=ky.extend({data:Kr(Cr()),encoding:wa(`base64`),compression:wa(`zstandard`)}),Py=ky.extend({data:Qs(),encoding:wa(`base64`),compression:Qs().optional()}),Fy=ia([Xr({x:Cr(),y:Cr(),width:Cr(),height:Cr(),data:Qs()}),Xr({x:Cr(),y:Cr(),width:Cr(),height:Cr(),data:Kr(Cr())})]),Iy=ia([Py,Ay,jy,My,Ny,ky.extend({startx:Cr(),starty:Cr(),chunks:Kr(Fy),encoding:Qs().optional(),compression:Qs().optional(),data:Gr()})]);function kl(e){return e.encoding===`base64`}function Dl(e){return e.encoding===`csv`||Array.isArray(e.data)}const Ly=Xr({x:Cr(),y:Cr()}),Ry=Kr(Ly),zy=Xr({text:Qs(),color:Qs().optional(),fontfamily:Qs().optional(),pixelsize:Cr().optional(),wrap:br().optional(),halign:ia([wa(`left`),wa(`center`),wa(`right`),wa(`justify`)]).optional(),valign:ia([wa(`top`),wa(`center`),wa(`bottom`)]).optional()}),By=Xr({id:Cr().optional(),name:Qs().optional(),type:Qs().optional(),x:Cr().optional(),y:Cr().optional(),rotation:Cr().optional(),height:Cr().optional(),width:Cr().optional(),visible:br().optional(),gid:Cr().optional(),text:zy.optional(),point:br().optional(),ellipse:br().optional(),polyline:Kr(Ly).optional(),polygon:Ry.optional(),template:Qs().optional(),properties:Kr(Oy).optional()}),Vy=Xr({duration:Cr(),tileid:Cr()}),Hy=Xr({name:Qs(),draworder:Qs(),type:wa(`objectgroup`),class:Qs().optional(),x:Cr(),y:Cr(),id:Cr(),color:Qs().optional(),tintcolor:Qs().optional(),parallaxx:Cr().optional(),parallaxy:Cr().optional(),offsetx:Cr().optional(),offsety:Cr().optional(),opacity:Cr(),properties:Kr(Oy).optional(),visible:br(),objects:Kr(By)}),Uy=ia([Iy,Xr({name:Qs(),x:Cr(),y:Cr(),id:Cr(),type:wa(`imagelayer`),class:Qs().optional(),image:Qs().optional(),opacity:Cr(),properties:Kr(Oy).optional(),visible:br(),tintcolor:Qs().optional(),repeatx:br().optional(),repeaty:br().optional(),parallaxx:Cr().optional(),parallaxy:Cr().optional(),offsetx:Cr().optional(),offsety:Cr().optional(),transparentcolor:Qs().optional()}),Hy]),Wy=Xr({draworder:Qs(),id:Cr().optional(),name:Qs(),x:Cr(),y:Cr(),opacity:Cr(),tintcolor:Qs().optional(),type:wa(`objectgroup`),visible:br(),objects:Kr(By),properties:Kr(Oy).optional()}),Gy=Xr({id:Cr(),type:Qs().optional(),animation:Kr(Vy).optional(),objectgroup:Wy.optional(),probability:Cr().optional(),properties:Kr(Oy).optional(),image:Qs().optional(),imageheight:Cr().optional(),imagewidth:Cr().optional()}),Ky=Xr({name:Qs(),firstgid:Cr().optional(),class:Qs().optional(),objectalignment:ia([wa(`topleft`),wa(`top`),wa(`topright`),wa(`left`),wa(`center`),wa(`right`),wa(`bottomleft`),wa(`bottom`),wa(`bottomright`)]).optional(),image:Qs().optional(),imagewidth:Cr().optional(),imageheight:Cr().optional(),columns:Cr(),tileheight:Cr(),tilewidth:Cr(),tilecount:Cr(),grid:Xr({height:Cr(),width:Cr(),orientation:ia([wa(`isometric`),wa(`orthogonal`)])}).optional(),tileoffset:Ly.optional(),spacing:Cr(),margin:Cr(),tiles:Kr(Gy).optional(),properties:Kr(Oy).optional()});function Ol(e){return!!e.image}function Ul(e){return!e.image}const qy=Ky.extend({tiledversion:Qs().optional(),type:wa(`tileset`),version:Qs().optional()}),Jy=Xr({firstgid:Cr(),source:Qs()}),Yy=ia([Ky,Jy]),Xy=Xr({object:By.extend({id:Cr().optional()}),tileset:Jy.optional(),type:wa(`template`)}),Zy=Xr({type:Qs(),class:Qs().optional(),tiledversion:Qs(),version:Qs(),width:Cr(),height:Cr(),tilewidth:Cr(),tileheight:Cr(),compressionlevel:Cr().optional(),infinite:br(),nextlayerid:Cr(),nextobjectid:Cr(),parallaxoriginx:Cr().optional(),parallaxoriginy:Cr().optional(),hexsidelength:Cr().optional(),staggeraxis:wa(`y`).or(wa(`x`)).optional(),staggerindex:wa(`odd`).or(wa(`even`)).optional(),orientation:ia([wa(`isometric`),wa(`orthogonal`),wa(`staggered`),wa(`hexagonal`)]),renderorder:ia([wa(`right-down`),wa(`right-up`),wa(`left-down`),wa(`left-up`)]),backgroundcolor:Qs().optional(),layers:Kr(Uy),tilesets:Kr(Yy),properties:Kr(Oy).optional()});function Hl(e){return!!e.chunks}function Pl(e){return!e.source}function $l(e){return!!e.source}var Qy=class Kl{constructor(e,R,W,Y){this.x=e,this.y=R,this.width=W,this.height=Y}combine(e){let R=this.x+this.width,W=this.y+this.height,Y=e.x+e.width,X=e.y+e.height,ie=Math.max(R,Y),ae=Math.max(W,X);return new Kl(Math.min(this.x,e.x),Math.min(this.y,e.y),ie-Math.min(this.x,e.x),ae-Math.min(this.y,e.y))}},Wl=class{constructor(){this._largestBounds=new Qy(0,0,0,0)}_coerceNumber(e){return+e}_coerceBoolean(e){switch(e){case`0`:case`false`:return!1;case`true`:return!0;default:return!!e}}_coerceType(e,R){return e===`bool`?this._coerceBoolean(R):e===`int`||e===`float`||e===`object`?this._coerceNumber(R):R}_parsePropertiesNode(e,R){let W=[];if(e)for(let R of e.children){let e=R.getAttribute(`type`)??`string`,Y=R.getAttribute(`value`);Y||=R.innerHTML,W.push({name:R.getAttribute(`name`),type:e,value:this._coerceType(e,Y)})}R.properties=W}_parseAttributes(e,R){let W=`width.height.columns.firstgid.spacing.margin.tilecount.tilewidth.tileheight.opacity.compressionlevel.nextlayerid.nextobjectid.parallaxoriginx.parallaxoriginy.parallaxx.parallaxy.hexsidelength.offsetx.offsety.id.gid.x.y.rotation.probability`.split(`.`),Y=[`infinite`,`visible`,`repeatx`,`repeaty`];for(let X of e.attributes)W.indexOf(X.name)>-1?R[X.name]=this._coerceNumber(X.value):Y.indexOf(X.name)>-1?R[X.name]=this._coerceBoolean(X.value):R[X.name]=X.value}_parseToDocument(e){if(typeof DOMParser<`u`)return new DOMParser().parseFromString(e,`application/xml`);try{let{JSDOM:R}=S(371);return new R(e,{contentType:`application/xml`,encoding:`utf-8`}).window.document}catch{}let R=Error(`Could not find DOM parser`);throw bt.error(R.message,R),R}parseObject(e,R=!0){let W={type:``,x:0,y:0};e.getAttribute(`template`)||(W.visible=!0,W.name=``,W.rotation=0,W.height=0,W.width=0),this._parseAttributes(e,W);let Y=e.querySelector(`properties`);Y&&this._parsePropertiesNode(Y,W);let X=e.querySelector(`text`);if(X){W.text={text:X.textContent};let e=X.getAttribute(`fontfamily`);e&&(W.text.fontfamily=e);let R=X.getAttribute(`color`);R&&(W.text.color=R);let Y=X.getAttribute(`pixelsize`);Y&&(W.text.pixelsize=this._coerceNumber(Y));let ie=X.getAttribute(`wrap`);ie&&(W.text.wrap=this._coerceBoolean(ie));let ae=X.getAttribute(`valign`);ae&&(W.text.valign=ae);let le=X.getAttribute(`halign`);le&&(W.text.halign=le)}e.querySelector(`point`)&&(W.point=!0),e.querySelector(`ellipse`)&&(W.ellipse=!0);let ie=e.querySelector(`polygon`);if(ie){let e=ie.getAttribute(`points`)?.split(` `);W.polygon=[],e&&e.forEach((e=>{let R=e.split(`,`);W.polygon.push({x:+R[0],y:+R[1]})}))}let ae=e.querySelector(`polyline`);if(ae){let e=ae.getAttribute(`points`)?.split(` `);W.polyline=[],e&&e.forEach((e=>{let R=e.split(`,`);W.polyline.push({x:+R[0],y:+R[1]})}))}if(R)try{return By.parse(W)}catch(e){throw bt.error(`Could not parse object`,W,e),e}return W}parseTileset(e,R=!0){let W={spacing:0,margin:0};if(this._parseAttributes(e,W),W.source)try{return Yy.parse(W)}catch(e){bt.error(`Could not parse external tileset`,W,e)}for(let Y of e.children)switch(Y.tagName){case`properties`:this._parsePropertiesNode(Y,W);break;case`tileoffset`:{let e={};this._parseAttributes(Y,e),W.tileoffset=e;break}case`grid`:{let e={};this._parseAttributes(Y,e),W.grid=e;break}case`image`:W.image=Y.getAttribute(`source`),W.imagewidth=this._coerceNumber(Y.getAttribute(`width`)),W.imageheight=this._coerceNumber(Y.getAttribute(`height`));break;case`tile`:{W.tiles||=[];let e={};this._parseAttributes(Y,e);for(let W of Y.children)switch(W.tagName){case`image`:e.image=W.getAttribute(`source`),e.imagewidth=this._coerceNumber(W.getAttribute(`width`)),e.imageheight=this._coerceNumber(W.getAttribute(`height`));break;case`objectgroup`:{let Y={type:`objectgroup`,name:``,visible:!0,x:0,y:0,opacity:1,objects:[]};this._parseAttributes(W,Y),e.objectgroup=Y;for(let e of W.children){let W=this.parseObject(e,R);Y.objects.push(W)}break}case`animation`:{let R=[];for(let e of W.children)R.push({duration:this._coerceNumber(e.getAttribute(`duration`)),tileid:this._coerceNumber(e.getAttribute(`tileid`))});e.animation=R;break}case`properties`:this._parsePropertiesNode(W,e)}if(R)try{W.tiles.push(Gy.parse(e))}catch(R){throw bt.error(`Could not parse Tile`,e,R),R}else W.tiles.push(e);break}}if(R)try{return Yy.parse(W)}catch(e){throw bt.error(`Could not parse Tileset`,W,e),e}return W}parseTileLayer(e,R,W=!0){let Y={type:`tilelayer`,x:0,y:0,opacity:1,visible:!0};this._parseAttributes(e,Y);for(let W of e.children)switch(W.tagName){case`properties`:this._parsePropertiesNode(W,Y);break;case`data`:{let e=W.getAttribute(`encoding`);e&&(Y.encoding=e);let X=W.getAttribute(`compression`);if(X&&(Y.compression=X),R){Y.width=0,Y.height=0,Y.chunks=[];let e=new Qy(0,0,0,0);for(let R of W.children)if(R.tagName===`chunk`){let W={};switch(this._parseAttributes(R,W),Y.encoding){case`base64`:W.data=R.textContent?.trim();break;case`csv`:W.data=R.textContent?.split(`,`).map((e=>+e))}let X=new Qy(W.x,W.y,W.width,W.height);e=e.combine(X),Y.chunks.push(W)}Y.width=e.width,Y.height=e.height,Y.startx=e.x,Y.starty=e.y,this._largestBounds=this._largestBounds.combine(new Qy(Y.startx,Y.starty,Y.width,Y.height))}else switch(Y.encoding){case`base64`:Y.data=W.textContent?.trim();break;case`csv`:Y.data=W.textContent?.split(`,`).map((e=>+e))}}}if(W)try{return Uy.parse(Y)}catch(e){throw bt.error(`Could not parse tiled tile layer`,Y,e),e}return Y}parseObjectGroup(e,R=!0){let W={type:`objectgroup`,draworder:`topdown`,visible:!0,x:0,y:0,opacity:1,objects:[]};this._parseAttributes(e,W);for(let Y of e.children)switch(Y.tagName){case`properties`:this._parsePropertiesNode(Y,W);break;case`object`:{let e=this.parseObject(Y,R);W.objects.push(e);break}}if(R)try{return Uy.parse(W)}catch(e){throw bt.error(`Could not parse object group`,W,e),e}return W}parseImageLayer(e,R=!0){let W={type:`imagelayer`,visible:!0,x:0,y:0,opacity:1},Y=e.querySelector(`image`);W.image=Y?.getAttribute(`source`);let X=e.querySelector(`properties`);X&&this._parsePropertiesNode(X,W);let ie=Y?.getAttribute(`trans`);if(ie&&(W.transparentcolor=`#`+ie),this._parseAttributes(e,W),R)try{return Uy.parse(W)}catch(e){throw bt.error(`Could not parse layer`,W,e),e}return W}parseExternalTemplate(e,R=!0){let W=this._parseToDocument(e).querySelector(`template`),Y={type:`template`},X=W.querySelector(`object`);X&&(Y.object=this.parseObject(X,R));let ie=W.querySelector(`tileset`);if(ie&&(Y.tileset=this.parseTileset(ie,R)),R)try{return Xy.parse(Y)}catch(e){throw bt.error(`Could not parse template`,Y,e),e}return Y}parseExternalTileset(e,R=!0){let W=this._parseToDocument(e).querySelector(`tileset`),Y=this.parseTileset(W,R);if(Y.type=`tileset`,this._parseAttributes(W,Y),R)try{return qy.parse(Y)}catch(e){throw bt.error(`Could not parse tileset file`,Y,e),e}return Y}parse(e,R=!0){let W=this._parseToDocument(e).querySelector(`map`),Y={type:`map`,compressionlevel:-1,layers:[],tilesets:[]};this._parseAttributes(W,Y);let n=(e,R=!0)=>{switch(e.tagName){case`group`:for(let W of e.children)n(W,R);break;case`layer`:{let W=this.parseTileLayer(e,Y.infinite,R);Y.layers.push(W);break}case`properties`:this._parsePropertiesNode(e,Y);break;case`tileset`:{let W=this.parseTileset(e,R);Y.tilesets.push(W);break}case`objectgroup`:{let W=this.parseObjectGroup(e,R);Y.layers.push(W);break}case`imagelayer`:{let W=this.parseImageLayer(e,R);Y.layers.push(W);break}}};for(let e of W.children)n(e,R);if(R)try{return Zy.parse(Y)}catch(e){throw bt.error(`Could not parse Tiled map`,e),e}return Y}},$y=S(668);let eb,tb,nb;const rb={env:{emscripten_notify_memory_growth:function(e){nb=new Uint8Array(tb.exports.memory.buffer)}}};var ic=class{init(){return eb||(eb=typeof fetch<`u`?fetch(`data:application/wasm;base64,`+ib).then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,rb))).then(this._init):WebAssembly.instantiate(Buffer.from(ib,`base64`),rb).then(this._init),eb)}_init(e){tb=e.instance,rb.env.emscripten_notify_memory_growth(0)}decode(e,R=0){if(!tb)throw Error(`ZSTDDecoder: Await .init() before decoding.`);let W=e.byteLength,Y=tb.exports.malloc(W);nb.set(e,Y),R||=Number(tb.exports.ZSTD_findDecompressedSize(Y,W));let X=tb.exports.malloc(R),ie=tb.exports.ZSTD_decompress(X,R,Y,W),ae=nb.slice(X,X+ie);return tb.exports.free(Y),tb.exports.free(X),ae}};const ib=`AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQh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ASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigC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C0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY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wOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEE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`;var oc=class{static decode(e,R){var W,Y,X,ie,ae,le;if(e.length%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var _e=43,ye=47,be=48,Ce=97,Te=65,Oe=45,Ae=95;function I(e){var R=e.charCodeAt(0);if(R===_e||R===Oe)return 62;if(R===ye||R===Ae)return 63;if(R<be)return-1;if(R<be+10)return R-be+26+26;if(R<Te+26)return R-Te;if(R<Ce+26)return R-Ce+26;throw Error(`Could not decode elt`)}var Me=e.length;ae=e.charAt(Me-2)===`=`?2:+(e.charAt(Me-1)===`=`),le=new Uint8Array(3*e.length/4-ae),X=ae>0?e.length-4:e.length;var Pe=0;function B(e){le[Pe++]=e}for(W=0,Y=0;W<X;W+=4,Y+=3)B((16711680&(ie=I(e.charAt(W))<<18|I(e.charAt(W+1))<<12|I(e.charAt(W+2))<<6|I(e.charAt(W+3))))>>16),B((65280&ie)>>8),B(255&ie);return ae===2?B(255&(ie=I(e.charAt(W))<<2|I(e.charAt(W+1))>>4)):ae===1&&(B((ie=I(e.charAt(W))<<10|I(e.charAt(W+1))<<4|I(e.charAt(W+2))>>2)>>8&255),B(255&ie)),new Promise((e=>{let i=function(e){for(var R=0,W=e.length-1;W>=0;W--)R=256*R+1*e[W];return R};if(R===`zlib`||R===`gzip`){var Y=(le=(0,$y.inflate)(le)).length/4,X=Array(Y);for(W=0;W<Y;W++)X[W]=i(le.slice(4*W,4*W+4));e(X)}if(R===`zstd`){let R=new ic;R.init().then((()=>{var Y=(le=R.decode(le)).length/4,X=Array(Y);for(W=0;W<Y;W++)X[W]=i(le.slice(4*W,4*W+4));e(X)}))}if(!R){for(Y=le.length/4,X=Array(Y),W=0;W<Y;W++)X[W]=i(le.slice(4*W,4*W+4));e(X)}}))}};const ab={TileData:{Tiled:`ex-tiled`},ZIndex:{ZIndex:`zindex`},Camera:{Camera:`camera`,Zoom:`zoom`},Animation:{Strategy:`animationstrategy`},Layer:{Solid:`solid`},Collision:{Type:`collisiontype`}},rc=async(e,R)=>{let W=await fetch(e);switch(R.toLowerCase()){case`xml`:default:return await W.text();case`json`:return await W.json()}},ac=e=>R=>R?.name&&e?R.name.toLocaleLowerCase().localeCompare(e.toLocaleLowerCase())===0:R?.name===e,lc=e=>R=>R?.class&&e?R.class.toLocaleLowerCase().localeCompare(e.toLocaleLowerCase())===0:R?.class===e,cc=e=>{let R=new Map;for(let[W,Y]of e)R.set(W.toLocaleLowerCase(),Y);return R},gc=(e,R,W=!0)=>Y=>{let X=cc(Y.properties);if(R!==void 0){let Y=R;typeof R==`string`&&(Y=W?R.toLocaleLowerCase():R);let ie=X.get(e.toLocaleLowerCase());return typeof ie==`string`?(W?ie.toLocaleLowerCase():ie)===Y:X.get(e.toLocaleLowerCase())===Y}return X.has(e.toLocaleLowerCase())},dc=(e,R)=>W=>R(cc(W.properties).get(e.toLocaleLowerCase())),pc=e=>!!(e&2147483648),fc=e=>!!(e&1073741824),Bc=e=>!!(e&536870912),Cc=e=>536870911&e;var Ec=class{constructor(e){this.type=e,this._loaded=!1,this.cache=new Map}getOrAdd(...e){let R=this.cache.get(e.join(`+`));return R||(R=new this.type(...e),this.cache.set(e.join(`+`),R),R)}values(){if(this._loaded)return Array.from(this.cache.values());throw Error(`Read through cache not yet loaded! No values to return!`)}async load(){let e=Array.from(this.cache.entries()),R=await Promise.allSettled(e.map((e=>e[1].load()))),W=0;for(let Y=0;Y<R.length;Y++){let X=R[Y];X.status===`rejected`&&(bt.error(`Error loading resource at ${e[Y][0]}, is your pathMap correct? or your Tiled map corrupted?`,X.reason),W++)}if(W)throw Error(`Error loading ${W} resources`);this._loaded=!0}};function Qc(e,R){try{if(R)for(let W of R){let R=W.value;typeof W.value==`string`&&(R=W.value.toLocaleLowerCase()),e.properties.set(W.name.toLocaleLowerCase(),R)}}catch(R){bt.error(`Unable to map properties onto ${e}`,R)}}function mc(e){let R=e.match(/[^/\\&\?]+\.\w{2,4}(?=([\#\?&].*$|$))/gi);if(R)return R[0];throw Error(`Could not locate filename from path: ${e}`)}function yc(e,R){for(let{path:W,output:Y}of R)if(typeof W==`string`){if(e.includes(W))return Y}else{let R=e.match(W);if(R)return Y.replace(`[match]`,R[0])}return e}function wc(e,R){if(!R)return!1;for(let{path:W,output:Y}of R)if(typeof W==`string`){if(e.includes(W))return!0}else if(e.match(W))return!0;return!1}function _c(e,R,W){if(wc(R,W)&&W)return yc(R,W);if(R.indexOf(`/`)===0)return R;let Y=e.split(`/`),X=R.split(`/`);return Y[Y.length-1].includes(`.`)&&Y.pop(),Y.concat(X).join(`/`)}var vc=class{constructor(e){this.properties=new Map,this.tiledObject=e.tiledObject,this.name=this.tiledObject.name,this.class=this.tiledObject.type,this.id=this.tiledObject.id??-1,this.x=this.tiledObject.x??0,this.y=this.tiledObject.y??0,this.rotation=this.tiledObject.rotation??0}},bc=class extends vc{constructor(e,R){if(super({tiledObject:e}),!e.template)throw Error(`Invalid template`);if(this.source=e.template,this.gid=e.gid,this.instanceObject=e,this.template=R,R.object){this.name=this.name||R.object.name,this.class=this.class||R.object.class;for(let[e,W]of R.object.properties.entries())this.properties.has(e)||this.properties.set(e,W)}if(R.tileset&&R.object.tiledObject.gid){let e=R.tileset.getTileByGid(R.object.tiledObject.gid);if(e){this.class=this.class||e.class;for(let[R,W]of e.properties.entries())this.properties.has(R)||this.properties.set(R,W)}}}},kc=class extends vc{constructor(e,R,W,Y){super({tiledObject:e}),this.gid=R,this.width=W,this.height=Y}},Dc=class extends vc{},Sc=class extends vc{constructor(e,R,W,Y){var X;super({tiledObject:e}),this.font=new Kp({family:R.fontfamily??`sans-serif`,color:R.color?gf.fromHex(R.color):gf.Black,size:R.pixelsize??16,unit:cp.Px,textAlign:this._textAlignFromTiled(R.halign),baseAlign:this._textBaselineFromTiled(R.valign),quality:Y});let ie=(X=R.wrap)!=null&&X;this.text=new qp({text:R.text,font:this.font,...ie?{maxWidth:W+10}:{}})}_textBaselineFromTiled(e){switch(e){case`bottom`:return up.Bottom;case`center`:return up.Middle;default:return up.Top}}_textAlignFromTiled(e){switch(e){case`left`:default:return lp.Left;case`center`:return lp.Center;case`right`:return lp.Right;case`justify`:return lp.Start}}},xc=class extends vc{constructor(e,R,W){super({tiledObject:e}),this.width=R,this.height=W}},zc=class extends vc{constructor(e,R,W,Y){super({tiledObject:e}),this.width=R,this.height=W,this.anchor=Y}},Fc=class extends vc{constructor(e,R){super({tiledObject:e}),this.points=[],this.localPoints=[],this.localPoints=R.map((e=>vec(e.x,e.y))),this.points=R.map((e=>vec(e.x,e.y).rotate(toRadians(this.rotation)).add(vec(this.x,this.y))))}},Lc=class extends vc{constructor(e,R){super({tiledObject:e}),this.points=[],this.points=R.map((e=>vec(e.x,e.y)))}};function Nc(e,R){let W;if(e.point)W=new Dc({tiledObject:e});else if(e.ellipse)e.width&&e.height?(W=new xc(e,e.width,e.height),W.x+=e.width/2,W.y+=e.height/2):W=new xc(e,20,20);else if(e.polygon)W=new Fc(e,e.polygon);else if(e.polyline)W=new Lc(e,e.polyline);else if(e.text)W=new Sc(e,e.text,e.width??0,R?.textQuality??4);else if(e.gid&&!e.template){W=new kc(e,e.gid,e.width??0,e.height??0);let Y=R?.getTilesetForTileGid(e.gid),X=e.type;if(Y){let R=Y?.getTileByGid(e.gid);if(X||=R?.class,R?.properties)for(let[e,Y]of R.properties.entries())W.properties.has(e)||W.properties.set(e,Y)}W.class=X}else if(e.template&&R){let Y=R.templates.find((R=>mc(R.templatePath)===mc(e.template)));if(!Y)throw Error(`Template object id ${e.id} with name ${e.name} is missing a loaded template file, there should be one loaded from ${e.template}! Is your tiled map or template corrupted?`);W=new bc(e,Y)}else W=e.width&&e.height?new zc(e,e.width,e.height,sf.Zero):new zc(e,20,20,sf.Half);return Qc(W,e.properties),W}function Gc(e,R){let W=[];for(let Y of e.objects){let e=Nc(Y,R);W.push(e)}return W}var Tc=class{constructor(e){let{templatePath:R,object:W,tiledTemplate:Y,tileset:X}=e;this.templatePath=R,this.object=W,this.tiledTemplate=Y,this.tileset=X}},Rc=class{constructor(e){this.objects=[],this.colliders=[],this.animation=[],this.properties=new Map;let{id:R,tileset:W,tiledTile:Y}=e;this.id=R,this.tileset=W,this.tiledTile=Y,this.class=Y.type,Qc(this,Y.properties),Y.objectgroup&&Y.objectgroup.objects&&(this.objects=Gc(Y.objectgroup)),Y.animation&&(this.animation=Y.animation)}},Mc=class{constructor(e){this.firstGid=-1,this.tileCount=0,this.tileWidth=0,this.tileHeight=0,this.tileOffset=vec(0,0),this.tiles=[],this.objectalignment=`bottomleft`,this.orientation=`orthogonal`,this.properties=new Map;let{name:R,tiledTileset:W,image:Y,tileToImage:X,firstGid:ie}=e;if(this.name=R,this.tiledTileset=W,this.firstGid=ie,Ol(W)){Qc(this,W.properties);let e=W.spacing,R=Math.floor((W.imagewidth+e)/(W.tilewidth+e)),X=Math.floor((W.imageheight+e)/(W.tileheight+e));if(this.class=W.class,this.orientation=W.grid?.orientation??`orthogonal`,this.horizontalFlipTransform=lf.identity().translate(W.tilewidth,0).scale(-1,1),this.verticalFlipTransform=lf.identity().translate(0,W.tileheight).scale(1,-1),this.diagonalFlipTransform=lf.identity().translate(0,0).rotate(-Math.PI/2).scale(-1,1),this.objectalignment=W.objectalignment??(this.orientation===`orthogonal`?`bottomleft`:`bottom`),Y&&(this.spritesheet=Sp.fromImageSource({image:Y,grid:{rows:X,columns:R,spriteWidth:W.tilewidth,spriteHeight:W.tileheight},spacing:{originOffset:{x:W.margin??0,y:W.margin??0},margin:{x:W.spacing??0,y:W.spacing??0}}})),this.tileCount=W.tilecount,this.tileWidth=W.tilewidth,this.tileHeight=W.tileheight,W.tileoffset&&(this.tileOffset=vec(W.tileoffset.x,W.tileoffset.y)),W.tiles)for(let e of W.tiles)this.tiles.push(new Rc({id:e.id,tileset:this,tiledTile:e,image:Y}))}if(Ul(W)&&W.firstgid!==void 0){this.horizontalFlipTransform=lf.identity().translate(W.tilewidth,0).scale(-1,1),this.verticalFlipTransform=lf.identity().translate(0,W.tileheight).scale(1,-1),this.diagonalFlipTransform=lf.identity().translate(0,0).rotate(-Math.PI/2).scale(-1,1),this.objectalignment=W.objectalignment??(this.orientation===`orthogonal`?`bottomleft`:`bottom`),this.orientation=W.grid?.orientation??`orthogonal`,this.tileCount=W.tilecount,this.tileWidth=W.tilewidth,this.tileHeight=W.tileheight,W.tileoffset&&(this.tileOffset=vec(W.tileoffset.x,W.tileoffset.y));let e=[];if(W.tiles)for(let R of W.tiles){let W=X?.get(R);W&&e.push(W.toSprite()),this.tiles.push(new Rc({id:R.id,tileset:this,tiledTile:R,image:W}))}X&&(this.spritesheet=new Sp({sprites:e}))}}getTilesetAlignmentAnchor(e){switch(e??this.objectalignment){case`topleft`:return vec(0,0);case`top`:return vec(.5,0);case`topright`:return vec(1,0);case`left`:return vec(0,.5);case`center`:return vec(.5,.5);case`right`:return vec(1,.5);case`bottomleft`:default:return vec(0,1);case`bottom`:return vec(.5,1);case`bottomright`:return vec(1,1)}}getTileByGid(e){let R=Cc(e)-this.firstGid;return this.tiles.find((e=>e.id===R))}getTilesByClassName(e){return this.tiles.filter(lc(e))}getTilesByProperty(e,R,W=!0){return this.tiles.filter(gc(e,R,W))}getTilesByPropertyValueMatcher(e,R){return this.tiles.filter(dc(e,R))}getSpriteForGid(e){let R=pc(e),W=fc(e),Y=Bc(e),X=Cc(e),ie=X-this.firstGid;if(this.spritesheet){let e=this.spritesheet.sprites[ie];return(Y||R||W)&&(e=e.clone()),Y&&(e.rotation=-Math.PI/2,e.scale=vec(-1,1)),R&&(e.scale=vec((Y?1:-1)*e.scale.x,(Y?-1:1)*e.scale.y)),W&&(e.scale=vec((Y?-1:1)*e.scale.x,(Y?1:-1)*e.scale.y)),e}throw Error(`Tileset: [${this.name}] Could not find sprite for gid: [${e}] normalized gid: [${X}]`)}_isometricTiledCoordToWorld(e){let R=this.tileWidth,W=this.tileHeight/2,Y=e.y/W,X=e.x/W;return vec((X-Y)*R/2+0,(X+Y)*W/2)}getCollidersForGid(e,R){let{anchor:W,scale:Y,orientationOverride:X,offset:ie}={anchor:sf.Zero,scale:sf.One,offset:sf.Zero,orientationOverride:void 0,...R},ae=X??this.orientation,le=this.getTileByGid(e),_e=[];if(le&&le.objects)for(let R of le.objects){if(R instanceof Fc){let W=R.points.map((e=>e.scale(Y)));W=this._applyFlipsToPoints(W,e),ae===`isometric`&&(W=W.map((e=>this._isometricTiledCoordToWorld(e)))),W=W.map((e=>e.add(ie)));let X=tp.Polygon(W,sf.Zero,!0);X.isConvex()?_e.push(X):_e.push(X.triangulate())}if(R instanceof zc){let W=R.width,X=R.height,le=R.anchor,ye=Pf.fromDimension(W*Y.x,X*Y.y,le).getPoints().map((e=>e.rotate(toRadians(R.rotation)).add(vec(R.x,R.y))));ae===`isometric`&&(ye=ye.map((e=>this._isometricTiledCoordToWorld(e)))),ye=this._applyFlipsToPoints(ye,e),ye=ye.map((e=>e.add(ie)));let be=tp.Polygon(ye);_e.push(be)}if(R instanceof xc){let e=vec(R.x,R.y);ae===`isometric`&&(e=this._isometricTiledCoordToWorld(e)),e=e.add(ie);let W=Math.min(R.width/2,R.height/2),X=tp.Circle(W,e.scale(Y));_e.push(X)}}return _e}_applyFlipsToPoints(e,R){let W=pc(R),Y=fc(R);return Bc(R)&&(e=e.map((e=>this.diagonalFlipTransform.multiply(e)))),W&&(e=e.map((e=>this.horizontalFlipTransform.multiply(e)))),Y&&(e=e.map((e=>this.verticalFlipTransform.multiply(e)))),e}getAnimationForGid(e){let R=this.getTileByGid(e);if(R&&R.animation?.length){let e=[];for(let W of R.animation)e.push({graphic:this.getSpriteForGid(W.tileid+this.firstGid),duration:W.duration});return new op({frames:e,strategy:ip.Loop})}return null}},Oc=class{constructor(e,R,W){this.path=e,this.strict=!0,this.headless=!1,this.orientation=`orthogonal`,this.fileLoader=rc;let{fileLoader:Y,parser:X,pathMap:ie,imageLoader:ae,strict:le,headless:_e,orientation:ye}={...W};this.headless=_e??this.headless,this.orientation=ye??this.orientation,this.strict=le??this.strict,this.fileLoader=Y??this.fileLoader,this.imageLoader=ae??new Ec(yp),this.parser=X??new Wl,this.firstGid=R,this.pathMap=ie}async load(){let e=this.path.includes(`.tsx`)?`xml`:`json`;try{let R=await this.fileLoader(this.path,e),W;if(W=e===`json`?this.strict?qy.parse(R):R:this.parser.parseExternalTileset(R,this.strict),Ol(W)){let e=_c(this.path,W.image,this.pathMap),R=this.headless?void 0:this.imageLoader.getOrAdd(e);this.data=new Mc({name:W.name,tiledTileset:W,firstGid:this.firstGid,image:R})}if(Ul(W)){let e=this.headless?void 0:new Map;if(e){let R=[];if(W.tiles){for(let Y of W.tiles)if(Y.image){let W=_c(this.path,Y.image,this.pathMap),X=this.imageLoader.getOrAdd(W);e.set(Y,X),R.push(X)}}}W.firstgid=this.firstGid,this.data=new Mc({name:W.name,tiledTileset:W,firstGid:this.firstGid,tileToImage:e})}if(this.headless||await this.imageLoader.load(),this.data)return this.data}catch(e){throw bt.error(`Could not load tileset at path ${this.path}`),e}throw Error(`No tileset at path ${this.path}`)}isLoaded(){return!!this.data}},Uc=class{constructor(e,R){this.templatePath=e,this.headless=!1,this.strict=!0,this.fileLoader=rc;let{fileLoader:W,parser:Y,pathMap:X,imageLoader:ie,strict:ae,headless:le}={...R};this.headless=le??this.headless,this.strict=ae??this.strict,this.fileLoader=W??this.fileLoader,this.imageLoader=ie??new Ec(yp),this.parser=Y??new Wl,this.pathMap=X}isLoaded(){return!!this.data}async load(){let e=this.templatePath.includes(`.tx`)?`xml`:`json`;try{let R=await this.fileLoader(this.templatePath,e),W;W=e===`xml`?this.parser.parseExternalTemplate(R,this.strict):this.strict?Xy.parse(R):R;let Y=W,X=Nc(W.object),ie;return W.tileset&&(ie=await new Oc(_c(this.templatePath,W.tileset.source,this.pathMap),W.tileset.firstgid,{headless:this.headless,strict:this.strict,fileLoader:this.fileLoader,imageLoader:this.imageLoader,parser:this.parser,pathMap:this.pathMap}).load()),this.data=new Tc({templatePath:this.templatePath,tiledTemplate:Y,object:X,tileset:ie})}catch(e){throw bt.error(`Could not load template at ${this.templatePath}, check to see if your pathMap is correct or if you're Tiled map is corrupted`),e}}},Jc=class extends Component{constructor(e){super();let{tiledObject:R}=e;this.tiledObject=R}},Zc=class extends Component{constructor(e){super();let{tiledTileLayer:R}=e;this.tiledTileLayer=R}},qc=class{get isInfinite(){return this._isInfinite}constructor(e,R,W){this.tiledTileLayer=e,this.resource=R,this.order=W,this.logger=bf.getInstance(),this.width=0,this.height=0,this.properties=new Map,this.data=[],this._isInfinite=!1,this._tileToChunkData=new WeakMap,this._tileToChunkIndex=new WeakMap,this._gidToTileInfo=new Map,this.name=e.name,this.id=e.id,this.class=e.class,this.width=e.width,this.height=e.height,this.visible=!!e.visible,Qc(this,e.properties)}getTilesByProperty(e,R,W=!0){return this.isometricMap.tiles.filter((Y=>{let X=Y.data.get(ab.TileData.Tiled);return!!X&&gc(e,R,W)(X)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}getTilesByPropertyValueMatcher(e,R){return this.isometricMap.tiles.filter((W=>{let Y=W.data.get(ab.TileData.Tiled);return!!Y&&dc(e,R)(Y)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}getTilesByGid(e){return this._gidToTileInfo.get(e)??[]}getTilesByClassName(e){return this.isometricMap.tiles.filter((R=>{let W=R.data.get(ab.TileData.Tiled);return!!W&&lc(e)(W)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}_getGidForTile(e){let R=0;if(this._isInfinite){let W=this._tileToChunkData.get(e);if(W===void 0)throw Error(`Missing chunk data for excalibur tile`);let Y=this._tileToChunkIndex.get(e);if(Y===void 0)throw Error(`Missing chunk index for excalibur tile`);R=Cc(W[Y])}else{let W=this.isometricMap.tiles.indexOf(e);R=Cc(this.data[W])}return R}getTileByPoint(e){if(!this.isometricMap)return this.logger.warn(`IsometricMap has not yet been loaded! getTileByPoint() will only return null`),null;if(this.isometricMap){let R=this.isometricMap.getTileByPoint(e);if(!R)return null;let W=this._getGidForTile(R),Y;return W>0&&(Y=this.resource.getTilesetForTileGid(W).getTileByGid(W)),{tiledTile:Y,exTile:R}}return null}getTileByCoordinate(e,R){if(!this.isometricMap)return this.logger.warn(`IsometricMap has not yet been loaded! getTileByCoordinate() will only return null`),null;if(this.isometricMap){let W=this.isometricMap.getTile(e,R),Y=this._getGidForTile(W),X;return Y>0&&(X=this.resource.getTilesetForTileGid(Y).getTileByGid(Y)),{tiledTile:X,exTile:W}}return null}_recordTileData(e,R){let W=this._gidToTileInfo.get(e),Y=this.resource.getTilesetForTileGid(e).getTileByGid(e);W?W.push({exTile:R,tiledTile:Y}):W=[{exTile:R,tiledTile:Y}],this._gidToTileInfo.set(e,W),R.data.set(ab.TileData.Tiled,Y)}updateTile(e,R,W,Y,X){this._recordTileData(R,e);let ie=this.resource.getLayerConfig(this.name)||this.resource.getLayerConfig(this.id);ie?.isSolid!==void 0&&(X=ie.isSolid),this.resource.useExcaliburWiring&&X&&(e.solid=!0);let ae=e.get(IsometricEntityComponent);ae&&(ae.elevation=this.order);let le=this.resource.getTilesetForTileGid(R),_e=le.getSpriteForGid(R);W&&(_e=_e.clone(),_e.tint=Y),e.addGraphic(_e,{offset:le.tileOffset});let ye=e.pos;if(le.orientation===`orthogonal`)ye=vec(0,0);else{let e=this.resource.map.tilewidth/2,R=this.resource.map.tileheight;ye=vec(e,R)}let be=le.getCollidersForGid(R,{offset:ye});for(let R of be)e.addCollider(R);ie!=null&&ie.useTileColliders&&be.length>0&&this.visible&&(e.solid=!0),ie!=null&&ie.useTileCollidersWhenInvisible&&be.length>0&&(e.solid=!0);let Ce=le.getAnimationForGid(R);if(Ce&&(W&&(Ce=Ce.clone(),Ce.tint=Y),e.clearGraphics(),e.addGraphic(Ce,{offset:le.tileOffset}),this.resource.useExcaliburWiring)){let e=le.getTileByGid(R)?.properties.get(ab.Animation.Strategy);if(e&&typeof e==`string`)switch(e.toLowerCase()){case ip.End.toLowerCase():Ce.strategy=ip.End;break;case ip.Freeze.toLowerCase():Ce.strategy=ip.Freeze;break;case ip.Loop.toLowerCase():Ce.strategy=ip.Loop;break;case ip.PingPong.toLowerCase():Ce.strategy=ip.PingPong;break;default:this.logger.warn(`Unknown animation strategy in tileset ${le.name} on tile gid ${R}: ${e}`)}}}async load(){let e=this.resource.getLayerConfig(this.name)||this.resource.getLayerConfig(this.id),R=this.tiledTileLayer,W=!!this.properties.get(ab.Layer.Solid),Y=(this.tiledTileLayer.opacity,!!this.tiledTileLayer.tintcolor),X=this.tiledTileLayer.tintcolor?gf.fromHex(this.tiledTileLayer.tintcolor):gf.Transparent,ie=vec(R.offsetx??0,R.offsety??0);this.tiledTileLayer.data&&kl(this.tiledTileLayer)?this.data=await oc.decode(this.tiledTileLayer.data,this.tiledTileLayer.compression):this.tiledTileLayer.data&&Dl(this.tiledTileLayer)&&(this.data=this.tiledTileLayer.data);let ae=this.order,le=this.properties.get(ab.ZIndex.ZIndex);if(typeof le==`number`&&(ae=le),this.resource.map.infinite&&Hl(this.tiledTileLayer)){let W=this.resource.isometricTiledCoordToWorld(this.tiledTileLayer.startx,this.tiledTileLayer.starty),Y=vec(W.x*this.resource.map.tilewidth,W.y*this.resource.map.tileheight);this.isometricMap=new IsometricMap({name:this.name,pos:ie.add(Y),tileHeight:this.resource.map.tileheight,tileWidth:this.resource.map.tilewidth,columns:R.width,rows:R.height,elevation:ae}),e?.collisionGroup&&(this.isometricMap.get(rm).group=e.collisionGroup)}else this.isometricMap=new IsometricMap({name:this.name,pos:ie,tileWidth:this.resource.map.tilewidth,tileHeight:this.resource.map.tileheight,columns:R.width,rows:R.height,elevation:ae}),e?.collisionGroup&&(this.isometricMap.get(rm).group=e.collisionGroup);if(this.isometricMap.visible=this.tiledTileLayer.visible,this.isometricMap.opacity=this.tiledTileLayer.opacity,this.isometricMap.addComponent(new Zc({tiledTileLayer:R})),R.parallaxx||R.parallaxy){let e=vec(R.parallaxx??1,R.parallaxy??1);this.isometricMap.addComponent(new ParallaxComponent(e))}if(this.resource.map.infinite&&Hl(this.tiledTileLayer)){this._isInfinite=!0;let e=this.tiledTileLayer;for(let ie of this.tiledTileLayer.chunks){let ae=[];kl(this.tiledTileLayer)?ae=await oc.decode(ie.data,e.compression):Dl(this.tiledTileLayer)&&(ae=ie.data);for(let e=0;e<ae.length;e++){let le=ae[e],_e=e%ie.width+(ie.x-this.tiledTileLayer.startx),ye=Math.floor(e/ie.width)+(ie.y-this.tiledTileLayer.starty),be=this.isometricMap.tiles[_e+ye*R.width];this._tileToChunkData.set(be,ae),this._tileToChunkIndex.set(be,e),le!=0&&this.updateTile(be,le,Y,X,W)}}}else for(let e=0;e<this.data.length;e++){let R=this.data[e];if(R!==0){let ie=this.isometricMap.tiles[e];this.updateTile(ie,R,Y,X,W)}}}},jc=class{get isInfinite(){return this._isInfinite}getTilesByProperty(e,R,W=!0){return this.tilemap.tiles.filter((Y=>{let X=Y.data.get(ab.TileData.Tiled);return!!X&&gc(e,R,W)(X)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}getTilesByPropertyValueMatcher(e,R){return this.tilemap.tiles.filter((W=>{let Y=W.data.get(ab.TileData.Tiled);return!!Y&&dc(e,R)(Y)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}getTilesByGid(e){return this._gidToTileInfo.get(e)??[]}getTilesByClassName(e){return this.tilemap.tiles.filter((R=>{let W=R.data.get(ab.TileData.Tiled);return!!W&&lc(e)(W)})).map((e=>({exTile:e,tiledTile:e.data.get(ab.TileData.Tiled)})))}_getGidForTile(e){let R=0;if(this._isInfinite){let W=this._tileToChunkData.get(e);if(W===void 0)throw Error(`Missing chunk data for excalibur tile (${e.x}, ${e.y})`);let Y=this._tileToChunkIndex.get(e);if(Y===void 0)throw Error(`Missing chunk index for excalibur tile (${e.x}, ${e.y})`);R=Cc(W[Y])}else{let W=this.tilemap.tiles.indexOf(e);R=Cc(this.data[W])}return R}getTileByPoint(e){if(!this.tilemap)return this.logger.warn(`Tilemap has not yet been loaded! getTileByPoint() will only return null`),null;if(this.tilemap){let R=this.tilemap.getTileByPoint(e);if(!R)return null;let W=this._getGidForTile(R),Y;return W>0&&(Y=this.resource.getTilesetForTileGid(W).getTileByGid(W)),{tiledTile:Y,exTile:R}}return null}getTileByCoordinate(e,R){if(!this.tilemap)return this.logger.warn(`Tilemap has not yet been loaded! getTileByCoordinate() will only return null`),null;if(this.tilemap){let W=this.tilemap.getTile(e,R),Y=this._getGidForTile(W),X;return Y>0&&(X=this.resource.getTilesetForTileGid(Y).getTileByGid(Y)),{tiledTile:X,exTile:W}}return null}constructor(e,R,W){this.tiledTileLayer=e,this.resource=R,this.order=W,this.logger=bf.getInstance(),this.width=0,this.height=0,this.properties=new Map,this.data=[],this._gidToTileInfo=new Map,this._isInfinite=!1,this._tileToChunkData=new Map,this._tileToChunkIndex=new Map,this.name=e.name,this.id=e.id,this.class=e.class,this.width=e.width,this.height=e.height,this.visible=!!e.visible,Qc(this,e.properties)}_recordTileData(e,R){let W=this._gidToTileInfo.get(e),Y=this.resource.getTilesetForTileGid(e).getTileByGid(e);W?W.push({exTile:R,tiledTile:Y}):W=[{exTile:R,tiledTile:Y}],this._gidToTileInfo.set(e,W),R.data.set(ab.TileData.Tiled,Y)}updateTile(e,R,W,Y,X){this._recordTileData(R,e);let ie=this.resource.getLayerConfig(this.name)||this.resource.getLayerConfig(this.id);ie?.isSolid!==void 0&&(X=ie.isSolid),this.resource.useExcaliburWiring&&X&&this.visible&&(e.solid=!0);let ae=this.resource.getTilesetForTileGid(R),le=this.resource.headless;if(!le){let X=ae.getSpriteForGid(R);W&&(X=X.clone(),X.tint=Y),e.addGraphic(X,{offset:ae.tileOffset})}let _e=ae.getCollidersForGid(R);for(let R of _e)e.addCollider(R);ie!=null&&ie.useTileColliders&&_e.length>0&&this.visible&&(e.solid=!0),ie!=null&&ie.useTileCollidersWhenInvisible&&_e.length>0&&(e.solid=!0);let ye=le?null:ae.getAnimationForGid(R);if(ye&&(W&&(ye=ye.clone(),ye.tint=Y),e.clearGraphics(),e.addGraphic(ye,{offset:ae.tileOffset}),this.resource.useExcaliburWiring)){let e=ae.getTileByGid(R)?.properties.get(ab.Animation.Strategy);if(e&&typeof e==`string`)switch(e.toLowerCase()){case ip.End.toLowerCase():ye.strategy=ip.End;break;case ip.Freeze.toLowerCase():ye.strategy=ip.Freeze;break;case ip.Loop.toLowerCase():ye.strategy=ip.Loop;break;case ip.PingPong.toLowerCase():ye.strategy=ip.PingPong;break;default:this.logger.warn(`Unknown animation strategy in tileset ${ae.name} on tile gid ${R}: ${e}`)}}}async load(){let e=this.resource.getLayerConfig(this.name)||this.resource.getLayerConfig(this.id),R=this.tiledTileLayer.opacity,W=!!this.tiledTileLayer.tintcolor,Y=this.tiledTileLayer.tintcolor?gf.fromHex(this.tiledTileLayer.tintcolor):gf.Transparent,X=!!this.properties.get(ab.Layer.Solid),ie=this.tiledTileLayer,ae=vec(ie.offsetx??0,ie.offsety??0);if(this.tiledTileLayer.data&&kl(this.tiledTileLayer)?this.data=await oc.decode(this.tiledTileLayer.data,this.tiledTileLayer.compression):this.tiledTileLayer.data&&Dl(this.tiledTileLayer)&&(this.data=this.tiledTileLayer.data),this.resource.map.infinite&&Hl(this.tiledTileLayer)){let R=vec(this.tiledTileLayer.startx*this.resource.map.tilewidth,this.tiledTileLayer.starty*this.resource.map.tileheight);this.tilemap=new TileMap({name:this.name,pos:ae.add(R),tileHeight:this.resource.map.tileheight,tileWidth:this.resource.map.tilewidth,columns:ie.width,rows:ie.height}),e?.collisionGroup&&(this.tilemap.get(rm).group=e.collisionGroup)}else this.tilemap=new TileMap({name:this.name,pos:ae,tileWidth:this.resource.map.tilewidth,tileHeight:this.resource.map.tileheight,columns:ie.width,rows:ie.height}),e?.collisionGroup&&(this.tilemap.get(rm).group=e.collisionGroup);this.tilemap.addComponent(new Zc({tiledTileLayer:ie}));let le=this.tilemap.get(Sf);if(le){le.z=this.order;let e=this.properties.get(ab.ZIndex.ZIndex);typeof e==`number`&&(le.z=e)}let _e=this.tilemap.get(Jp);if(_e&&(_e.isVisible=this.tiledTileLayer.visible,_e.opacity=R),ie.parallaxx||ie.parallaxy){let e=vec(ie.parallaxx??1,ie.parallaxy??1);this.tilemap.addComponent(new ParallaxComponent(e))}if(this.resource.map.infinite&&Hl(this.tiledTileLayer)){this._isInfinite=!0;let e=this.tiledTileLayer;for(let R of this.tiledTileLayer.chunks){let ae=[];kl(this.tiledTileLayer)?ae=await oc.decode(R.data,e.compression):Dl(this.tiledTileLayer)&&(ae=R.data);for(let e=0;e<ae.length;e++){let le=ae[e],_e=e%R.width+(R.x-this.tiledTileLayer.startx),ye=Math.floor(e/R.width)+(R.y-this.tiledTileLayer.starty),be=this.tilemap.tiles[_e+ye*ie.width];this._tileToChunkData.set(be,ae),this._tileToChunkIndex.set(be,e),le!==0&&this.updateTile(be,le,W,Y,X)}}}else for(let e=0;e<this.data.length;e++){let R=this.data[e];if(R!==0){let ie=this.tilemap.tiles[e];this.updateTile(ie,R,W,Y,X)}}}},Yc=class{constructor(e,R,W){this.tiledObjectLayer=e,this.resource=R,this.order=W,this.logger=bf.getInstance(),this.properties=new Map,this.objects=[],this.entities=[],this._objectToEntity=new Map,this._entityToObject=new Map,this._loaded=!1,this.name=e.name,this.class=e.class,Qc(this,e.properties)}_logLoadedWarning(e){this.logger.warn(`ObjectLayer ${this.name} is not yet loaded, ${e}() will always be empty!`)}getObjectsByName(e){return this._loaded||this._logLoadedWarning(`getObjectsByName`),this.objects.filter(ac(e))}getEntitiesByName(e){return this._loaded||this._logLoadedWarning(`getEntitiesByName`),this.entities.filter(ac(e))}getEntityByObject(e){return this._loaded||this._logLoadedWarning(`getEntityByObject`),this._objectToEntity.get(e)}getObjectByEntity(e){return this._loaded||this._logLoadedWarning(`getObjectByEntity`),this._entityToObject.get(e)}getObjectsByProperty(e,R,W=!0){return this._loaded||this._logLoadedWarning(`getObjectsByProperty`),this.objects.filter(gc(e,R,W))}getObjectsByPropertyValueMatcher(e,R){return this._loaded||this._logLoadedWarning(`getObjectsByPropertyValueMatcher`),this.objects.filter(dc(e,R))}getEntitiesByProperty(e,R,W=!0){return this._loaded||this._logLoadedWarning(`getEntitiesByProperty`),this.getObjectsByProperty(e,R,W).map((e=>this._objectToEntity.get(e))).filter((e=>!!e))}getEntitiesByPropertyValueMatcher(e,R){return this._loaded||this._logLoadedWarning(`getEntitiesByPropertyValueMatcher`),this.getObjectsByProperty(e,R).map((e=>this._objectToEntity.get(e))).filter((e=>!!e))}getObjectsByClassName(e){return this._loaded||this._logLoadedWarning(`getObjectsByClassName`),this.objects.filter(lc(e))}getEntitiesByClassName(e){return this._loaded||this._logLoadedWarning(`getEntitiesByClassName`),this.getObjectsByClassName(e).map((e=>this._objectToEntity.get(e))).filter((e=>!!e))}getTemplates(){return this._loaded||this._logLoadedWarning(`getTemplates`),this.objects.filter((e=>e instanceof bc))}runFactory(e){let R=vec(this.tiledObjectLayer.offsetx??0,this.tiledObjectLayer.offsety??0),W=this.objects.slice();for(let Y of W){let W=Y.class;if(Y instanceof bc&&(W||=Y.template.object.class),e!==W)continue;let X=vec((Y.x??0)+R.x,(Y.y??0)+R.y);this.resource.map.orientation===`isometric`&&(X=this.resource.isometricTiledCoordToWorld(X.x,X.y));let ie=this.resource.factories.get(e);if(ie){let e=ie({worldPos:X,name:Y.name,class:W,layer:this,object:Y,properties:Y.properties});e&&this._recordObjectEntityMapping(Y,e)}}}_actorFromObject(e,R,W){let Y=this.resource.headless,X=!!this.tiledObjectLayer.tintcolor,ie=this.tiledObjectLayer.tintcolor?gf.fromHex(this.tiledObjectLayer.tintcolor):gf.White;if(e instanceof kc&&W){let ae=this.resource.map.orientation===`isometric`&&W.orientation===`orthogonal`?`bottom`:void 0,le=W.getTilesetAlignmentAnchor(ae);R.anchor=le;let _e=vec((e.tiledObject.width??W.tileWidth)/W.tileWidth,(e.tiledObject.width??W.tileWidth)/W.tileWidth);if(!Y){let Y=W.getSpriteForGid(e.gid).clone();Y.destSize.width=e.tiledObject.width??Y.width,Y.destSize.height=e.tiledObject.height??Y.height,X&&(Y.tint=ie),R.graphics.use(Y),R.graphics.offset=W.tileOffset;let ae=W.getAnimationForGid(e.gid);if(ae){let e=ae.clone();e.scale=_e,X&&(e.tint=ie),R.graphics.use(e),R.graphics.offset=W.tileOffset}}let ye=e.tiledObject.width??0,be=e.tiledObject.height??0,Ce=-ye*le.x,Te=-be*le.y,Oe=this.resource.map.tilewidth/2,Ae=this.resource.map.tileheight,Me=vec(Ce,Te);this.resource.map.orientation===`isometric`&&(Me=vec(Ce+Oe,Te+Ae),W.orientation===`orthogonal`&&(Me=Me.sub(vec(Oe,Ae))));let Pe=W.getCollidersForGid(e.gid,{anchor:sf.Zero,scale:_e,offset:Me});if(Pe.length)R.collider.useCompositeCollider(Pe);else{let W=e.width,Y=e.height;if(this.resource.map.orientation===`isometric`){let R=e.height/2;W=R,Y=R}let X=tp.Box(W,Y,this.resource.map.orientation===`isometric`?vec(1,1):vec(0,1));this.resource.map.orientation===`isometric`&&(X.points=X.points.map((e=>this.resource.isometricTiledCoordToWorld(e.x,e.y)))),R.collider.set(X)}}if(e instanceof Sc&&R.graphics.use(e.text),e instanceof Fc){let W=vec(e.x,e.y),Y=e.localPoints;this.resource.map.orientation===`isometric`&&(W=this.resource.isometricTiledCoordToWorld(W.x,W.y),Y=Y.map((e=>this.resource.isometricTiledCoordToWorld(e.x,e.y)))),R.anchor=vec(0,1),R.pos=W;let X=tp.Polygon(Y,sf.Zero,!0);X.isConvex()?R.collider.set(X):R.collider.set(X.triangulate())}if(e instanceof zc){R.anchor=e.anchor;let W=tp.Box(e.width,e.height,e.anchor);this.resource.map.orientation===`isometric`&&(W.points=W.points.map((e=>this.resource.isometricTiledCoordToWorld(e.x,e.y)))),R.collider.set(W)}e instanceof xc&&R.collider.useCircleCollider(Math.min(e.width,e.height)/2)}async load(){let e=this.tiledObjectLayer.opacity,R=vec(this.tiledObjectLayer.offsetx??0,this.tiledObjectLayer.offsety??0),W=Gc(this.tiledObjectLayer,this.resource);for(let Y of W){let W=vec((Y.x??0)+R.x,(Y.y??0)+R.y);this.resource.map.orientation===`isometric`&&(W=this.resource.isometricTiledCoordToWorld(W.x,W.y));let X,ie=Y.class;if(Y instanceof bc&&(ie||=Y.template.object.class),ie){let e=this.resource.factories.get(ie);if(e){let R=e({worldPos:W,name:Y.name,class:ie,layer:this,object:Y,properties:Y.properties});R&&this._recordObjectEntityMapping(Y,R);continue}}let ae=this.properties.get(ab.ZIndex.ZIndex);typeof ae==`number`&&(X=ae);let le=new $p({name:Y.tiledObject.name,pos:W,anchor:sf.Zero,rotation:toRadians(Y.tiledObject.rotation??0),z:X}),_e=le.get(Jp);if(_e&&(_e.visible=this.tiledObjectLayer.visible&&(Y.tiledObject.visible===void 0||!!Y.tiledObject.visible),_e.opacity=e),this.resource.map.orientation===`isometric`){let e=new IsometricEntityComponent({rows:this.resource.map.height,columns:this.resource.map.width,tileWidth:this.resource.map.tilewidth,tileHeight:this.resource.map.tileheight});e.elevation=X??this.order,le.addComponent(e)}if(this.resource.useExcaliburWiring){let e=Y.properties.get(ab.Collision.Type);if(e&&typeof e==`string`)switch(e.toLowerCase()){case xf.Active.toLowerCase():le.body.collisionType=xf.Active;break;case xf.Fixed.toLowerCase():le.body.collisionType=xf.Fixed;break;case xf.Passive.toLowerCase():le.body.collisionType=xf.Passive;break;case xf.PreventCollision.toLowerCase():le.body.collisionType=xf.PreventCollision;break;default:this.logger.warn(`Unknown collision type in layer ${this.name}, for object id ${Y.id} and name ${Y.name}: ${e}`)}}if(Y instanceof bc){let e=Y.template.tileset,R=Y.template.object;R&&(Y.gid&&R instanceof kc&&(e=this.resource.getTilesetForTileGid(Y.gid),R=new kc(R.tiledObject,Y.gid,R.width,R.height)),this._actorFromObject(R,le,e))}else{let e;Y instanceof kc&&(e=this.resource.getTilesetForTileGid(Y.gid)),this._actorFromObject(Y,le,e)}this._recordObjectEntityMapping(Y,le)}this._loaded=!0}_recordObjectEntityMapping(e,R){R.addComponent(new Jc({tiledObject:e})),this.objects.push(e),this.entities.push(R),this._objectToEntity.set(e,R),this._entityToObject.set(R,e)}};const ob=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Pc=e=>{if(typeof e!=`string`)throw TypeError(`Invalid argument expected string`);let R=e.match(ob);if(!R)throw Error(`Invalid argument not valid semver ('${e}' received)`);return R.shift(),R},$c=e=>e===`*`||e===`x`||e===`X`,Kc=e=>{let R=parseInt(e,10);return isNaN(R)?e:R},Wc=(e,R)=>{if($c(e)||$c(R))return 0;let[W,Y]=((e,R)=>typeof e==typeof R?[e,R]:[String(e),String(R)])(Kc(e),Kc(R));return W>Y?1:W<Y?-1:0},Vc=(e,R)=>{for(let W=0;W<Math.max(e.length,R.length);W++){let Y=Wc(e[W]||`0`,R[W]||`0`);if(Y!==0)return Y}return 0},Xc=(e,R,W)=>{Ag(W);let Y=((e,R)=>{let W=Pc(e),Y=Pc(R),X=W.pop(),ie=Y.pop(),ae=Vc(W,Y);return ae===0?X&&ie?Vc(X.split(`.`),ie.split(`.`)):X||ie?X?-1:1:0:ae})(e,R);return sb[W].includes(Y)},sb={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},lb=Object.keys(sb),Ag=e=>{if(typeof e!=`string`)throw TypeError(`Invalid operator type, expected string but got `+typeof e);if(lb.indexOf(e)===-1)throw Error(`Invalid operator, expected one of ${lb.join(`|`)}`)};var ig=class{constructor(e,R,W){this.tiledImageLayer=e,this.resource=R,this.order=W,this.properties=new Map,this.image=null,this.imageActor=null,this.name=e.name,this.class=e.class,Qc(this,e.properties),e.image&&(this.image=new yp(_c(this.resource.path,e.image,this.resource.pathMap)))}async load(){let e=this.tiledImageLayer.opacity,R=!!this.tiledImageLayer.tintcolor,W=this.tiledImageLayer.tintcolor?gf.fromHex(this.tiledImageLayer.tintcolor):gf.White,Y=vec(this.tiledImageLayer.offsetx??0,this.tiledImageLayer.offsety??0),X=this.tiledImageLayer.parallaxx??1,ie=this.tiledImageLayer.parallaxy??1;if(this.image){this.resource.headless||await this.image.load(),this.imageActor=new $p({name:this.tiledImageLayer.name,pos:Y,anchor:sf.Zero,z:this.order}),this.imageActor.addComponent(new ParallaxComponent(vec(X,ie)));let ae=this.image.toSprite();this.imageActor.graphics.use(ae),this.imageActor.graphics.visible=this.tiledImageLayer.visible,this.imageActor.graphics.opacity=e,R&&(ae.tint=W)}}},ub=class ng{constructor(e,R){this.path=e,this.logger=bf.getInstance(),this.tilesets=[],this.templates=[],this.layers=[],this.mapFormat=`TMX`,this.strict=!0,this.factories=new Map,this.parser=new Wl,this.fileLoader=rc,this.startZIndex=0,this.textQuality=4,this.useExcaliburWiring=!0,this.useMapBackgroundColor=!1,this.useTilemapCameraStrategy=!1,this.headless=!1,this.layerConfig={},this._imageLoader=new Ec(yp),this._tilesetLoader=new Ec(Oc),this._templateLoader=new Ec(Uc);let{mapFormatOverride:W,textQuality:Y,entityClassNameFactories:X,useExcaliburWiring:ie,useTilemapCameraStrategy:ae,useMapBackgroundColor:le,layerConfig:_e,pathMap:ye,fileLoader:be,strict:Ce,headless:Te,startZIndex:Oe}={...R};this.strict=Ce??this.strict,this.headless=Te??this.headless,this.useExcaliburWiring=ie??this.useExcaliburWiring,this.useTilemapCameraStrategy=ae??this.useTilemapCameraStrategy,this.useMapBackgroundColor=le??this.useMapBackgroundColor,this.layerConfig=_e??this.layerConfig,this.textQuality=Y??this.textQuality,this.startZIndex=Oe??this.startZIndex,this.fileLoader=be??this.fileLoader,this.pathMap=ye;for(let e in X)this.registerEntityFactory(e,X[e]);this.mapFormat=W??(e.includes(`.tmx`)?`TMX`:`TMJ`)}registerEntityFactory(e,R){if(this.factories.has(e)&&bt.warn(`Another factory has already been registered for tiled class/type "${e}", this is probably a bug.`),this.factories.set(e,R),this.isLoaded())for(let R of this.getObjectLayers())R.runFactory(e)}unregisterEntityFactory(e){this.factories.has(e)||bt.warn(`No factory has been registered for tiled class/type "${e}", cannot unregister!`),this.factories.delete(e)}getLayerConfig(e){return this.layerConfig[e]}getTilesetForTileGid(e){let R=Cc(e);if(this.tilesets){for(let e of this.tilesets)if(R>=e.firstGid&&R<=e.firstGid+e.tileCount-1)return e}throw Error(`No tileset exists for tiled gid [${e}] normalized [${R}]!`)}getTilesetByName(e){return this.tilesets.filter(ac(e))}getTilesetByClassName(e){return this.tilesets.filter(lc(e))}getTilesetByProperty(e,R){return this.tilesets.filter(gc(e,R))}getTileMetadataByClassName(e){let R=[];for(let W of this.tilesets)R=R.concat(W.tiles.filter(lc(e)));return R}getTileMetadataByProperty(e,R){let W=[];for(let Y of this.tilesets)W=W.concat(Y.tiles.filter(gc(e,R)));return W}getTilesByGid(e){if(this.map.orientation===`orthogonal`){let R=[];for(let W of this.getTileLayers())R=R.concat(W.getTilesByGid(e));return R}{let R=[];for(let W of this.getIsoTileLayers())R=R.concat(W.getTilesByGid(e));return R}}getTilesByClassName(e){if(this.map.orientation===`orthogonal`){let R=[];for(let W of this.getTileLayers())R=R.concat(W.getTilesByClassName(e));return R}{let R=[];for(let W of this.getIsoTileLayers())R=R.concat(W.getTilesByClassName(e));return R}}getTilesByProperty(e,R){if(this.map.orientation===`orthogonal`){let W=[];for(let Y of this.getTileLayers())W=W.concat(Y.getTilesByProperty(e,R));return W}{let W=[];for(let Y of this.getIsoTileLayers())W=W.concat(Y.getTilesByProperty(e,R));return W}}getTileByPoint(e,R){if(this.map.orientation===`isometric`){let W=this.getIsoTileLayers().find(ac(e));if(W)return W.getTileByPoint(R)}else{let W=this.getTileLayers().find(ac(e));if(W)return W.getTileByPoint(R)}return null}getTileByCoordinate(e,R,W){if(this.map.orientation===`isometric`){let Y=this.getIsoTileLayers().find(ac(e));if(Y)return Y.getTileByCoordinate(R,W)}else{let Y=this.getTileLayers().find(ac(e));if(Y)return Y.getTileByCoordinate(R,W)}return null}getTilesByPoint(e){if(this.map.orientation===`orthogonal`){let R=[];for(let W of this.getTileLayers()){let Y=W.getTileByPoint(e);Y&&R.push(Y)}return R}{let R=[];for(let W of this.getIsoTileLayers()){let Y=W.getTileByPoint(e);Y&&R.push(Y)}return R}}getTilesByCoordinate(e,R){if(this.map.orientation===`orthogonal`){let W=[];for(let Y of this.getTileLayers()){let X=Y.getTileByCoordinate(e,R);X&&W.push(X)}return W}{let W=[];for(let Y of this.getIsoTileLayers()){let X=Y.getTileByCoordinate(e,R);X&&W.push(X)}return W}}getObjectsByName(e){let R=[];for(let W of this.getObjectLayers())R=R.concat(W.getObjectsByName(e));return R}getEntitiesByName(e){let R=[];for(let W of this.getObjectLayers())R=R.concat(W.getEntitiesByName(e));return R}getEntityByObject(e){for(let R of this.getObjectLayers()){let W=R.getEntityByObject(e);if(W)return W}}getObjectByEntity(e){for(let R of this.getObjectLayers()){let W=R.getObjectByEntity(e);if(W)return W}}getObjectsByProperty(e,R){let W=[];for(let Y of this.getObjectLayers())W=W.concat(Y.getObjectsByProperty(e,R));return W}getEntitiesByProperty(e,R){let W=[];for(let Y of this.getObjectLayers())W=W.concat(Y.getEntitiesByProperty(e,R));return W}getObjectsByClassName(e){let R=[];for(let W of this.getObjectLayers())R=R.concat(W.getObjectsByClassName(e));return R}getEntitiesByClassName(e){let R=[];for(let W of this.getObjectLayers())R=R.concat(W.getEntitiesByClassName(e));return R}getImageLayers(e){let R=this.layers.filter((e=>e instanceof ig));return e?R.filter(ac(e)):R}getTileLayers(e){let R=this.layers.filter((e=>e instanceof jc));return e?R.filter(ac(e)):R}getIsoTileLayers(e){let R=this.layers.filter((e=>e instanceof qc));return e?R.filter(ac(e)):R}getObjectLayers(e){let R=this.layers.filter((e=>e instanceof Yc));return e?R.filter(ac(e)):R}getLayersByName(e){return this.layers.filter(ac(e))}getLayersByClassName(e){return this.layers.filter(lc(e))}getLayersByProperty(e,R){return this.layers.filter(gc(e,R))}_parseMap(e){return this.mapFormat===`TMX`?this.parser.parse(e,this.strict):e}async load(){let e=await this.fileLoader(this.path,this.mapFormat===`TMX`?`xml`:`json`),R;if(this.strict)try{R=this._parseMap(e)}catch(e){throw bt.error(`Could not parse tiled map from location ${this.path}, attempted to interpret as ${this.mapFormat}.\nExcalibur only supports the latest version of Tiled formats as of the plugin's release.`),bt.error(`Is your map file corrupted or being interpreted as the wrong type?`),e}else R=this._parseMap(e);Xc(ng.supportedTiledVersion,R.tiledversion??`0.0.0`,`>`)&&bt.warn(`The excalibur tiled plugin officially supports ${ng.supportedTiledVersion}+, the current map has tiled version ${R.tiledversion}`),this.map=R,this._collectTilesets(),this._collectTemplates(),await Promise.all([this._tilesetLoader.load(),this.headless?Promise.resolve():this._imageLoader.load(),this._templateLoader.load()]),this.tilesets=[...this.tilesets,...this._tilesetLoader.values().map((e=>e.data))],this.templates=this._templateLoader.values().map((e=>e.data));let W=[],Y=this.startZIndex;for(let e of this.map.layers){if(e.type===`tilelayer`){if(this.map.orientation===`isometric`){let R=new qc(e,this,Y);W.push(R)}if(this.map.orientation===`orthogonal`){let R=new jc(e,this,Y);W.push(R)}}if(e.type===`objectgroup`){let R=new Yc(e,this,Y);W.push(R)}if(e.type===`imagelayer`){let R=new ig(e,this,Y);W.push(R)}Y++}await Promise.all(W.map((e=>e.load()))),this.layers=W}_collectTilesets(){for(let e of this.map.tilesets){if(Pl(e)){if(Ol(e)){let R=_c(this.path,e.image,this.pathMap),W=this._imageLoader.getOrAdd(R),Y=new Mc({name:e.name,tiledTileset:e,image:W,firstGid:e.firstgid});this.tilesets.push(Y)}if(Ul(e)){let R=new Map;if(e.tiles){for(let W of e.tiles)if(W.image){let e=_c(this.path,W.image,this.pathMap),Y=this._imageLoader.getOrAdd(e);R.set(W,Y)}}let W=new Mc({name:e.name,tiledTileset:e,tileToImage:R,firstGid:e.firstgid});this.tilesets.push(W)}}if($l(e)){let R=_c(this.path,e.source,this.pathMap);this._tilesetLoader.getOrAdd(R,e.firstgid,{strict:this.strict,headless:this.headless,parser:this.parser,fileLoader:this.fileLoader,imageLoader:this._imageLoader,pathMap:this.pathMap})}}}_collectTemplates(){let e=[];for(let R of this.map.layers)if(R.type===`objectgroup`){let W=R.objects.filter((e=>e.template)).map((e=>e.template));e=e.concat(W)}let R=e.filter(((e,R,W)=>W.findIndex((R=>R===e))===R));for(let e of R){let R=_c(this.path,e,this.pathMap);this._templateLoader.getOrAdd(R,{strict:this.strict,headless:this.headless,parser:this.parser,fileLoader:this.fileLoader,imageLoader:this._imageLoader,pathMap:this.pathMap})}}addToScene(e,R){if(!this.isLoaded())return void this.logger.warn(`TiledResource ${this.path} is not loaded! Nothing will be wired into excalibur!`);let{pos:W}={pos:vec(0,0),...R};for(let R of this.layers){if(R instanceof jc&&(R.tilemap.pos=R.tilemap.pos.add(W),e.add(R.tilemap)),R instanceof qc&&e.add(R.isometricMap),R instanceof Yc)for(let Y of R.entities){let R=Y.get(Sf);R&&(R.pos=R.pos.add(W)),e.add(Y)}R instanceof ig&&R.imageActor&&(R.imageActor.pos=R.imageActor.pos.add(W),e.add(R.imageActor))}if(this.useExcaliburWiring){let R=this.getObjectsByProperty(ab.Camera.Camera,!0);if(R&&R.length){let W=R[0],Y=1,X=W.properties.get(ab.Camera.Zoom);X&&typeof X==`number`&&(Y=X),this.map.orientation===`isometric`?e.camera.pos=this.isometricTiledCoordToWorld(W.x,W.y):e.camera.pos=vec(W.x,W.y),e.camera.zoom=Y}}if(this.useTilemapCameraStrategy){let R=this.getTileLayers()[0];if(R){let Y=Pf.fromDimension(this.map.width*this.map.tilewidth,this.map.height*this.map.tileheight,sf.Zero,W.add(R.tilemap.pos));e.camera.strategy.limitCameraBounds(Y)}}this.useMapBackgroundColor&&this.map.backgroundcolor&&(e.backgroundColor=gf.fromHex(this.map.backgroundcolor))}isometricTiledCoordToWorld(e,R){let W=this.map.tilewidth,Y=this.map.tileheight,X=R/Y,ie=e/Y;return vec((ie-X)*W/2+0,(ie+X)*Y/2)}isLoaded(){return!!this.map}};ub.supportedTiledVersion=`1.10.1`;const db={img:{player:new yp(`/res/images/Player.png`),level1Background:new yp(`/res/images/Forest_Background_0.png`),spiderGreen:new yp(`/res/images/Spider_1.png`),spiderGray:new yp(`/res/images/Spider_2.png`),birdPurple:new yp(`/res/images/Bird_1.png`),birdOrange:new yp(`/res/images/Bird_2.png`),platform:new yp(`/res/images/Platform.png`),bouncepadGreen:new yp(`/res/images/Bouncepad_Green.png`),bouncepadRed:new yp(`/res/images/Bouncepad_Red.png`),bouncepadWood:new yp(`/res/images/Bouncepad_Wood.png`),axe:new yp(`/res/images/Axe_Trap.png`),circularSaw:new yp(`/res/images/Circular_Saw.png`),smokePuff:new yp(`/res/images/Smoke_Puff.png`),smokeLand:new yp(`/res/images/Smoke_Land.png`),coin:new yp(`/res/images/Coin.png`),coinsUi:new yp(`/res/images/Coins_Ui.png`)},fonts:{round:new FontSource(`/res/fonts/Round9x13.ttf`,`Round9x13`,{filtering:pp.Pixel,quality:4})},music:{stage1:new Sound(`/res/music/stage1.mp3`),stage2:new Sound(`/res/music/stage2.mp3`)},sfx:{jump:new Sound(`/res/sfx/jump.wav`),jumpSpring:new Sound(`/res/sfx/jump-spring.wav`),land:new Sound(`/res/sfx/land.wav`),turnAround:new Sound(`/res/sfx/turn-around.wav`),stomp:new Sound(`/res/sfx/stomp.wav`),damage:new Sound(`/res/sfx/damage.wav`),collectCoin:new Sound(`/res/sfx/coin.wav`)},tiled:{level1:new ub(`/res/tilemaps/level1.tmx`,{useTilemapCameraStrategy:!0})}};var DevLoader=class extends dm{showPlayButton(){return Promise.resolve()}draw(){}dispose(){}static __type=[()=>dm,`showPlayButton`,`draw`,`dispose`,`DevLoader`,`P7!P"0"P"0#P"0$5w%`]};const fb=new DevLoader;for(let e of Object.values(db))for(let R of Object.values(e))fb.addResource(R);function __assignType$19(e,R){return e.__type=R,e}__name$1(__assignType$19,`__assignType`);var OneWayCollisionComponent=class extends Component{type=`one-way-collision`;onAdd(e){let R=e.onPreCollisionResolve.bind(e);e.onPreCollisionResolve=__assignType$19((...e)=>{this.onPreCollisionResolve(...e),R(...e)},[`args`,``,`P"@2!"/"`])}onPreCollisionResolve(e,R,W,Y){if(!(R.owner instanceof $p))return;let X=R.owner.pos.sub(R.owner.oldPos),ie=R.bounds.bottom-X.y<e.bounds.top+1;if(W!==Mf.Top||!ie){Y.cancel();return}}static __type=[()=>Component,`type`,function(){return`one-way-collision`},`owner`,`onAdd`,`self`,`other`,`side`,`contact`,`onPreCollisionResolve`,`OneWayCollisionComponent`,`P7!&3">#P!2$$0%P!2&!2'!2(!2)$0*5w+`]};function __assignType$18(e,R){return e.__type=R,e}__name$1(__assignType$18,`__assignType`);const pb=[`Ground`,()=>1,`Player`,()=>2,`Enemy`,()=>4,`Item`,()=>8,`PhysicalItem`,()=>16,`Hazard`,()=>32,`Climbable`,()=>64,`Category`,`PC!>"C#>$C%>&C'>(C)>*C+>,C->.Bw/`],mb={Ground:new Ef(`ground`,1,collideWith(2,4,16)),Player:new Ef(`player`,2,collideWith(1,4,8,32,16,64)),Enemy:new Ef(`enemy`,4,collideWith(1,2)),Hazard:new Ef(`hazard`,32,collideWith(2)),Item:new Ef(`item`,8,collideWith(2)),PhysicalItem:new Ef(`phys-item`,16,collideWith(1,2)),Climbable:new Ef(`climbable`,64,collideWith(2))};function collideWith(...e){return e.reduce(__assignType$18((e,R)=>e|R,[`acc`,`cat`,``,`P"2!"2""/#`]),0)}collideWith.__type=[()=>pb,`categories`,`collideWith`,`Pn!@2""/#`];var OneWayPlatform=class extends $p{constructor(e){super({...e,collisionType:xf.Fixed,collisionGroup:mb.Ground,anchor:vec(0,0),height:16}),this.addComponent(new OneWayCollisionComponent)}static __type=[()=>$p,`args`,`constructor`,`OneWayPlatform`,`P7!P!2""0#5w$`]};const hb=[`K`,`T`,`Record`,`l'e#"Rb!b"Pde"!N#!w#y`];function __assignType$17(e,R){return e.__type=R,e}__name$1(__assignType$17,`__assignType`);var AnimationComponent=class extends Component{type=`animation`;_animations;_speed=1;_frameDurations=(WeakMap.Ω=[[`!`],[`'`]],new WeakMap);constructor(e){super(),this._animations=e}set(e,R=0,W){let Y=this.owner.graphics.current,X=this._animations[e];this.is(e)||(R?X.goToFrame(R,W):X.reset(),Y&&(X.scale.setTo(Y.scale.x,Y.scale.y),X.opacity=Y.opacity),this.owner.graphics.use(X))}get(e){return this._animations[e]}set speed(e){this._speed=e,e!==0&&this.current.frames.forEach(__assignType$17(R=>{this._frameDurations.has(R)||this._frameDurations.set(R,R.duration??0),R.duration=this._frameDurations.get(R)/e},[`frame`,``,`P"2!"/"`]))}get speed(){return this._speed}get current(){return this.owner.graphics.current}is(e){return this.current===this.get(e)}static __type=[`Keys`,()=>Component,`graphics`,`owner`,`type`,function(){return`animation`},()=>hb,`_animations`,`_speed`,function(){return 1},`_frameDurations`,function(){return WeakMap.Ω=[[`!`],[`'`]],new WeakMap},()=>hb,`animations`,`constructor`,`name`,`startFromFrame`,`durationLeft`,`set`,`get`,`animation`,`is`,`AnimationComponent`,`b!P7"P!P!4#MK3$&3%>&e!!!o'#3(;'3);>*!3+;>,Pe"!!o-#2."0/Pe"!20"21'228"03Pe"!20"04!!Pe"!25"065w7`]};function __assignType$16(e,R){return e.__type=R,e}__name$1(__assignType$16,`__assignType`);var ControlsComponent=class extends Component{type=`input`;controls={Left:[gm.Left,hm.DpadLeft],Right:[gm.Right,hm.DpadRight],Up:[gm.Up,hm.DpadUp],Down:[gm.Down,hm.DpadDown],Jump:[gm.A,hm.Face1],Run:[gm.S,hm.Face3]};isHeld(e){let R=this.owner.scene.engine,[W,Y]=this.controls[e];return!!(R.input.keyboard.isHeld(W)||this.getGamepad()?.isButtonHeld(Y))}wasPressed(e){let R=this.owner.scene.engine,[W,Y]=this.controls[e];return!!(R.input.keyboard.wasPressed(W)||this.getGamepad()?.wasButtonPressed(Y))}wasReleased(e){let R=this.owner.scene.engine,[W,Y]=this.controls[e];return!!(R.input.keyboard.wasReleased(W)||this.getGamepad()?.wasButtonReleased(Y))}getGamepad(){let e=this.owner.scene.engine;return[e.input.gamepads.at(0),e.input.gamepads.at(1),e.input.gamepads.at(2),e.input.gamepads.at(3)].find(__assignType$16(e=>e.connected,[`g`,``,`P"2!"/"`]))}getHeldXDirection(){let e=this.owner.scene.engine;for(let R of e.input.keyboard.getKeys().slice().reverse()){if(this.controls.Left.includes(R))return`Left`;if(this.controls.Right.includes(R))return`Right`}if(this.getGamepad()){if(this.isHeld(`Left`))return`Left`;if(this.isHeld(`Right`))return`Right`}}getHeldYDirection(){let e=this.owner.scene.engine;for(let R of e.input.keyboard.getKeys().slice().reverse()){if(this.controls.Up.includes(R))return`Up`;if(this.controls.Down.includes(R))return`Down`}if(this.getGamepad()){if(this.isHeld(`Up`))return`Up`;if(this.isHeld(`Down`))return`Down`}}static __type=[()=>Component,`owner`,`type`,function(){return`input`},`controls`,function(){return{Left:[gm.Left,hm.DpadLeft],Right:[gm.Right,hm.DpadRight],Up:[gm.Up,hm.DpadUp],Down:[gm.Down,hm.DpadDown],Jump:[gm.A,hm.Face1],Run:[gm.S,hm.Face3]}},()=>this.controls,`control`,`isHeld`,()=>this.controls,`wasPressed`,()=>this.controls,`wasReleased`,`getGamepad`,`Left`,`Right`,`getHeldXDirection`,`Up`,`Down`,`getHeldYDirection`,`ControlsComponent`,`P7!!3"&3#>$!3%>&Pi'g2("0)Pi*g2("0+Pi,g2("0-P"0.PP./.0-J01PP.2.3-J045w5`]},ClimbableComponent=class extends Component{static __type=[()=>Component,`ClimbableComponent`,`P7!5w"`]};function __assignType$15(e,R){return e.__type=R,e}__name$1(__assignType$15,`__assignType`);const gb=[`left`,`right`,`top`,`bottom`,`Side`,`P.!.".#.$Jw%y`];var TouchingComponent=class extends Component{type=`touching`;contacts=(Map.Ω=[[`&`],[`contact`,`actor`,()=>gb,`side`,`P!4!!4"n#4$M`]],new Map);left=(Set.Ω=[[`!`]],new Set);right=(Set.Ω=[[`!`]],new Set);top=(Set.Ω=[[`!`]],new Set);bottom=(Set.Ω=[[`!`]],new Set);passives=(Set.Ω=[[`!`]],new Set);onAdd(e){e.on(`collisionstart`,__assignType$15(e=>{let R=e.other.owner;if(R)if(R.get(rm)?.collisionType===xf.Passive)this.passives.add(R);else{let W=e.side.toLowerCase();this.contacts.set(e.contact.id,{contact:e.contact,actor:R,side:W}),this.updateSides()}},[`ev`,``,`P"2!"/"`])),e.on(`collisionend`,__assignType$15(e=>{let R=e.other.owner;R?.get(rm)?.collisionType===xf.Passive?this.passives.delete(R):(this.contacts.delete(e.lastContact.id),this.updateSides())},[`ev`,``,`P"2!"/"`]))}updateSides(){this.left.clear(),this.right.clear(),this.top.clear(),this.bottom.clear();for(let{side:e,actor:R}of this.contacts.values())this[e].add(R)}get ladders(){return new Set(Array.from(this.passives).filter(__assignType$15(e=>e.has(ClimbableComponent),[`e`,``,`P"2!"/"`])))}static __type=[()=>Component,`type`,function(){return`touching`},`contacts`,function(){return Map.Ω=[[`&`],[`contact`,`actor`,()=>gb,`side`,`P!4!!4"n#4$M`]],new Map},`left`,function(){return Set.Ω=[[`!`]],new Set},`right`,function(){return Set.Ω=[[`!`]],new Set},`top`,function(){return Set.Ω=[[`!`]],new Set},`bottom`,function(){return Set.Ω=[[`!`]],new Set},`passives`,function(){return Set.Ω=[[`!`]],new Set},`owner`,`onAdd`,`updateSides`,`TouchingComponent`,`P7!&3">#!3$;>%!3&>'!3(>)!3*>+!3,>-!3.>/P!20$01P"02;!5w3`]},CarrierComponent=class extends Component{type=`carrier`;onAdd(e){e.on(`collisionstart`,this.onCollisionStart.bind(this)),e.on(`collisionend`,this.onCollisionEnd.bind(this)),e.on(`initialize`,this.onInitialize.bind(this))}onInitialize(){let e=this.owner;e.once(`postupdate`,()=>{--e.pos.y,e.once(`preupdate`,()=>{e.pos.y+=1})})}onCollisionStart(e){let R=e.other.owner;R.get(CarriableComponent)?.canBeCarried&&e.side===Mf.Top&&!this.owner.children.includes(R)&&this.addChild(R)}onCollisionEnd(e){let R=e.other.owner;this.owner.children.includes(R)&&this.removeChild(R)}addChild(e){this.owner.addChild(e),e.pos.x-=this.owner.pos.x,e.pos.y-=this.owner.pos.y}removeChild(e){this.owner.removeChild(e),this.owner.scene.add(e),e.pos.x+=this.owner.pos.x,e.pos.y+=this.owner.pos.y}static __type=[()=>Component,`owner`,`type`,function(){return`carrier`},`onAdd`,`onInitialize`,`event`,`onCollisionStart`,`onCollisionEnd`,`actor`,`addChild`,`removeChild`,`CarrierComponent`,`P7!!3"&3#>$P!2"$0%P$0&P!2'$0(P!2'$0)P!2*"0+P!2*"0,5w-`]},CarriableComponent=class extends Component{canBeCarried=!0;static __type=[()=>Component,`owner`,`canBeCarried`,function(){return!0},`CarriableComponent`,`P7!!3")3#>$5w%`]};const _b=[`T`,`K`,()=>vb,()=>yb,`Omit`,`b!b"e!!e!!ge!"o$#o##w%y`],vb=[`T`,`K`,`Pick`,`l+e#!e"!fRb!b"Pde""N#!w#y`],yb=[`T`,`U`,`Exclude`,`l6!Re$!RPe#!e$"qk#%QRb!b"Pde"!p)w#y`];function __assignType$14(e,R){return e.__type=R,e}__name$1(__assignType$14,`__assignType`);var PhysicsActor=class extends $p{touching=new TouchingComponent;isOnGround=!1;_oldPosGlobal=vec(0,0);_ray1=new Ray(vec(0,0),vec(1,0));_ray2=new Ray(vec(0,0),vec(1,0));constructor(e){super(e),this.addComponent(new CarriableComponent)}onInitialize(e){this.addComponent(this.touching),this.on(`preupdate`,()=>{this.isOnGround=this.touching.bottom.size>0}),this.on(`postupdate`,()=>{let e=this.getGlobalPos();this._oldPosGlobal.setTo(e.x,e.y)})}get canBeCarried(){return this.get(CarriableComponent).canBeCarried}set canBeCarried(e){this.get(CarriableComponent).canBeCarried=e}raycast(e,R,W){return this.scene.physics.rayCast(e,{maxDistance:R,searchAllColliders:!0,...W}).filter(__assignType$14(e=>e.body!==this.body,[`hit`,``,`P"2!"/"`])).sort(__assignType$14((e,R)=>e.distance-R.distance,[`a`,`b`,``,`P"2!"2""/#`]))}raycastSide(e,R,W){let Y=this.collider.bounds,X=Math.round(Y.left)+1,ie=Math.round(Y.right)-1,ae=Math.round(Y.top)+1,le=Math.round(Y.bottom)-1;if(e===`left`||e===`right`){let R=e===`left`?X:ie,W=e===`left`?-1:1;this._ray1.pos.setTo(R,ae),this._ray1.dir.setTo(W,0),this._ray2.pos.setTo(R,le),this._ray2.dir.setTo(W,0)}else{let R=e===`top`?ae:le,W=e===`top`?-1:1;this._ray1.pos.setTo(X,R),this._ray1.dir.setTo(0,W),this._ray2.pos.setTo(ie,R),this._ray2.dir.setTo(0,W)}let _e=this.raycast(this._ray1,R,W),ye=this.raycast(this._ray2,R,W);if(ye.length===0)return _e;if(_e.length===0)return ye;let be=_e.slice();for(let e of ye)_e.indexOf(e)===-1&&be.push(e);return be}getGlobalOldPos(){return this._oldPosGlobal}static __type=[()=>$p,`touching`,function(){return new TouchingComponent},`isOnGround`,function(){return!1},`_oldPosGlobal`,function(){return vec(0,0)},`_ray1`,function(){return new Ray(vec(0,0),vec(1,0))},`_ray2`,function(){return new Ray(vec(0,0),vec(1,0))},`args`,`constructor`,`_engine`,`onInitialize`,`ray`,`distance`,()=>_b,`maxDistance`,`opts`,`raycast`,`left`,`right`,`top`,`bottom`,`side`,()=>_b,`maxDistance`,`raycastSide`,`getGlobalOldPos`,`PhysicsActor`,`P7!!3">#)3$>%!3&;>'!3(;>)!3*;>+P!2,"0-P!2.$0/!P!20'21!.3o2#248"05PP.6.7.8.9J2:'21!.<o;#248"0=P"0>5w?`]};let bb=null,xb=!1;var Sb=class AudioManager{static levels=(Map.Ω=[[`!`],[`'`]],new Map([[db.music.stage1,.1],[db.music.stage2,.1],[db.sfx.jump,.25],[db.sfx.jumpSpring,.25],[db.sfx.land,.25],[db.sfx.turnAround,.25],[db.sfx.stomp,.25],[db.sfx.damage,.25],[db.sfx.collectCoin,.25]]));static get isMuted(){return xb}static init(e=!1){xb=e;for(let e of Object.values(db))for(let R of Object.values(e))R instanceof Sound&&(R.volume=xb?0:AudioManager.levels.get(R)??1)}static muteAll(){xb=!0;for(let e of Object.values(db))for(let R of Object.values(e))R instanceof Sound&&(R.stop(),R.volume=0)}static unmuteAll(){xb=!1;for(let e of Object.values(db))for(let R of Object.values(e))R instanceof Sound&&(R.volume=AudioManager.levels.get(R)??1);bb&&(bb.play(),bb.loop=!0)}static playSong(e){bb&&bb.stop(),bb=e,xb||bb.play(),bb.loop=!0}static playSfx(e,R={}){if(xb)return;let{volume:W=AudioManager.levels.get(e),force:Y=!1}=R;(Y||!e.isPlaying())&&e.play(W)}static __type=[`levels`,function(){return Map.Ω=[[`!`],[`'`]],new Map([[db.music.stage1,.1],[db.music.stage2,.1],[db.sfx.jump,.25],[db.sfx.jumpSpring,.25],[db.sfx.land,.25],[db.sfx.turnAround,.25],[db.sfx.stomp,.25],[db.sfx.damage,.25],[db.sfx.collectCoin,.25]])},`startMuted`,`init`,`muteAll`,`unmuteAll`,`song`,`playSong`,`sfx`,()=>Cb,`opts`,()=>({}),`playSfx`,`AudioManager`,`!3!s>"!P"2#"0$sP"0%sP"0&sP!2'"0(sP!2)n*2+>,"0-s5w.`]};const Cb=[`volume`,`force`,`PlaySfxOptions`,`P'4!8)4"8Mw#y`],wb=new sf(0,1450),Tb={rows:1,columns:3,spriteWidth:48,spriteHeight:48},Eb={green:{force:500,spritesheet:Sp.fromImageSource({image:db.img.bouncepadGreen,grid:Tb})},red:{force:700,spritesheet:Sp.fromImageSource({image:db.img.bouncepadRed,grid:Tb})}},Db=[()=>Eb,`type`,`BouncepadArgs`,`P!Pi!g4"8MKw#y`];var Bouncepad=class extends $p{COMPRESS_TIME=250;COMPRESS_DISTANCE=2;spritesheet;force;animation;touching=new TouchingComponent;colliderShape;constructor({type:e=`green`,...R}){super({...R,name:`bouncepad`,anchor:vec(.5,1),width:16,height:16,collisionType:xf.Fixed}),this.graphics.offset=vec(0,16),this.pos.x+=this.width*this.anchor.x,this.pos.y+=this.height*this.anchor.y,this.spritesheet=Eb[e].spritesheet,this.force=Eb[e].force,this.animation=new AnimationComponent({neutral:op.fromSpriteSheet(this.spritesheet,[2],0),compressed:op.fromSpriteSheet(this.spritesheet,[1],this.COMPRESS_TIME),released:op.fromSpriteSheet(this.spritesheet,[0,0,0,0,1],150)}),this.colliderShape=tp.Box(16,16,this.anchor),this.collider.set(this.colliderShape),this.addTag(`bouncepad`),this.addComponent(this.animation),this.addComponent(this.touching),this.addComponent(new OneWayCollisionComponent)}onInitialize(e){this.graphics.use(this.animation.get(`neutral`)),this.animation.get(`compressed`).events.on(`loop`,()=>{this.release()}),this.animation.get(`released`).events.on(`loop`,()=>{this.animation.set(`neutral`)})}compress(){if(this.animation.current===this.animation.get(`compressed`))return;this.graphics.use(this.animation.get(`compressed`));let e=this.colliderShape.points[0],R=this.colliderShape.points[1];e.y+=this.COMPRESS_DISTANCE,R.y+=this.COMPRESS_DISTANCE,this.colliderShape.points=this.colliderShape.points;for(let e of this.touching.top)e instanceof $p&&(e.pos.y+=this.COMPRESS_DISTANCE)}release(){if(this.animation.current!==this.animation.get(`compressed`))return;this.graphics.use(this.animation.get(`released`));let e=this.colliderShape.points[0],R=this.colliderShape.points[1];e.y-=this.COMPRESS_DISTANCE,R.y-=this.COMPRESS_DISTANCE,this.colliderShape.points=this.colliderShape.points;for(let e of this.touching.top)e instanceof $p&&(e.pos.y-=this.COMPRESS_DISTANCE,e.vel.y=-this.force,Sb.playSfx(db.sfx.jumpSpring))}onCollisionStart(e,R,W,Y){W===Mf.Top&&R.owner instanceof $p&&this.compress()}static __type=[()=>$p,`COMPRESS_TIME`,function(){return 250},`COMPRESS_DISTANCE`,function(){return 2},`spritesheet`,`force`,`neutral`,`compressed`,`released`,()=>AnimationComponent,`animation`,`touching`,function(){return new TouchingComponent},`colliderShape`,()=>Db,`param0`,`constructor`,`_engine`,`onInitialize`,`compress`,`release`,`self`,`other`,`side`,`_contact`,`onCollisionStart`,`Bouncepad`,`P7!'3">#'3$>%!3&'3'PP.(.).*J7+3,!3->.!3/;Pn021"02P!23$04P"05P"06P!27!28!29!2:$0;5w<`]},StompableComponent=class extends Component{stomped=!1;stomp(){this.stomped||(this.stomped=!0,this.owner.graphics.current.scale=vec(1,.25))}isBeingStomped(e){let R=e.getGlobalPos().sub(e.getGlobalOldPos());return e.collider.bounds.bottom-R.y<this.owner.collider.bounds.top+1}static __type=[()=>Component,`owner`,`stomped`,function(){return!1},`stomp`,`PhysicsActor`,`other`,`isBeingStomped`,`StompableComponent`,`P7!!3")3#>$P"0%P"w&2'"0(5w)`]};const Ob=[`instant`,`stomp`,`KillMethod`,`P.!."Jw#y`],kb=[`stompDuration`,`KillableComponentArgs`,`P'4!8Mw"y`];var KillableComponent=class extends Component{dead=!1;events=(EventEmitter.Ω=[[()=>Ob,`method`,`kill`,`PPn!4"M4#M`]],new EventEmitter);stompDuration=700;constructor({stompDuration:e}={}){super(),this.stompDuration=e??700}kill(e){if(e===`stomp`&&!this.owner.has(StompableComponent))throw Error(`Cannot kill with stomp method: actor does not have a StompableComponent`);if(!this.dead){if(this.dead=!0,this.events.emit(`kill`,{method:e}),e===`instant`)this.owner.kill();else if(e===`stomp`){let e=this.owner.get(StompableComponent);this.owner.actions.callMethod(()=>{e.stomp()}).delay(this.stompDuration*.8).fade(0,this.stompDuration*.2).callMethod(()=>{this.owner.kill()})}}}static __type=[()=>Component,`owner`,`dead`,function(){return!1},`events`,function(){return EventEmitter.Ω=[[()=>Ob,`method`,`kill`,`PPn!4"M4#M`]],new EventEmitter},`stompDuration`,function(){return 700},()=>kb,`param0`,()=>({}),`constructor`,()=>Ob,`method`,`kill`,`KillableComponent`,`P7!!3")3#>$!3%>&'3';>(Pn)2*>+"0,Pn-2."0/5w0`]};const Ab={puff:{spritesheet:Sp.fromImageSource({image:db.img.smokePuff,grid:{rows:1,columns:8,spriteWidth:32,spriteHeight:32}}),get animation(){return op.fromSpriteSheet(this.spritesheet,[0,1,2,3,4,5,6,7],50,ip.End)}},land:{spritesheet:Sp.fromImageSource({image:db.img.smokeLand,grid:{rows:1,columns:3,spriteWidth:32,spriteHeight:32}}),get animation(){return op.fromSpriteSheet(this.spritesheet,[0,0,0,1,1,2],60,ip.End)}}},jb=[`puff`,`land`,`type`,`SmokeArgs`,`P!PP.!."J4#MKw$y`];var Smoke=class extends $p{constructor({type:e,...R}){super({anchor:vec(.5,.5),...R});let W=Ab[e].animation;W.events.on(`end`,()=>{this.kill()}),this.graphics.use(W),e===`puff`&&(this.vel.y=-20)}static __type=[()=>$p,()=>jb,`param0`,`constructor`,`Smoke`,`P7!Pn"2#"0$5w%`]},HealthComponent=class extends Component{_amount;_max;events=(EventEmitter.Ω=[[`die`,`amount`,`change`,`P$4!P'4"M4#M`]],new EventEmitter);constructor({amount:e}){super(),this._max=e,this._amount=e}get max(){return this._max}get amount(){return this._amount}set amount(e){this._amount=e,this.events.emit(`change`,{amount:e}),this._amount<=0&&this.events.emit(`die`)}static __type=[()=>Component,`_amount`,`_max`,`events`,function(){return EventEmitter.Ω=[[`die`,`amount`,`change`,`P$4!P'4"M4#M`]],new EventEmitter},`amount`,`param0`,`constructor`,`HealthComponent`,`P7!'3";'3#;!3$>%PP'4&M2'"0(!!5w)`]};const Mb=[`T`,`args`,``,`ReturnType`,`l>e"!R"RPde#!P"@2"h"!/#qk#'QRb!Pde"!p)w$y`];function __assignType$13(e,R){return e.__type=R,e}__name$1(__assignType$13,`__assignType`);var Nb=class DamageableComponent extends Component{events=(EventEmitter.Ω=[[`amount`,`left`,`right`,`knockback`,`damage`,`PP'4!P.".#J4$8M4%M`]],new EventEmitter);INVINCIBILITY_DURATION=2e3;KNOCKBACK_DURATION=200;isInvincible=!1;isBeingKnockedBack=!1;damage(e,R){if(this.isInvincible)return;let W=this.owner.get(HealthComponent);if(this.events.emit(`damage`,{amount:e,knockback:R}),this.isInvincible=!0,Sb.playSfx(db.sfx.damage),W&&(W.amount-=e),R){let e=100*(R===`left`?-1:1);this.owner.vel=vec(e,-300),this.owner.acc=vec(0,0),this.isBeingKnockedBack=!0}coroutine(this.owner.scene.engine,__assignType$13(function*(){let e=0;for(;e<Math.max(this.KNOCKBACK_DURATION,this.INVINCIBILITY_DURATION);)if(e+=yield 1,this.isBeingKnockedBack&&e>=this.KNOCKBACK_DURATION&&(this.isBeingKnockedBack=!1,this.owner.vel.x=0),e>=this.INVINCIBILITY_DURATION&&(this.isInvincible=!1),this.owner.graphics.current){let R=Math.floor(e/100)%2==0;this.owner.graphics.current.opacity=R?.35:1}this.owner.graphics.current&&(this.owner.graphics.current.opacity=1)},[()=>DamageableComponent,`this`,()=>Mb,``,`PP7!2"!o#"/$`]).bind(this))}static __type=[()=>Component,`owner`,`events`,function(){return EventEmitter.Ω=[[`amount`,`left`,`right`,`knockback`,`damage`,`PP'4!P.".#J4$8M4%M`]],new EventEmitter},`INVINCIBILITY_DURATION`,function(){return 2e3},`KNOCKBACK_DURATION`,function(){return 200},`isInvincible`,function(){return!1},`isBeingKnockedBack`,function(){return!1},`amount`,`left`,`right`,`knockback`,`damage`,`DamageableComponent`,`P7!!3"!3#>$'3%>&'3'>()3)>*)3+>,P'2-P.../J208"015w2`]},CollectableComponent=class extends Component{isCollected=!1;isCollectable=!0;static __type=[()=>Component,`isCollected`,function(){return!1},`isCollectable`,function(){return!0},`CollectableComponent`,`P7!)3">#)3$>%5w&`]};let Pb=3;var Fb=class GameManager{static events=(EventEmitter.Ω=[[()=>Ib,`n!`]],new EventEmitter);static get coins(){return Pb}static set coins(e){e<0&&(e=0),Pb=e,GameManager.events.emit(`coinchange`,{coins:Pb})}static __type=[`events`,function(){return EventEmitter.Ω=[[()=>Ib,`n!`]],new EventEmitter},`GameManager`,`!3!s>"!5w#`]};const Ib=[`coins`,`coinchange`,`GameManagerEvents`,`PP'4!M4"Mw#y`];function __assignType$12(e,R){return e.__type=R,e}__name$1(__assignType$12,`__assignType`);var CoinItem=class extends $p{elapsedMs=0;collected=!1;constructor(e){super({anchor:vec(.5,.75),collisionType:xf.Passive,collisionGroup:mb.Item,width:8,height:8,...e}),this.pos.x+=this.width*this.anchor.x,this.pos.y-=this.height*this.anchor.y,this.addComponent(new CollectableComponent),this.graphics.use(db.img.coin.toSprite())}get collectable(){return this.get(CollectableComponent)}onPreUpdate(e,R){this.elapsedMs+=R,this.pos.y-=Math.sin(this.elapsedMs/200)/10}collect(){!this.collectable.isCollectable||this.collectable.isCollected||(Sb.playSfx(db.sfx.collectCoin,{force:!0}),Fb.coins+=1,this.collectable.isCollected=!0,this.actions.clearActions(),this.actions.runAction(new ParallelActions([new Am(this,__assignType$12(e=>e.moveBy(vec(0,-16),150),[`ctx`,``,`P"2!"/"`])),new Am(this,__assignType$12(e=>e.fade(0,150),[`ctx`,``,`P"2!"/"`]))])).callMethod(()=>{this.kill()}))}onPreCollisionResolve(e,R,W,Y){R.owner instanceof Bb&&(this.collect(),Y.cancel())}static __type=[()=>$p,`elapsedMs`,function(){return 0},`collected`,function(){return!1},`args`,`constructor`,`engine`,`elapsed`,`onPreUpdate`,`collect`,`self`,`other`,`side`,`contact`,`onPreCollisionResolve`,`CoinItem`,`P7!'3">#)3$>%P!2&"0'!P!2('2)$0*P"0+P!2,!2-!2.!2/$005w1`]};function __assignType$11(e,R){return e.__type=R,e}__name$1(__assignType$11,`__assignType`);var LostCoin=class extends CoinItem{touching=new TouchingComponent;LIFETIME=3e3;TIME_UNTIL_COLLECTABLE=500;BOUNCE=1;FRICTION=.1;constructor(e){super({anchor:vec(.5,.5),collisionType:xf.Active,collisionGroup:mb.PhysicalItem,width:8,height:8,z:500,...e}),this.pos.x+=this.width*this.anchor.x,this.pos.y-=this.height*this.anchor.y,this.addComponent(this.touching),this.addComponent(new CarriableComponent),this.graphics.use(db.img.coin.toSprite()),this.collectable.isCollectable=!1}onInitialize(e){this.actions.runAction(new ParallelActions([new Am(this,__assignType$11(e=>e.delay(this.TIME_UNTIL_COLLECTABLE).callMethod(()=>{this.collectable.isCollectable=!0}),[`ctx`,``,`P"2!"/"`])),new Am(this,__assignType$11(e=>e.delay(this.LIFETIME).callMethod(()=>this.kill()),[`ctx`,``,`P"2!"/"`]))]))}onPreUpdate(e,R){this.elapsedMs+=R;let W=Math.floor(this.elapsedMs/50)%2==0;this.graphics.current&&(this.graphics.current.opacity=W?.35:.65)}onPreCollisionResolve(e,R,W,Y){if(R.owner instanceof Bb&&!this.collectable.isCollectable)return Y.cancel();super.onPreCollisionResolve(e,R,W,Y)}onPostCollisionResolve(e,R,W,Y){W===Mf.Bottom||W===Mf.Top?this.vel.x=this.oldVel.x*(1-this.FRICTION):(W==Mf.Left||W==Mf.Right)&&(this.vel.y=this.oldVel.y*(1-this.FRICTION))}onCollisionStart(e,R,W,Y){R.owner instanceof Bb?super.onCollisionStart(e,R,W,Y):W===Mf.Bottom||W===Mf.Top?this.vel.y=this.oldVel.y*-this.BOUNCE:(W==Mf.Left||W==Mf.Right)&&(this.vel.x=this.oldVel.x*-this.BOUNCE)}static __type=[()=>CoinItem,`touching`,function(){return new TouchingComponent},`LIFETIME`,function(){return 3e3},`TIME_UNTIL_COLLECTABLE`,function(){return 500},`BOUNCE`,function(){return 1},`FRICTION`,function(){return .1},`args`,`constructor`,`_engine`,`onInitialize`,`engine`,`elapsed`,`onPreUpdate`,`self`,`other`,`side`,`contact`,`onPreCollisionResolve`,`_contact`,`onPostCollisionResolve`,`onCollisionStart`,`LostCoin`,`P7!!3">#'3$>%'3&>''3(>)'3*>+P!2,"0-P!2.$0/P!20'21$02P!23!24!25!26$07P!23!24!25!28$09P!23!24!25!26$0:5w;`]};const Lb=[`K`,`T`,`Record`,`l'e#"Rb!b"Pde"!N#!w#y`];var CoyoteComponent=class extends Component{actions;counter={};constructor(e){super(),this.actions=e}onAdd(e){e.on(`preupdate`,this.onPreUpdate.bind(this))}onPreUpdate(e){for(let R in this.actions){let W=this.actions[R];W.condition(e.elapsed)?this.counter[R]=W.time:this.counter[R]=Math.max(0,this.counter[R]-e.elapsed)}}allow(e){return this.counter[e]>0}reset(e){this.counter[e]=0}static __type=[`T`,()=>Component,`actions`,()=>Lb,`counter`,function(){return{}},`constructor`,`owner`,`onAdd`,`ev`,`onPreUpdate`,`action`,`allow`,`reset`,`CoyoteComponent`,`b!P7"e!!3#e!!g'o$#3%>&Pe"!2#"0'P!2($0)P!2*"0+Pe"!g2,"0-Pe"!g2,"0.5w/`]},FakeDie=class extends $p{constructor(e){super({...e,collisionType:xf.Active,z:9999}),this.body.useGravity=!1,this.acc.y=wb.y/2,this.graphics.use(new qp({text:`// TODO: die`,color:gf.White,font:new Kp({size:10,family:`sans-serif`})})),this.vel.y=-300,this.vel.x=randomInRange(-100,100)}onPreUpdate(e,R){this.isOffScreen&&this.kill()}static __type=[()=>$p,`args`,`constructor`,`_engine`,`_elapsed`,`onPreUpdate`,`FakeDie`,`P7!P!2""0#P!2$'2%$0&5w'`]};const Rb=[`T`,`args`,``,`ReturnType`,`l>e"!R"RPde#!P"@2"h"!/#qk#'QRb!Pde"!p)w$y`];function __assignType$10(e,R){return e.__type=R,e}__name$1(__assignType$10,`__assignType`);const zb=Sp.fromImageSource({image:db.img.player,grid:{columns:4,rows:7,spriteWidth:48,spriteHeight:48}});var Bb=class Player extends PhysicsActor{JUMP_GRAVITY=wb.y*.5;APEX_GRAVITY=wb.y*.3;MAX_FALL_SPEED=270;WALL_SLIDE_SPEED=80;LADDER_CLIMB_SPEED=75;ACCELERATION=300;STOP_DECELERATION=this.ACCELERATION;GROUND_TURN_DECELERATION=this.ACCELERATION*4;AIR_TURN_DECELERATION=this.ACCELERATION*7;WALK_MAX_VELOCITY=90;RUN_MAX_VELOCITY=150;SPRINT_MAX_VELOCITY=210;SPRINT_TRIGGER_TIME=1e3;JUMP_FORCE=300;RUN_JUMP_FORCE=this.JUMP_FORCE*1.1;SPRINT_JUMP_FORCE=this.JUMP_FORCE*1.2;WALL_JUMP_X_DISTANCE=4;WALL_JUMP_DURATION=70;FX_SQUISH_AMOUNT=8/48;animation=new AnimationComponent({idle:op.fromSpriteSheet(zb,[0,1,2,3],140),run:op.fromSpriteSheet(zb,[4,5,6,7],140),sprint:op.fromSpriteSheet(zb,[8,9,10,11],140),jump:op.fromSpriteSheet(zb,[12],140),fall:op.fromSpriteSheet(zb,[13],140),turn:op.fromSpriteSheet(zb,[16],140),ladder_climb:op.fromSpriteSheet(zb,[20,21],140),wall_slide:op.fromSpriteSheet(zb,[16],100,ip.Loop)});controls=new PlayerControlsComponent;coyote=new CoyoteComponent({jump:{time:70,condition:()=>this.isOnGround}});isUsingJumpGravity=!1;facing=`right`;isClimbingLadder=!1;isSlidingOnWall=!1;isWallJumping=!1;get maxXVelocity(){switch(!0){case this.controls.isSprinting:return this.SPRINT_MAX_VELOCITY;case this.controls.isRunning:return this.RUN_MAX_VELOCITY;default:return this.WALK_MAX_VELOCITY}}get maxFallingVelocity(){switch(!0){case this.isSlidingOnWall:return this.WALL_SLIDE_SPEED;default:return this.MAX_FALL_SPEED}}get bouncepad(){for(let e of this.touching.bottom)if(e.hasTag(`bouncepad`))return e}get isTouchingLadder(){return this.touching.ladders.size>0}get isAboveLadder(){return this.raycastSide(`bottom`,1,{searchAllColliders:!0}).filter(__assignType$10(e=>e.body.owner?.has(ClimbableComponent),[`hit`,``,`P"2!"/"`])).length>0}get isXMovementAllowed(){let{isBeingKnockedBack:e}=this.get(Nb);return!this.isClimbingLadder&&!this.bouncepad&&!this.isWallJumping&&!e}constructor(e){super({...e,name:`player`,anchor:new sf(.5,1),width:16,height:16,collisionType:xf.Active,collisionGroup:mb.Player,collider:tp.Box(12,12,vec(.5,1))}),this.body.useGravity=!1;let R=new Nb;this.addComponent(this.animation),this.addComponent(this.controls),this.addComponent(this.coyote),this.addComponent(R),this.addComponent(new HealthComponent({amount:3})),R.events.on(`damage`,__assignType$10(({amount:e})=>{if(Fb.coins===0)this.scene?.entities.find(__assignType$10(e=>e instanceof FakeDie,[`e`,``,`P"2!"/"`]))||this.scene?.add(new FakeDie({x:this.getGlobalPos().x,y:this.getGlobalPos().y}));else{let R=Fb.coins-e<0?Fb.coins:e;Fb.coins-=R;for(let e=0;e<R;e++)this.scene?.add(new LostCoin({pos:vec(this.facing===`left`?this.collider.bounds.right:this.collider.bounds.left,this.collider.bounds.top),vel:vec(100*(this.facing===`right`?-1:1),-200)}))}},[`param0`,``,`P"2!"/"`])),this.animation.get(`turn`).events.on(`frame`,__assignType$10(e=>{e.frameIndex===0&&Sb.playSfx(db.sfx.turnAround)},[`frame`,``,`P"2!"/"`])),this.animation.get(`sprint`).events.on(`frame`,__assignType$10(e=>{e.frameIndex%2==0&&this.spawnSmokePuffAtFeet(this.facing===`left`?`right`:`left`,vec(-2,0))},[`frame`,``,`P"2!"/"`])),this.animation.get(`turn`).events.on(`frame`,__assignType$10(e=>{this.spawnSmokePuffAtFeet(this.facing===`left`?`right`:`left`)},[`_frame`,``,`P"2!"/"`])),this.animation.get(`wall_slide`).events.on(`loop`,__assignType$10(e=>{this.spawnSmokePuffAtHands(this.facing,vec(randomIntInRange(-1,1),0))},[`_frame`,``,`P"2!"/"`])),this.addTag(`player`),globalThis.player=this}onInitialize(e){super.onInitialize(e),this.graphics.offset=new sf(0,16),this.animation.set(`idle`)}onPreUpdate(e,R){this.isOnGround&&(this.isUsingJumpGravity=!1,this.isWallJumping=!1,this.isSlidingOnWall=!1),this.isTouchingLadder||(this.isClimbingLadder=!1),!this.isOnWall(`right`)&&!this.isOnWall(`left`)&&(this.isSlidingOnWall=!1),this.handleInput(e,R)}update(e,R){let W=!1;this.vel.y<0&&(this.isUsingJumpGravity=this.controls.isHeld(`Jump`)),this.isUsingJumpGravity&&this.vel.y>-10&&this.vel.y<10&&(W=!0),W?this.acc.setTo(0,this.APEX_GRAVITY):this.isUsingJumpGravity?this.acc.setTo(0,this.JUMP_GRAVITY):this.acc.setTo(0,wb.y),this.isClimbingLadder&&(this.acc.setTo(0,0),this.vel.setTo(0,0)),this.vel.y>=this.maxFallingVelocity&&(this.vel.y=this.maxFallingVelocity,this.acc.y=0),super.update(e,R)}onPostUpdate(e,R){let{isBeingKnockedBack:W}=this.get(Nb);this.animation.speed=Math.min(1+(Math.abs(this.vel.x)/200)**2*3,3),this.handleAnimation(),!this.isWallJumping&&!W&&this.applyDeceleration()}onPreCollisionResolve(e,R,W,Y){super.onPreCollisionResolve(e,R,W,Y);let X=R.owner.has(StompableComponent)?R.owner.get(StompableComponent):void 0;X&&X&&!X.stomped&&X.isBeingStomped(this)&&(this.stomp(R.owner),Y.cancel())}onCollisionStart(e,R,W,Y){if(Y.isCanceled())return;let X=R.owner.get(rm);if(X?.collisionType===xf.Fixed||X?.collisionType===xf.Active){let e=this.oldVel.y>0;W===Mf.Bottom&&e&&(R.owner instanceof Bouncepad&&(this.vel.x=0),this.land())}}handleInput(e,R){let W=this.controls.wasPressed(`Jump`),Y=this.controls.isHeld(`Jump`),X=this.controls.getHeldXDirection(),ie=this.controls.getHeldYDirection(),ae=this.isOnWall(`left`,4),le=this.isOnWall(`right`,4);if(X&&this.isXMovementAllowed){let e=X===`Left`?-1:1,R=this.ACCELERATION*e;if(this.facing=e===-1?`left`:`right`,this.acc.x+=R,!this.isOnGround&&this.vel.y>0){let e=this.isOnWall(`right`),R=this.isOnWall(`left`);e&&X===`Right`||R&&X===`Left`?this.isSlidingOnWall=!0:this.isSlidingOnWall=!1}}else this.isSlidingOnWall=!1;ie&&this.climbLadder(),W?this.isClimbingLadder?(this.isClimbingLadder=!1,ie!==`Down`&&this.jump()):this.isOnGround||this.coyote.allow(`jump`)?this.jump():(ae||le)&&this.wallJump(ae?`left`:`right`):!Y&&this.vel.y<0&&this.vel.y>-200&&!this.isClimbingLadder&&(this.vel.y*=.5,this.isUsingJumpGravity=!1)}handleAnimation(){let e=this.animation.current.currentFrameIndex,R=this.animation.current.currentFrameTimeLeft,W=this.controls.getHeldXDirection();if(this.graphics.flipHorizontal=this.facing===`left`,this.isSlidingOnWall)this.animation.is(`wall_slide`)||Sb.playSfx(db.sfx.land),this.animation.set(`wall_slide`);else if(this.isClimbingLadder)this.animation.set(`ladder_climb`),this.vel.y===0&&this.animation.current.goToFrame(0);else if(this.isOnGround){if(this.controls.isTurning)this.animation.set(`turn`);else if(!W||W===`Left`&&this.vel.x<0||W===`Right`&&this.vel.x>0){if(this.controls.isSprinting&&Math.abs(this.vel.x)>this.RUN_MAX_VELOCITY){let W=this.animation.is(`run`);this.animation.set(`sprint`,W?e:0,W?R:0)}else if(this.vel.x!==0){let W=this.animation.is(`sprint`);this.animation.set(`run`,W?e:0,W?R:0)}}else this.animation.set(`idle`);Math.round(this.vel.x)===0&&this.animation.set(`idle`)}else this.vel.y!==0&&(this.vel.y<0?this.animation.set(`jump`):this.animation.set(`fall`));this.animation.is(`jump`)&&this.oldVel.y>=0&&this.vel.y<0&&coroutine(this.scene.engine,__assignType$10(function*(){let e=1+1*this.FX_SQUISH_AMOUNT,R=Xp.EaseOutCubic,W=this.vel.y,Y=0;for(;this.vel.y<W*.25;)Y+=yield 1,Y<70&&this.squishGraphic(R(Math.min(Y,70),1,e,70));for(Y=0;!this.touching.bottom.size;)Y+=yield 1,Y<70&&this.squishGraphic(R(Math.min(Y,70),e,1,140));this.squishGraphic(1)},[()=>Player,`this`,()=>Rb,``,`PP7!2"!o#"/$`]).bind(this))}land(){this.isOnGround=!0,Sb.playSfx(db.sfx.land),this.spawnSmoke(`land`,{pos:vec(this.center.x,this.collider.bounds.bottom-8),scale:vec(.5,.5)});let e=1-this.FX_SQUISH_AMOUNT,R=Xp.EaseOutCubic;coroutine(this.scene.engine,__assignType$10(function*(){let W=0;for(;W<70&&this.isOnGround;)W+=yield 1,this.squishGraphic(R(Math.min(W,70),1,e,70));for(this.squishGraphic(e),W=0;W<70&&this.isOnGround;)W+=yield 1,this.squishGraphic(R(Math.min(W,70),e,1,70));this.squishGraphic(1)},[()=>Player,`this`,()=>Rb,``,`PP7!2"!o#"/$`]).bind(this))}climbLadder(){let e=this.controls.getHeldYDirection();if(this.isTouchingLadder){let R=Array.from(this.touching.ladders).sort(__assignType$10((e,R)=>Math.abs(this.collider.bounds.bottom-e.collider.bounds.bottom)-Math.abs(this.collider.bounds.bottom-R.collider.bounds.bottom),[`a`,`b`,``,`P"2!"2""/#`])).at(0),W=e===`Up`?-1:1,Y=Math.abs(this.pos.x-R.center.x)<8,X=__assignType$10(e=>Math.floor(Math.round(e)/16),[`n`,``,`P'2!"/"`]),ie=X(this.collider.bounds.bottom)===X(R.collider.bounds.bottom);e===`Up`&&!this.isClimbingLadder&&ie&&Y&&(this.isClimbingLadder=!0),this.isClimbingLadder&&(this.pos.x=R.center.x,this.vel.y=this.LADDER_CLIMB_SPEED*W,this.vel.x=0,this.isOnGround&&e===`Down`&&(this.isClimbingLadder=!1))}else this.isAboveLadder&&e===`Down`&&(this.isClimbingLadder=!0,this.pos.y=Math.ceil(this.pos.y)+1)}jump(e,R=!0){if(this.isOnGround=!1,this.coyote.reset(`jump`),this.bouncepad){this.bouncepad.release();return}e===void 0&&(e=this.JUMP_FORCE,this.controls.isSprinting?e=this.SPRINT_JUMP_FORCE:this.controls.isRunning&&(e=this.RUN_JUMP_FORCE)),this.vel.y=-e,R&&Sb.playSfx(db.sfx.jump)}wallJump(e){this.isWallJumping||(this.jump(),this.isWallJumping=!0,this.spawnSmokePuffAtFeet(e,vec(0,-4)),coroutine(this.scene.engine,__assignType$10(function*(){let R=0,W=e===`left`?1:-1,Y=this.WALL_JUMP_X_DISTANCE/(this.WALL_JUMP_DURATION/1e3)*W;for(;R<this.WALL_JUMP_DURATION&&this.isWallJumping;)R+=yield 1,this.vel.x=Y;this.isWallJumping&&(this.controls.getHeldXDirection()||(this.vel.x=0)),this.isWallJumping=!1},[()=>Player,`this`,()=>Rb,``,`PP7!2"!o#"/$`]).bind(this)))}stomp(e){let R=e.get(KillableComponent);if(R.dead)return;this.land(),R.kill(`stomp`),Sb.playSfx(db.sfx.stomp);let W=this.controls.isSprinting?this.SPRINT_JUMP_FORCE:this.RUN_JUMP_FORCE;this.jump(W,!1)}isOnWall(e,R=1){return this.raycastSide(e,R,{filter:__assignType$10(e=>e.body.group===mb.Ground,[`hit`,``,`P"2!"/"`])}).length>0}applyDeceleration(){let e=this.isOnGround,R=Math.abs(this.vel.x)>this.maxXVelocity;e?this.controls.isTurning?this.acc.x=-this.GROUND_TURN_DECELERATION*Math.sign(this.vel.x):(!this.controls.isMoving||R)&&this.vel.x!==0&&(this.acc.x=-this.STOP_DECELERATION*Math.sign(this.vel.x)):this.controls.isTurning?this.acc.x=-this.AIR_TURN_DECELERATION*Math.sign(this.vel.x):R&&(this.vel.x=clamp(this.vel.x,-this.maxXVelocity,this.maxXVelocity),this.acc.x=0),Math.sign(this.vel.x)!==0&&Math.sign(this.vel.x)!==Math.sign(this.acc.x)&&Math.abs(this.vel.x)<1&&(this.vel.x=0,this.acc.x=0)}squishGraphic(e){let R=e,W=2-R;this.graphics.current.scale=vec(W,R)}spawnSmoke(e,R){this.scene?.add(new Smoke({type:e,z:this.z+1,...R}))}spawnSmokePuffAtFeet(e,R=vec(0,0)){this.spawnSmoke(`puff`,{pos:vec(e===`left`?this.collider.bounds.left+R.x:this.collider.bounds.right-R.x,this.collider.bounds.bottom+R.y),scale:vec(.35,.35)})}spawnSmokePuffAtHands(e,R=vec(0,0)){this.spawnSmoke(`puff`,{pos:vec(e===`left`?this.collider.bounds.left+R.x:this.collider.bounds.right-R.x,this.center.y+R.y),scale:vec(.35,.35)})}static __type=[()=>PhysicsActor,`JUMP_GRAVITY`,function(){return wb.y*.5},`APEX_GRAVITY`,function(){return wb.y*.3},`MAX_FALL_SPEED`,function(){return 270},`WALL_SLIDE_SPEED`,function(){return 80},`LADDER_CLIMB_SPEED`,function(){return 75},`ACCELERATION`,function(){return 300},`STOP_DECELERATION`,function(){return this.ACCELERATION},`GROUND_TURN_DECELERATION`,function(){return this.ACCELERATION*4},`AIR_TURN_DECELERATION`,function(){return this.ACCELERATION*7},`WALK_MAX_VELOCITY`,function(){return 90},`RUN_MAX_VELOCITY`,function(){return 150},`SPRINT_MAX_VELOCITY`,function(){return 210},`SPRINT_TRIGGER_TIME`,function(){return 1e3},`JUMP_FORCE`,function(){return 300},`RUN_JUMP_FORCE`,function(){return this.JUMP_FORCE*1.1},`SPRINT_JUMP_FORCE`,function(){return this.JUMP_FORCE*1.2},`WALL_JUMP_X_DISTANCE`,function(){return 4},`WALL_JUMP_DURATION`,function(){return 70},`FX_SQUISH_AMOUNT`,function(){return 8/48},`animation`,function(){return new AnimationComponent({idle:op.fromSpriteSheet(zb,[0,1,2,3],140),run:op.fromSpriteSheet(zb,[4,5,6,7],140),sprint:op.fromSpriteSheet(zb,[8,9,10,11],140),jump:op.fromSpriteSheet(zb,[12],140),fall:op.fromSpriteSheet(zb,[13],140),turn:op.fromSpriteSheet(zb,[16],140),ladder_climb:op.fromSpriteSheet(zb,[20,21],140),wall_slide:op.fromSpriteSheet(zb,[16],100,ip.Loop)})},`controls`,function(){return new PlayerControlsComponent},`coyote`,function(){return new CoyoteComponent({jump:{time:70,condition:()=>this.isOnGround}})},`isUsingJumpGravity`,function(){return!1},`left`,`right`,`facing`,function(){return`right`},`isClimbingLadder`,function(){return!1},`isSlidingOnWall`,function(){return!1},`isWallJumping`,function(){return!1},`x`,`y`,`z`,`args`,`constructor`,`engine`,`onInitialize`,`elapsed`,`onPreUpdate`,`update`,`_engine`,`_elapsed`,`onPostUpdate`,`self`,`other`,`side`,`contact`,`onPreCollisionResolve`,`onCollisionStart`,`handleInput`,`handleAnimation`,`land`,`climbLadder`,`force`,`playSfx`,`jump`,`left`,`right`,`wallJump`,`stomp`,`left`,`right`,`distance`,`isOnWall`,`applyDeceleration`,`scale`,`squishGraphic`,`puff`,`land`,`type`,`pos`,`spawnSmoke`,`left`,`right`,`offset`,`spawnSmokePuffAtFeet`,`left`,`right`,`spawnSmokePuffAtHands`,`Player`,`P7!!3">#!3$>%'3&>''3(>)'3*>+'3,>-!3.>/!30>1!32>3'34>5'36>7'38>9'3:>;'3<>=!3>>?!3@>A'3B>C'3D>E!3F>G!3H>I!3J>K!3L>M)3N>OP.P.QJ3R>S)3T>U)3V>W)3X>Y!!!!!!PP'4Z'4['4\\8M2]"0^P!2_"0\`P!2_'2a$0bP!2_'2a$0cP!2d'2e$0fP!2g!2h!2i!2j$0kP!2g!2h!2i!2j$0lP!2d'2e"0mP"0nP"0oP"0pP'2q8"2r"0sPP.t.uJ2i"0vP!2h"0wPP.x.yJ2i"2z"0{P"0|P'2}"0~PP..J2P!4!4}8M2]"0PP..
J2i"2"0PP..J2i"2"05w`]},PlayerControlsComponent=class extends ControlsComponent{sprintTimer=0;onAdd(e){super.onAdd?.(e),e.on(`postupdate`,__assignType$10(({elapsed:e})=>{let R=this.owner.isOnGround,W=!R&&!this.isSprinting,Y=this.isTurning&&R;this.isRunning&&R&&!Y?this.sprintTimer=Math.min(this.sprintTimer+e,this.owner.SPRINT_TRIGGER_TIME):(!this.isRunning||Y||W)&&(this.sprintTimer=0)},[`param0`,``,`P"2!"/"`]))}get isMoving(){return this.getHeldXDirection()!==void 0}get isRunning(){return this.isMoving&&this.isHeld(`Run`)}get isSprinting(){return this.isRunning&&this.sprintTimer>=this.owner.SPRINT_TRIGGER_TIME}get isTurning(){let e=this.getHeldXDirection(),{isBeingKnockedBack:R}=this.owner.get(Nb);return R?!1:e===`Left`&&this.owner.vel.x>0||e===`Right`&&this.owner.vel.x<0}static __type=[()=>ControlsComponent,()=>Bb,`owner`,`sprintTimer`,function(){return 0},()=>Bb,`onAdd`,`PlayerControlsComponent`,`P7!P7"3#'3$>%PP7&2#$0'!!!!5w(`]};function __assignType$9(e,R){return e.__type=R,e}__name$1(__assignType$9,`__assignType`);var ScrollingBackground=class extends Of{xSpeed;ySpeed;image;graphics=new Jp;transform=new Sf;constructor(e){let{xSpeed:R=.25,ySpeed:W=.1,z:Y=-100,image:X}=e;super(),this.addComponent(this.graphics),this.addComponent(this.transform),this.image=X,this.xSpeed=R,this.ySpeed=W,this.graphics.anchor=vec(.5,.5),this.transform.pos=vec(0,0),this.transform.z=Y}onInitialize(e){let R=this.image.toSprite(),W=this.scene.camera.viewport.width,Y=this.scene.camera.viewport.height,X=Math.ceil(W/R.width)+1,ie=Math.ceil(Y/R.height)+1;this.graphics.use(new sp({members:Array.from({length:X*ie}).map(__assignType$9((e,W)=>{let Y=W%X,ae=Math.floor(W/ie);return{graphic:R,offset:vec(R.width*Y,R.height*ae)}},[`_`,`i`,``,`P"2!"2""/#`]))})),this.on(`pretransformdraw`,()=>{let W=this.scene.camera,Y=W.drawPos.x-e.halfDrawWidth,X=W.drawPos.y-e.halfDrawHeight;this.transform.pos.x=Y,this.transform.pos.y=X;let ie=Y*-this.xSpeed%R.width+R.width,ae=X*-this.ySpeed%R.height+R.height;this.graphics.offset.setTo(ie,ae)})}static __type=[()=>Of,`xSpeed`,`ySpeed`,`image`,`graphics`,function(){return new Jp},`transform`,function(){return new Sf},`z`,`args`,`constructor`,`_engine`,`onInitialize`,`ScrollingBackground`,`P7!'3"'3#!3$!3%>&!3'>(PP!4$'4"8'4#8'4)8M2*"0+P!2,$0-5w.`]};function __assignType$8(e,R){return e.__type=R,e}__name$1(__assignType$8,`__assignType`);var Tween=class{engine;value;_startValue=0;_targetValue=0;_easing;_duration=0;_elapsed=0;constructor(e,R,W){let{easing:Y=Xp.Linear,duration:X=1e3}=W;this.engine=e,this.value=R,this._startValue=R,this._targetValue=R,this._easing=Y,this._duration=X,e.on(`preupdate`,this.onUpdate)}onUpdate=__assignType$8(e=>{this._elapsed<this._duration&&(this._elapsed=Math.min(this._duration,this._elapsed+e.elapsed),this.value=this._easing(this._elapsed,this._startValue,this._targetValue,this._duration))},[`ev`,``,`P!2!"/"`]);set(e,R=!1){this._elapsed=0,R?(this.value=e,this._startValue=e,this._targetValue=e):(this._startValue=this.value,this._targetValue=e)}destroy(){this.engine.off(`preupdate`,this.onUpdate)}static __type=[`engine`,`value`,`_startValue`,function(){return 0},`_targetValue`,function(){return 0},`_easing`,`_duration`,function(){return 0},`_elapsed`,function(){return 0},`easing`,`duration`,`opts`,`constructor`,`onUpdate`,function(){return __assignType$8(e=>{this._elapsed<this._duration&&(this._elapsed=Math.min(this._duration,this._elapsed+e.elapsed),this.value=this._easing(this._elapsed,this._startValue,this._targetValue,this._duration))},[`ev`,``,`P!2!"/"`])},`immediately`,`set`,`destroy`,`Tween`,`!3!'3"'3#;>$'3%;>&!3';'3(;>)'3*;>+P!2!'2"P!4,8'4-8M2."0/!30>1P'2""22"03P"045w5`]},LockToPlayerStrategy=class{FOLLOW_DAMPING=.5;TURN_TWEEN_DURATION=400;X_EDGE_BUFFER=20;Y_EDGE_BUFFER=40;target;xOffset;facing=`right`;isFirstUpdate=!0;constructor(e){this.target=e,this.xOffset=new Tween(this.target.scene.engine,0,{easing:Xp.Linear,duration:this.TURN_TWEEN_DURATION}),this.turn(`right`,!0)}action(e,R,W,Y){let X=e.getGlobalPos(),ie=X.x-R.pos.x+this.xOffset.value,ae=X.y-R.pos.y,le=ie<-this.X_EDGE_BUFFER,_e=ie>this.X_EDGE_BUFFER,ye=ae<-this.Y_EDGE_BUFFER,be=ae>this.Y_EDGE_BUFFER,Ce=R.pos.x,Te=R.pos.y;if((le&&this.facing!==`left`||_e&&this.facing!==`right`)&&this.turn(le?`left`:`right`),le?Ce=X.x+this.X_EDGE_BUFFER+this.xOffset.value:_e&&(Ce=X.x-this.X_EDGE_BUFFER+this.xOffset.value),(ye||be)&&(Te=ye?X.y+this.Y_EDGE_BUFFER:X.y-this.Y_EDGE_BUFFER),this.isFirstUpdate)return this.isFirstUpdate=!1,vec(Ce,Te);if(le||_e){let e=Ce-R.pos.x,W=Te-R.pos.y;Math.abs(e)>.1&&(Ce-=e*this.FOLLOW_DAMPING),Math.abs(W)>.1&&(Te-=W*this.FOLLOW_DAMPING)}return vec(Ce,Te)}turn(e,R=!1){this.facing=e,e===`left`?this.xOffset.set(-this.X_EDGE_BUFFER*4,R):this.xOffset.set(this.X_EDGE_BUFFER*4,R)}static __type=[`FOLLOW_DAMPING`,function(){return .5},`TURN_TWEEN_DURATION`,function(){return 400},`X_EDGE_BUFFER`,function(){return 20},`Y_EDGE_BUFFER`,function(){return 40},`Player`,`target`,()=>Tween,`xOffset`,`left`,`right`,`facing`,function(){return`right`},`isFirstUpdate`,function(){return!0},`constructor`,`camera`,`_engine`,`_elapsed`,`action`,`left`,`right`,`direction`,`immediately`,`turn`,`LockToPlayerStrategy`,`'3!>"'3#>$'3%>&'3'>("w)3*P7+3,P.-..J3/>0)31;>2P"w)2*"03P"w)2*!24!25'26"07PP.8.9J2:"2;"0<5"x"w=`]},DamageComponent=class extends Component{amount;cancelContactOnDamage;constructor({amount:e,cancelContactOnDamage:R}){super(),this.amount=e,this.cancelContactOnDamage=R??!0}onAdd(e){e.on(`precollision`,this.onPreCollisionResolve.bind(this))}onPreCollisionResolve(e){let R=this.owner.get(KillableComponent),W=this.owner.get(StompableComponent),Y=R?.dead??!1,X=e.other.owner,ie=X.get(Nb),ae=X instanceof PhysicsActor&&W?.isBeingStomped(X);ie&&(this.cancelContactOnDamage&&e.contact.cancel(),!Y&&!ae&&ie.damage(this.amount,X.center.x<this.owner.center.x?`left`:`right`))}static __type=[()=>Component,`owner`,`amount`,`cancelContactOnDamage`,`param0`,`constructor`,`onAdd`,`event`,`onPreCollisionResolve`,`DamageComponent`,`P7!!3"'3#)3$PP'4#)4$8M2%"0&P!2"$0'P!2("0)5w*`]};const Vb=[`stompDuration`,`EnemyActorArgs`,`P!P'4!8MKw"y`];var Hb=class EnemyActor extends PhysicsActor{killable;stompable;constructor({stompDuration:e,...R}){super({collisionType:xf.Active,collisionGroup:mb.Enemy,...R}),this.killable=new KillableComponent({stompDuration:e}),this.stompable=new StompableComponent,this.addComponent(new DamageComponent({amount:1})),this.addComponent(this.stompable),this.addComponent(this.killable),this.killable.events.on(`kill`,this.onKill.bind(this))}get dead(){return this.killable.dead}set dead(e){this.killable.dead=e}onPreCollisionResolve(e,R,W,Y){R.owner instanceof EnemyActor&&Y.cancel()}onKill(){}static __type=[()=>PhysicsActor,()=>KillableComponent,`killable`,()=>StompableComponent,`stompable`,()=>Vb,`param0`,`constructor`,`self`,`other`,`side`,`contact`,`onPreCollisionResolve`,`onKill`,`EnemyActor`,`P7!P7"3#<P7$3%<Pn&2'"0(!P!2)!2*!2+!2,$0-P"0.5w/`]};const Ub={rows:1,columns:3,spriteWidth:64,spriteHeight:48},Wb={green:{speed:20,spritesheet:Sp.fromImageSource({image:db.img.spiderGreen,grid:Ub})},gray:{speed:30,spritesheet:Sp.fromImageSource({image:db.img.spiderGray,grid:Ub})}},Gb=[()=>Wb,`type`,`SpiderEnemyArgs`,`P!Pi!g4"MKw#y`];var SpiderEnemy=class extends Hb{spritesheet;speed;direction=`left`;constructor(e){super({...e,anchor:vec(.5,32/48),collider:tp.Box(24,4,vec(.5,1))}),this.spritesheet=Wb[e.type].spritesheet,this.speed=Wb[e.type].speed,this.graphics.use(op.fromSpriteSheet(this.spritesheet,[0,1,2],2500/this.speed))}onPreUpdate(e,R){if(this.dead)return;let W=this.raycast(new Ray(vec(this.collider.bounds.left+1,Math.round(this.collider.bounds.bottom)-1),sf.Down),1),Y=this.raycast(new Ray(vec(this.collider.bounds.right-1,Math.round(this.collider.bounds.bottom)-1),sf.Down),1),X=this.direction===`left`&&W.length===0,ie=this.direction===`right`&&Y.length===0;(X||ie)&&(this.direction=this.direction===`left`?`right`:`left`),this.graphics.flipHorizontal=this.direction===`right`,this.direction===`left`?this.vel.x=-this.speed:this.vel.x=this.speed}onCollisionStart(e,R,W,Y){R.owner instanceof Bb||R.owner instanceof $p&&R.owner.body.collisionType===xf.Passive||(W===Mf.Left||W===Mf.Right)&&(this.direction=this.direction===`left`?`right`:`left`)}onKill(){this.graphics.current.pause(),this.vel.x=0,this.vel.y=0,this.body.useGravity=!1}static __type=[()=>Hb,`spritesheet`,`speed`,`left`,`right`,`direction`,function(){return`left`},()=>Gb,`args`,`constructor`,`_engine`,`_elapsed`,`onPreUpdate`,`self`,`other`,`side`,`_contact`,`onCollisionStart`,`onKill`,`SpiderEnemy`,`P7!!3"'3#P.$.%J3&>'Pn(2)"0*P!2+'2,$0-P!2.!2/!20!21$02P"035w4`]};function __assignType$7(e,R){return e.__type=R,e}__name$1(__assignType$7,`__assignType`);const Kb=db.img.platform.toSprite(),qb=new mp({image:Kb.image,destSize:{height:16,width:16},sourceView:{x:0,y:0,width:16,height:16}}),Jb=new mp({image:Kb.image,destSize:{height:16,width:16},sourceView:{x:32,y:0,width:16,height:16}}),Yb=new mp({image:Kb.image,destSize:{height:16,width:16},sourceView:{x:16,y:0,width:16,height:16}}),Xb=[`oneWay`,`MovingPlatformArgs`,`P!P)4!8MKw"y`];var MovingPlatform=class extends $p{constructor({oneWay:e=!0,...R},W){super({color:gf.Green,anchor:vec(0,0),collisionType:xf.Fixed,collisionGroup:mb.Ground,...R});let Y=this.width-32;this.graphics.use(new sp({members:[{graphic:qb,offset:vec(0,0)},...Array.from({length:Y/16},__assignType$7((e,R)=>({graphic:Yb,offset:vec(16+R*16,0)}),[`_`,`i`,``,`P"2!"2""/#`])),{graphic:Jb,offset:vec(this.width-16,0)}]})),W(this.actions),this.addComponent(new CarrierComponent),e&&this.addComponent(new OneWayCollisionComponent)}static __type=[()=>$p,()=>Xb,`param0`,`actions`,``,`cb`,`constructor`,`MovingPlatform`,`P7!Pn"2#P!2$#/%2&"0'5w(`]};const Zb=[`x`,`y`,`pos`,`EnemyActor`,``,`spawn`,`EnemySpawnerArgs`,`P'4!'4"P!2#"w$/%4&Mw'y`];var EnemySpawner=class extends $p{OFFSCREEN_BUFFER=100;spawnedInstance=null;canSpawn=!0;spawn;constructor({x:e,y:R,spawn:W}){super({x:e,y:R}),this.spawn=W,this.on(`enterviewport`,()=>{this.spawnInstance()})}spawnInstance(){this.spawnedInstance||!this.canSpawn||(this.canSpawn=!1,this.spawnedInstance=this.spawn(this.pos),this.spawnedInstance.on(`kill`,()=>{this.spawnedInstance=null}),this.scene.engine.add(this.spawnedInstance))}onPreUpdate(e,R){let W=e.currentScene.camera.viewport,Y=this.OFFSCREEN_BUFFER,X=W.left-Y,ie=W.top-Y,ae=W.right+Y,le=W.bottom+Y,{x:_e,y:ye}=this.pos;if(_e<X||_e>ae||ye<ie||ye>le?this.spawnedInstance||(this.canSpawn=!0):this.spawnInstance(),this.spawnedInstance){let e=this.spawnedInstance.getGlobalPos();(e.x<X||e.x>ae||e.y<ie||e.y>le)&&(this.spawnedInstance.kill(),this.spawnedInstance=null)}}static __type=[()=>$p,`OFFSCREEN_BUFFER`,function(){return 100},`EnemyActor`,`spawnedInstance`,function(){return null},`canSpawn`,function(){return!0},`pos`,``,`spawn`,()=>Zb,`param0`,`constructor`,`spawnInstance`,`engine`,`_elapsed`,`onPreUpdate`,`EnemySpawner`,`P7!'3">#P"w$,J3%;>&)3';>(P!2)"w$/*3+Pn,2-"0.P"0/P!20'21$025w3`]};const Qb={rows:1,columns:3,spriteWidth:48,spriteHeight:48},$b={purple:{speed:20,distance:60,spritesheet:Sp.fromImageSource({image:db.img.birdPurple,grid:Qb})},orange:{speed:30,distance:100,spritesheet:Sp.fromImageSource({image:db.img.birdOrange,grid:Qb})}},ex=[()=>$b,`type`,`BirdEnemyArgs`,`P!Pi!g4"MKw#y`];var BirdEnemy=class extends Hb{spritesheet;speed;distance;direction=`left`;elapsedMs=0;deathPosition=null;initialPos;constructor(e){super({...e,stompDuration:1500,anchor:vec(.5,.6),collider:tp.Box(16,5,vec(.5,1)),collisionType:xf.Passive}),this.spritesheet=$b[e.type].spritesheet,this.speed=$b[e.type].speed,this.distance=$b[e.type].distance,this.body.useGravity=!1,this.graphics.use(op.fromSpriteSheet(this.spritesheet,[0,1,2],3e3/this.speed)),this.initialPos=this.pos.clone(),this.canBeCarried=!1}onPreUpdate(e,R){this.elapsedMs+=R,this.dead&&this.deathPosition?(this.vel.y=10,this.pos.x+=Math.sin((this.pos.y-this.deathPosition.y)/2),this.rotation=-Math.sin((this.pos.x-this.deathPosition.x)/50)):(this.graphics.flipHorizontal=this.direction===`right`,this.direction===`left`?this.vel.x=-this.speed:this.vel.x=this.speed,this.pos.y+=Math.sin(this.elapsedMs/(this.speed*10)*Math.PI)*.3),this.pos.x<this.initialPos.x-this.distance?this.direction=`right`:this.pos.x>this.initialPos.x&&(this.direction=`left`)}onKill(){this.deathPosition=this.pos.clone(),this.graphics.current.pause(),this.vel.x=0,this.vel.y=0,this.body.useGravity=!1}static __type=[()=>Hb,`spritesheet`,`speed`,`distance`,`left`,`right`,`direction`,function(){return`left`},`elapsedMs`,function(){return 0},`deathPosition`,function(){return null},`initialPos`,()=>ex,`args`,`constructor`,`engine`,`elapsed`,`onPreUpdate`,`onKill`,`BirdEnemy`,`P7!!3"'3#'3$P.%.&J3'>('3);>*P!,J3+;>,!3-;Pn.2/"00P!21'22$03P"045w5`]},AxeHazard=class extends $p{elapsedMs=0;constructor(e){super({...e,anchor:vec(.5,0),width:12,height:48,rotation:0,collisionType:xf.Passive,collisionGroup:mb.Enemy,collider:tp.Box(28,12,vec(.5,.5),vec(0,42))}),this.body.useGravity=!1,this.graphics.offset=vec(0,-8),this.graphics.use(db.img.axe.toSprite()),this.addComponent(new DamageComponent({amount:1}))}onPreUpdate(e,R){this.elapsedMs+=R;let W=Math.PI/2,Y=this.elapsedMs/1e3;this.rotation=W*Math.cos(Math.sqrt(wb.y/600)*Y)}static __type=[()=>$p,`elapsedMs`,function(){return 0},`args`,`constructor`,`_engine`,`elapsed`,`onPreUpdate`,`AxeHazard`,`P7!'3";>#P!2$"0%P!2&'2'"0(5w)`]};function __assignType$6(e,R){return e.__type=R,e}__name$1(__assignType$6,`__assignType`);var CircularSawHazard=class extends PhysicsActor{direction=1;speed=25;bladeSize={width:24,height:12};lastGroundHit=null;constructor(e){super({...e,name:`circular-saw`,anchor:vec(.5,.5),width:4,height:4,collisionType:xf.Passive,collisionGroup:mb.Enemy}),this.pos.x+=this.width*this.anchor.x,this.pos.y-=this.height*this.anchor.y,this.body.useGravity=!1,this.graphics.use(db.img.circularSaw.toSprite()),this.graphics.offset=vec(0,2);let R=new $p({pos:vec(0,0),anchor:vec(.5,1),width:this.bladeSize.width,height:this.bladeSize.height,collisionType:xf.Passive,collisionGroup:mb.Enemy});R.addComponent(new DamageComponent({amount:1})),this.addChild(R),this.addComponent(new CarriableComponent)}onInitialize(e){this.graphics.material=new RenderTopHalfMaterial(e.graphicsContext,this)}onPreUpdate(e,R){let W=this.direction===1?this.collider.bounds.right+this.bladeSize.width/2:this.collider.bounds.left-this.bladeSize.width/2,Y=this.collider.bounds.bottom-1,[X]=this.raycast(new Ray(vec(W,Y),sf.Down),1,{collisionGroup:mb.Ground}),[ie]=this.raycast(new Ray(vec(W,Y),this.direction===1?sf.Right:sf.Left),1,{collisionGroup:mb.Ground});(!X&&this.lastGroundHit||ie)&&(this.direction*=-1);let ae=this.graphics.current;ae.rotation=(ae.rotation+toRadians(this.speed*5/R))%(Math.PI*2),this.vel.x=this.speed*this.direction,X&&(this.lastGroundHit=X)}static __type=[()=>PhysicsActor,`direction`,function(){return 1},`speed`,function(){return 25},`bladeSize`,function(){return{width:24,height:12}},`lastGroundHit`,function(){return null},`args`,`constructor`,`engine`,`onInitialize`,`_engine`,`elapsed`,`onPreUpdate`,`CircularSawHazard`,`P7!'3">#'3$>%!3&>'P!,J3(>)P!2*"0+P!2,$0-P!2.'2/"005w1`]},RenderTopHalfMaterial=class extends Up{constructor(e,R){super({name:`render-top-half-material`,fragmentSource:`#version 300 es
|
|
1106
1106
|
precision mediump float;
|
|
1107
1107
|
|
|
1108
1108
|
uniform sampler2D u_graphic;
|