hytopia 0.10.15 → 0.10.16

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/server.mjs CHANGED
@@ -396,7 +396,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
396
396
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
397
397
  if (condition) { yield value; }`)};import{Buffer as dH1}from"node:buffer";import{StringDecoder as aH1}from"node:string_decoder";var zF=(Z,J,X)=>{if(X)return;if(Z)return{transform:nH1.bind(void 0,new TextEncoder)};let $=new aH1(J);return{transform:sH1.bind(void 0,$),final:oH1.bind(void 0,$)}},nH1=function*(Z,J){if(dH1.isBuffer(J))yield s7(J);else if(typeof J==="string")yield Z.encode(J);else yield J},sH1=function*(Z,J){yield _8(J)?Z.write(J):J},oH1=function*(Z){let J=Z.end();if(J!=="")yield J};import{callbackify as hy}from"node:util";var YM=hy(async(Z,J,X,$)=>{J.currentIterable=Z(...X);try{for await(let Y of J.currentIterable)$.push(Y)}finally{delete J.currentIterable}}),vF=async function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:$=tH1}=J[X];for await(let Y of $(Z))yield*vF(Y,J,X+1)},Sy=async function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*rH1(X,Number(J),Z)},rH1=async function*(Z,J,X){if(Z===void 0)return;for await(let $ of Z())yield*vF($,X,J+1)},Ay=hy(async({currentIterable:Z},J)=>{if(Z!==void 0){await(J?Z.throw(J):Z.return());return}if(J)throw J}),tH1=function*(Z){yield Z};var QM=(Z,J,X,$)=>{try{for(let Y of Z(...J))X.push(Y);$()}catch(Y){$(Y)}},my=(Z,J)=>[...J.flatMap((X)=>[...R$(X,Z,0)]),...tW(Z)],R$=function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:$=Zq1}=J[X];for(let Y of $(Z))yield*R$(Y,J,X+1)},tW=function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*eH1(X,Number(J),Z)},eH1=function*(Z,J,X){if(Z===void 0)return;for(let $ of Z())yield*R$($,X,J+1)},Zq1=function*(Z){yield Z};var KM=({value:Z,value:{transform:J,final:X,writableObjectMode:$,readableObjectMode:Y},optionName:Q},{encoding:K})=>{let W={},G=ly(Z,K,Q),z=M$(J),v=M$(X),H=z?YM.bind(void 0,vF,W):QM.bind(void 0,R$),V=z||v?YM.bind(void 0,Sy,W):QM.bind(void 0,tW),q=z||v?Ay.bind(void 0,W):void 0;return{stream:new Jq1({writableObjectMode:$,writableHighWaterMark:uy($),readableObjectMode:Y,readableHighWaterMark:uy(Y),transform(x,c,w){H([x,G,0],this,w)},flush(x){V([G],this,x)},destroy:q})}},VF=(Z,J,X,$)=>{let Y=J.filter(({type:K})=>K==="generator"),Q=$?Y.reverse():Y;for(let{value:K,optionName:W}of Q){let G=ly(K,X,W);Z=my(G,Z)}return Z},ly=({transform:Z,final:J,binary:X,writableObjectMode:$,readableObjectMode:Y,preserveNewlines:Q},K,W)=>{let G={};return[{transform:Iy($,W)},zF(X,K,$),GF(X,Q,$,G),{transform:Z,final:J},{transform:_y(Y,W)},Ey({binary:X,preserveNewlines:Q,readableObjectMode:Y,state:G})].filter(Boolean)};var yy=(Z,J)=>{for(let X of Xq1(Z))$q1(Z,X,J)},Xq1=(Z)=>new Set(Object.entries(Z).filter(([,{direction:J}])=>J==="input").map(([J])=>Number(J))),$q1=(Z,J,X)=>{let{stdioItems:$}=Z[J],Y=$.filter(({contents:W})=>W!==void 0);if(Y.length===0)return;if(J!==0){let[{type:W,optionName:G}]=Y;throw new TypeError(`Only the \`stdin\` option, not \`${G}\`, can be ${fJ[W]} with synchronous methods.`)}let K=Y.map(({contents:W})=>W).map((W)=>Yq1(W,$));X.input=iW(K)},Yq1=(Z,J)=>{let X=VF(Z,J,"utf8",!0);return Qq1(X),iW(X)},Qq1=(Z)=>{let J=Z.find((X)=>typeof X!=="string"&&!_8(X));if(J!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${J}.`)};import{writeFileSync as zq1,appendFileSync as vq1}from"node:fs";var HF=({stdioItems:Z,encoding:J,verboseInfo:X,fdNumber:$})=>$!=="all"&&lQ(X,$)&&!f5.has(J)&&Kq1($)&&(Z.some(({type:Y,value:Q})=>Y==="native"&&Wq1.has(Q))||Z.every(({type:Y})=>v4.has(Y))),Kq1=(Z)=>Z===1||Z===2,Wq1=new Set(["pipe","overlapped"]),py=async(Z,J,X,$)=>{for await(let Y of Z)if(!Gq1(J))gy(Y,X,$)},iy=(Z,J,X)=>{for(let $ of Z)gy($,J,X)},Gq1=(Z)=>Z._readableState.pipes.length>0,gy=(Z,J,X)=>{let $=Mq(Z);r9({type:"output",verboseMessage:$,fdNumber:J,verboseInfo:X})};var dy=({fileDescriptors:Z,syncResult:{output:J},options:X,isMaxBuffer:$,verboseInfo:Y})=>{if(J===null)return{output:Array.from({length:3})};let Q={},K=new Set([]);return{output:J.map((G,z)=>Vq1({result:G,fileDescriptors:Z,fdNumber:z,state:Q,outputFiles:K,isMaxBuffer:$,verboseInfo:Y},X)),...Q}},Vq1=({result:Z,fileDescriptors:J,fdNumber:X,state:$,outputFiles:Y,isMaxBuffer:Q,verboseInfo:K},{buffer:W,encoding:G,lines:z,stripFinalNewline:v,maxBuffer:H})=>{if(Z===null)return;let V=al(Z,Q,H),q=s7(V),{stdioItems:F,objectMode:x}=J[X],c=Hq1([q],F,G,$),{serializedResult:w,finalResult:B=w}=qq1({chunks:c,objectMode:x,encoding:G,lines:z,stripFinalNewline:v,fdNumber:X});Fq1({serializedResult:w,fdNumber:X,state:$,verboseInfo:K,encoding:G,stdioItems:F,objectMode:x});let j=W[X]?B:void 0;try{if($.error===void 0)xq1(w,F,Y);return j}catch(L){return $.error=L,j}},Hq1=(Z,J,X,$)=>{try{return VF(Z,J,X,!1)}catch(Y){return $.error=Y,Z}},qq1=({chunks:Z,objectMode:J,encoding:X,lines:$,stripFinalNewline:Y,fdNumber:Q})=>{if(J)return{serializedResult:Z};if(X==="buffer")return{serializedResult:iW(Z)};let K=Wm(Z,X);if($[Q])return{serializedResult:K,finalResult:$M(K,!Y[Q],J)};return{serializedResult:K}},Fq1=({serializedResult:Z,fdNumber:J,state:X,verboseInfo:$,encoding:Y,stdioItems:Q,objectMode:K})=>{if(!HF({stdioItems:Q,encoding:Y,verboseInfo:$,fdNumber:J}))return;let W=$M(Z,!1,K);try{iy(W,J,$)}catch(G){X.error??=G}},xq1=(Z,J,X)=>{for(let{path:$,append:Y}of J.filter(({type:Q})=>KF.has(Q))){let Q=typeof $==="string"?$:$.toString();if(Y||X.has(Q))vq1($,Z);else X.add(Q),zq1($,Z)}};var ay=([,Z,J],X)=>{if(!X.all)return;if(Z===void 0)return J;if(J===void 0)return Z;if(Array.isArray(Z))return Array.isArray(J)?[...Z,...J]:[...Z,e7(J,X,"all")];if(Array.isArray(J))return[e7(Z,X,"all"),...J];if(_8(Z)&&_8(J))return HD([Z,J]);return`${Z}${J}`};import{once as WM}from"node:events";var ny=async(Z,J)=>{let[X,$]=await cq1(Z);return J.isForcefullyTerminated??=!1,[X,$]},cq1=async(Z)=>{let[J,X]=await Promise.allSettled([WM(Z,"spawn"),WM(Z,"exit")]);if(J.status==="rejected")return[];return X.status==="rejected"?sy(Z):X.value},sy=async(Z)=>{try{return await WM(Z,"exit")}catch{return sy(Z)}},oy=async(Z)=>{let[J,X]=await Z;if(!wq1(J,X)&&GM(J,X))throw new t9;return[J,X]},wq1=(Z,J)=>Z===void 0&&J===void 0,GM=(Z,J)=>Z!==0||J!==null;var ry=({error:Z,status:J,signal:X,output:$},{maxBuffer:Y})=>{let Q=Uq1(Z,J,X),K=Q?.code==="ETIMEDOUT",W=dl(Q,$,Y);return{resultError:Q,exitCode:J,signal:X,timedOut:K,isMaxBuffer:W}},Uq1=(Z,J,X)=>{if(Z!==void 0)return Z;return GM(J,X)?new t9:void 0};var ty=(Z,J,X)=>{let{file:$,commandArguments:Y,command:Q,escapedCommand:K,startTime:W,verboseInfo:G,options:z,fileDescriptors:v}=jq1(Z,J,X),H=Mq1({file:$,commandArguments:Y,options:z,command:Q,escapedCommand:K,verboseInfo:G,fileDescriptors:v,startTime:W});return oQ(H,G,z)},jq1=(Z,J,X)=>{let{command:$,escapedCommand:Y,startTime:Q,verboseInfo:K}=Nq(Z,J,X),W=Lq1(X),{file:G,commandArguments:z,options:v}=nq(Z,J,W);Dq1(v);let H=Ty(v,K);return{file:G,commandArguments:z,command:$,escapedCommand:Y,startTime:Q,verboseInfo:K,options:v,fileDescriptors:H}},Lq1=(Z)=>Z.node&&!Z.ipc?{...Z,ipc:!1}:Z,Dq1=({ipc:Z,ipcInput:J,detached:X,cancelSignal:$})=>{if(J)qF("ipcInput");if(Z)qF("ipc: true");if(X)qF("detached: true");if($)qF("cancelSignal")},qF=(Z)=>{throw new TypeError(`The "${Z}" option cannot be used with synchronous methods.`)},Mq1=({file:Z,commandArguments:J,options:X,command:$,escapedCommand:Y,verboseInfo:Q,fileDescriptors:K,startTime:W})=>{let G=Rq1({file:Z,commandArguments:J,options:X,command:$,escapedCommand:Y,fileDescriptors:K,startTime:W});if(G.failed)return G;let{resultError:z,exitCode:v,signal:H,timedOut:V,isMaxBuffer:q}=ry(G,X),{output:F,error:x=z}=dy({fileDescriptors:K,syncResult:G,options:X,isMaxBuffer:q,verboseInfo:Q}),c=F.map((B,j)=>e7(B,X,j)),w=e7(ay(F,X),X,"all");return Oq1({error:x,exitCode:v,signal:H,timedOut:V,isMaxBuffer:q,stdio:c,all:w,options:X,command:$,escapedCommand:Y,startTime:W})},Rq1=({file:Z,commandArguments:J,options:X,command:$,escapedCommand:Y,fileDescriptors:Q,startTime:K})=>{try{yy(Q,X);let W=Nq1(X);return Bq1(Z,J,W)}catch(W){return sQ({error:W,command:$,escapedCommand:Y,fileDescriptors:Q,options:X,startTime:K,isSync:!0})}},Nq1=({encoding:Z,maxBuffer:J,...X})=>({...X,encoding:"buffer",maxBuffer:XF(J)}),Oq1=({error:Z,exitCode:J,signal:X,timedOut:$,isMaxBuffer:Y,stdio:Q,all:K,options:W,command:G,escapedCommand:z,startTime:v})=>Z===void 0?$F({command:G,escapedCommand:z,stdio:Q,all:K,ipcOutput:[],options:W,startTime:v}):rW({error:Z,command:G,escapedCommand:z,timedOut:$,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:Y,isForcefullyTerminated:!1,exitCode:J,signal:X,stdio:Q,all:K,ipcOutput:[],options:W,startTime:v,isSync:!0});import{setMaxListeners as qx1}from"node:events";import{spawn as Fx1}from"node:child_process";import $p from"node:process";import{once as zM,on as Pq1}from"node:events";var ey=({anyProcess:Z,channel:J,isSubprocess:X,ipc:$},{reference:Y=!0,filter:Q}={})=>{return iQ({methodName:"getOneMessage",isSubprocess:X,ipc:$,isConnected:yq(Z)}),Tq1({anyProcess:Z,channel:J,isSubprocess:X,filter:Q,reference:Y})},Tq1=async({anyProcess:Z,channel:J,isSubprocess:X,filter:$,reference:Y})=>{Aq(J,Y);let Q=CJ(Z,J,X),K=new AbortController;try{return await Promise.race([Cq1(Q,$,K),fq1(Q,X,K),kq1(Q,X,K)])}catch(W){throw gQ(Z),W}finally{K.abort(),mq(J,Y)}},Cq1=async(Z,J,{signal:X})=>{if(J===void 0){let[$]=await zM(Z,"message",{signal:X});return $}for await(let[$]of Pq1(Z,"message",{signal:X}))if(J($))return $},fq1=async(Z,J,{signal:X})=>{await zM(Z,"disconnect",{signal:X}),Au(J)},kq1=async(Z,J,{signal:X})=>{let[$]=await zM(Z,"strict:error",{signal:X});throw bq($,J)};import{once as Jp,on as Eq1}from"node:events";var Xp=({anyProcess:Z,channel:J,isSubprocess:X,ipc:$},{reference:Y=!0}={})=>vM({anyProcess:Z,channel:J,isSubprocess:X,ipc:$,shouldAwait:!X,reference:Y}),vM=({anyProcess:Z,channel:J,isSubprocess:X,ipc:$,shouldAwait:Y,reference:Q})=>{iQ({methodName:"getEachMessage",isSubprocess:X,ipc:$,isConnected:yq(Z)}),Aq(J,Q);let K=CJ(Z,J,X),W=new AbortController,G={};return Iq1(Z,K,W),_q1({ipcEmitter:K,isSubprocess:X,controller:W,state:G}),bq1({anyProcess:Z,channel:J,ipcEmitter:K,isSubprocess:X,shouldAwait:Y,controller:W,state:G,reference:Q})},Iq1=async(Z,J,X)=>{try{await Jp(J,"disconnect",{signal:X.signal}),X.abort()}catch{}},_q1=async({ipcEmitter:Z,isSubprocess:J,controller:X,state:$})=>{try{let[Y]=await Jp(Z,"strict:error",{signal:X.signal});$.error=bq(Y,J),X.abort()}catch{}},bq1=async function*({anyProcess:Z,channel:J,ipcEmitter:X,isSubprocess:$,shouldAwait:Y,controller:Q,state:K,reference:W}){try{for await(let[G]of Eq1(X,"message",{signal:Q.signal}))Zp(K),yield G}catch{Zp(K)}finally{if(Q.abort(),mq(J,W),!$)gQ(Z);if(Y)await Z}},Zp=({error:Z})=>{if(Z)throw Z};var Yp=(Z,{ipc:J})=>{Object.assign(Z,Kp(Z,!1,J))},Qp=()=>{let Z=$p,J=!0,X=$p.channel!==void 0;return{...Kp(Z,!0,X),getCancelSignal:Vl.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:!0,ipc:X})}},Kp=(Z,J,X)=>({sendMessage:dq.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getOneMessage:ey.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getEachMessage:Xp.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X})});import{ChildProcess as hq1}from"node:child_process";import{PassThrough as Sq1,Readable as Aq1,Writable as mq1,Duplex as uq1}from"node:stream";var Wp=({error:Z,command:J,escapedCommand:X,fileDescriptors:$,options:Y,startTime:Q,verboseInfo:K})=>{ZM($);let W=new hq1;lq1(W,$),Object.assign(W,{readable:yq1,writable:pq1,duplex:iq1});let G=sQ({error:Z,command:J,escapedCommand:X,fileDescriptors:$,options:Y,startTime:Q,isSync:!1}),z=gq1(G,K,Y);return{subprocess:W,promise:z}},lq1=(Z,J)=>{let X=eW(),$=eW(),Y=eW(),Q=Array.from({length:J.length-3},eW),K=eW(),W=[X,$,Y,...Q];Object.assign(Z,{stdin:X,stdout:$,stderr:Y,all:K,stdio:W})},eW=()=>{let Z=new Sq1;return Z.end(),Z},yq1=()=>new Aq1({read(){}}),pq1=()=>new mq1({write(){}}),iq1=()=>new uq1({read(){},write(){}}),gq1=async(Z,J,X)=>oQ(Z,J,X);import{createReadStream as Gp,createWriteStream as zp}from"node:fs";import{Buffer as dq1}from"node:buffer";import{Readable as ZG,Writable as aq1,Duplex as nq1}from"node:stream";var Vp=(Z,J)=>WF(sq1,Z,J,!1),JG=({type:Z,optionName:J})=>{throw new TypeError(`The \`${J}\` option cannot be ${fJ[Z]}.`)},vp={fileNumber:JG,generator:KM,asyncGenerator:KM,nodeStream:({value:Z})=>({stream:Z}),webTransform({value:{transform:Z,writableObjectMode:J,readableObjectMode:X}}){let $=J||X;return{stream:nq1.fromWeb(Z,{objectMode:$})}},duplex:({value:{transform:Z}})=>({stream:Z}),native(){}},sq1={input:{...vp,fileUrl:({value:Z})=>({stream:Gp(Z)}),filePath:({value:{file:Z}})=>({stream:Gp(Z)}),webStream:({value:Z})=>({stream:ZG.fromWeb(Z)}),iterable:({value:Z})=>({stream:ZG.from(Z)}),asyncIterable:({value:Z})=>({stream:ZG.from(Z)}),string:({value:Z})=>({stream:ZG.from(Z)}),uint8Array:({value:Z})=>({stream:ZG.from(dq1.from(Z))})},output:{...vp,fileUrl:({value:Z})=>({stream:zp(Z)}),filePath:({value:{file:Z,append:J}})=>({stream:zp(Z,J?{flags:"a"}:{})}),webStream:({value:Z})=>({stream:aq1.fromWeb(Z)}),iterable:JG,asyncIterable:JG,string:JG,uint8Array:JG}};import{on as oq1,once as Hp}from"node:events";import{PassThrough as rq1,getDefaultHighWaterMark as tq1}from"node:stream";import{finished as xp}from"node:stream/promises";function N$(Z){if(!Array.isArray(Z))throw new TypeError(`Expected an array, got \`${typeof Z}\`.`);for(let Y of Z)VM(Y);let J=Z.some(({readableObjectMode:Y})=>Y),X=eq1(Z,J),$=new cp({objectMode:J,writableHighWaterMark:X,readableHighWaterMark:X});for(let Y of Z)$.add(Y);return $}var eq1=(Z,J)=>{if(Z.length===0)return tq1(J);let X=Z.filter(({readableObjectMode:$})=>$===J).map(({readableHighWaterMark:$})=>$);return Math.max(...X)};class cp extends rq1{#Z=new Set([]);#J=new Set([]);#$=new Set([]);#X;#Y=Symbol("unpipe");#v=new WeakMap;add(Z){if(VM(Z),this.#Z.has(Z))return;this.#Z.add(Z),this.#X??=ZF1(this,this.#Z,this.#Y);let J=$F1({passThroughStream:this,stream:Z,streams:this.#Z,ended:this.#J,aborted:this.#$,onFinished:this.#X,unpipeEvent:this.#Y});this.#v.set(Z,J),Z.pipe(this,{end:!1})}async remove(Z){if(VM(Z),!this.#Z.has(Z))return!1;let J=this.#v.get(Z);if(J===void 0)return!1;return this.#v.delete(Z),Z.unpipe(this),await J,!0}}var ZF1=async(Z,J,X)=>{FF(Z,qp);let $=new AbortController;try{await Promise.race([JF1(Z,$),XF1(Z,J,X,$)])}finally{$.abort(),FF(Z,-qp)}},JF1=async(Z,{signal:J})=>{try{await xp(Z,{signal:J,cleanup:!0})}catch(X){throw wp(Z,X),X}},XF1=async(Z,J,X,{signal:$})=>{for await(let[Y]of oq1(Z,"unpipe",{signal:$}))if(J.has(Y))Y.emit(X)},VM=(Z)=>{if(typeof Z?.pipe!=="function")throw new TypeError(`Expected a readable stream, got: \`${typeof Z}\`.`)},$F1=async({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,onFinished:Q,unpipeEvent:K})=>{FF(Z,Fp);let W=new AbortController;try{await Promise.race([YF1(Q,J,W),QF1({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,controller:W}),KF1({stream:J,streams:X,ended:$,aborted:Y,unpipeEvent:K,controller:W})])}finally{W.abort(),FF(Z,-Fp)}if(X.size>0&&X.size===$.size+Y.size)if($.size===0&&Y.size>0)HM(Z);else WF1(Z)},YF1=async(Z,J,{signal:X})=>{try{if(await Z,!X.aborted)HM(J)}catch($){if(!X.aborted)wp(J,$)}},QF1=async({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,controller:{signal:Q}})=>{try{if(await xp(J,{signal:Q,cleanup:!0,readable:!0,writable:!1}),X.has(J))$.add(J)}catch(K){if(Q.aborted||!X.has(J))return;if(Up(K))Y.add(J);else Bp(Z,K)}},KF1=async({stream:Z,streams:J,ended:X,aborted:$,unpipeEvent:Y,controller:{signal:Q}})=>{if(await Hp(Z,Y,{signal:Q}),!Z.readable)return Hp(Q,"abort",{signal:Q});J.delete(Z),X.delete(Z),$.delete(Z)},WF1=(Z)=>{if(Z.writable)Z.end()},wp=(Z,J)=>{if(Up(J))HM(Z);else Bp(Z,J)},Up=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",HM=(Z)=>{if(Z.readable||Z.writable)Z.destroy()},Bp=(Z,J)=>{if(!Z.destroyed)Z.once("error",GF1),Z.destroy(J)},GF1=()=>{},FF=(Z,J)=>{let X=Z.getMaxListeners();if(X!==0&&X!==Number.POSITIVE_INFINITY)Z.setMaxListeners(X+J)},qp=2,Fp=1;import{finished as jp}from"node:stream/promises";var tQ=(Z,J)=>{Z.pipe(J),zF1(Z,J),vF1(Z,J)},zF1=async(Z,J)=>{if(V9(Z)||V9(J))return;try{await jp(Z,{cleanup:!0,readable:!0,writable:!1})}catch{}qM(J)},qM=(Z)=>{if(Z.writable)Z.end()},vF1=async(Z,J)=>{if(V9(Z)||V9(J))return;try{await jp(J,{cleanup:!0,readable:!1,writable:!0})}catch{}FM(Z)},FM=(Z)=>{if(Z.readable)Z.destroy()};var Lp=(Z,J,X)=>{let $=new Map;for(let[Y,{stdioItems:Q,direction:K}]of Object.entries(J)){for(let{stream:W}of Q.filter(({type:G})=>v4.has(G)))VF1(Z,W,K,Y);for(let{stream:W}of Q.filter(({type:G})=>!v4.has(G)))qF1({subprocess:Z,stream:W,direction:K,fdNumber:Y,pipeGroups:$,controller:X})}for(let[Y,Q]of $.entries()){let K=Q.length===1?Q[0]:N$(Q);tQ(K,Y)}},VF1=(Z,J,X,$)=>{if(X==="output")tQ(Z.stdio[$],J);else tQ(J,Z.stdio[$]);let Y=HF1[$];if(Y!==void 0)Z[Y]=J;Z.stdio[$]=J},HF1=["stdin","stdout","stderr"],qF1=({subprocess:Z,stream:J,direction:X,fdNumber:$,pipeGroups:Y,controller:Q})=>{if(J===void 0)return;FF1(J,Q);let[K,W]=X==="output"?[J,Z.stdio[$]]:[Z.stdio[$],J],G=Y.get(K)??[];Y.set(K,[...G,W])},FF1=(Z,{signal:J})=>{if(V9(Z))L$(Z,xF1,J)},xF1=2;import{addAbortListener as UF1}from"node:events";var O$=[];O$.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")O$.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")O$.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var xF=(Z)=>!!Z&&typeof Z==="object"&&typeof Z.removeListener==="function"&&typeof Z.emit==="function"&&typeof Z.reallyExit==="function"&&typeof Z.listeners==="function"&&typeof Z.kill==="function"&&typeof Z.pid==="number"&&typeof Z.on==="function",xM=Symbol.for("signal-exit emitter"),cM=globalThis,cF1=Object.defineProperty.bind(Object);class Dp{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(cM[xM])return cM[xM];cF1(cM,xM,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Z,J){this.listeners[Z].push(J)}removeListener(Z,J){let X=this.listeners[Z],$=X.indexOf(J);if($===-1)return;if($===0&&X.length===1)X.length=0;else X.splice($,1)}emit(Z,J,X){if(this.emitted[Z])return!1;this.emitted[Z]=!0;let $=!1;for(let Y of this.listeners[Z])$=Y(J,X)===!0||$;if(Z==="exit")$=this.emit("afterExit",J,X)||$;return $}}class UM{}var wF1=(Z)=>{return{onExit(J,X){return Z.onExit(J,X)},load(){return Z.load()},unload(){return Z.unload()}}};class Mp extends UM{onExit(){return()=>{}}load(){}unload(){}}class Rp extends UM{#Z=wM.platform==="win32"?"SIGINT":"SIGHUP";#J=new Dp;#$;#X;#Y;#v={};#H=!1;constructor(Z){super();this.#$=Z,this.#v={};for(let J of O$)this.#v[J]=()=>{let X=this.#$.listeners(J),{count:$}=this.#J,Y=Z;if(typeof Y.__signal_exit_emitter__==="object"&&typeof Y.__signal_exit_emitter__.count==="number")$+=Y.__signal_exit_emitter__.count;if(X.length===$){this.unload();let Q=this.#J.emit("exit",null,J),K=J==="SIGHUP"?this.#Z:J;if(!Q)Z.kill(Z.pid,K)}};this.#Y=Z.reallyExit,this.#X=Z.emit}onExit(Z,J){if(!xF(this.#$))return()=>{};if(this.#H===!1)this.load();let X=J?.alwaysLast?"afterExit":"exit";return this.#J.on(X,Z),()=>{if(this.#J.removeListener(X,Z),this.#J.listeners.exit.length===0&&this.#J.listeners.afterExit.length===0)this.unload()}}load(){if(this.#H)return;this.#H=!0,this.#J.count+=1;for(let Z of O$)try{let J=this.#v[Z];if(J)this.#$.on(Z,J)}catch(J){}this.#$.emit=(Z,...J)=>{return this.#G(Z,...J)},this.#$.reallyExit=(Z)=>{return this.#W(Z)}}unload(){if(!this.#H)return;this.#H=!1,O$.forEach((Z)=>{let J=this.#v[Z];if(!J)throw new Error("Listener not defined for signal: "+Z);try{this.#$.removeListener(Z,J)}catch(X){}}),this.#$.emit=this.#X,this.#$.reallyExit=this.#Y,this.#J.count-=1}#W(Z){if(!xF(this.#$))return 0;return this.#$.exitCode=Z||0,this.#J.emit("exit",this.#$.exitCode,null),this.#Y.call(this.#$,this.#$.exitCode)}#G(Z,...J){let X=this.#X;if(Z==="exit"&&xF(this.#$)){if(typeof J[0]==="number")this.#$.exitCode=J[0];let $=X.call(this.#$,Z,...J);return this.#J.emit("exit",this.#$.exitCode,null),$}else return X.call(this.#$,Z,...J)}}var wM=globalThis.process,{onExit:Np,load:_j6,unload:bj6}=wF1(xF(wM)?new Rp(wM):new Mp);var Op=(Z,{cleanup:J,detached:X},{signal:$})=>{if(!J||X)return;let Y=Np(()=>{Z.kill()});UF1($,()=>{Y()})};var Tp=({source:Z,sourcePromise:J,boundOptions:X,createNested:$},...Y)=>{let Q=Rq(),{destination:K,destinationStream:W,destinationError:G,from:z,unpipeSignal:v}=BF1(X,$,Y),{sourceStream:H,sourceError:V}=LF1(Z,z),{options:q,fileDescriptors:F}=Z7.get(Z);return{sourcePromise:J,sourceStream:H,sourceOptions:q,sourceError:V,destination:K,destinationStream:W,destinationError:G,unpipeSignal:v,fileDescriptors:F,startTime:Q}},BF1=(Z,J,X)=>{try{let{destination:$,pipeOptions:{from:Y,to:Q,unpipeSignal:K}={}}=jF1(Z,J,...X),W=Sq($,Q);return{destination:$,destinationStream:W,from:Y,unpipeSignal:K}}catch($){return{destinationError:$}}},jF1=(Z,J,X,...$)=>{if(Array.isArray(X))return{destination:J(Pp,Z)(X,...$),pipeOptions:Z};if(typeof X==="string"||X instanceof URL||vD(X)){if(Object.keys(Z).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[Y,Q,K]=Fq(X,...$);return{destination:J(Pp)(Y,Q,K),pipeOptions:K}}if(Z7.has(X)){if(Object.keys(Z).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:X,pipeOptions:$[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${X}`)},Pp=({options:Z})=>({options:{...Z,stdin:"pipe",piped:!0}}),LF1=(Z,J)=>{try{return{sourceStream:dQ(Z,J)}}catch(X){return{sourceError:X}}};var fp=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$,fileDescriptors:Y,sourceOptions:Q,startTime:K})=>{let W=DF1({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$});if(W!==void 0)throw BM({error:W,fileDescriptors:Y,sourceOptions:Q,startTime:K})},DF1=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$})=>{if(J!==void 0&&$!==void 0)return $;if($!==void 0)return FM(Z),$;if(J!==void 0)return qM(X),J},BM=({error:Z,fileDescriptors:J,sourceOptions:X,startTime:$})=>sQ({error:Z,command:Cp,escapedCommand:Cp,fileDescriptors:J,options:X,startTime:$,isSync:!1}),Cp="source.pipe(destination)";var kp=async(Z)=>{let[{status:J,reason:X,value:$=X},{status:Y,reason:Q,value:K=Q}]=await Z;if(!K.pipedFrom.includes($))K.pipedFrom.push($);if(Y==="rejected")throw K;if(J==="rejected")throw $;return K};import{finished as MF1}from"node:stream/promises";var Ep=(Z,J,X)=>{let $=cF.has(J)?NF1(Z,J):RF1(Z,J);return L$(Z,PF1,X.signal),L$(J,TF1,X.signal),OF1(J),$},RF1=(Z,J)=>{let X=N$([Z]);return tQ(X,J),cF.set(J,X),X},NF1=(Z,J)=>{let X=cF.get(J);return X.add(Z),X},OF1=async(Z)=>{try{await MF1(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}cF.delete(Z)},cF=new WeakMap,PF1=2,TF1=1;import{aborted as CF1}from"node:util";var Ip=(Z,J)=>Z===void 0?[]:[fF1(Z,J)],fF1=async(Z,{sourceStream:J,mergedStream:X,fileDescriptors:$,sourceOptions:Y,startTime:Q})=>{await CF1(Z,J),await X.remove(J);let K=new Error("Pipe canceled by `unpipeSignal` option.");throw BM({error:K,fileDescriptors:$,sourceOptions:Y,startTime:Q})};var wF=(Z,...J)=>{if(c8(J[0]))return wF.bind(void 0,{...Z,boundOptions:{...Z.boundOptions,...J[0]}});let{destination:X,...$}=Tp(Z,...J),Y=kF1({...$,destination:X});return Y.pipe=wF.bind(void 0,{...Z,source:X,sourcePromise:Y,boundOptions:{}}),Y},kF1=async({sourcePromise:Z,sourceStream:J,sourceOptions:X,sourceError:$,destination:Y,destinationStream:Q,destinationError:K,unpipeSignal:W,fileDescriptors:G,startTime:z})=>{let v=EF1(Z,Y);fp({sourceStream:J,sourceError:$,destinationStream:Q,destinationError:K,fileDescriptors:G,sourceOptions:X,startTime:z});let H=new AbortController;try{let V=Ep(J,Q,H);return await Promise.race([kp(v),...Ip(W,{sourceStream:J,mergedStream:V,sourceOptions:X,fileDescriptors:G,startTime:z})])}finally{H.abort()}},EF1=(Z,J)=>Promise.allSettled([Z,J]);import{setImmediate as mF1}from"node:timers/promises";import{on as IF1}from"node:events";import{getDefaultHighWaterMark as _F1}from"node:stream";var UF=({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:$,encoding:Y,preserveNewlines:Q})=>{let K=new AbortController;return bF1(J,K),bp({stream:Z,controller:K,binary:X,shouldEncode:!Z.readableObjectMode&&$,encoding:Y,shouldSplit:!Z.readableObjectMode,preserveNewlines:Q})},bF1=async(Z,J)=>{try{await Z}catch{}finally{J.abort()}},jM=({stream:Z,onStreamEnd:J,lines:X,encoding:$,stripFinalNewline:Y,allMixed:Q})=>{let K=new AbortController;hF1(J,K,Z);let W=Z.readableObjectMode&&!Q;return bp({stream:Z,controller:K,binary:$==="buffer",shouldEncode:!W,encoding:$,shouldSplit:!W&&X,preserveNewlines:!Y})},hF1=async(Z,J,X)=>{try{await Z}catch{X.destroy()}finally{J.abort()}},bp=({stream:Z,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K})=>{let W=IF1(Z,"data",{signal:J.signal,highWaterMark:_p,highWatermark:_p});return SF1({onStdoutChunk:W,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K})},LM=_F1(!0),_p=LM,SF1=async function*({onStdoutChunk:Z,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K}){let W=AF1({binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K});try{for await(let[G]of Z)yield*R$(G,W,0)}catch(G){if(!J.signal.aborted)throw G}finally{yield*tW(W)}},AF1=({binary:Z,shouldEncode:J,encoding:X,shouldSplit:$,preserveNewlines:Y})=>[zF(Z,X,!J),GF(Z,Y,!$,{})].filter(Boolean);var hp=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,buffer:Y,maxBuffer:Q,lines:K,allMixed:W,stripFinalNewline:G,verboseInfo:z,streamInfo:v})=>{let H=uF1({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,allMixed:W,verboseInfo:z,streamInfo:v});if(!Y){await Promise.all([lF1(Z),H]);return}let V=JM(G,X),q=jM({stream:Z,onStreamEnd:J,lines:K,encoding:$,stripFinalNewline:V,allMixed:W}),[F]=await Promise.all([yF1({stream:Z,iterable:q,fdNumber:X,encoding:$,maxBuffer:Q,lines:K}),H]);return F},uF1=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,allMixed:Y,verboseInfo:Q,streamInfo:{fileDescriptors:K}})=>{if(!HF({stdioItems:K[X]?.stdioItems,encoding:$,verboseInfo:Q,fdNumber:X}))return;let W=jM({stream:Z,onStreamEnd:J,lines:!0,encoding:$,stripFinalNewline:!0,allMixed:Y});await py(W,Z,X,Q)},lF1=async(Z)=>{if(await mF1(),Z.readableFlowing===null)Z.resume()},yF1=async({stream:Z,stream:{readableObjectMode:J},iterable:X,fdNumber:$,encoding:Y,maxBuffer:Q,lines:K})=>{try{if(J||K)return await tq(X,{maxBuffer:Q});if(Y==="buffer")return new Uint8Array(await eq(X,{maxBuffer:Q}));return await JF(X,{maxBuffer:Q})}catch(W){return Sp(pl({error:W,stream:Z,readableObjectMode:J,lines:K,encoding:Y,fdNumber:$}))}},DM=async(Z)=>{try{return await Z}catch(J){return Sp(J)}},Sp=({bufferedData:Z})=>Qm(Z)?new Uint8Array(Z):Z;import{finished as pF1}from"node:stream/promises";var XG=async(Z,J,X,{isSameDirection:$,stopOnExit:Y=!1}={})=>{let Q=iF1(Z,X),K=new AbortController;try{await Promise.race([...Y?[X.exitPromise]:[],pF1(Z,{cleanup:!0,signal:K.signal})])}catch(W){if(!Q.stdinCleanedUp)aF1(W,J,X,$)}finally{K.abort()}},iF1=(Z,{originalStreams:[J],subprocess:X})=>{let $={stdinCleanedUp:!1};if(Z===J)gF1(Z,X,$);return $},gF1=(Z,J,X)=>{let{_destroy:$}=Z;Z._destroy=(...Y)=>{dF1(J,X),$.call(Z,...Y)}},dF1=({exitCode:Z,signalCode:J},X)=>{if(Z!==null||J!==null)X.stdinCleanedUp=!0},aF1=(Z,J,X,$)=>{if(!nF1(Z,J,X,$))throw Z},nF1=(Z,J,X,$=!0)=>{if(X.propagating)return Ap(Z)||BF(Z);return X.propagating=!0,MM(X,J)===$?Ap(Z):BF(Z)},MM=({fileDescriptors:Z},J)=>J!=="all"&&Z[J].direction==="input",BF=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",Ap=(Z)=>Z?.code==="EPIPE";var mp=({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>Z.stdio.map((G,z)=>RM({stream:G,fdNumber:z,encoding:J,buffer:X[z],maxBuffer:$[z],lines:Y[z],allMixed:!1,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})),RM=async({stream:Z,fdNumber:J,encoding:X,buffer:$,maxBuffer:Y,lines:Q,allMixed:K,stripFinalNewline:W,verboseInfo:G,streamInfo:z})=>{if(!Z)return;let v=XG(Z,J,z);if(MM(z,J)){await v;return}let[H]=await Promise.all([hp({stream:Z,onStreamEnd:v,fdNumber:J,encoding:X,buffer:$,maxBuffer:Y,lines:Q,allMixed:K,stripFinalNewline:W,verboseInfo:G,streamInfo:z}),v]);return H};var up=({stdout:Z,stderr:J},{all:X})=>X&&(Z||J)?N$([Z,J].filter(Boolean)):void 0,lp=({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>RM({...sF1(Z,X),fdNumber:"all",encoding:J,maxBuffer:$[1]+$[2],lines:Y[1]||Y[2],allMixed:oF1(Z),stripFinalNewline:Q,verboseInfo:K,streamInfo:W}),sF1=({stdout:Z,stderr:J,all:X},[,$,Y])=>{let Q=$||Y;if(!Q)return{stream:X,buffer:Q};if(!$)return{stream:J,buffer:Q};if(!Y)return{stream:Z,buffer:Q};return{stream:X,buffer:Q}},oF1=({all:Z,stdout:J,stderr:X})=>Z&&J&&X&&J.readableObjectMode!==X.readableObjectMode;import{once as rF1}from"node:events";var yp=(Z)=>lQ(Z,"ipc"),pp=(Z,J)=>{let X=Mq(Z);r9({type:"ipc",verboseMessage:X,fdNumber:"ipc",verboseInfo:J})};var ip=async({subprocess:Z,buffer:J,maxBuffer:X,ipc:$,ipcOutput:Y,verboseInfo:Q})=>{if(!$)return Y;let K=yp(Q),W=o7(J,"ipc"),G=o7(X,"ipc");for await(let z of vM({anyProcess:Z,channel:Z.channel,isSubprocess:!1,ipc:$,shouldAwait:!1,reference:!0})){if(W)il(Z,Y,G),Y.push(z);if(K)pp(z,Q)}return Y},gp=async(Z,J)=>{return await Promise.allSettled([Z]),J};var dp=async({subprocess:Z,options:{encoding:J,buffer:X,maxBuffer:$,lines:Y,timeoutDuration:Q,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,stripFinalNewline:z,ipc:v,ipcInput:H},context:V,verboseInfo:q,fileDescriptors:F,originalStreams:x,onInternalError:c,controller:w})=>{let B=ny(Z,V),j={originalStreams:x,fileDescriptors:F,subprocess:Z,exitPromise:B,propagating:!1},L=mp({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:z,verboseInfo:q,streamInfo:j}),R=lp({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:z,verboseInfo:q,streamInfo:j}),M=[],N=ip({subprocess:Z,buffer:X,maxBuffer:$,ipc:v,ipcOutput:M,verboseInfo:q}),P=tF1(x,Z,j),O=eF1(F,j);try{return await Promise.race([Promise.all([{},oy(B),Promise.all(L),R,N,Ll(Z,H),...P,...O]),c,Zx1(Z,w),...cl(Z,Q,V,w),...Su({subprocess:Z,cancelSignal:K,gracefulCancel:W,context:V,controller:w}),...Fl({subprocess:Z,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,context:V,controller:w})])}catch(_){return V.terminationReason??="other",Promise.all([{error:_},B,Promise.all(L.map((k)=>DM(k))),DM(R),gp(N,M),Promise.allSettled(P),Promise.allSettled(O)])}},tF1=(Z,J,X)=>Z.map(($,Y)=>$===J.stdio[Y]?void 0:XG($,Y,X)),eF1=(Z,J)=>Z.flatMap(({stdioItems:X},$)=>X.filter(({value:Y,stream:Q=Y})=>q9(Q,{checkOpen:!1})&&!V9(Q)).map(({type:Y,value:Q,stream:K=Q})=>XG(K,$,J,{isSameDirection:v4.has(Y),stopOnExit:Y==="native"}))),Zx1=async(Z,{signal:J})=>{let[X]=await rF1(Z,"error",{signal:J});throw X};var ap=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),$G=(Z,J,X)=>{let $=Z[X];if(!$.has(J))$.set(J,[]);let Y=$.get(J),Q=e9();return Y.push(Q),{resolve:Q.resolve.bind(Q),promises:Y}},eQ=async({resolve:Z,promises:J},X)=>{Z();let[$]=await Promise.race([Promise.allSettled([!0,X]),Promise.all([!1,...J])]);return!$};import{Readable as Jx1}from"node:stream";import{callbackify as Xx1}from"node:util";import{finished as np}from"node:stream/promises";var NM=async(Z)=>{if(Z===void 0)return;try{await OM(Z)}catch{}},sp=async(Z)=>{if(Z===void 0)return;try{await PM(Z)}catch{}},OM=async(Z)=>{await np(Z,{cleanup:!0,readable:!1,writable:!0})},PM=async(Z)=>{await np(Z,{cleanup:!0,readable:!0,writable:!1})},jF=async(Z,J)=>{if(await Z,J)throw J},LF=(Z,J,X)=>{if(X&&!BF(X))Z.destroy(X);else if(J)Z.destroy()};var op=({subprocess:Z,concurrentStreams:J,encoding:X},{from:$,binary:Y=!0,preserveNewlines:Q=!0}={})=>{let K=Y||f5.has(X),{subprocessStdout:W,waitReadableDestroy:G}=TM(Z,$,J),{readableEncoding:z,readableObjectMode:v,readableHighWaterMark:H}=CM(W,K),{read:V,onStdoutDataDone:q}=fM({subprocessStdout:W,subprocess:Z,binary:K,encoding:X,preserveNewlines:Q}),F=new Jx1({read:V,destroy:Xx1(EM.bind(void 0,{subprocessStdout:W,subprocess:Z,waitReadableDestroy:G})),highWaterMark:H,objectMode:v,encoding:z});return kM({subprocessStdout:W,onStdoutDataDone:q,readable:F,subprocess:Z}),F},TM=(Z,J,X)=>{let $=dQ(Z,J),Y=$G(X,$,"readableDestroy");return{subprocessStdout:$,waitReadableDestroy:Y}},CM=({readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X},$)=>$?{readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X}:{readableEncoding:Z,readableObjectMode:!0,readableHighWaterMark:LM},fM=({subprocessStdout:Z,subprocess:J,binary:X,encoding:$,preserveNewlines:Y})=>{let Q=e9(),K=UF({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:!X,encoding:$,preserveNewlines:Y});return{read(){$x1(this,K,Q)},onStdoutDataDone:Q}},$x1=async(Z,J,X)=>{try{let{value:$,done:Y}=await J.next();if(Y)X.resolve();else Z.push($)}catch{}},kM=async({subprocessStdout:Z,onStdoutDataDone:J,readable:X,subprocess:$,subprocessStdin:Y})=>{try{if(await PM(Z),await $,await NM(Y),await J,X.readable)X.push(null)}catch(Q){await NM(Y),rp(X,Q)}},EM=async({subprocessStdout:Z,subprocess:J,waitReadableDestroy:X},$)=>{if(await eQ(X,J))rp(Z,$),await jF(J,$)},rp=(Z,J)=>{LF(Z,Z.readable,J)};import{Writable as Yx1}from"node:stream";import{callbackify as tp}from"node:util";var ep=({subprocess:Z,concurrentStreams:J},{to:X}={})=>{let{subprocessStdin:$,waitWritableFinal:Y,waitWritableDestroy:Q}=IM(Z,X,J),K=new Yx1({..._M($,Z,Y),destroy:tp(hM.bind(void 0,{subprocessStdin:$,subprocess:Z,waitWritableFinal:Y,waitWritableDestroy:Q})),highWaterMark:$.writableHighWaterMark,objectMode:$.writableObjectMode});return bM($,K),K},IM=(Z,J,X)=>{let $=Sq(Z,J),Y=$G(X,$,"writableFinal"),Q=$G(X,$,"writableDestroy");return{subprocessStdin:$,waitWritableFinal:Y,waitWritableDestroy:Q}},_M=(Z,J,X)=>({write:Qx1.bind(void 0,Z),final:tp(Kx1.bind(void 0,Z,J,X))}),Qx1=(Z,J,X,$)=>{if(Z.write(J,X))$();else Z.once("drain",$)},Kx1=async(Z,J,X)=>{if(await eQ(X,J)){if(Z.writable)Z.end();await J}},bM=async(Z,J,X)=>{try{if(await OM(Z),J.writable)J.end()}catch($){await sp(X),Zi(J,$)}},hM=async({subprocessStdin:Z,subprocess:J,waitWritableFinal:X,waitWritableDestroy:$},Y)=>{if(await eQ(X,J),await eQ($,J))Zi(Z,Y),await jF(J,Y)},Zi=(Z,J)=>{LF(Z,Z.writable,J)};import{Duplex as Wx1}from"node:stream";import{callbackify as Gx1}from"node:util";var Ji=({subprocess:Z,concurrentStreams:J,encoding:X},{from:$,to:Y,binary:Q=!0,preserveNewlines:K=!0}={})=>{let W=Q||f5.has(X),{subprocessStdout:G,waitReadableDestroy:z}=TM(Z,$,J),{subprocessStdin:v,waitWritableFinal:H,waitWritableDestroy:V}=IM(Z,Y,J),{readableEncoding:q,readableObjectMode:F,readableHighWaterMark:x}=CM(G,W),{read:c,onStdoutDataDone:w}=fM({subprocessStdout:G,subprocess:Z,binary:W,encoding:X,preserveNewlines:K}),B=new Wx1({read:c,..._M(v,Z,H),destroy:Gx1(zx1.bind(void 0,{subprocessStdout:G,subprocessStdin:v,subprocess:Z,waitReadableDestroy:z,waitWritableFinal:H,waitWritableDestroy:V})),readableHighWaterMark:x,writableHighWaterMark:v.writableHighWaterMark,readableObjectMode:F,writableObjectMode:v.writableObjectMode,encoding:q});return kM({subprocessStdout:G,onStdoutDataDone:w,readable:B,subprocess:Z,subprocessStdin:v}),bM(v,B,G),B},zx1=async({subprocessStdout:Z,subprocessStdin:J,subprocess:X,waitReadableDestroy:$,waitWritableFinal:Y,waitWritableDestroy:Q},K)=>{await Promise.all([EM({subprocessStdout:Z,subprocess:X,waitReadableDestroy:$},K),hM({subprocessStdin:J,subprocess:X,waitWritableFinal:Y,waitWritableDestroy:Q},K)])};var SM=(Z,J,{from:X,binary:$=!1,preserveNewlines:Y=!1}={})=>{let Q=$||f5.has(J),K=dQ(Z,X),W=UF({subprocessStdout:K,subprocess:Z,binary:Q,shouldEncode:!0,encoding:J,preserveNewlines:Y});return vx1(W,K,Z)},vx1=async function*(Z,J,X){try{yield*Z}finally{if(J.readable)J.destroy();await X}};var Xi=(Z,{encoding:J})=>{let X=ap();Z.readable=op.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.writable=ep.bind(void 0,{subprocess:Z,concurrentStreams:X}),Z.duplex=Ji.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.iterable=SM.bind(void 0,Z,J),Z[Symbol.asyncIterator]=SM.bind(void 0,Z,J,{})};var $i=(Z,J)=>{for(let[X,$]of Hx1){let Y=$.value.bind(J);Reflect.defineProperty(Z,X,{...$,value:Y})}},Vx1=(async()=>{})().constructor.prototype,Hx1=["then","catch","finally"].map((Z)=>[Z,Reflect.getOwnPropertyDescriptor(Vx1,Z)]);var Yi=(Z,J,X,$)=>{let{file:Y,commandArguments:Q,command:K,escapedCommand:W,startTime:G,verboseInfo:z,options:v,fileDescriptors:H}=xx1(Z,J,X),{subprocess:V,promise:q}=wx1({file:Y,commandArguments:Q,options:v,startTime:G,verboseInfo:z,command:K,escapedCommand:W,fileDescriptors:H});return V.pipe=wF.bind(void 0,{source:V,sourcePromise:q,boundOptions:{},createNested:$}),$i(V,q),Z7.set(V,{options:v,fileDescriptors:H}),V},xx1=(Z,J,X)=>{let{command:$,escapedCommand:Y,startTime:Q,verboseInfo:K}=Nq(Z,J,X),{file:W,commandArguments:G,options:z}=nq(Z,J,X),v=cx1(z),H=Vp(v,K);return{file:W,commandArguments:G,command:$,escapedCommand:Y,startTime:Q,verboseInfo:K,options:v,fileDescriptors:H}},cx1=({timeout:Z,signal:J,...X})=>{if(J!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...X,timeoutDuration:Z}},wx1=({file:Z,commandArguments:J,options:X,startTime:$,verboseInfo:Y,command:Q,escapedCommand:K,fileDescriptors:W})=>{let G;try{G=Fx1(Z,J,X)}catch(F){return Wp({error:F,command:Q,escapedCommand:K,fileDescriptors:W,options:X,startTime:$,verboseInfo:Y})}let z=new AbortController;qx1(Number.POSITIVE_INFINITY,z.signal);let v=[...G.stdio];Lp(G,W,z),Op(G,X,z);let H={},V=e9();G.kill=bu.bind(void 0,{kill:G.kill.bind(G),options:X,onInternalError:V,context:H,controller:z}),G.all=up(G,X),Xi(G,X),Yp(G,X);let q=Ux1({subprocess:G,options:X,startTime:$,verboseInfo:Y,fileDescriptors:W,originalStreams:v,command:Q,escapedCommand:K,context:H,onInternalError:V,controller:z});return{subprocess:G,promise:q}},Ux1=async({subprocess:Z,options:J,startTime:X,verboseInfo:$,fileDescriptors:Y,originalStreams:Q,command:K,escapedCommand:W,context:G,onInternalError:z,controller:v})=>{let[H,[V,q],F,x,c]=await dp({subprocess:Z,options:J,context:G,verboseInfo:$,fileDescriptors:Y,originalStreams:Q,onInternalError:z,controller:v});v.abort(),z.resolve();let w=F.map((L,R)=>e7(L,J,R)),B=e7(x,J,"all"),j=Bx1({errorInfo:H,exitCode:V,signal:q,stdio:w,all:B,ipcOutput:c,context:G,options:J,command:K,escapedCommand:W,startTime:X});return oQ(j,$,J)},Bx1=({errorInfo:Z,exitCode:J,signal:X,stdio:$,all:Y,ipcOutput:Q,context:K,options:W,command:G,escapedCommand:z,startTime:v})=>("error"in Z)?rW({error:Z.error,command:G,escapedCommand:z,timedOut:K.terminationReason==="timeout",isCanceled:K.terminationReason==="cancel"||K.terminationReason==="gracefulCancel",isGracefullyCanceled:K.terminationReason==="gracefulCancel",isMaxBuffer:Z.error instanceof r7,isForcefullyTerminated:K.isForcefullyTerminated,exitCode:J,signal:X,stdio:$,all:Y,ipcOutput:Q,options:W,startTime:v,isSync:!1}):$F({command:G,escapedCommand:z,stdio:$,all:Y,ipcOutput:Q,options:W,startTime:v});var DF=(Z,J)=>{let X=Object.fromEntries(Object.entries(J).map(([$,Y])=>[$,jx1($,Z[$],Y)]));return{...Z,...X}},jx1=(Z,J,X)=>{if(Lx1.has(Z)&&c8(J)&&c8(X))return{...J,...X};return X},Lx1=new Set(["env",...cD]);var kJ=(Z,J,X,$)=>{let Y=(K,W,G)=>kJ(K,W,X,G),Q=(...K)=>Dx1({mapArguments:Z,deepOptions:X,boundOptions:J,setBoundExeca:$,createNested:Y},...K);if($!==void 0)$(Q,Y,J);return Q},Dx1=({mapArguments:Z,deepOptions:J={},boundOptions:X={},setBoundExeca:$,createNested:Y},Q,...K)=>{if(c8(Q))return Y(Z,DF(X,Q),$);let{file:W,commandArguments:G,options:z,isSync:v}=Mx1({mapArguments:Z,firstArgument:Q,nextArguments:K,deepOptions:J,boundOptions:X});return v?ty(W,G,z):Yi(W,G,z,Y)},Mx1=({mapArguments:Z,firstArgument:J,nextArguments:X,deepOptions:$,boundOptions:Y})=>{let Q=Vm(J)?Hm(J,X):[J,...X],[K,W,G]=Fq(...Q),z=DF(DF($,Y),G),{file:v=K,commandArguments:H=W,options:V=z,isSync:q=!1}=Z({file:K,commandArguments:W,options:z});return{file:v,commandArguments:H,options:V,isSync:q}};var Qi=({file:Z,commandArguments:J})=>Wi(Z,J),Ki=({file:Z,commandArguments:J})=>({...Wi(Z,J),isSync:!0}),Wi=(Z,J)=>{if(J.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${Z} ${J}.`);let[X,...$]=Rx1(Z);return{file:X,commandArguments:$}},Rx1=(Z)=>{if(typeof Z!=="string")throw new TypeError(`The command must be a string: ${String(Z)}.`);let J=Z.trim();if(J==="")return[];let X=[];for(let $ of J.split(Nx1)){let Y=X.at(-1);if(Y&&Y.endsWith("\\"))X[X.length-1]=`${Y.slice(0,-1)} ${$}`;else X.push($)}return X},Nx1=/ +/g;var Gi=(Z,J,X)=>{Z.sync=J(Ox1,X),Z.s=Z.sync},zi=({options:Z})=>vi(Z),Ox1=({options:Z})=>({...vi(Z),isSync:!0}),vi=(Z)=>({options:{...Px1(Z),...Z}}),Px1=({input:Z,inputFile:J,stdio:X})=>Z===void 0&&J===void 0&&X===void 0?{stdin:"inherit"}:{},Vi={preferLocal:!0};var Hi=kJ(()=>({})),MM6=kJ(()=>({isSync:!0})),RM6=kJ(Qi),NM6=kJ(Ki),OM6=kJ(Ul),PM6=kJ(zi,{},Vi,Gi),{sendMessage:TM6,getOneMessage:CM6,getEachMessage:fM6,getCancelSignal:kM6}=Qp();var Ei=t(Ri(),1);var QG=(Z)=>{if(typeof Z!=="string")throw new TypeError("invalid pattern");if(Z.length>65536)throw new TypeError("pattern is too long")};var bx1={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},KG=(Z)=>Z.replace(/[[\]\\-]/g,"\\$&"),hx1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ni=(Z)=>Z.join(""),Oi=(Z,J)=>{let X=J;if(Z.charAt(X)!=="[")throw new Error("not in a brace expression");let $=[],Y=[],Q=X+1,K=!1,W=!1,G=!1,z=!1,v=X,H="";Z:while(Q<Z.length){let x=Z.charAt(Q);if((x==="!"||x==="^")&&Q===X+1){z=!0,Q++;continue}if(x==="]"&&K&&!G){v=Q+1;break}if(K=!0,x==="\\"){if(!G){G=!0,Q++;continue}}if(x==="["&&!G){for(let[c,[w,B,j]]of Object.entries(bx1))if(Z.startsWith(c,Q)){if(H)return["$.",!1,Z.length-X,!0];if(Q+=c.length,j)Y.push(w);else $.push(w);W=W||B;continue Z}}if(G=!1,H){if(x>H)$.push(KG(H)+"-"+KG(x));else if(x===H)$.push(KG(x));H="",Q++;continue}if(Z.startsWith("-]",Q+1)){$.push(KG(x+"-")),Q+=2;continue}if(Z.startsWith("-",Q+1)){H=x,Q+=2;continue}$.push(KG(x)),Q++}if(v<Q)return["",!1,0,!1];if(!$.length&&!Y.length)return["$.",!1,Z.length-X,!0];if(Y.length===0&&$.length===1&&/^\\?.$/.test($[0])&&!z){let x=$[0].length===2?$[0].slice(-1):$[0];return[hx1(x),!1,v-X,!1]}let V="["+(z?"^":"")+Ni($)+"]",q="["+(z?"":"^")+Ni(Y)+"]";return[$.length&&Y.length?"("+V+"|"+q+")":$.length?V:q,W,v-X,!0]};var F9=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/\[([^\/\\])\]/g,"$1"):Z.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var Sx1=new Set(["!","?","+","*","@"]),Pi=(Z)=>Sx1.has(Z),Ax1="(?!(?:^|/)\\.\\.?(?:$|/))",MF="(?!\\.)",mx1=new Set(["[","."]),ux1=new Set(["..","."]),lx1=new Set("().*{}+?[]^$\\!"),yx1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),lM="[^/]",Ti=lM+"*?",Ci=lM+"+?";class Z6{type;#Z;#J;#$=!1;#X=[];#Y;#v;#H;#W=!1;#G;#z;#V=!1;constructor(Z,J,X={}){if(this.type=Z,Z)this.#J=!0;if(this.#Y=J,this.#Z=this.#Y?this.#Y.#Z:this,this.#G=this.#Z===this?X:this.#Z.#G,this.#H=this.#Z===this?[]:this.#Z.#H,Z==="!"&&!this.#Z.#W)this.#H.push(this);this.#v=this.#Y?this.#Y.#X.length:0}get hasMagic(){if(this.#J!==void 0)return this.#J;for(let Z of this.#X){if(typeof Z==="string")continue;if(Z.type||Z.hasMagic)return this.#J=!0}return this.#J}toString(){if(this.#z!==void 0)return this.#z;if(!this.type)return this.#z=this.#X.map((Z)=>String(Z)).join("");else return this.#z=this.type+"("+this.#X.map((Z)=>String(Z)).join("|")+")"}#Q(){if(this!==this.#Z)throw new Error("should only call on root");if(this.#W)return this;this.toString(),this.#W=!0;let Z;while(Z=this.#H.pop()){if(Z.type!=="!")continue;let J=Z,X=J.#Y;while(X){for(let $=J.#v+1;!X.type&&$<X.#X.length;$++)for(let Y of Z.#X){if(typeof Y==="string")throw new Error("string part in extglob AST??");Y.copyIn(X.#X[$])}J=X,X=J.#Y}}return this}push(...Z){for(let J of Z){if(J==="")continue;if(typeof J!=="string"&&!(J instanceof Z6&&J.#Y===this))throw new Error("invalid part: "+J);this.#X.push(J)}}toJSON(){let Z=this.type===null?this.#X.slice().map((J)=>typeof J==="string"?J:J.toJSON()):[this.type,...this.#X.map((J)=>J.toJSON())];if(this.isStart()&&!this.type)Z.unshift([]);if(this.isEnd()&&(this===this.#Z||this.#Z.#W&&this.#Y?.type==="!"))Z.push({});return Z}isStart(){if(this.#Z===this)return!0;if(!this.#Y?.isStart())return!1;if(this.#v===0)return!0;let Z=this.#Y;for(let J=0;J<this.#v;J++){let X=Z.#X[J];if(!(X instanceof Z6&&X.type==="!"))return!1}return!0}isEnd(){if(this.#Z===this)return!0;if(this.#Y?.type==="!")return!0;if(!this.#Y?.isEnd())return!1;if(!this.type)return this.#Y?.isEnd();let Z=this.#Y?this.#Y.#X.length:0;return this.#v===Z-1}copyIn(Z){if(typeof Z==="string")this.push(Z);else this.push(Z.clone(this))}clone(Z){let J=new Z6(this.type,Z);for(let X of this.#X)J.copyIn(X);return J}static#F(Z,J,X,$){let Y=!1,Q=!1,K=-1,W=!1;if(J.type===null){let V=X,q="";while(V<Z.length){let F=Z.charAt(V++);if(Y||F==="\\"){Y=!Y,q+=F;continue}if(Q){if(V===K+1){if(F==="^"||F==="!")W=!0}else if(F==="]"&&!(V===K+2&&W))Q=!1;q+=F;continue}else if(F==="["){Q=!0,K=V,W=!1,q+=F;continue}if(!$.noext&&Pi(F)&&Z.charAt(V)==="("){J.push(q),q="";let x=new Z6(F,J);V=Z6.#F(Z,x,V,$),J.push(x);continue}q+=F}return J.push(q),V}let G=X+1,z=new Z6(null,J),v=[],H="";while(G<Z.length){let V=Z.charAt(G++);if(Y||V==="\\"){Y=!Y,H+=V;continue}if(Q){if(G===K+1){if(V==="^"||V==="!")W=!0}else if(V==="]"&&!(G===K+2&&W))Q=!1;H+=V;continue}else if(V==="["){Q=!0,K=G,W=!1,H+=V;continue}if(Pi(V)&&Z.charAt(G)==="("){z.push(H),H="";let q=new Z6(V,z);z.push(q),G=Z6.#F(Z,q,G,$);continue}if(V==="|"){z.push(H),H="",v.push(z),z=new Z6(null,J);continue}if(V===")"){if(H===""&&J.#X.length===0)J.#V=!0;return z.push(H),H="",J.push(...v,z),G}H+=V}return J.type=null,J.#J=void 0,J.#X=[Z.substring(X-1)],G}static fromGlob(Z,J={}){let X=new Z6(null,void 0,J);return Z6.#F(Z,X,0,J),X}toMMPattern(){if(this!==this.#Z)return this.#Z.toMMPattern();let Z=this.toString(),[J,X,$,Y]=this.toRegExpSource();if(!($||this.#J||this.#G.nocase&&!this.#G.nocaseMagicOnly&&Z.toUpperCase()!==Z.toLowerCase()))return X;let K=(this.#G.nocase?"i":"")+(Y?"u":"");return Object.assign(new RegExp(`^${J}$`,K),{_src:J,_glob:Z})}get options(){return this.#G}toRegExpSource(Z){let J=Z??!!this.#G.dot;if(this.#Z===this)this.#Q();if(!this.type){let W=this.isStart()&&this.isEnd(),G=this.#X.map((V)=>{let[q,F,x,c]=typeof V==="string"?Z6.#x(V,this.#J,W):V.toRegExpSource(Z);return this.#J=this.#J||x,this.#$=this.#$||c,q}).join(""),z="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&ux1.has(this.#X[0]))){let q=mx1,F=J&&q.has(G.charAt(0))||G.startsWith("\\.")&&q.has(G.charAt(2))||G.startsWith("\\.\\.")&&q.has(G.charAt(4)),x=!J&&!Z&&q.has(G.charAt(0));z=F?Ax1:x?MF:""}}}let v="";if(this.isEnd()&&this.#Z.#W&&this.#Y?.type==="!")v="(?:$|\\/)";return[z+G+v,F9(G),this.#J=!!this.#J,this.#$]}let X=this.type==="*"||this.type==="+",$=this.type==="!"?"(?:(?!(?:":"(?:",Y=this.#c(J);if(this.isStart()&&this.isEnd()&&!Y&&this.type!=="!"){let W=this.toString();return this.#X=[W],this.type=null,this.#J=void 0,[W,F9(this.toString()),!1,!1]}let Q=!X||Z||J||!MF?"":this.#c(!0);if(Q===Y)Q="";if(Q)Y=`(?:${Y})(?:${Q})*?`;let K="";if(this.type==="!"&&this.#V)K=(this.isStart()&&!J?MF:"")+Ci;else{let W=this.type==="!"?"))"+(this.isStart()&&!J&&!Z?MF:"")+Ti+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&Q?")":this.type==="*"&&Q?")?":`)${this.type}`;K=$+Y+W}return[K,F9(Y),this.#J=!!this.#J,this.#$]}#c(Z){return this.#X.map((J)=>{if(typeof J==="string")throw new Error("string type in extglob ast??");let[X,$,Y,Q]=J.toRegExpSource(Z);return this.#$=this.#$||Q,X}).filter((J)=>!(this.isStart()&&this.isEnd())||!!J).join("|")}static#x(Z,J,X=!1){let $=!1,Y="",Q=!1;for(let K=0;K<Z.length;K++){let W=Z.charAt(K);if($){$=!1,Y+=(lx1.has(W)?"\\":"")+W;continue}if(W==="\\"){if(K===Z.length-1)Y+="\\\\";else $=!0;continue}if(W==="["){let[G,z,v,H]=Oi(Z,K);if(v){Y+=G,Q=Q||z,K+=v-1,J=J||H;continue}}if(W==="*"){if(X&&Z==="*")Y+=Ci;else Y+=Ti;J=!0;continue}if(W==="?"){Y+=lM,J=!0;continue}Y+=yx1(W)}return[Y,F9(Z),!!J,Q]}}var Z3=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/[?*()[\]]/g,"[$&]"):Z.replace(/[?*()[\]\\]/g,"\\$&")};var b6=(Z,J,X={})=>{if(QG(J),!X.nocomment&&J.charAt(0)==="#")return!1;return new H4(J,X).match(Z)},px1=/^\*+([^+@!?\*\[\(]*)$/,ix1=(Z)=>(J)=>!J.startsWith(".")&&J.endsWith(Z),gx1=(Z)=>(J)=>J.endsWith(Z),dx1=(Z)=>{return Z=Z.toLowerCase(),(J)=>!J.startsWith(".")&&J.toLowerCase().endsWith(Z)},ax1=(Z)=>{return Z=Z.toLowerCase(),(J)=>J.toLowerCase().endsWith(Z)},nx1=/^\*+\.\*+$/,sx1=(Z)=>!Z.startsWith(".")&&Z.includes("."),ox1=(Z)=>Z!=="."&&Z!==".."&&Z.includes("."),rx1=/^\.\*+$/,tx1=(Z)=>Z!=="."&&Z!==".."&&Z.startsWith("."),ex1=/^\*+$/,Zc1=(Z)=>Z.length!==0&&!Z.startsWith("."),Jc1=(Z)=>Z.length!==0&&Z!=="."&&Z!=="..",Xc1=/^\?+([^+@!?\*\[\(]*)?$/,$c1=([Z,J=""])=>{let X=Ii([Z]);if(!J)return X;return J=J.toLowerCase(),($)=>X($)&&$.toLowerCase().endsWith(J)},Yc1=([Z,J=""])=>{let X=_i([Z]);if(!J)return X;return J=J.toLowerCase(),($)=>X($)&&$.toLowerCase().endsWith(J)},Qc1=([Z,J=""])=>{let X=_i([Z]);return!J?X:($)=>X($)&&$.endsWith(J)},Kc1=([Z,J=""])=>{let X=Ii([Z]);return!J?X:($)=>X($)&&$.endsWith(J)},Ii=([Z])=>{let J=Z.length;return(X)=>X.length===J&&!X.startsWith(".")},_i=([Z])=>{let J=Z.length;return(X)=>X.length===J&&X!=="."&&X!==".."},bi=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",fi={win32:{sep:"\\"},posix:{sep:"/"}},Wc1=bi==="win32"?fi.win32.sep:fi.posix.sep;b6.sep=Wc1;var J6=Symbol("globstar **");b6.GLOBSTAR=J6;var Gc1="[^/]",zc1=Gc1+"*?",vc1="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Vc1="(?:(?!(?:\\/|^)\\.).)*?",Hc1=(Z,J={})=>(X)=>b6(X,Z,J);b6.filter=Hc1;var V4=(Z,J={})=>Object.assign({},Z,J),qc1=(Z)=>{if(!Z||typeof Z!=="object"||!Object.keys(Z).length)return b6;let J=b6;return Object.assign(($,Y,Q={})=>J($,Y,V4(Z,Q)),{Minimatch:class $ extends J.Minimatch{constructor(Y,Q={}){super(Y,V4(Z,Q))}static defaults(Y){return J.defaults(V4(Z,Y)).Minimatch}},AST:class $ extends J.AST{constructor(Y,Q,K={}){super(Y,Q,V4(Z,K))}static fromGlob(Y,Q={}){return J.AST.fromGlob(Y,V4(Z,Q))}},unescape:($,Y={})=>J.unescape($,V4(Z,Y)),escape:($,Y={})=>J.escape($,V4(Z,Y)),filter:($,Y={})=>J.filter($,V4(Z,Y)),defaults:($)=>J.defaults(V4(Z,$)),makeRe:($,Y={})=>J.makeRe($,V4(Z,Y)),braceExpand:($,Y={})=>J.braceExpand($,V4(Z,Y)),match:($,Y,Q={})=>J.match($,Y,V4(Z,Q)),sep:J.sep,GLOBSTAR:J6})};b6.defaults=qc1;var hi=(Z,J={})=>{if(QG(Z),J.nobrace||!/\{(?:(?!\{).)*\}/.test(Z))return[Z];return Ei.default(Z)};b6.braceExpand=hi;var Fc1=(Z,J={})=>new H4(Z,J).makeRe();b6.makeRe=Fc1;var xc1=(Z,J,X={})=>{let $=new H4(J,X);if(Z=Z.filter((Y)=>$.match(Y)),$.options.nonull&&!Z.length)Z.push(J);return Z};b6.match=xc1;var ki=/[?*]|[+@!]\(.*?\)|\[|\]/,cc1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class H4{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Z,J={}){if(QG(Z),J=J||{},this.options=J,this.pattern=Z,this.platform=J.platform||bi,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!J.windowsPathsNoEscape||J.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!J.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!J.nonegate,this.comment=!1,this.empty=!1,this.partial=!!J.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=J.windowsNoMagicRoot!==void 0?J.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let Z of this.set)for(let J of Z)if(typeof J!=="string")return!0;return!1}debug(...Z){}make(){let Z=this.pattern,J=this.options;if(!J.nocomment&&Z.charAt(0)==="#"){this.comment=!0;return}if(!Z){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],J.debug)this.debug=(...Y)=>console.error(...Y);this.debug(this.pattern,this.globSet);let X=this.globSet.map((Y)=>this.slashSplit(Y));this.globParts=this.preprocess(X),this.debug(this.pattern,this.globParts);let $=this.globParts.map((Y,Q,K)=>{if(this.isWindows&&this.windowsNoMagicRoot){let W=Y[0]===""&&Y[1]===""&&(Y[2]==="?"||!ki.test(Y[2]))&&!ki.test(Y[3]),G=/^[a-z]:/i.test(Y[0]);if(W)return[...Y.slice(0,4),...Y.slice(4).map((z)=>this.parse(z))];else if(G)return[Y[0],...Y.slice(1).map((z)=>this.parse(z))]}return Y.map((W)=>this.parse(W))});if(this.debug(this.pattern,$),this.set=$.filter((Y)=>Y.indexOf(!1)===-1),this.isWindows)for(let Y=0;Y<this.set.length;Y++){let Q=this.set[Y];if(Q[0]===""&&Q[1]===""&&this.globParts[Y][2]==="?"&&typeof Q[3]==="string"&&/^[a-z]:$/i.test(Q[3]))Q[2]="?"}this.debug(this.pattern,this.set)}preprocess(Z){if(this.options.noglobstar){for(let X=0;X<Z.length;X++)for(let $=0;$<Z[X].length;$++)if(Z[X][$]==="**")Z[X][$]="*"}let{optimizationLevel:J=1}=this.options;if(J>=2)Z=this.firstPhasePreProcess(Z),Z=this.secondPhasePreProcess(Z);else if(J>=1)Z=this.levelOneOptimize(Z);else Z=this.adjascentGlobstarOptimize(Z);return Z}adjascentGlobstarOptimize(Z){return Z.map((J)=>{let X=-1;while((X=J.indexOf("**",X+1))!==-1){let $=X;while(J[$+1]==="**")$++;if($!==X)J.splice(X,$-X)}return J})}levelOneOptimize(Z){return Z.map((J)=>{return J=J.reduce((X,$)=>{let Y=X[X.length-1];if($==="**"&&Y==="**")return X;if($===".."){if(Y&&Y!==".."&&Y!=="."&&Y!=="**")return X.pop(),X}return X.push($),X},[]),J.length===0?[""]:J})}levelTwoFileOptimize(Z){if(!Array.isArray(Z))Z=this.slashSplit(Z);let J=!1;do{if(J=!1,!this.preserveMultipleSlashes){for(let $=1;$<Z.length-1;$++){let Y=Z[$];if($===1&&Y===""&&Z[0]==="")continue;if(Y==="."||Y==="")J=!0,Z.splice($,1),$--}if(Z[0]==="."&&Z.length===2&&(Z[1]==="."||Z[1]===""))J=!0,Z.pop()}let X=0;while((X=Z.indexOf("..",X+1))!==-1){let $=Z[X-1];if($&&$!=="."&&$!==".."&&$!=="**")J=!0,Z.splice(X-1,2),X-=2}}while(J);return Z.length===0?[""]:Z}firstPhasePreProcess(Z){let J=!1;do{J=!1;for(let X of Z){let $=-1;while(($=X.indexOf("**",$+1))!==-1){let Q=$;while(X[Q+1]==="**")Q++;if(Q>$)X.splice($+1,Q-$);let K=X[$+1],W=X[$+2],G=X[$+3];if(K!=="..")continue;if(!W||W==="."||W===".."||!G||G==="."||G==="..")continue;J=!0,X.splice($,1);let z=X.slice(0);z[$]="**",Z.push(z),$--}if(!this.preserveMultipleSlashes){for(let Q=1;Q<X.length-1;Q++){let K=X[Q];if(Q===1&&K===""&&X[0]==="")continue;if(K==="."||K==="")J=!0,X.splice(Q,1),Q--}if(X[0]==="."&&X.length===2&&(X[1]==="."||X[1]===""))J=!0,X.pop()}let Y=0;while((Y=X.indexOf("..",Y+1))!==-1){let Q=X[Y-1];if(Q&&Q!=="."&&Q!==".."&&Q!=="**"){J=!0;let W=Y===1&&X[Y+1]==="**"?["."]:[];if(X.splice(Y-1,2,...W),X.length===0)X.push("");Y-=2}}}}while(J);return Z}secondPhasePreProcess(Z){for(let J=0;J<Z.length-1;J++)for(let X=J+1;X<Z.length;X++){let $=this.partsMatch(Z[J],Z[X],!this.preserveMultipleSlashes);if($){Z[J]=[],Z[X]=$;break}}return Z.filter((J)=>J.length)}partsMatch(Z,J,X=!1){let $=0,Y=0,Q=[],K="";while($<Z.length&&Y<J.length)if(Z[$]===J[Y])Q.push(K==="b"?J[Y]:Z[$]),$++,Y++;else if(X&&Z[$]==="**"&&J[Y]===Z[$+1])Q.push(Z[$]),$++;else if(X&&J[Y]==="**"&&Z[$]===J[Y+1])Q.push(J[Y]),Y++;else if(Z[$]==="*"&&J[Y]&&(this.options.dot||!J[Y].startsWith("."))&&J[Y]!=="**"){if(K==="b")return!1;K="a",Q.push(Z[$]),$++,Y++}else if(J[Y]==="*"&&Z[$]&&(this.options.dot||!Z[$].startsWith("."))&&Z[$]!=="**"){if(K==="a")return!1;K="b",Q.push(J[Y]),$++,Y++}else return!1;return Z.length===J.length&&Q}parseNegate(){if(this.nonegate)return;let Z=this.pattern,J=!1,X=0;for(let $=0;$<Z.length&&Z.charAt($)==="!";$++)J=!J,X++;if(X)this.pattern=Z.slice(X);this.negate=J}matchOne(Z,J,X=!1){let $=this.options;if(this.isWindows){let F=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),x=!F&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&/^[a-z]:$/i.test(Z[3]),c=typeof J[0]==="string"&&/^[a-z]:$/i.test(J[0]),w=!c&&J[0]===""&&J[1]===""&&J[2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]),B=x?3:F?0:void 0,j=w?3:c?0:void 0;if(typeof B==="number"&&typeof j==="number"){let[L,R]=[Z[B],J[j]];if(L.toLowerCase()===R.toLowerCase()){if(J[j]=L,j>B)J=J.slice(j);else if(B>j)Z=Z.slice(B)}}}let{optimizationLevel:Y=1}=this.options;if(Y>=2)Z=this.levelTwoFileOptimize(Z);this.debug("matchOne",this,{file:Z,pattern:J}),this.debug("matchOne",Z.length,J.length);for(var Q=0,K=0,W=Z.length,G=J.length;Q<W&&K<G;Q++,K++){this.debug("matchOne loop");var z=J[K],v=Z[Q];if(this.debug(J,z,v),z===!1)return!1;if(z===J6){this.debug("GLOBSTAR",[J,z,v]);var H=Q,V=K+1;if(V===G){this.debug("** at the end");for(;Q<W;Q++)if(Z[Q]==="."||Z[Q]===".."||!$.dot&&Z[Q].charAt(0)===".")return!1;return!0}while(H<W){var q=Z[H];if(this.debug(`
398
398
  globstar while`,Z,H,J,V,q),this.matchOne(Z.slice(H),J.slice(V),X))return this.debug("globstar found match!",H,W,q),!0;else{if(q==="."||q===".."||!$.dot&&q.charAt(0)==="."){this.debug("dot detected!",Z,H,J,V);break}this.debug("globstar swallow a segment, and continue"),H++}}if(X){if(this.debug(`
399
- >>> no match, partial?`,Z,H,J,V),H===W)return!0}return!1}let F;if(typeof z==="string")F=v===z,this.debug("string match",z,v,F);else F=z.test(v),this.debug("pattern match",z,v,F);if(!F)return!1}if(Q===W&&K===G)return!0;else if(Q===W)return X;else if(K===G)return Q===W-1&&Z[Q]==="";else throw new Error("wtf?")}braceExpand(){return hi(this.pattern,this.options)}parse(Z){QG(Z);let J=this.options;if(Z==="**")return J6;if(Z==="")return"";let X,$=null;if(X=Z.match(ex1))$=J.dot?Jc1:Zc1;else if(X=Z.match(px1))$=(J.nocase?J.dot?ax1:dx1:J.dot?gx1:ix1)(X[1]);else if(X=Z.match(Xc1))$=(J.nocase?J.dot?Yc1:$c1:J.dot?Qc1:Kc1)(X);else if(X=Z.match(nx1))$=J.dot?ox1:sx1;else if(X=Z.match(rx1))$=tx1;let Y=Z6.fromGlob(Z,this.options).toMMPattern();if($&&typeof Y==="object")Reflect.defineProperty(Y,"test",{value:$});return Y}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Z=this.set;if(!Z.length)return this.regexp=!1,this.regexp;let J=this.options,X=J.noglobstar?zc1:J.dot?vc1:Vc1,$=new Set(J.nocase?["i"]:[]),Y=Z.map((W)=>{let G=W.map((z)=>{if(z instanceof RegExp)for(let v of z.flags.split(""))$.add(v);return typeof z==="string"?cc1(z):z===J6?J6:z._src});return G.forEach((z,v)=>{let H=G[v+1],V=G[v-1];if(z!==J6||V===J6)return;if(V===void 0)if(H!==void 0&&H!==J6)G[v+1]="(?:\\/|"+X+"\\/)?"+H;else G[v]=X;else if(H===void 0)G[v-1]=V+"(?:\\/|"+X+")?";else if(H!==J6)G[v-1]=V+"(?:\\/|\\/"+X+"\\/)"+H,G[v+1]=J6}),G.filter((z)=>z!==J6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if(Y="^"+Q+Y+K+"$",this.negate)Y="^(?!"+Y+").+$";try{this.regexp=new RegExp(Y,[...$].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit(Z){if(this.preserveMultipleSlashes)return Z.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Z))return["",...Z.split(/\/+/)];else return Z.split(/\/+/)}match(Z,J=this.partial){if(this.debug("match",Z,this.pattern),this.comment)return!1;if(this.empty)return Z==="";if(Z==="/"&&J)return!0;let X=this.options;if(this.isWindows)Z=Z.split("\\").join("/");let $=this.slashSplit(Z);this.debug(this.pattern,"split",$);let Y=this.set;this.debug(this.pattern,"set",Y);let Q=$[$.length-1];if(!Q)for(let K=$.length-2;!Q&&K>=0;K--)Q=$[K];for(let K=0;K<Y.length;K++){let W=Y[K],G=$;if(X.matchBase&&W.length===1)G=[Q];if(this.matchOne(G,W,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return b6.defaults(Z).Minimatch}}b6.AST=Z6;b6.Minimatch=H4;b6.escape=Z3;b6.unescape=F9;import{fileURLToPath as nc1}from"node:url";var J3=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,Ai=new Set,yM=typeof process==="object"&&!!process?process:{},mi=(Z,J,X,$)=>{typeof yM.emitWarning==="function"?yM.emitWarning(Z,J,X,$):console.error(`[${X}] ${J}: ${Z}`)},RF=globalThis.AbortController,Si=globalThis.AbortSignal;if(typeof RF==="undefined"){Si=class X{onabort;_onabort=[];reason;aborted=!1;addEventListener($,Y){this._onabort.push(Y)}},RF=class X{constructor(){J()}signal=new Si;abort($){if(this.signal.aborted)return;this.signal.reason=$,this.signal.aborted=!0;for(let Y of this.signal._onabort)Y($);this.signal.onabort?.($)}};let Z=yM.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,mi("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",J)}}var wc1=(Z)=>!Ai.has(Z),oM6=Symbol("type"),EJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),ui=(Z)=>!EJ(Z)?null:Z<=Math.pow(2,8)?Uint8Array:Z<=Math.pow(2,16)?Uint16Array:Z<=Math.pow(2,32)?Uint32Array:Z<=Number.MAX_SAFE_INTEGER?WG:null;class WG extends Array{constructor(Z){super(Z);this.fill(0)}}class X3{heap;length;static#Z=!1;static create(Z){let J=ui(Z);if(!J)return[];X3.#Z=!0;let X=new X3(Z,J);return X3.#Z=!1,X}constructor(Z,J){if(!X3.#Z)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new J(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}}class GG{#Z;#J;#$;#X;#Y;#v;#H;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#z;#V;#Q;#F;#c;#x;#U;#P;#B;#T;#D;#L;#j;#N;#w;#f;static unsafeExposeInternals(Z){return{starts:Z.#D,ttls:Z.#L,sizes:Z.#T,keyMap:Z.#z,keyList:Z.#V,valList:Z.#Q,next:Z.#F,prev:Z.#c,get head(){return Z.#x},get tail(){return Z.#U},free:Z.#P,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,$,Y)=>Z.#b(J,X,$,Y),moveToTail:(J)=>Z.#A(J),indexes:(J)=>Z.#O(J),rindexes:(J)=>Z.#C(J),isStale:(J)=>Z.#R(J)}}get max(){return this.#Z}get maxSize(){return this.#J}get calculatedSize(){return this.#G}get size(){return this.#W}get fetchMethod(){return this.#v}get memoMethod(){return this.#H}get dispose(){return this.#$}get onInsert(){return this.#X}get disposeAfter(){return this.#Y}constructor(Z){let{max:J=0,ttl:X,ttlResolution:$=1,ttlAutopurge:Y,updateAgeOnGet:Q,updateAgeOnHas:K,allowStale:W,dispose:G,onInsert:z,disposeAfter:v,noDisposeOnSet:H,noUpdateTTL:V,maxSize:q=0,maxEntrySize:F=0,sizeCalculation:x,fetchMethod:c,memoMethod:w,noDeleteOnFetchRejection:B,noDeleteOnStaleGet:j,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:R,ignoreFetchAbort:M}=Z;if(J!==0&&!EJ(J))throw new TypeError("max option must be a nonnegative integer");let N=J?ui(J):Array;if(!N)throw new Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=F||this.#J,this.sizeCalculation=x,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw new TypeError("sizeCalculation set to non-function")}if(w!==void 0&&typeof w!=="function")throw new TypeError("memoMethod must be a function if defined");if(this.#H=w,c!==void 0&&typeof c!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#v=c,this.#N=!!c,this.#z=new Map,this.#V=new Array(J).fill(void 0),this.#Q=new Array(J).fill(void 0),this.#F=new N(J),this.#c=new N(J),this.#x=0,this.#U=0,this.#P=X3.create(J),this.#W=0,this.#G=0,typeof G==="function")this.#$=G;if(typeof z==="function")this.#X=z;if(typeof v==="function")this.#Y=v,this.#B=[];else this.#Y=void 0,this.#B=void 0;if(this.#j=!!this.#$,this.#f=!!this.#X,this.#w=!!this.#Y,this.noDisposeOnSet=!!H,this.noUpdateTTL=!!V,this.noDeleteOnFetchRejection=!!B,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!EJ(this.#J))throw new TypeError("maxSize must be a positive integer if specified")}if(!EJ(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#u()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!j,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=EJ($)||$===0?$:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!EJ(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(wc1("LRU_CACHE_UNBOUNDED"))Ai.add("LRU_CACHE_UNBOUNDED"),mi("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",GG)}}getRemainingTTL(Z){return this.#z.has(Z)?1/0:0}#K(){let Z=new WG(this.#Z),J=new WG(this.#Z);this.#L=Z,this.#D=J,this.#k=(Y,Q,K=J3.now())=>{if(J[Y]=Q!==0?K:0,Z[Y]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#R(Y))this.#E(this.#V[Y],"expire")},Q+1);if(W.unref)W.unref()}},this.#I=(Y)=>{J[Y]=Z[Y]!==0?J3.now():0},this.#M=(Y,Q)=>{if(Z[Q]){let K=Z[Q],W=J[Q];if(!K||!W)return;Y.ttl=K,Y.start=W,Y.now=X||$();let G=Y.now-W;Y.remainingTTL=K-G}};let X=0,$=()=>{let Y=J3.now();if(this.ttlResolution>0){X=Y;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return Y};this.getRemainingTTL=(Y)=>{let Q=this.#z.get(Y);if(Q===void 0)return 0;let K=Z[Q],W=J[Q];if(!K||!W)return 1/0;let G=(X||$())-W;return K-G},this.#R=(Y)=>{let Q=J[Y],K=Z[Y];return!!K&&!!Q&&(X||$())-Q>K}}#I=()=>{};#M=()=>{};#k=()=>{};#R=()=>!1;#u(){let Z=new WG(this.#Z);this.#G=0,this.#T=Z,this.#_=(J)=>{this.#G-=Z[J],Z[J]=0},this.#l=(J,X,$,Y)=>{if(this.#q(X))return 0;if(!EJ($))if(Y){if(typeof Y!=="function")throw new TypeError("sizeCalculation must be a function");if($=Y(X,J),!EJ($))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return $},this.#h=(J,X,$)=>{if(Z[J]=X,this.#J){let Y=this.#J-Z[J];while(this.#G>Y)this.#S(!0)}if(this.#G+=Z[J],$)$.entrySize=X,$.totalCalculatedSize=this.#G}}#_=(Z)=>{};#h=(Z,J,X)=>{};#l=(Z,J,X,$)=>{if(X||$)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#U;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#x)break;else J=this.#c[J]}}*#C({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#x;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#U)break;else J=this.#F[J]}}#y(Z){return Z!==void 0&&this.#z.get(this.#V[Z])===Z}*entries(){for(let Z of this.#O())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#C())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*keys(){for(let Z of this.#O()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#C()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#O())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#C())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,J={}){for(let X of this.#O()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;if(Z(Y,this.#V[X],this))return this.get(this.#V[X],J)}}forEach(Z,J=this){for(let X of this.#O()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#V[X],this)}}rforEach(Z,J=this){for(let X of this.#C()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#V[X],this)}}purgeStale(){let Z=!1;for(let J of this.#C({allowStale:!0}))if(this.#R(J))this.#E(this.#V[J],"expire"),Z=!0;return Z}info(Z){let J=this.#z.get(Z);if(J===void 0)return;let X=this.#Q[J],$=this.#q(X)?X.__staleWhileFetching:X;if($===void 0)return;let Y={value:$};if(this.#L&&this.#D){let Q=this.#L[J],K=this.#D[J];if(Q&&K){let W=Q-(J3.now()-K);Y.ttl=W,Y.start=Date.now()}}if(this.#T)Y.size=this.#T[J];return Y}dump(){let Z=[];for(let J of this.#O({allowStale:!0})){let X=this.#V[J],$=this.#Q[J],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0||X===void 0)continue;let Q={value:Y};if(this.#L&&this.#D){Q.ttl=this.#L[J];let K=J3.now()-this.#D[J];Q.start=Math.floor(Date.now()-K)}if(this.#T)Q.size=this.#T[J];Z.unshift([X,Q])}return Z}load(Z){this.clear();for(let[J,X]of Z){if(X.start){let $=Date.now()-X.start;X.start=J3.now()-$}this.set(J,X.value,X)}}set(Z,J,X={}){if(J===void 0)return this.delete(Z),this;let{ttl:$=this.ttl,start:Y,noDisposeOnSet:Q=this.noDisposeOnSet,sizeCalculation:K=this.sizeCalculation,status:W}=X,{noUpdateTTL:G=this.noUpdateTTL}=X,z=this.#l(Z,J,X.size||0,K);if(this.maxEntrySize&&z>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#E(Z,"set"),this}let v=this.#W===0?void 0:this.#z.get(Z);if(v===void 0){if(v=this.#W===0?this.#U:this.#P.length!==0?this.#P.pop():this.#W===this.#Z?this.#S(!1):this.#W,this.#V[v]=Z,this.#Q[v]=J,this.#z.set(Z,v),this.#F[this.#U]=v,this.#c[v]=this.#U,this.#U=v,this.#W++,this.#h(v,z,W),W)W.set="add";if(G=!1,this.#f)this.#X?.(J,Z,"add")}else{this.#A(v);let H=this.#Q[v];if(J!==H){if(this.#N&&this.#q(H)){H.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:V}=H;if(V!==void 0&&!Q){if(this.#j)this.#$?.(V,Z,"set");if(this.#w)this.#B?.push([V,Z,"set"])}}else if(!Q){if(this.#j)this.#$?.(H,Z,"set");if(this.#w)this.#B?.push([H,Z,"set"])}if(this.#_(v),this.#h(v,z,W),this.#Q[v]=J,W){W.set="replace";let V=H&&this.#q(H)?H.__staleWhileFetching:H;if(V!==void 0)W.oldValue=V}}else if(W)W.set="update";if(this.#f)this.onInsert?.(J,Z,J===H?"update":"replace")}if($!==0&&!this.#L)this.#K();if(this.#L){if(!G)this.#k(v,$,Y);if(W)this.#M(W,v)}if(!Q&&this.#w&&this.#B){let H=this.#B,V;while(V=H?.shift())this.#Y?.(...V)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#x];if(this.#S(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#w&&this.#B){let Z=this.#B,J;while(J=Z?.shift())this.#Y?.(...J)}}}#S(Z){let J=this.#x,X=this.#V[J],$=this.#Q[J];if(this.#N&&this.#q($))$.__abortController.abort(new Error("evicted"));else if(this.#j||this.#w){if(this.#j)this.#$?.($,X,"evict");if(this.#w)this.#B?.push([$,X,"evict"])}if(this.#_(J),Z)this.#V[J]=void 0,this.#Q[J]=void 0,this.#P.push(J);if(this.#W===1)this.#x=this.#U=0,this.#P.length=0;else this.#x=this.#F[J];return this.#z.delete(X),this.#W--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:$}=J,Y=this.#z.get(Z);if(Y!==void 0){let Q=this.#Q[Y];if(this.#q(Q)&&Q.__staleWhileFetching===void 0)return!1;if(!this.#R(Y)){if(X)this.#I(Y);if($)$.has="hit",this.#M($,Y);return!0}else if($)$.has="stale",this.#M($,Y)}else if($)$.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,$=this.#z.get(Z);if($===void 0||!X&&this.#R($))return;let Y=this.#Q[$];return this.#q(Y)?Y.__staleWhileFetching:Y}#b(Z,J,X,$){let Y=J===void 0?void 0:this.#Q[J];if(this.#q(Y))return Y;let Q=new RF,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:$},G=(F,x=!1)=>{let{aborted:c}=Q.signal,w=X.ignoreFetchAbort&&F!==void 0;if(X.status)if(c&&!x){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,w)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(c&&!w&&!x)return v(Q.signal.reason);let B=V;if(this.#Q[J]===V)if(F===void 0)if(B.__staleWhileFetching)this.#Q[J]=B.__staleWhileFetching;else this.#E(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,F,W.options)}return F},z=(F)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=F;return v(F)},v=(F)=>{let{aborted:x}=Q.signal,c=x&&X.allowStaleOnFetchAbort,w=c||X.allowStaleOnFetchRejection,B=w||X.noDeleteOnFetchRejection,j=V;if(this.#Q[J]===V){if(!B||j.__staleWhileFetching===void 0)this.#E(Z,"fetch");else if(!c)this.#Q[J]=j.__staleWhileFetching}if(w){if(X.status&&j.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return j.__staleWhileFetching}else if(j.__returned===j)throw F},H=(F,x)=>{let c=this.#v?.(Z,Y,W);if(c&&c instanceof Promise)c.then((w)=>F(w===void 0?void 0:w),x);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(F(void 0),X.allowStaleOnFetchAbort)F=(w)=>G(w,!0)}})};if(X.status)X.status.fetchDispatched=!0;let V=new Promise(H).then(G,z),q=Object.assign(V,{__abortController:Q,__staleWhileFetching:Y,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#z.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#N)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof RF}async fetch(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,ttl:Q=this.ttl,noDisposeOnSet:K=this.noDisposeOnSet,size:W=0,sizeCalculation:G=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:v=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:H=this.allowStaleOnFetchRejection,ignoreFetchAbort:V=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:F,forceRefresh:x=!1,status:c,signal:w}=J;if(!this.#N){if(c)c.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,status:c})}let B={allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:z,noDeleteOnFetchRejection:v,allowStaleOnFetchRejection:H,allowStaleOnFetchAbort:q,ignoreFetchAbort:V,status:c,signal:w},j=this.#z.get(Z);if(j===void 0){if(c)c.fetch="miss";let L=this.#b(Z,j,B,F);return L.__returned=L}else{let L=this.#Q[j];if(this.#q(L)){let O=X&&L.__staleWhileFetching!==void 0;if(c){if(c.fetch="inflight",O)c.returnedStale=!0}return O?L.__staleWhileFetching:L.__returned=L}let R=this.#R(j);if(!x&&!R){if(c)c.fetch="hit";if(this.#A(j),$)this.#I(j);if(c)this.#M(c,j);return L}let M=this.#b(Z,j,B,F),P=M.__staleWhileFetching!==void 0&&X;if(c){if(c.fetch=R?"stale":"refresh",P&&R)c.returnedStale=!0}return P?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw new Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#H;if(!X)throw new Error("no memoMethod provided to constructor");let{context:$,forceRefresh:Y,...Q}=J,K=this.get(Z,Q);if(!Y&&K!==void 0)return K;let W=X(Z,K,{options:Q,context:$});return this.set(Z,W,Q),W}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,status:Q}=J,K=this.#z.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#M(Q,K);if(this.#R(K)){if(Q)Q.get="stale";if(!G){if(!Y)this.#E(Z,"expire");if(Q&&X)Q.returnedStale=!0;return X?W:void 0}else{if(Q&&X&&W.__staleWhileFetching!==void 0)Q.returnedStale=!0;return X?W.__staleWhileFetching:void 0}}else{if(Q)Q.get="hit";if(G)return W.__staleWhileFetching;if(this.#A(K),$)this.#I(K);return W}}else if(Q)Q.get="miss"}#p(Z,J){this.#c[J]=Z,this.#F[Z]=J}#A(Z){if(Z!==this.#U){if(Z===this.#x)this.#x=this.#F[Z];else this.#p(this.#c[Z],this.#F[Z]);this.#p(this.#U,Z),this.#U=Z}}delete(Z){return this.#E(Z,"delete")}#E(Z,J){let X=!1;if(this.#W!==0){let $=this.#z.get(Z);if($!==void 0)if(X=!0,this.#W===1)this.#m(J);else{this.#_($);let Y=this.#Q[$];if(this.#q(Y))Y.__abortController.abort(new Error("deleted"));else if(this.#j||this.#w){if(this.#j)this.#$?.(Y,Z,J);if(this.#w)this.#B?.push([Y,Z,J])}if(this.#z.delete(Z),this.#V[$]=void 0,this.#Q[$]=void 0,$===this.#U)this.#U=this.#c[$];else if($===this.#x)this.#x=this.#F[$];else{let Q=this.#c[$];this.#F[Q]=this.#F[$];let K=this.#F[$];this.#c[K]=this.#c[$]}this.#W--,this.#P.push($)}}if(this.#w&&this.#B?.length){let $=this.#B,Y;while(Y=$?.shift())this.#Y?.(...Y)}return X}clear(){return this.#m("delete")}#m(Z){for(let J of this.#C({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(new Error("deleted"));else{let $=this.#V[J];if(this.#j)this.#$?.(X,$,Z);if(this.#w)this.#B?.push([X,$,Z])}}if(this.#z.clear(),this.#Q.fill(void 0),this.#V.fill(void 0),this.#L&&this.#D)this.#L.fill(0),this.#D.fill(0);if(this.#T)this.#T.fill(0);if(this.#x=0,this.#U=0,this.#P.length=0,this.#G=0,this.#W=0,this.#w&&this.#B){let J=this.#B,X;while(X=J?.shift())this.#Y?.(...X)}}}import{posix as Tc1,win32 as tM}from"node:path";import{fileURLToPath as Cc1}from"node:url";import{lstatSync as fc1,readdir as kc1,readdirSync as Ec1,readlinkSync as Ic1,realpathSync as _c1}from"fs";import*as bc1 from"node:fs";import{lstat as Sc1,readdir as Ac1,readlink as mc1,realpath as uc1}from"node:fs/promises";import{EventEmitter as nM}from"node:events";import gi from"node:stream";import{StringDecoder as Uc1}from"node:string_decoder";var li=typeof process==="object"&&process?process:{stdout:null,stderr:null},Bc1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof T$||Z instanceof gi||jc1(Z)||Lc1(Z)),jc1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof nM&&typeof Z.pipe==="function"&&Z.pipe!==gi.Writable.prototype.pipe,Lc1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof nM&&typeof Z.write==="function"&&typeof Z.end==="function",ZZ=Symbol("EOF"),JZ=Symbol("maybeEmitEnd"),IJ=Symbol("emittedEnd"),NF=Symbol("emittingEnd"),zG=Symbol("emittedError"),OF=Symbol("closed"),yi=Symbol("read"),PF=Symbol("flush"),pi=Symbol("flushChunk"),x9=Symbol("encoding"),$3=Symbol("decoder"),y8=Symbol("flowing"),vG=Symbol("paused"),Y3=Symbol("resume"),p8=Symbol("buffer"),h6=Symbol("pipes"),i8=Symbol("bufferLength"),pM=Symbol("bufferPush"),TF=Symbol("bufferShift"),x6=Symbol("objectMode"),w8=Symbol("destroyed"),iM=Symbol("error"),gM=Symbol("emitData"),ii=Symbol("emitEnd"),dM=Symbol("emitEnd2"),X7=Symbol("async"),aM=Symbol("abort"),CF=Symbol("aborted"),VG=Symbol("signal"),P$=Symbol("dataListeners"),k5=Symbol("discarded"),HG=(Z)=>Promise.resolve().then(Z),Dc1=(Z)=>Z(),Mc1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",Rc1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,Nc1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class sM{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[Y3](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(Z){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class di extends sM{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Z,J,X){super(Z,J,X);this.proxyErrors=($)=>J.emit("error",$),Z.on("error",this.proxyErrors)}}var Oc1=(Z)=>!!Z.objectMode,Pc1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class T$ extends nM{[y8]=!1;[vG]=!1;[h6]=[];[p8]=[];[x6];[x9];[X7];[$3];[ZZ]=!1;[IJ]=!1;[NF]=!1;[OF]=!1;[zG]=null;[i8]=0;[w8]=!1;[VG];[CF]=!1;[P$]=0;[k5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(Oc1(J))this[x6]=!0,this[x9]=null;else if(Pc1(J))this[x9]=J.encoding,this[x6]=!1;else this[x6]=!1,this[x9]=null;if(this[X7]=!!J.async,this[$3]=this[x9]?new Uc1(this[x9]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[p8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[h6]});let{signal:X}=J;if(X)if(this[VG]=X,X.aborted)this[aM]();else X.addEventListener("abort",()=>this[aM]())}get bufferLength(){return this[i8]}get encoding(){return this[x9]}set encoding(Z){throw new Error("Encoding must be set at instantiation time")}setEncoding(Z){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[x6]}set objectMode(Z){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[X7]}set["async"](Z){this[X7]=this[X7]||!!Z}[aM](){this[CF]=!0,this.emit("abort",this[VG]?.reason),this.destroy(this[VG]?.reason)}get aborted(){return this[CF]}set aborted(Z){}write(Z,J,X){if(this[CF])return!1;if(this[ZZ])throw new Error("write after end");if(this[w8])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof J==="function")X=J,J="utf8";if(!J)J="utf8";let $=this[X7]?HG:Dc1;if(!this[x6]&&!Buffer.isBuffer(Z)){if(Nc1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(Rc1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[x6]){if(this[y8]&&this[i8]!==0)this[PF](!0);if(this[y8])this.emit("data",Z);else this[pM](Z);if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}if(!Z.length){if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}if(typeof Z==="string"&&!(J===this[x9]&&!this[$3]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[x9])Z=this[$3].write(Z);if(this[y8]&&this[i8]!==0)this[PF](!0);if(this[y8])this.emit("data",Z);else this[pM](Z);if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}read(Z){if(this[w8])return null;if(this[k5]=!1,this[i8]===0||Z===0||Z&&Z>this[i8])return this[JZ](),null;if(this[x6])Z=null;if(this[p8].length>1&&!this[x6])this[p8]=[this[x9]?this[p8].join(""):Buffer.concat(this[p8],this[i8])];let J=this[yi](Z||null,this[p8][0]);return this[JZ](),J}[yi](Z,J){if(this[x6])this[TF]();else{let X=J;if(Z===X.length||Z===null)this[TF]();else if(typeof X==="string")this[p8][0]=X.slice(Z),J=X.slice(0,Z),this[i8]-=Z;else this[p8][0]=X.subarray(Z),J=X.subarray(0,Z),this[i8]-=Z}if(this.emit("data",J),!this[p8].length&&!this[ZZ])this.emit("drain");return J}end(Z,J,X){if(typeof Z==="function")X=Z,Z=void 0;if(typeof J==="function")X=J,J="utf8";if(Z!==void 0)this.write(Z,J);if(X)this.once("end",X);if(this[ZZ]=!0,this.writable=!1,this[y8]||!this[vG])this[JZ]();return this}[Y3](){if(this[w8])return;if(!this[P$]&&!this[h6].length)this[k5]=!0;if(this[vG]=!1,this[y8]=!0,this.emit("resume"),this[p8].length)this[PF]();else if(this[ZZ])this[JZ]();else this.emit("drain")}resume(){return this[Y3]()}pause(){this[y8]=!1,this[vG]=!0,this[k5]=!1}get destroyed(){return this[w8]}get flowing(){return this[y8]}get paused(){return this[vG]}[pM](Z){if(this[x6])this[i8]+=1;else this[i8]+=Z.length;this[p8].push(Z)}[TF](){if(this[x6])this[i8]-=1;else this[i8]-=this[p8][0].length;return this[p8].shift()}[PF](Z=!1){do;while(this[pi](this[TF]())&&this[p8].length);if(!Z&&!this[p8].length&&!this[ZZ])this.emit("drain")}[pi](Z){return this.emit("data",Z),this[y8]}pipe(Z,J){if(this[w8])return Z;this[k5]=!1;let X=this[IJ];if(J=J||{},Z===li.stdout||Z===li.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[h6].push(!J.proxyErrors?new sM(this,Z,J):new di(this,Z,J)),this[X7])HG(()=>this[Y3]());else this[Y3]();return Z}unpipe(Z){let J=this[h6].find((X)=>X.dest===Z);if(J){if(this[h6].length===1){if(this[y8]&&this[P$]===0)this[y8]=!1;this[h6]=[]}else this[h6].splice(this[h6].indexOf(J),1);J.unpipe()}}addListener(Z,J){return this.on(Z,J)}on(Z,J){let X=super.on(Z,J);if(Z==="data"){if(this[k5]=!1,this[P$]++,!this[h6].length&&!this[y8])this[Y3]()}else if(Z==="readable"&&this[i8]!==0)super.emit("readable");else if(Mc1(Z)&&this[IJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[zG]){let $=J;if(this[X7])HG(()=>$.call(this,this[zG]));else $.call(this,this[zG])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[P$]=this.listeners("data").length,this[P$]===0&&!this[k5]&&!this[h6].length)this[y8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[P$]=0,!this[k5]&&!this[h6].length)this[y8]=!1}return J}get emittedEnd(){return this[IJ]}[JZ](){if(!this[NF]&&!this[IJ]&&!this[w8]&&this[p8].length===0&&this[ZZ]){if(this[NF]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[OF])this.emit("close");this[NF]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==w8&&this[w8])return!1;else if(Z==="data")return!this[x6]&&!X?!1:this[X7]?(HG(()=>this[gM](X)),!0):this[gM](X);else if(Z==="end")return this[ii]();else if(Z==="close"){if(this[OF]=!0,!this[IJ]&&!this[w8])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Z==="error"){this[zG]=X,super.emit(iM,X);let Y=!this[VG]||this.listeners("error").length?super.emit("error",X):!1;return this[JZ](),Y}else if(Z==="resume"){let Y=super.emit("resume");return this[JZ](),Y}else if(Z==="finish"||Z==="prefinish"){let Y=super.emit(Z);return this.removeAllListeners(Z),Y}let $=super.emit(Z,...J);return this[JZ](),$}[gM](Z){for(let X of this[h6])if(X.dest.write(Z)===!1)this.pause();let J=this[k5]?!1:super.emit("data",Z);return this[JZ](),J}[ii](){if(this[IJ])return!1;return this[IJ]=!0,this.readable=!1,this[X7]?(HG(()=>this[dM]()),!0):this[dM]()}[dM](){if(this[$3]){let J=this[$3].end();if(J){for(let X of this[h6])X.dest.write(J);if(!this[k5])super.emit("data",J)}}for(let J of this[h6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[x6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[x6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[x6])throw new Error("cannot concat in objectMode");let Z=await this.collect();return this[x9]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(w8,()=>J(new Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[k5]=!1;let Z=!1,J=async()=>{return this.pause(),Z=!0,{value:void 0,done:!0}};return{next:()=>{if(Z)return J();let $=this.read();if($!==null)return Promise.resolve({done:!1,value:$});if(this[ZZ])return J();let Y,Q,K=(v)=>{this.off("data",W),this.off("end",G),this.off(w8,z),J(),Q(v)},W=(v)=>{this.off("error",K),this.off("end",G),this.off(w8,z),this.pause(),Y({value:v,done:!!this[ZZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(w8,z),J(),Y({done:!0,value:void 0})},z=()=>K(new Error("stream destroyed"));return new Promise((v,H)=>{Q=H,Y=v,this.once(w8,z),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[k5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(iM,J),this.off(w8,J),this.off("end",J),Z=!0,{done:!0,value:void 0}},X=()=>{if(Z)return J();let $=this.read();return $===null?J():{done:!1,value:$}};return this.once("end",J),this.once(iM,J),this.once(w8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[w8]){if(Z)this.emit("error",Z);else this.emit(w8);return this}this[w8]=!0,this[k5]=!0,this[p8].length=0,this[i8]=0;let J=this;if(typeof J.close==="function"&&!this[OF])J.close();if(Z)this.emit("error",Z);else this.emit(w8);return this}static get isStream(){return Bc1}}var hc1=_c1.native,FG={lstatSync:fc1,readdir:kc1,readdirSync:Ec1,readlinkSync:Ic1,realpathSync:hc1,promises:{lstat:Sc1,readdir:Ac1,readlink:mc1,realpath:uc1}},ri=(Z)=>!Z||Z===FG||Z===bc1?FG:{...FG,...Z,promises:{...FG.promises,...Z.promises||{}}},ti=/^\\\\\?\\([a-z]:)\\?$/i,lc1=(Z)=>Z.replace(/\//g,"\\").replace(ti,"$1\\"),yc1=/[\\\/]/,F4=0,ei=1,Zg=2,$7=4,Jg=6,Xg=8,C$=10,$g=12,q4=15,qG=~q4,oM=16,ai=32,xG=64,c9=128,fF=256,EF=512,ni=xG|c9|EF,pc1=1023,rM=(Z)=>Z.isFile()?Xg:Z.isDirectory()?$7:Z.isSymbolicLink()?C$:Z.isCharacterDevice()?Zg:Z.isBlockDevice()?Jg:Z.isSocket()?$g:Z.isFIFO()?ei:F4,si=new Map,cG=(Z)=>{let J=si.get(Z);if(J)return J;let X=Z.normalize("NFKD");return si.set(Z,X),X},oi=new Map,kF=(Z)=>{let J=oi.get(Z);if(J)return J;let X=cG(Z.toLowerCase());return oi.set(Z,X),X};class eM extends GG{constructor(){super({max:256})}}class Yg extends GG{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var Qg=Symbol("PathScurry setAsCwd");class S6{name;root;roots;parent;nocase;isCWD=!1;#Z;#J;get dev(){return this.#J}#$;get mode(){return this.#$}#X;get nlink(){return this.#X}#Y;get uid(){return this.#Y}#v;get gid(){return this.#v}#H;get rdev(){return this.#H}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#z;get size(){return this.#z}#V;get blocks(){return this.#V}#Q;get atimeMs(){return this.#Q}#F;get mtimeMs(){return this.#F}#c;get ctimeMs(){return this.#c}#x;get birthtimeMs(){return this.#x}#U;get atime(){return this.#U}#P;get mtime(){return this.#P}#B;get ctime(){return this.#B}#T;get birthtime(){return this.#T}#D;#L;#j;#N;#w;#f;#K;#I;#M;#k;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=F4,X,$,Y,Q,K){if(this.name=Z,this.#D=Y?kF(Z):cG(Z),this.#K=J&pc1,this.nocase=Y,this.roots=$,this.root=X||this,this.#I=Q,this.#j=K.fullpath,this.#w=K.relative,this.#f=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=ri(K.fs)}depth(){if(this.#L!==void 0)return this.#L;if(!this.parent)return this.#L=0;return this.#L=this.parent.depth()+1}childrenCache(){return this.#I}resolve(Z){if(!Z)return this;let J=this.getRootString(Z),$=Z.substring(J.length).split(this.splitSep);return J?this.getRoot(J).#R($):this.#R($)}#R(Z){let J=this;for(let X of Z)J=J.child(X);return J}children(){let Z=this.#I.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#I.set(this,J),this.#K&=~oM,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),$=this.nocase?kF(Z):cG(Z);for(let W of X)if(W.#D===$)return W;let Y=this.parent?this.sep:"",Q=this.#j?this.#j+Y+Z:void 0,K=this.newChild(Z,F4,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=c9;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#w!==void 0)return this.#w;let Z=this.name,J=this.parent;if(!J)return this.#w=this.name;let X=J.relative();return X+(!X||!J.parent?"":this.sep)+Z}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#f!==void 0)return this.#f;let Z=this.name,J=this.parent;if(!J)return this.#f=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#j!==void 0)return this.#j;let Z=this.name,J=this.parent;if(!J)return this.#j=this.name;let $=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#j=$}fullpathPosix(){if(this.#N!==void 0)return this.#N;if(this.sep==="/")return this.#N=this.fullpath();if(!this.parent){let $=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test($))return this.#N=`//?/${$}`;else return this.#N=$}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#N=X}isUnknown(){return(this.#K&q4)===F4}isType(Z){return this[`is${Z}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#K&q4)===Xg}isDirectory(){return(this.#K&q4)===$7}isCharacterDevice(){return(this.#K&q4)===Zg}isBlockDevice(){return(this.#K&q4)===Jg}isFIFO(){return(this.#K&q4)===ei}isSocket(){return(this.#K&q4)===$g}isSymbolicLink(){return(this.#K&C$)===C$}lstatCached(){return this.#K&ai?this:void 0}readlinkCached(){return this.#M}realpathCached(){return this.#k}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#M)return!0;if(!this.parent)return!1;let Z=this.#K&q4;return!(Z!==F4&&Z!==C$||this.#K&fF||this.#K&c9)}calledReaddir(){return!!(this.#K&oM)}isENOENT(){return!!(this.#K&c9)}isNamed(Z){return!this.nocase?this.#D===cG(Z):this.#D===kF(Z)}async readlink(){let Z=this.#M;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=await this.#Z.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(J);if(X)return this.#M=X}catch(J){this.#S(J.code);return}}readlinkSync(){let Z=this.#M;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=this.#Z.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(J);if(X)return this.#M=X}catch(J){this.#S(J.code);return}}#u(Z){this.#K|=oM;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#_()}}#_(){if(this.#K&c9)return;this.#K=(this.#K|c9)&qG,this.#h()}#h(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#_()}#l(){this.#K|=EF,this.#O()}#O(){if(this.#K&xG)return;let Z=this.#K;if((Z&q4)===$7)Z&=qG;this.#K=Z|xG,this.#h()}#C(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#O();else if(Z==="ENOENT")this.#_();else this.children().provisional=0}#y(Z=""){if(Z==="ENOTDIR")this.parent.#O();else if(Z==="ENOENT")this.#_()}#S(Z=""){let J=this.#K;if(J|=fF,Z==="ENOENT")J|=c9;if(Z==="EINVAL"||Z==="UNKNOWN")J&=qG;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#O()}#b(Z,J){return this.#p(Z,J)||this.#q(Z,J)}#q(Z,J){let X=rM(Z),$=this.newChild(Z.name,X,{parent:this}),Y=$.#K&q4;if(Y!==$7&&Y!==C$&&Y!==F4)$.#K|=xG;return J.unshift($),J.provisional++,$}#p(Z,J){for(let X=J.provisional;X<J.length;X++){let $=J[X];if((this.nocase?kF(Z.name):cG(Z.name))!==$.#D)continue;return this.#A(Z,$,X,J)}}#A(Z,J,X,$){let Y=J.name;if(J.#K=J.#K&qG|rM(Z),Y!==Z.name)J.name=Z.name;if(X!==$.provisional){if(X===$.length-1)$.pop();else $.splice(X,1);$.unshift(J)}return $.provisional++,J}async lstat(){if((this.#K&c9)===0)try{return this.#E(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#y(Z.code)}}lstatSync(){if((this.#K&c9)===0)try{return this.#E(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#y(Z.code)}}#E(Z){let{atime:J,atimeMs:X,birthtime:$,birthtimeMs:Y,blksize:Q,blocks:K,ctime:W,ctimeMs:G,dev:z,gid:v,ino:H,mode:V,mtime:q,mtimeMs:F,nlink:x,rdev:c,size:w,uid:B}=Z;this.#U=J,this.#Q=X,this.#T=$,this.#x=Y,this.#W=Q,this.#V=K,this.#B=W,this.#c=G,this.#J=z,this.#v=v,this.#G=H,this.#$=V,this.#P=q,this.#F=F,this.#X=x,this.#H=c,this.#z=w,this.#Y=B;let j=rM(Z);if(this.#K=this.#K&qG|j|ai,j!==F4&&j!==$7&&j!==C$)this.#K|=xG}#m=[];#g=!1;#d(Z){this.#g=!1;let J=this.#m.slice();this.#m.length=0,J.forEach((X)=>X(null,Z))}readdirCB(Z,J=!1){if(!this.canReaddir()){if(J)Z(null,[]);else queueMicrotask(()=>Z(null,[]));return}let X=this.children();if(this.calledReaddir()){let Y=X.slice(0,X.provisional);if(J)Z(null,Y);else queueMicrotask(()=>Z(null,Y));return}if(this.#m.push(Z),this.#g)return;this.#g=!0;let $=this.fullpath();this.#Z.readdir($,{withFileTypes:!0},(Y,Q)=>{if(Y)this.#C(Y.code),X.provisional=0;else{for(let K of Q)this.#b(K,X);this.#u(X)}this.#d(X.slice(0,X.provisional));return})}#i;async readdir(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();if(this.#i)await this.#i;else{let X=()=>{};this.#i=new Promise(($)=>X=$);try{for(let $ of await this.#Z.promises.readdir(J,{withFileTypes:!0}))this.#b($,Z);this.#u(Z)}catch($){this.#C($.code),Z.provisional=0}this.#i=void 0,X()}return Z.slice(0,Z.provisional)}readdirSync(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();try{for(let X of this.#Z.readdirSync(J,{withFileTypes:!0}))this.#b(X,Z);this.#u(Z)}catch(X){this.#C(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&ni)return!1;let Z=q4&this.#K;if(!(Z===F4||Z===$7||Z===C$))return!1;return!0}shouldWalk(Z,J){return(this.#K&$7)===$7&&!(this.#K&ni)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#k)return this.#k;if((EF|fF|c9)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}realpathSync(){if(this.#k)return this.#k;if((EF|fF|c9)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}[Qg](Z){if(Z===this)return;Z.isCWD=!1,this.isCWD=!0;let J=new Set([]),X=[],$=this;while($&&$.parent)J.add($),$.#w=X.join(this.sep),$.#f=X.join("/"),$=$.parent,X.push("..");$=Z;while($&&$.parent&&!J.has($))$.#w=void 0,$.#f=void 0,$=$.parent}}class IF extends S6{sep="\\";splitSep=yc1;constructor(Z,J=F4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}newChild(Z,J=F4,X={}){return new IF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return tM.parse(Z).root}getRoot(Z){if(Z=lc1(Z.toUpperCase()),Z===this.root.name)return this.root;for(let[J,X]of Object.entries(this.roots))if(this.sameRoot(Z,J))return this.roots[Z]=X;return this.roots[Z]=new wG(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(ti,"$1\\"),Z===J}}class _F extends S6{splitSep="/";sep="/";constructor(Z,J=F4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=F4,X={}){return new _F(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class ZR{root;rootPath;roots;cwd;#Z;#J;#$;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:$,childrenCacheSize:Y=16384,fs:Q=FG}={}){if(this.#X=ri(Q),Z instanceof URL||Z.startsWith("file://"))Z=Cc1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new eM,this.#J=new eM,this.#$=new Yg(Y);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if($===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=$,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let G=this.root,z=W.length-1,v=J.sep,H=this.rootPath,V=!1;for(let q of W){let F=z--;G=G.child(q,{relative:new Array(F).fill("..").join(v),relativePosix:new Array(F).fill("..").join("/"),fullpath:H+=(V?"":v)+q}),V=!0}this.cwd=G}depth(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.depth()}childrenCache(){return this.#$}resolve(...Z){let J="";for(let Y=Z.length-1;Y>=0;Y--){let Q=Z[Y];if(!Q||Q===".")continue;if(J=J?`${Q}/${J}`:Q,this.isAbsolute(Q))break}let X=this.#Z.get(J);if(X!==void 0)return X;let $=this.cwd.resolve(J).fullpath();return this.#Z.set(J,$),$}resolvePosix(...Z){let J="";for(let Y=Z.length-1;Y>=0;Y--){let Q=Z[Y];if(!Q||Q===".")continue;if(J=J?`${Q}/${J}`:Q,this.isAbsolute(Q))break}let X=this.#J.get(J);if(X!==void 0)return X;let $=this.cwd.resolve(J).fullpathPosix();return this.#J.set(J,$),$}relative(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.relative()}relativePosix(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.relativePosix()}basename(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.name}dirname(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return(Z.parent||Z).fullpath()}async readdir(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X}=J;if(!Z.canReaddir())return[];else{let $=await Z.readdir();return X?$:$.map((Y)=>Y.name)}}readdirSync(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0}=J;if(!Z.canReaddir())return[];else if(X)return Z.readdirSync();else return Z.readdirSync().map(($)=>$.name)}async lstat(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.lstat()}lstatSync(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.lstatSync()}async readlink(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.readlink();return J?X:X?.fullpath()}readlinkSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z.withFileTypes,Z=this.cwd;let X=Z.readlinkSync();return J?X:X?.fullpath()}async realpath(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.realpath();return J?X:X?.fullpath()}realpathSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z.withFileTypes,Z=this.cwd;let X=Z.realpathSync();return J?X:X?.fullpath()}async walk(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=[];if(!Y||Y(Z))K.push(X?Z:Z.fullpath());let W=new Set,G=(v,H)=>{W.add(v),v.readdirCB((V,q)=>{if(V)return H(V);let F=q.length;if(!F)return H();let x=()=>{if(--F===0)H()};for(let c of q){if(!Y||Y(c))K.push(X?c:c.fullpath());if($&&c.isSymbolicLink())c.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(W,Q)?G(w,x):x());else if(c.shouldWalk(W,Q))G(c,x);else x()}},!0)},z=Z;return new Promise((v,H)=>{G(z,(V)=>{if(V)return H(V);v(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=[];if(!Y||Y(Z))K.push(X?Z:Z.fullpath());let W=new Set([Z]);for(let G of W){let z=G.readdirSync();for(let v of z){if(!Y||Y(v))K.push(X?v:v.fullpath());let H=v;if(v.isSymbolicLink()){if(!($&&(H=v.realpathSync())))continue;if(H.isUnknown())H.lstatSync()}if(H.shouldWalk(W,Q))W.add(H)}}return K}[Symbol.asyncIterator](){return this.iterate()}iterate(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;return this.stream(Z,J)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J;if(!Y||Y(Z))yield X?Z:Z.fullpath();let K=new Set([Z]);for(let W of K){let G=W.readdirSync();for(let z of G){if(!Y||Y(z))yield X?z:z.fullpath();let v=z;if(z.isSymbolicLink()){if(!($&&(v=z.realpathSync())))continue;if(v.isUnknown())v.lstatSync()}if(v.shouldWalk(K,Q))K.add(v)}}}stream(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new T$({objectMode:!0});if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=(x,c,w=!1)=>{if(x)return K.emit("error",x);if($&&!w){let B=[];for(let j of c)if(j.isSymbolicLink())B.push(j.realpath().then((L)=>L?.isUnknown()?L.lstat():L));if(B.length){Promise.all(B).then(()=>q(null,c,!0));return}}for(let B of c)if(B&&(!Y||Y(B))){if(!K.write(X?B:B.fullpath()))H=!0}z--;for(let B of c){let j=B.realpathCached()||B;if(j.shouldWalk(W,Q))G.push(j)}if(H&&!K.flowing)K.once("drain",v);else if(!F)v()},F=!0;V.readdirCB(q,!0),F=!1}};return v(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new T$({objectMode:!0}),W=new Set;if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=V.readdirSync();for(let F of q)if(!Y||Y(F)){if(!K.write(X?F:F.fullpath()))H=!0}z--;for(let F of q){let x=F;if(F.isSymbolicLink()){if(!($&&(x=F.realpathSync())))continue;if(x.isUnknown())x.lstatSync()}if(x.shouldWalk(W,Q))G.push(x)}}if(H&&!K.flowing)K.once("drain",v)};return v(),K}chdir(Z=this.cwd){let J=this.cwd;this.cwd=typeof Z==="string"?this.cwd.resolve(Z):Z,this.cwd[Qg](J)}}class wG extends ZR{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,tM,"\\",{...J,nocase:X});this.nocase=X;for(let $=this.cwd;$;$=$.parent)$.nocase=this.nocase}parseRootPath(Z){return tM.parse(Z).root.toUpperCase()}newRoot(Z){return new IF(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class UG extends ZR{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,Tc1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new _F(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class bF extends UG{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var GR6=process.platform==="win32"?IF:_F,Kg=process.platform==="win32"?wG:process.platform==="darwin"?bF:UG;var ic1=(Z)=>Z.length>=1,gc1=(Z)=>Z.length>=1;class Q3{#Z;#J;#$;length;#X;#Y;#v;#H;#W;#G;#z=!0;constructor(Z,J,X,$){if(!ic1(Z))throw new TypeError("empty pattern list");if(!gc1(J))throw new TypeError("empty glob list");if(J.length!==Z.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw new TypeError("index out of range");if(this.#Z=Z,this.#J=J,this.#$=X,this.#X=$,this.#$===0){if(this.isUNC()){let[Y,Q,K,W,...G]=this.#Z,[z,v,H,V,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let F=[Y,Q,K,W,""].join("/"),x=[z,v,H,V,""].join("/");this.#Z=[F,...G],this.#J=[x,...q],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[Y,...Q]=this.#Z,[K,...W]=this.#J;if(Q[0]==="")Q.shift(),W.shift();let G=Y+"/",z=K+"/";this.#Z=[G,...Q],this.#J=[z,...W],this.length=this.#Z.length}}}pattern(){return this.#Z[this.#$]}isString(){return typeof this.#Z[this.#$]==="string"}isGlobstar(){return this.#Z[this.#$]===J6}isRegExp(){return this.#Z[this.#$]instanceof RegExp}globString(){return this.#v=this.#v||(this.#$===0?this.isAbsolute()?this.#J[0]+this.#J.slice(1).join("/"):this.#J.join("/"):this.#J.slice(this.#$).join("/"))}hasMore(){return this.length>this.#$+1}rest(){if(this.#Y!==void 0)return this.#Y;if(!this.hasMore())return this.#Y=null;return this.#Y=new Q3(this.#Z,this.#J,this.#$+1,this.#X),this.#Y.#G=this.#G,this.#Y.#W=this.#W,this.#Y.#H=this.#H,this.#Y}isUNC(){let Z=this.#Z;return this.#W!==void 0?this.#W:this.#W=this.#X==="win32"&&this.#$===0&&Z[0]===""&&Z[1]===""&&typeof Z[2]==="string"&&!!Z[2]&&typeof Z[3]==="string"&&!!Z[3]}isDrive(){let Z=this.#Z;return this.#H!==void 0?this.#H:this.#H=this.#X==="win32"&&this.#$===0&&this.length>1&&typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0])}isAbsolute(){let Z=this.#Z;return this.#G!==void 0?this.#G:this.#G=Z[0]===""&&Z.length>1||this.isDrive()||this.isUNC()}root(){let Z=this.#Z[0];return typeof Z==="string"&&this.isAbsolute()&&this.#$===0?Z:""}checkFollowGlobstar(){return!(this.#$===0||!this.isGlobstar()||!this.#z)}markFollowGlobstar(){if(this.#$===0||!this.isGlobstar()||!this.#z)return!1;return this.#z=!1,!0}}var dc1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class BG{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:$,noglobstar:Y,platform:Q=dc1}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=Q,this.mmopts={dot:!0,nobrace:J,nocase:X,noext:$,noglobstar:Y,optimizationLevel:2,platform:Q,nocomment:!0,nonegate:!0};for(let K of Z)this.add(K)}add(Z){let J=new H4(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let $=J.set[X],Y=J.globParts[X];if(!$||!Y)throw new Error("invalid pattern object");while($[0]==="."&&Y[0]===".")$.shift(),Y.shift();let Q=new Q3($,Y,0,this.platform),K=new H4(Q.globString(),this.mmopts),W=Y[Y.length-1]==="**",G=Q.isAbsolute();if(G)this.absolute.push(K);else this.relative.push(K);if(W)if(G)this.absoluteChildren.push(K);else this.relativeChildren.push(K)}}ignored(Z){let J=Z.fullpath(),X=`${J}/`,$=Z.relative()||".",Y=`${$}/`;for(let Q of this.relative)if(Q.match($)||Q.match(Y))return!0;for(let Q of this.absolute)if(Q.match(J)||Q.match(X))return!0;return!1}childrenIgnored(Z){let J=Z.fullpath()+"/",X=(Z.relative()||".")+"/";for(let $ of this.relativeChildren)if($.match(X))return!0;for(let $ of this.absoluteChildren)if($.match(J))return!0;return!1}}class JR{store;constructor(Z=new Map){this.store=Z}copy(){return new JR(new Map(this.store))}hasWalked(Z,J){return this.store.get(Z.fullpath())?.has(J.globString())}storeWalked(Z,J){let X=Z.fullpath(),$=this.store.get(X);if($)$.add(J.globString());else this.store.set(X,new Set([J.globString()]))}}class Wg{store=new Map;add(Z,J,X){let $=(J?2:0)|(X?1:0),Y=this.store.get(Z);this.store.set(Z,Y===void 0?$:$&Y)}entries(){return[...this.store.entries()].map(([Z,J])=>[Z,!!(J&2),!!(J&1)])}}class Gg{store=new Map;add(Z,J){if(!Z.canReaddir())return;let X=this.store.get(Z);if(X){if(!X.find(($)=>$.globString()===J.globString()))X.push(J)}else this.store.set(Z,[J])}get(Z){let J=this.store.get(Z);if(!J)throw new Error("attempting to walk unknown path");return J}entries(){return this.keys().map((Z)=>[Z,this.store.get(Z)])}keys(){return[...this.store.keys()].filter((Z)=>Z.canReaddir())}}class jG{hasWalkedCache;matches=new Wg;subwalks=new Gg;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new JR}processPatterns(Z,J){this.patterns=J;let X=J.map(($)=>[Z,$]);for(let[$,Y]of X){this.hasWalkedCache.storeWalked($,Y);let Q=Y.root(),K=Y.isAbsolute()&&this.opts.absolute!==!1;if(Q){$=$.resolve(Q==="/"&&this.opts.root!==void 0?this.opts.root:Q);let v=Y.rest();if(!v){this.matches.add($,!0,!1);continue}else Y=v}if($.isENOENT())continue;let W,G,z=!1;while(typeof(W=Y.pattern())==="string"&&(G=Y.rest()))$=$.resolve(W),Y=G,z=!0;if(W=Y.pattern(),G=Y.rest(),z){if(this.hasWalkedCache.hasWalked($,Y))continue;this.hasWalkedCache.storeWalked($,Y)}if(typeof W==="string"){let v=W===".."||W===""||W===".";this.matches.add($.resolve(W),K,v);continue}else if(W===J6){if(!$.isSymbolicLink()||this.follow||Y.checkFollowGlobstar())this.subwalks.add($,Y);let v=G?.pattern(),H=G?.rest();if(!G||(v===""||v===".")&&!H)this.matches.add($,K,v===""||v===".");else if(v===".."){let V=$.parent||$;if(!H)this.matches.add(V,K,!0);else if(!this.hasWalkedCache.hasWalked(V,H))this.subwalks.add(V,H)}}else if(W instanceof RegExp)this.subwalks.add($,Y)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new jG(this.opts,this.hasWalkedCache)}filterEntries(Z,J){let X=this.subwalks.get(Z),$=this.child();for(let Y of J)for(let Q of X){let K=Q.isAbsolute(),W=Q.pattern(),G=Q.rest();if(W===J6)$.testGlobstar(Y,Q,G,K);else if(W instanceof RegExp)$.testRegExp(Y,W,G,K);else $.testString(Y,W,G,K)}return $}testGlobstar(Z,J,X,$){if(this.dot||!Z.name.startsWith(".")){if(!J.hasMore())this.matches.add(Z,$,!1);if(Z.canReaddir()){if(this.follow||!Z.isSymbolicLink())this.subwalks.add(Z,J);else if(Z.isSymbolicLink()){if(X&&J.checkFollowGlobstar())this.subwalks.add(Z,X);else if(J.markFollowGlobstar())this.subwalks.add(Z,J)}}}if(X){let Y=X.pattern();if(typeof Y==="string"&&Y!==".."&&Y!==""&&Y!==".")this.testString(Z,Y,X.rest(),$);else if(Y===".."){let Q=Z.parent||Z;this.subwalks.add(Q,X)}else if(Y instanceof RegExp)this.testRegExp(Z,Y,X.rest(),$)}}testRegExp(Z,J,X,$){if(!J.test(Z.name))return;if(!X)this.matches.add(Z,$,!1);else this.subwalks.add(Z,X)}testString(Z,J,X,$){if(!Z.isNamed(J))return;if(!X)this.matches.add(Z,$,!1);else this.subwalks.add(Z,X)}}var ac1=(Z,J)=>typeof Z==="string"?new BG([Z],J):Array.isArray(Z)?new BG(Z,J):Z;class XR{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#J;#$;signal;maxDepth;includeChildMatches;constructor(Z,J,X){if(this.patterns=Z,this.path=J,this.opts=X,this.#$=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#J=ac1(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw new Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#X(Z){return this.seen.has(Z)||!!this.#J?.ignored?.(Z)}#Y(Z){return!!this.#J?.childrenIgnored?.(Z)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Z=void 0;while(!this.paused&&(Z=this.#Z.shift()))Z()}onResume(Z){if(this.signal?.aborted)return;if(!this.paused)Z();else this.#Z.push(Z)}async matchCheck(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||await Z.realpath(),!X)return;Z=X}let Y=Z.isUnknown()||this.opts.stat?await Z.lstat():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=await Y.realpath();if(Q&&(Q.isUnknown()||this.opts.stat))await Q.lstat()}return this.matchCheckTest(Y,J)}matchCheckTest(Z,J){return Z&&(this.maxDepth===1/0||Z.depth()<=this.maxDepth)&&(!J||Z.canReaddir())&&(!this.opts.nodir||!Z.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Z.isSymbolicLink()||!Z.realpathCached()?.isDirectory())&&!this.#X(Z)?Z:void 0}matchCheckSync(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||Z.realpathSync(),!X)return;Z=X}let Y=Z.isUnknown()||this.opts.stat?Z.lstatSync():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=Y.realpathSync();if(Q&&(Q?.isUnknown()||this.opts.stat))Q.lstatSync()}return this.matchCheckTest(Y,J)}matchFinish(Z,J){if(this.#X(Z))return;if(!this.includeChildMatches&&this.#J?.add){let Y=`${Z.relativePosix()}/**`;this.#J.add(Y)}let X=this.opts.absolute===void 0?J:this.opts.absolute;this.seen.add(Z);let $=this.opts.mark&&Z.isDirectory()?this.#$:"";if(this.opts.withFileTypes)this.matchEmit(Z);else if(X){let Y=this.opts.posix?Z.fullpathPosix():Z.fullpath();this.matchEmit(Y+$)}else{let Y=this.opts.posix?Z.relativePosix():Z.relative(),Q=this.opts.dotRelative&&!Y.startsWith(".."+this.#$)?"."+this.#$:"";this.matchEmit(!Y?"."+$:Q+Y+$)}}async match(Z,J,X){let $=await this.matchCheck(Z,X);if($)this.matchFinish($,J)}matchSync(Z,J,X){let $=this.matchCheckSync(Z,X);if($)this.matchFinish($,J)}walkCB(Z,J,X){if(this.signal?.aborted)X();this.walkCB2(Z,J,new jG(this.opts),X)}walkCB2(Z,J,X,$){if(this.#Y(Z))return $();if(this.signal?.aborted)$();if(this.paused){this.onResume(()=>this.walkCB2(Z,J,X,$));return}X.processPatterns(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;Y++,this.match(K,W,G).then(()=>Q())}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;Y++;let W=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,W,X,Q);else K.readdirCB((G,z)=>this.walkCB3(K,z,X,Q),!0)}Q()}walkCB3(Z,J,X,$){X=X.filterEntries(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;Y++,this.match(K,W,G).then(()=>Q())}for(let[K,W]of X.subwalks.entries())Y++,this.walkCB2(K,W,X.child(),Q);Q()}walkCBSync(Z,J,X){if(this.signal?.aborted)X();this.walkCB2Sync(Z,J,new jG(this.opts),X)}walkCB2Sync(Z,J,X,$){if(this.#Y(Z))return $();if(this.signal?.aborted)$();if(this.paused){this.onResume(()=>this.walkCB2Sync(Z,J,X,$));return}X.processPatterns(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;Y++;let W=K.readdirSync();this.walkCB3Sync(K,W,X,Q)}Q()}walkCB3Sync(Z,J,X,$){X=X.filterEntries(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let[K,W]of X.subwalks.entries())Y++,this.walkCB2Sync(K,W,X.child(),Q);Q()}}class hF extends XR{matches=new Set;constructor(Z,J,X){super(Z,J,X)}matchEmit(Z){this.matches.add(Z)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Z,J)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)J(this.signal.reason);else Z(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class SF extends XR{results;constructor(Z,J,X){super(Z,J,X);this.results=new T$({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(Z){if(this.results.write(Z),!this.results.flowing)this.pause()}stream(){let Z=this.path;if(Z.isUnknown())Z.lstat().then(()=>{this.walkCB(Z,this.patterns,()=>this.results.end())});else this.walkCB(Z,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var sc1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Y7{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Z,J){if(!J)throw new TypeError("glob options required");if(this.withFileTypes=!!J.withFileTypes,this.signal=J.signal,this.follow=!!J.follow,this.dot=!!J.dot,this.dotRelative=!!J.dotRelative,this.nodir=!!J.nodir,this.mark=!!J.mark,!J.cwd)this.cwd="";else if(J.cwd instanceof URL||J.cwd.startsWith("file://"))J.cwd=nc1(J.cwd);if(this.cwd=J.cwd||"",this.root=J.root,this.magicalBraces=!!J.magicalBraces,this.nobrace=!!J.nobrace,this.noext=!!J.noext,this.realpath=!!J.realpath,this.absolute=J.absolute,this.includeChildMatches=J.includeChildMatches!==!1,this.noglobstar=!!J.noglobstar,this.matchBase=!!J.matchBase,this.maxDepth=typeof J.maxDepth==="number"?J.maxDepth:1/0,this.stat=!!J.stat,this.ignore=J.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof Z==="string")Z=[Z];if(this.windowsPathsNoEscape=!!J.windowsPathsNoEscape||J.allowWindowsEscape===!1,this.windowsPathsNoEscape)Z=Z.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(J.noglobstar)throw new TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||sc1,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?wG:J.platform==="darwin"?bF:J.platform?UG:Kg;this.scurry=new W(this.cwd,{nocase:J.nocase,fs:J.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",$={...J,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:X,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},Y=this.pattern.map((W)=>new H4(W,$)),[Q,K]=Y.reduce((W,G)=>{return W[0].push(...G.set),W[1].push(...G.globParts),W},[[],[]]);this.patterns=Q.map((W,G)=>{let z=K[G];if(!z)throw new Error("invalid pattern object");return new Q3(W,z,0,this.platform)})}async walk(){return[...await new hF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new hF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new SF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new SF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var $R=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new H4(X,J).hasMagic())return!0;return!1};function mF(Z,J={}){return new Y7(Z,J).streamSync()}function vg(Z,J={}){return new Y7(Z,J).stream()}function Vg(Z,J={}){return new Y7(Z,J).walkSync()}async function zg(Z,J={}){return new Y7(Z,J).walk()}function uF(Z,J={}){return new Y7(Z,J).iterateSync()}function Hg(Z,J={}){return new Y7(Z,J).iterate()}var oc1=mF,rc1=Object.assign(vg,{sync:mF}),tc1=uF,ec1=Object.assign(Hg,{sync:uF}),Zw1=Object.assign(Vg,{stream:mF,iterate:uF}),AF=Object.assign(zg,{glob:zg,globSync:Vg,sync:Zw1,globStream:vg,stream:rc1,globStreamSync:mF,streamSync:oc1,globIterate:Hg,iterate:ec1,globIterateSync:uF,iterateSync:tc1,Glob:Y7,hasMagic:$R,escape:Z3,unescape:F9});AF.glob=AF;class YR{constructor(){this._listeners={}}addEventListener(Z,J){let X=this._listeners;if(X[Z]===void 0)X[Z]=[];if(X[Z].indexOf(J)===-1)X[Z].push(J);return this}removeEventListener(Z,J){let $=this._listeners[Z];if($!==void 0){let Y=$.indexOf(J);if(Y!==-1)$.splice(Y,1)}return this}dispatchEvent(Z){let X=this._listeners[Z.type];if(X!==void 0){let $=X.slice(0);for(let Y=0,Q=$.length;Y<Q;Y++)$[Y].call(this,Z)}return this}dispose(){for(let Z in this._listeners)delete this._listeners[Z]}}class XZ{constructor(Z,J,X,$={}){if(this._name=void 0,this._parent=void 0,this._child=void 0,this._attributes=void 0,this._disposed=!1,this._name=Z,this._parent=J,this._child=X,this._attributes=$,!J.isOnGraph(X))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(Z){return this._child=Z,this}getAttributes(){return this._attributes}dispose(){if(this._disposed)return;this._parent._destroyRef(this),this._disposed=!0}isDisposed(){return this._disposed}}class lF extends YR{constructor(...Z){super(...Z);this._emptySet=new Set,this._edges=new Set,this._parentEdges=new Map,this._childEdges=new Map}listEdges(){return Array.from(this._edges)}listParentEdges(Z){return Array.from(this._childEdges.get(Z)||this._emptySet)}listParents(Z){let J=new Set;for(let X of this.listParentEdges(Z))J.add(X.getParent());return Array.from(J)}listChildEdges(Z){return Array.from(this._parentEdges.get(Z)||this._emptySet)}listChildren(Z){let J=new Set;for(let X of this.listChildEdges(Z))J.add(X.getChild());return Array.from(J)}disconnectParents(Z,J){for(let X of this.listParentEdges(Z))if(!J||J(X.getParent()))X.dispose();return this}_createEdge(Z,J,X,$){let Y=new XZ(Z,J,X,$);this._edges.add(Y);let Q=Y.getParent();if(!this._parentEdges.has(Q))this._parentEdges.set(Q,new Set);this._parentEdges.get(Q).add(Y);let K=Y.getChild();if(!this._childEdges.has(K))this._childEdges.set(K,new Set);return this._childEdges.get(K).add(Y),Y}_destroyEdge(Z){return this._edges.delete(Z),this._parentEdges.get(Z.getParent()).delete(Z),this._childEdges.get(Z.getChild()).delete(Z),this}}function LG(){return LG=Object.assign||function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)if(Object.prototype.hasOwnProperty.call(X,$))Z[$]=X[$]}return Z},LG.apply(this,arguments)}class w9{constructor(Z){if(this.list=[],Z)for(let J of Z)this.list.push(J)}add(Z){this.list.push(Z)}remove(Z){let J=this.list.indexOf(Z);if(J>=0)this.list.splice(J,1)}removeChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);for(let X of J)this.remove(X);return J}listRefsByChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);return J}values(){return this.list}}class x1{constructor(Z){if(this.set=new Set,this.map=new Map,Z)for(let J of Z)this.add(J)}add(Z){let J=Z.getChild();this.removeChild(J),this.set.add(Z),this.map.set(J,Z)}remove(Z){this.set.delete(Z),this.map.delete(Z.getChild())}removeChild(Z){let J=this.map.get(Z)||null;if(J)this.remove(J);return J}getRefByChild(Z){return this.map.get(Z)||null}values(){return Array.from(this.set)}}class A6{constructor(Z){if(this.map={},Z)Object.assign(this.map,Z)}set(Z,J){this.map[Z]=J}delete(Z){delete this.map[Z]}get(Z){return this.map[Z]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}}var H1=Symbol("attributes"),_J=Symbol("immutableKeys");class yF extends YR{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[H1]=void 0,this[_J]=void 0,this.graph=Z,this[_J]=new Set,this[H1]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let $=Z[X];if($ instanceof yF){let Y=this.graph._createEdge(X,this,$);this[_J].add(X),J[X]=Y}else J[X]=$}return J}isOnGraph(Z){return this.graph===Z.graph}isDisposed(){return this._disposed}dispose(){if(this._disposed)return;this.graph.listChildEdges(this).forEach((Z)=>Z.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"})}detach(){return this.graph.disconnectParents(this),this}swap(Z,J){for(let X in this[H1]){let $=this[H1][X];if($ instanceof XZ){let Y=$;if(Y.getChild()===Z)this.setRef(X,J,Y.getAttributes())}else if($ instanceof w9)for(let Y of $.listRefsByChild(Z)){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if($ instanceof x1){let Y=$.getRefByChild(Z);if(Y){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if($ instanceof A6)for(let Y of $.keys()){let Q=$.get(Y);if(Q.getChild()===Z)this.setRefMap(X,Y,J,Q.getAttributes())}}return this}get(Z){return this[H1][Z]}set(Z,J){return this[H1][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[H1][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[_J].has(Z))throw new Error(`Cannot overwrite immutable attribute, "${Z}".`);let $=this[H1][Z];if($)$.dispose();if(!J)return this;let Y=this.graph._createEdge(Z,this,J,X);return this[H1][Z]=Y,this.dispatchEvent({type:"change",attribute:Z})}listRefs(Z){return this.assertRefList(Z).values().map((X)=>X.getChild())}addRef(Z,J,X){let $=this.graph._createEdge(Z,this,J,X);return this.assertRefList(Z).add($),this.dispatchEvent({type:"change",attribute:Z})}removeRef(Z,J){let X=this.assertRefList(Z);if(X instanceof w9)for(let $ of X.listRefsByChild(J))$.dispose();else{let $=X.getRefByChild(J);if($)$.dispose()}return this}assertRefList(Z){let J=this[H1][Z];if(J instanceof w9||J instanceof x1)return J;throw new Error(`Expected RefList or RefSet for attribute "${Z}"`)}listRefMapKeys(Z){return this.assertRefMap(Z).keys()}listRefMapValues(Z){return this.assertRefMap(Z).values().map((J)=>J.getChild())}getRefMap(Z,J){let $=this.assertRefMap(Z).get(J);return $?$.getChild():null}setRefMap(Z,J,X,$){let Y=this.assertRefMap(Z),Q=Y.get(J);if(Q)Q.dispose();if(!X)return this;$=Object.assign($||{},{key:J});let K=this.graph._createEdge(Z,this,X,LG({},$,{key:J}));return Y.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[H1][Z];if(J instanceof A6)return J;throw new Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(LG({},Z,{target:this})),this.graph.dispatchEvent(LG({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[H1][J]===Z){if(this[H1][J]=null,this[_J].has(J))Z.getChild().dispose()}else if(this[H1][J]instanceof w9)this[H1][J].remove(Z);else if(this[H1][J]instanceof x1)this[H1][J].remove(Z);else if(this[H1][J]instanceof A6){let X=this[H1][J];for(let $ of X.keys())if(X.get($)===Z)X.delete($)}else return;this.graph._destroyEdge(Z),this.dispatchEvent({type:"change",attribute:J})}}var Bg="v4.2.1",k$="@glb.bin",i;(function(Z){Z.ACCESSOR="Accessor",Z.ANIMATION="Animation",Z.ANIMATION_CHANNEL="AnimationChannel",Z.ANIMATION_SAMPLER="AnimationSampler",Z.BUFFER="Buffer",Z.CAMERA="Camera",Z.MATERIAL="Material",Z.MESH="Mesh",Z.PRIMITIVE="Primitive",Z.PRIMITIVE_TARGET="PrimitiveTarget",Z.NODE="Node",Z.ROOT="Root",Z.SCENE="Scene",Z.SKIN="Skin",Z.TEXTURE="Texture",Z.TEXTURE_INFO="TextureInfo"})(i||(i={}));var nF;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(nF||(nF={}));var I5;(function(Z){Z.ARRAY_BUFFER="ARRAY_BUFFER",Z.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",Z.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",Z.OTHER="OTHER",Z.SPARSE="SPARSE"})(I5||(I5={}));var v5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(v5||(v5={}));var $Z;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})($Z||($Z={}));var hJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array};class E0{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let $=0;$<J.length;$++)X[$]=J.charCodeAt($);return X}else{let J=Z.split(",")[1],X=Z.indexOf("base64")>=0;return Buffer.from(J,X?"base64":"utf8")}}static encodeText(Z){return new TextEncoder().encode(Z)}static decodeText(Z){return new TextDecoder().decode(Z)}static concat(Z){let J=0;for(let Y of Z)J+=Y.byteLength;let X=new Uint8Array(J),$=0;for(let Y of Z)X.set(Y,$),$+=Y.byteLength;return X}static pad(Z,J=0){let X=this.padNumber(Z.byteLength);if(X===Z.byteLength)return Z;let $=new Uint8Array(X);if($.set(Z),J!==0)for(let Y=Z.byteLength;Y<X;Y++)$[Y]=J;return $}static padNumber(Z){return Math.ceil(Z/4)*4}static equals(Z,J){if(Z===J)return!0;if(Z.byteLength!==J.byteLength)return!1;let X=Z.byteLength;while(X--)if(Z[X]!==J[X])return!1;return!0}static toView(Z,J=0,X=1/0){return new Uint8Array(Z.buffer,Z.byteOffset+J,Math.min(Z.byteLength,X))}static assertView(Z){if(Z&&!ArrayBuffer.isView(Z))throw new Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class vR{static hexToFactor(Z,J){Z=Math.floor(Z);let X=J;return X[0]=(Z>>16&255)/255,X[1]=(Z>>8&255)/255,X[2]=(Z&255)/255,this.convertSRGBToLinear(J,J)}static factorToHex(Z){let J=[...Z],[X,$,Y]=this.convertLinearToSRGB(Z,J);return X*255<<16^$*255<<8^Y*255<<0}static convertSRGBToLinear(Z,J){let X=Z,$=J;for(let Y=0;Y<3;Y++)$[Y]=X[Y]<0.04045?X[Y]*0.0773993808:Math.pow(X[Y]*0.9478672986+0.0521327014,2.4);return J}static convertLinearToSRGB(Z,J){let X=Z,$=J;for(let Y=0;Y<3;Y++)$[Y]=X[Y]<0.0031308?X[Y]*12.92:1.055*Math.pow(X[Y],0.41666)-0.055;return J}}class jg{match(Z){return Z.length>=3&&Z[0]===255&&Z[1]===216&&Z[2]===255}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset+4),X,$;while(J.byteLength){if(X=J.getUint16(0,!1),Jw1(J,X),$=J.getUint8(X+1),$===192||$===193||$===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class rF{match(Z){return Z.length>=8&&Z[0]===137&&Z[1]===80&&Z[2]===78&&Z[3]===71&&Z[4]===13&&Z[5]===10&&Z[6]===26&&Z[7]===10}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset);if(E0.decodeText(Z.slice(12,16))===rF.PNG_FRIED_CHUNK_NAME)return[J.getUint32(32,!1),J.getUint32(36,!1)];return[J.getUint32(16,!1),J.getUint32(20,!1)]}getChannels(Z){return 4}}rF.PNG_FRIED_CHUNK_NAME="CgBI";class E5{static registerFormat(Z,J){this.impls[Z]=J}static getMimeType(Z){for(let J in this.impls)if(this.impls[J].match(Z))return J;return null}static getSize(Z,J){if(!this.impls[J])return null;return this.impls[J].getSize(Z)}static getChannels(Z,J){if(!this.impls[J])return null;return this.impls[J].getChannels(Z)}static getVRAMByteLength(Z,J){if(!this.impls[J])return null;if(this.impls[J].getVRAMByteLength)return this.impls[J].getVRAMByteLength(Z);let X=0,$=4,Y=this.getSize(Z,J);if(!Y)return null;while(Y[0]>1||Y[1]>1)X+=Y[0]*Y[1]*$,Y[0]=Math.max(Math.floor(Y[0]/2),1),Y[1]=Math.max(Math.floor(Y[1]/2),1);return X+=1*$,X}static mimeTypeToExtension(Z){if(Z==="image/jpeg")return"jpg";return Z.split("/").pop()}static extensionToMimeType(Z){if(Z==="jpg")return"image/jpeg";if(!Z)return"";return`image/${Z}`}}E5.impls={"image/jpeg":new jg,"image/png":new rF};function Jw1(Z,J){if(J>Z.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return Z}class YZ{static basename(Z){let J=Z.split(/[\\/]/).pop();return J.substring(0,J.lastIndexOf("."))}static extension(Z){if(Z.startsWith("data:image/")){let J=Z.match(/data:(image\/\w+)/)[1];return E5.mimeTypeToExtension(J)}else if(Z.startsWith("data:model/gltf+json"))return"gltf";else if(Z.startsWith("data:model/gltf-binary"))return"glb";else if(Z.startsWith("data:application/"))return"bin";return Z.split(/[\\/]/).pop().split(/[.]/).pop()}}var KR=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function Xw1(){var Z=new KR(3);if(KR!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function QR(Z){var J=Z[0],X=Z[1],$=Z[2];return Math.hypot(J,X,$)}function $w1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=X[3]*$+X[7]*Y+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*$+X[4]*Y+X[8]*Q+X[12])/K,Z[1]=(X[1]*$+X[5]*Y+X[9]*Q+X[13])/K,Z[2]=(X[2]*$+X[6]*Y+X[10]*Q+X[14])/K,Z}(function(){var Z=Xw1();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=3;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();function RG(Z){let J=Lg(),X=Z.propertyType===i.NODE?[Z]:Z.listChildren();for(let $ of X)$.traverse((Y)=>{let Q=Y.getMesh();if(!Q)return;let K=Yw1(Q,Y.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))WR(K.min,J),WR(K.max,J)});return J}function Yw1(Z,J){let X=Lg();for(let $ of Z.listPrimitives()){let Y=$.getAttribute("POSITION"),Q=$.getIndices();if(!Y)continue;let K=[0,0,0],W=[0,0,0];for(let G=0,z=Q?Q.getCount():Y.getCount();G<z;G++){let v=Q?Q.getScalar(G):G;K=Y.getElement(v,K),W=$w1(W,K,J),WR(W,X)}}return X}function WR(Z,J){for(let X=0;X<3;X++)J.min[X]=Math.min(Z[X],J.min[X]),J.max[X]=Math.max(Z[X],J.max[X])}function Lg(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}var qg="https://null.example";class x4{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return YZ.basename(new URL(Z,qg).pathname)}static extension(Z){return YZ.extension(new URL(Z,qg).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),$=J.split("/");X.pop();for(let Y=0;Y<$.length;Y++){if($[Y]===".")continue;if($[Y]==="..")X.pop();else X.push($[Y])}return X.join("/")}static isAbsoluteURL(Z){return this.PROTOCOL_REGEXP.test(Z)}static isRelativePath(Z){return!/^(?:[a-zA-Z]+:)?\//.test(Z)}}x4.DEFAULT_INIT={};x4.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;function Fg(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function f$(Z){if(Fg(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Fg(X)===!1)return!1;if(Object.hasOwn(X,"isPrototypeOf")===!1)return!1;return!0}var GR,DG;(function(Z){Z[Z.SILENT=4]="SILENT",Z[Z.ERROR=3]="ERROR",Z[Z.WARN=2]="WARN",Z[Z.INFO=1]="INFO",Z[Z.DEBUG=0]="DEBUG"})(DG||(DG={}));class z5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=z5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=z5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=z5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=z5.Verbosity.ERROR)console.error(Z)}}GR=z5;z5.Verbosity=DG;z5.DEFAULT_INSTANCE=new GR(GR.Verbosity.INFO);function Qw1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],x=Z[14],c=Z[15],w=J*K-X*Q,B=J*W-$*Q,j=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,N=z*F-v*q,P=z*x-H*q,O=z*c-V*q,_=v*x-H*F,k=v*c-V*F,h=H*c-V*x;return w*h-B*k+j*_+L*O-R*P+M*N}function Kw1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],x=J[12],c=J[13],w=J[14],B=J[15],j=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=j*$+L*W+R*H+M*x,Z[1]=j*Y+L*G+R*V+M*c,Z[2]=j*Q+L*z+R*q+M*w,Z[3]=j*K+L*v+R*F+M*B,j=X[4],L=X[5],R=X[6],M=X[7],Z[4]=j*$+L*W+R*H+M*x,Z[5]=j*Y+L*G+R*V+M*c,Z[6]=j*Q+L*z+R*q+M*w,Z[7]=j*K+L*v+R*F+M*B,j=X[8],L=X[9],R=X[10],M=X[11],Z[8]=j*$+L*W+R*H+M*x,Z[9]=j*Y+L*G+R*V+M*c,Z[10]=j*Q+L*z+R*q+M*w,Z[11]=j*K+L*v+R*F+M*B,j=X[12],L=X[13],R=X[14],M=X[15],Z[12]=j*$+L*W+R*H+M*x,Z[13]=j*Y+L*G+R*V+M*c,Z[14]=j*Q+L*z+R*q+M*w,Z[15]=j*K+L*v+R*F+M*B,Z}function Ww1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],z=J[9],v=J[10];return Z[0]=Math.hypot(X,$,Y),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,z,v),Z}function Gw1(Z,J){var X=new KR(3);Ww1(X,J);var $=1/X[0],Y=1/X[1],Q=1/X[2],K=J[0]*$,W=J[1]*Y,G=J[2]*Q,z=J[4]*$,v=J[5]*Y,H=J[6]*Q,V=J[8]*$,q=J[9]*Y,F=J[10]*Q,x=K+v+F,c=0;if(x>0)c=Math.sqrt(x+1)*2,Z[3]=0.25*c,Z[0]=(H-q)/c,Z[1]=(V-G)/c,Z[2]=(W-z)/c;else if(K>v&&K>F)c=Math.sqrt(1+K-v-F)*2,Z[3]=(H-q)/c,Z[0]=0.25*c,Z[1]=(W+z)/c,Z[2]=(V+G)/c;else if(v>F)c=Math.sqrt(1+v-K-F)*2,Z[3]=(V-G)/c,Z[0]=(W+z)/c,Z[1]=0.25*c,Z[2]=(H+q)/c;else c=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/c,Z[0]=(V+G)/c,Z[1]=(H+q)/c,Z[2]=0.25*c;return Z}class I0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(I0.clamp(Z,0,1)*65535);case 5121:return Math.round(I0.clamp(Z,0,1)*255);case 5122:return Math.round(I0.clamp(Z,-1,1)*32767);case 5120:return Math.round(I0.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,$){let Y=QR([Z[0],Z[1],Z[2]]),Q=QR([Z[4],Z[5],Z[6]]),K=QR([Z[8],Z[9],Z[10]]);if(Qw1(Z)<0)Y=-Y;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),z=1/Y,v=1/Q,H=1/K;G[0]*=z,G[1]*=z,G[2]*=z,G[4]*=v,G[5]*=v,G[6]*=v,G[8]*=H,G[9]*=H,G[10]*=H,Gw1(X,G),$[0]=Y,$[1]=Q,$[2]=K}static compose(Z,J,X,$){let Y=$,Q=J[0],K=J[1],W=J[2],G=J[3],z=Q+Q,v=K+K,H=W+W,V=Q*z,q=Q*v,F=Q*H,x=K*v,c=K*H,w=W*H,B=G*z,j=G*v,L=G*H,R=X[0],M=X[1],N=X[2];return Y[0]=(1-(x+w))*R,Y[1]=(q+L)*R,Y[2]=(F-j)*R,Y[3]=0,Y[4]=(q-L)*M,Y[5]=(1-(V+w))*M,Y[6]=(c+B)*M,Y[7]=0,Y[8]=(F+j)*N,Y[9]=(c-B)*N,Y[10]=(1-(V+x))*N,Y[11]=0,Y[12]=Z[0],Y[13]=Z[1],Y[14]=Z[2],Y[15]=1,Y}}function zw1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),$=J.getChild();return X===$||X.equals($)}function vw1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),$=J.values();if(X.length!==$.length)return!1;for(let Y=0;Y<X.length;Y++){let Q=X[Y],K=$[Y];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function Vw1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),$=J.keys();if(X.length!==$.length)return!1;for(let Y of X){let Q=Z.get(Y),K=J.get(Y);if(!!Q!==!!K)return!1;let W=Q.getChild(),G=K.getChild();if(W===G)continue;if(!W.equals(G))return!1}return!0}function Dg(Z,J){if(Z===J)return!0;if(!!Z!==!!J||!Z||!J)return!1;if(Z.length!==J.length)return!1;for(let X=0;X<Z.length;X++)if(Z[X]!==J[X])return!1;return!0}function Mg(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!f$(Z)||!f$(J))return Z===J;let X=Z,$=J,Y=0,Q=0,K;for(K in X)Y++;for(K in $)Q++;if(Y!==Q)return!1;for(K in X){let W=X[K],G=$[K];if(sF(W)&&sF(G)){if(!Dg(W,G))return!1}else if(f$(W)&&f$(G)){if(!Mg(W,G))return!1}else if(W!==G)return!1}return!0}function sF(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var xg="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",Hw1=999,qw1=6,cg=new Set,Fw1=function Z(){let J="";for(let X=0;X<qw1;X++)J+=xg.charAt(Math.floor(Math.random()*xg.length));return J},Rg=function Z(){for(let J=0;J<Hw1;J++){let X=Fw1();if(!cg.has(X))return cg.add(X),X}return""},bJ=(Z)=>Z,xw1=new Set;class tF extends yF{constructor(Z,J=""){super(Z);this[H1].name=J,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(Z,J){if(Array.isArray(J))J=J.slice();return super.set(Z,J)}getName(){return this.get("name")}setName(Z){return this.set("name",Z)}getExtras(){return this.get("extras")}setExtras(Z){return this.set("extras",Z)}clone(){return new this.constructor(this.graph).copy(this,bJ)}copy(Z,J=bJ){for(let X in this[H1]){let $=this[H1][X];if($ instanceof XZ){if(!this[_J].has(X))$.dispose()}else if($ instanceof w9||$ instanceof x1)for(let Y of $.values())Y.dispose();else if($ instanceof A6)for(let Y of $.values())Y.dispose()}for(let X in Z[H1]){let $=this[H1][X],Y=Z[H1][X];if(Y instanceof XZ)if(this[_J].has(X))$.getChild().copy(J(Y.getChild()),J);else this.setRef(X,J(Y.getChild()),Y.getAttributes());else if(Y instanceof x1||Y instanceof w9)for(let Q of Y.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if(Y instanceof A6)for(let Q of Y.keys()){let K=Y.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(f$(Y))this[H1][X]=JSON.parse(JSON.stringify(Y));else if(Array.isArray(Y)||Y instanceof ArrayBuffer||ArrayBuffer.isView(Y))this[H1][X]=Y.slice();else this[H1][X]=Y}return this}equals(Z,J=xw1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[H1]){if(J.has(X))continue;let $=this[H1][X],Y=Z[H1][X];if($ instanceof XZ||Y instanceof XZ){if(!zw1($,Y))return!1}else if($ instanceof x1||Y instanceof x1||$ instanceof w9||Y instanceof w9){if(!vw1($,Y))return!1}else if($ instanceof A6||Y instanceof A6){if(!Vw1($,Y))return!1}else if(f$($)||f$(Y)){if(!Mg($,Y))return!1}else if(sF($)||sF(Y)){if(!Dg($,Y))return!1}else if($!==Y)return!1}return!0}detach(){return this.graph.disconnectParents(this,(Z)=>Z.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}}class w6 extends tF{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new A6})}getExtension(Z){return this.getRefMap("extensions",Z)}setExtension(Z,J){if(J)J._validateParent(this);return this.setRefMap("extensions",Z,J)}listExtensions(){return this.listRefMapValues("extensions")}}class K0 extends w6{init(){this.propertyType=i.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:K0.Type.SCALAR,componentType:K0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case K0.Type.SCALAR:return 1;case K0.Type.VEC2:return 2;case K0.Type.VEC3:return 3;case K0.Type.VEC4:return 4;case K0.Type.MAT2:return 4;case K0.Type.MAT3:return 9;case K0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case K0.ComponentType.BYTE:return 1;case K0.ComponentType.UNSIGNED_BYTE:return 1;case K0.ComponentType.SHORT:return 2;case K0.ComponentType.UNSIGNED_SHORT:return 2;case K0.ComponentType.UNSIGNED_INT:return 4;case K0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMin(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=I0.decodeNormalizedInt(Z[Y],$);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),$=this.getElementSize();for(let Y=0;Y<$;Y++)Z[Y]=1/0;for(let Y=0;Y<X*$;Y+=$)for(let Q=0;Q<$;Q++){let K=J[Y+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMax(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=I0.decodeNormalizedInt(Z[Y],$);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),$=this.getElementSize();for(let Y=0;Y<$;Y++)Z[Y]=-1/0;for(let Y=0;Y<X*$;Y+=$)for(let Q=0;Q<$;Q++){let K=J[Y+Q];if(Number.isFinite(K))Z[Q]=Math.max(Z[Q],K)}return Z}getCount(){let Z=this.get("array");return Z?Z.length/this.getElementSize():0}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getElementSize(){return K0.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(Z){return this.set("normalized",Z)}getScalar(Z){let J=this.getElementSize(),X=this.getComponentType(),$=this.getArray();if(this.getNormalized())return I0.decodeNormalizedInt($[Z*J],X);return $[Z*J]}setScalar(Z,J){let X=this.getElementSize(),$=this.getComponentType(),Y=this.getArray();if(this.getNormalized())Y[Z*X]=I0.encodeNormalizedInt(J,$);else Y[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),$=this.getElementSize(),Y=this.getComponentType(),Q=this.getArray();for(let K=0;K<$;K++)if(X)J[K]=I0.decodeNormalizedInt(Q[Z*$+K],Y);else J[K]=Q[Z*$+K];return J}setElement(Z,J){let X=this.getNormalized(),$=this.getElementSize(),Y=this.getComponentType(),Q=this.getArray();for(let K=0;K<$;K++)if(X)Q[Z*$+K]=I0.encodeNormalizedInt(J[K],Y);else Q[Z*$+K]=J[K];return this}getSparse(){return this.get("sparse")}setSparse(Z){return this.set("sparse",Z)}getBuffer(){return this.getRef("buffer")}setBuffer(Z){return this.setRef("buffer",Z)}getArray(){return this.get("array")}setArray(Z){return this.set("componentType",Z?cw1(Z):K0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}K0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};K0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function cw1(Z){switch(Z.constructor){case Float32Array:return K0.ComponentType.FLOAT;case Uint32Array:return K0.ComponentType.UNSIGNED_INT;case Uint16Array:return K0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return K0.ComponentType.UNSIGNED_BYTE;case Int16Array:return K0.ComponentType.SHORT;case Int8Array:return K0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class VR extends w6{init(){this.propertyType=i.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new x1,samplers:new x1})}addChannel(Z){return this.addRef("channels",Z)}removeChannel(Z){return this.removeRef("channels",Z)}listChannels(){return this.listRefs("channels")}addSampler(Z){return this.addRef("samplers",Z)}removeSampler(Z){return this.removeRef("samplers",Z)}listSamplers(){return this.listRefs("samplers")}}class QZ extends w6{init(){this.propertyType=i.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(Z){return this.set("targetPath",Z)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(Z){return this.setRef("targetNode",Z)}getSampler(){return this.getRef("sampler")}setSampler(Z){return this.setRef("sampler",Z)}}QZ.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class SJ extends w6{init(){this.propertyType=i.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:SJ.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(Z){return this.set("interpolation",Z)}getInput(){return this.getRef("input")}setInput(Z){return this.setRef("input",Z,{usage:I5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:I5.OTHER})}}SJ.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class HR extends w6{init(){this.propertyType=i.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class E$ extends w6{init(){this.propertyType=i.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:E$.Type.PERSPECTIVE,znear:0.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getZNear(){return this.get("znear")}setZNear(Z){return this.set("znear",Z)}getZFar(){return this.get("zfar")}setZFar(Z){return this.set("zfar",Z)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(Z){return this.set("aspectRatio",Z)}getYFov(){return this.get("yfov")}setYFov(Z){return this.set("yfov",Z)}getXMag(){return this.get("xmag")}setXMag(Z){return this.set("xmag",Z)}getYMag(){return this.get("ymag")}setYMag(Z){return this.set("ymag",Z)}}E$.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class O1 extends tF{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}O1.EXTENSION_NAME=void 0;class F1 extends w6{init(){this.propertyType=i.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:F1.WrapMode.REPEAT,wrapT:F1.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}getMagFilter(){return this.get("magFilter")}setMagFilter(Z){return this.set("magFilter",Z)}getMinFilter(){return this.get("minFilter")}setMinFilter(Z){return this.set("minFilter",Z)}getWrapS(){return this.get("wrapS")}setWrapS(Z){return this.set("wrapS",Z)}getWrapT(){return this.get("wrapT")}setWrapT(Z){return this.set("wrapT",Z)}}F1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};F1.MagFilter={NEAREST:9728,LINEAR:9729};F1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:pF,G:iF,B:gF,A:ww1}=v5;class Q7 extends w6{init(){this.propertyType=i.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:Q7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new F1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new F1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new F1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new F1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new F1(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(Z){return this.set("doubleSided",Z)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(Z){let J=this.get("baseColorFactor").slice();return J[3]=Z,this.set("baseColorFactor",J)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(Z){return this.set("alphaMode",Z)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(Z){return this.set("alphaCutoff",Z)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(Z){return this.set("baseColorFactor",Z)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(Z){return this.setRef("baseColorTexture",Z,{channels:pF|iF|gF|ww1,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(Z){return this.set("emissiveFactor",Z)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(Z){return this.setRef("emissiveTexture",Z,{channels:pF|iF|gF,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(Z){return this.set("normalScale",Z)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(Z){return this.setRef("normalTexture",Z,{channels:pF|iF|gF})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(Z){return this.set("occlusionStrength",Z)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(Z){return this.setRef("occlusionTexture",Z,{channels:pF})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(Z){return this.set("roughnessFactor",Z)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(Z){return this.set("metallicFactor",Z)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(Z){return this.setRef("metallicRoughnessTexture",Z,{channels:iF|gF})}}Q7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class NG extends w6{init(){this.propertyType=i.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new x1})}addPrimitive(Z){return this.addRef("primitives",Z)}removePrimitive(Z){return this.removeRef("primitives",Z)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}}class eF extends w6{init(){this.propertyType=i.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new x1})}copy(Z,J=bJ){if(J===bJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return I0.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),$=this.get("scale").slice();return I0.decompose(Z,J,X,$),this.set("translation",J).set("rotation",X).set("scale",$)}getWorldTranslation(){let Z=[0,0,0];return I0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return I0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return I0.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let $=this;$!=null;$=$.getParentNode())Z.push($);let J,X=Z.pop().getMatrix();while(J=Z.pop())Kw1(X,X,J.getMatrix());return X}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);for(let X of Z.listParents())if(X.propertyType===i.SCENE)X.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}getParentNode(){for(let Z of this.listParents())if(Z.propertyType===i.NODE)return Z;return null}getMesh(){return this.getRef("mesh")}setMesh(Z){return this.setRef("mesh",Z)}getCamera(){return this.getRef("camera")}setCamera(Z){return this.setRef("camera",Z)}getSkin(){return this.getRef("skin")}setSkin(Z){return this.setRef("skin",Z)}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}traverse(Z){Z(this);for(let J of this.listChildren())J.traverse(Z);return this}}class g1 extends w6{init(){this.propertyType=i.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:g1.Mode.TRIANGLES,material:null,indices:null,attributes:new A6,targets:new x1})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:I5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:I5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}getMode(){return this.get("mode")}setMode(Z){return this.set("mode",Z)}listTargets(){return this.listRefs("targets")}addTarget(Z){return this.addRef("targets",Z)}removeTarget(Z){return this.removeRef("targets",Z)}}g1.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class qR extends tF{init(){this.propertyType=i.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:I5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function m6(){return m6=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},m6.apply(null,arguments)}class K3 extends w6{init(){this.propertyType=i.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new x1})}copy(Z,J=bJ){if(J===bJ)throw new Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class FR extends w6{init(){this.propertyType=i.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new x1})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(Z){return this.setRef("skeleton",Z)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(Z){return this.setRef("inverseBindMatrices",Z,{usage:I5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class I$ extends w6{init(){this.propertyType=i.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||E5.extensionToMimeType(YZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=E5.extensionToMimeType(YZ.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",E0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return E5.getSize(Z,this.getMimeType())}}class W3 extends w6{init(){this.propertyType=i.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Bg}`,version:"2.0"},defaultScene:null,accessors:new x1,animations:new x1,buffers:new x1,cameras:new x1,materials:new x1,meshes:new x1,nodes:new x1,scenes:new x1,skins:new x1,textures:new x1})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(Z,J=bJ){if(J===bJ)throw new Error("Root cannot be copied.");this.set("asset",m6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(m6({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let $=Z.getExtension(X);this.setExtension(X,J($))}return this}_addChildOfRoot(Z){if(Z instanceof K3)this.addRef("scenes",Z);else if(Z instanceof eF)this.addRef("nodes",Z);else if(Z instanceof E$)this.addRef("cameras",Z);else if(Z instanceof FR)this.addRef("skins",Z);else if(Z instanceof NG)this.addRef("meshes",Z);else if(Z instanceof Q7)this.addRef("materials",Z);else if(Z instanceof I$)this.addRef("textures",Z);else if(Z instanceof VR)this.addRef("animations",Z);else if(Z instanceof K0)this.addRef("accessors",Z);else if(Z instanceof HR)this.addRef("buffers",Z);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((Z)=>Z.isRequired())}_enableExtension(Z){return this._extensions.add(Z),this}_disableExtension(Z){return this._extensions.delete(Z),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(Z){return this.setRef("defaultScene",Z)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class c6{static fromGraph(Z){return c6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new lF,this._root=new W3(this._graph),this._logger=z5.DEFAULT_INSTANCE,c6._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(($)=>$.extensionName===J)||new Z(this)}createScene(Z=""){return new K3(this._graph,Z)}createNode(Z=""){return new eF(this._graph,Z)}createCamera(Z=""){return new E$(this._graph,Z)}createSkin(Z=""){return new FR(this._graph,Z)}createMesh(Z=""){return new NG(this._graph,Z)}createPrimitive(){return new g1(this._graph)}createPrimitiveTarget(Z=""){return new qR(this._graph,Z)}createMaterial(Z=""){return new Q7(this._graph,Z)}createTexture(Z=""){return new I$(this._graph,Z)}createAnimation(Z=""){return new VR(this._graph,Z)}createAnimationChannel(Z=""){return new QZ(this._graph,Z)}createAnimationSampler(Z=""){return new SJ(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new K0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new HR(this._graph,Z)}}c6._GRAPH_DOCUMENTS=new WeakMap;class P1{constructor(Z){this.extensionName="",this.prereadTypes=[],this.prewriteTypes=[],this.readDependencies=[],this.writeDependencies=[],this.document=void 0,this.required=!1,this.properties=new Set,this._listener=void 0,this.document=Z,Z.getRoot()._enableExtension(this),this._listener=(X)=>{let $=X,Y=$.target;if(Y instanceof O1&&Y.extensionName===this.extensionName){if($.type==="node:create")this._addExtensionProperty(Y);if($.type==="node:dispose")this._removeExtensionProperty(Y)}};let J=Z.getGraph();J.addEventListener("node:create",this._listener),J.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let Z=this.document.getGraph();Z.removeEventListener("node:create",this._listener),Z.removeEventListener("node:dispose",this._listener);for(let J of this.properties)J.dispose()}static register(){}isRequired(){return this.required}setRequired(Z){return this.required=Z,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(Z){return this.properties.add(Z),this}_removeExtensionProperty(Z){return this.properties.delete(Z),this}install(Z,J){return this}preread(Z,J){return this}prewrite(Z,J){return this}}P1.EXTENSION_NAME=void 0;class Ng{constructor(Z){this.jsonDoc=void 0,this.buffers=[],this.bufferViews=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.textureInfos=new Map,this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[],this.jsonDoc=Z}setTextureInfo(Z,J){if(this.textureInfos.set(Z,J),J.texCoord!==void 0)Z.setTexCoord(J.texCoord);if(J.extras!==void 0)Z.setExtras(J.extras);let X=this.jsonDoc.json.textures[J.index];if(X.sampler===void 0)return;let $=this.jsonDoc.json.samplers[X.sampler];if($.magFilter!==void 0)Z.setMagFilter($.magFilter);if($.minFilter!==void 0)Z.setMinFilter($.minFilter);if($.wrapS!==void 0)Z.setWrapS($.wrapS);if($.wrapT!==void 0)Z.setWrapT($.wrapT)}}var wg={logger:z5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},Uw1=new Set([i.BUFFER,i.TEXTURE,i.MATERIAL,i.MESH,i.PRIMITIVE,i.NODE,i.SCENE]);class Og{static read(Z,J=wg){let X=m6({},wg,J),{json:$}=Z,Y=new c6().setLogger(X.logger);this.validate(Z,X);let Q=new Ng(Z),K=$.asset,W=Y.getRoot().getAsset();if(K.copyright)W.copyright=K.copyright;if(K.extras)W.extras=K.extras;if($.extras!==void 0)Y.getRoot().setExtras(m6({},$.extras));let G=$.extensionsUsed||[],z=$.extensionsRequired||[];X.extensions.sort((M,N)=>M.EXTENSION_NAME>N.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let N=Y.createExtension(M).setRequired(z.includes(M.EXTENSION_NAME)),P=N.prereadTypes.filter((O)=>!Uw1.has(O));if(P.length)X.logger.warn(`Preread hooks for some types (${P.join()}), requested by extension ${N.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of N.readDependencies)N.install(O,X.dependencies[O])}let v=$.buffers||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.BUFFER)).forEach((M)=>M.preread(Q,i.BUFFER)),Q.buffers=v.map((M)=>{let N=Y.createBuffer(M.name);if(M.extras)N.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)N.setURI(M.uri);return N});let H=$.bufferViews||[];Q.bufferViewBuffers=H.map((M,N)=>{if(!Q.bufferViews[N]){let P=Z.json.buffers[M.buffer],O=P.uri?Z.resources[P.uri]:Z.resources[k$],_=M.byteOffset||0;Q.bufferViews[N]=E0.toView(O,_,M.byteLength)}return Q.buffers[M.buffer]});let V=$.accessors||[];Q.accessors=V.map((M)=>{let N=Q.bufferViewBuffers[M.bufferView],P=Y.createAccessor(M.name,N).setType(M.type);if(M.extras)P.setExtras(M.extras);if(M.normalized!==void 0)P.setNormalized(M.normalized);if(M.bufferView===void 0)return P;return P.setArray(aF(M,Q)),P});let q=$.images||[],F=$.textures||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.TEXTURE)).forEach((M)=>M.preread(Q,i.TEXTURE)),Q.textures=q.map((M)=>{let N=Y.createTexture(M.name);if(M.extras)N.setExtras(M.extras);if(M.bufferView!==void 0){let P=$.bufferViews[M.bufferView],O=Z.json.buffers[P.buffer],_=O.uri?Z.resources[O.uri]:Z.resources[k$],k=P.byteOffset||0,h=P.byteLength,f=_.slice(k,k+h);N.setImage(f)}else if(M.uri!==void 0){if(N.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)N.setURI(M.uri)}if(M.mimeType!==void 0)N.setMimeType(M.mimeType);else if(M.uri){let P=YZ.extension(M.uri);N.setMimeType(E5.extensionToMimeType(P))}return N}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MATERIAL)).forEach((M)=>M.preread(Q,i.MATERIAL));let x=$.materials||[];Q.materials=x.map((M)=>{let N=Y.createMaterial(M.name);if(M.extras)N.setExtras(M.extras);if(M.alphaMode!==void 0)N.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)N.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)N.setDoubleSided(M.doubleSided);let P=M.pbrMetallicRoughness||{};if(P.baseColorFactor!==void 0)N.setBaseColorFactor(P.baseColorFactor);if(M.emissiveFactor!==void 0)N.setEmissiveFactor(M.emissiveFactor);if(P.metallicFactor!==void 0)N.setMetallicFactor(P.metallicFactor);if(P.roughnessFactor!==void 0)N.setRoughnessFactor(P.roughnessFactor);if(P.baseColorTexture!==void 0){let O=P.baseColorTexture,_=Q.textures[F[O.index].source];N.setBaseColorTexture(_),Q.setTextureInfo(N.getBaseColorTextureInfo(),O)}if(M.emissiveTexture!==void 0){let O=M.emissiveTexture,_=Q.textures[F[O.index].source];N.setEmissiveTexture(_),Q.setTextureInfo(N.getEmissiveTextureInfo(),O)}if(M.normalTexture!==void 0){let O=M.normalTexture,_=Q.textures[F[O.index].source];if(N.setNormalTexture(_),Q.setTextureInfo(N.getNormalTextureInfo(),O),M.normalTexture.scale!==void 0)N.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let O=M.occlusionTexture,_=Q.textures[F[O.index].source];if(N.setOcclusionTexture(_),Q.setTextureInfo(N.getOcclusionTextureInfo(),O),M.occlusionTexture.strength!==void 0)N.setOcclusionStrength(M.occlusionTexture.strength)}if(P.metallicRoughnessTexture!==void 0){let O=P.metallicRoughnessTexture,_=Q.textures[F[O.index].source];N.setMetallicRoughnessTexture(_),Q.setTextureInfo(N.getMetallicRoughnessTextureInfo(),O)}return N}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MESH)).forEach((M)=>M.preread(Q,i.MESH));let c=$.meshes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.PRIMITIVE)).forEach((M)=>M.preread(Q,i.PRIMITIVE)),Q.meshes=c.map((M)=>{let N=Y.createMesh(M.name);if(M.extras)N.setExtras(M.extras);if(M.weights!==void 0)N.setWeights(M.weights);return(M.primitives||[]).forEach((O)=>{let _=Y.createPrimitive();if(O.extras)_.setExtras(O.extras);if(O.material!==void 0)_.setMaterial(Q.materials[O.material]);if(O.mode!==void 0)_.setMode(O.mode);for(let[f,C]of Object.entries(O.attributes||{}))_.setAttribute(f,Q.accessors[C]);if(O.indices!==void 0)_.setIndices(Q.accessors[O.indices]);let k=M.extras&&M.extras.targetNames||[];(O.targets||[]).forEach((f,C)=>{let b=k[C]||C.toString(),I=Y.createPrimitiveTarget(b);for(let[a,s]of Object.entries(f))I.setAttribute(a,Q.accessors[s]);_.addTarget(I)}),N.addPrimitive(_)}),N});let w=$.cameras||[];Q.cameras=w.map((M)=>{let N=Y.createCamera(M.name).setType(M.type);if(M.extras)N.setExtras(M.extras);if(M.type===E$.Type.PERSPECTIVE){let P=M.perspective;if(N.setYFov(P.yfov),N.setZNear(P.znear),P.zfar!==void 0)N.setZFar(P.zfar);if(P.aspectRatio!==void 0)N.setAspectRatio(P.aspectRatio)}else{let P=M.orthographic;N.setZNear(P.znear).setZFar(P.zfar).setXMag(P.xmag).setYMag(P.ymag)}return N});let B=$.nodes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.NODE)).forEach((M)=>M.preread(Q,i.NODE)),Q.nodes=B.map((M)=>{let N=Y.createNode(M.name);if(M.extras)N.setExtras(M.extras);if(M.translation!==void 0)N.setTranslation(M.translation);if(M.rotation!==void 0)N.setRotation(M.rotation);if(M.scale!==void 0)N.setScale(M.scale);if(M.matrix!==void 0){let P=[0,0,0],O=[0,0,0,1],_=[1,1,1];I0.decompose(M.matrix,P,O,_),N.setTranslation(P),N.setRotation(O),N.setScale(_)}if(M.weights!==void 0)N.setWeights(M.weights);return N});let j=$.skins||[];Q.skins=j.map((M)=>{let N=Y.createSkin(M.name);if(M.extras)N.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)N.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)N.setSkeleton(Q.nodes[M.skeleton]);for(let P of M.joints)N.addJoint(Q.nodes[P]);return N}),B.map((M,N)=>{let P=Q.nodes[N];if((M.children||[]).forEach((_)=>P.addChild(Q.nodes[_])),M.mesh!==void 0)P.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)P.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)P.setSkin(Q.skins[M.skin])});let L=$.animations||[];Q.animations=L.map((M)=>{let N=Y.createAnimation(M.name);if(M.extras)N.setExtras(M.extras);let O=(M.samplers||[]).map((k)=>{let h=Y.createAnimationSampler().setInput(Q.accessors[k.input]).setOutput(Q.accessors[k.output]).setInterpolation(k.interpolation||SJ.Interpolation.LINEAR);if(k.extras)h.setExtras(k.extras);return N.addSampler(h),h});return(M.channels||[]).forEach((k)=>{let h=Y.createAnimationChannel().setSampler(O[k.sampler]).setTargetPath(k.target.path);if(k.target.node!==void 0)h.setTargetNode(Q.nodes[k.target.node]);if(k.extras)h.setExtras(k.extras);N.addChannel(h)}),N});let R=$.scenes||[];if(Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.SCENE)).forEach((M)=>M.preread(Q,i.SCENE)),Q.scenes=R.map((M)=>{let N=Y.createScene(M.name);if(M.extras)N.setExtras(M.extras);return(M.nodes||[]).map((O)=>Q.nodes[O]).forEach((O)=>N.addChild(O)),N}),$.scene!==void 0)Y.getRoot().setDefaultScene(Q.scenes[$.scene]);return Y.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),V.forEach((M,N)=>{let P=Q.accessors[N],O=!!M.sparse,_=!M.bufferView&&!P.getArray();if(O||_)P.setSparse(!0).setArray(jw1(M,Q))}),Y}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let $ of X.extensionsRequired)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))throw new Error(`Missing required extension, "${$}".`)}if(X.extensionsUsed){for(let $ of X.extensionsUsed)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))J.logger.warn(`Missing optional extension, "${$}".`)}}}function Bw1(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=hJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,z=new Q(Z.count*K),v=new DataView($.buffer,$.byteOffset,$.byteLength),H=Y.byteStride;for(let V=0;V<Z.count;V++)for(let q=0;q<K;q++){let F=G+V*H+q*W,x;switch(Z.componentType){case K0.ComponentType.FLOAT:x=v.getFloat32(F,!0);break;case K0.ComponentType.UNSIGNED_INT:x=v.getUint32(F,!0);break;case K0.ComponentType.UNSIGNED_SHORT:x=v.getUint16(F,!0);break;case K0.ComponentType.UNSIGNED_BYTE:x=v.getUint8(F);break;case K0.ComponentType.SHORT:x=v.getInt16(F,!0);break;case K0.ComponentType.BYTE:x=v.getInt8(F);break;default:throw new Error(`Unexpected componentType "${Z.componentType}".`)}z[V*K+q]=x}return z}function aF(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=hJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if(Y.byteStride!==void 0&&Y.byteStride!==G)return Bw1(Z,J);let z=$.byteOffset+(Z.byteOffset||0),v=Z.count*K*W;return new Q($.buffer.slice(z,z+v))}function jw1(Z,J){let X=hJ[Z.componentType],$=K0.getElementSize(Z.type),Y;if(Z.bufferView!==void 0)Y=aF(Z,J);else Y=new X(Z.count*$);let Q=Z.sparse;if(!Q)return Y;let K=Q.count,W=m6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=m6({},Z,Q.values,{count:K}),z=aF(W,J),v=aF(G,J);for(let H=0;H<W.count;H++)for(let V=0;V<$;V++)Y[z[H]*$+V]=v[H*$+V];return Y}var MG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(MG||(MG={}));class c4{constructor(Z,J,X){this._doc=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this._accessorUsageMap=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this._doc=Z,this.jsonDoc=J,this.options=X;let $=Z.getRoot(),Y=$.listBuffers().length,Q=$.listTextures().length;this.bufferURIGenerator=new zR(Y>1,()=>X.basename||"buffer"),this.imageURIGenerator=new zR(Q>1,(K)=>Lw1(Z,K)||X.basename||"texture"),this.logger=Z.getLogger()}createTextureInfoDef(Z,J){let X={magFilter:J.getMagFilter()||void 0,minFilter:J.getMinFilter()||void 0,wrapS:J.getWrapS(),wrapT:J.getWrapT()},$=JSON.stringify(X);if(!this.samplerDefIndexMap.has($))this.samplerDefIndexMap.set($,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let Y={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get($)},Q=JSON.stringify(Y);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(Y);let K={index:this.textureDefIndexMap.get(Q)};if(J.getTexCoord()!==0)K.texCoord=J.getTexCoord();if(Object.keys(J.getExtras()).length>0)K.extras=J.getExtras();return this.textureInfoDefMap.set(J,K),K}createPropertyDef(Z){let J={};if(Z.getName())J.name=Z.getName();if(Object.keys(Z.getExtras()).length>0)J.extras=Z.getExtras();return J}createAccessorDef(Z){let J=this.createPropertyDef(Z);if(J.type=Z.getType(),J.componentType=Z.getComponentType(),J.count=Z.getCount(),this._doc.getGraph().listParentEdges(Z).some(($)=>$.getName()==="attributes"&&$.getAttributes().key==="POSITION"||$.getName()==="input"))J.max=Z.getMax([]).map(Math.fround),J.min=Z.getMin([]).map(Math.fround);if(Z.getNormalized())J.normalized=Z.getNormalized();return J}createImageData(Z,J,X){if(this.options.format===$Z.GLB)this.imageBufferViews.push(J),Z.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:J.byteLength});else{let $=E5.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,$),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let $=this.jsonDoc.resources;if(!(Z in $)){$[Z]=J;return}if(J===$[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let Y=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn(Y);return}throw new Error(Y)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return I5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:$}=X.getAttributes();if($)return $;if(X.getParent().propertyType!==i.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return I5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw new Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}c4.BufferViewTarget=MG;c4.BufferViewUsage=I5;c4.USAGE_TO_TARGET={[I5.ARRAY_BUFFER]:MG.ARRAY_BUFFER,[I5.ELEMENT_ARRAY_BUFFER]:MG.ELEMENT_ARRAY_BUFFER};class zR{constructor(Z,J){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=Z,this.basename=J}createURI(Z,J){if(Z.getURI())return Z.getURI();else if(!this.multiple)return`${this.basename(Z)}.${J}`;else{let X=this.basename(Z);return this.counter[X]=this.counter[X]||1,`${X}_${this.counter[X]++}.${J}`}}}function Lw1(Z,J){let X=Z.getGraph().listParentEdges(J).find(($)=>$.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:dF}=c4,{UNSIGNED_INT:Dw1,UNSIGNED_SHORT:Mw1,UNSIGNED_BYTE:Rw1}=K0.ComponentType,Nw1=new Set([i.ACCESSOR,i.BUFFER,i.MATERIAL,i.MESH]);class Pg{static write(Z,J){let X=Z.getGraph(),$=Z.getRoot(),Y={asset:m6({generator:`glTF-Transform ${Bg}`},$.getAsset()),extras:m6({},$.getExtras())},Q={json:Y,resources:{}},K=new c4(Z,Q,J),W=J.logger||z5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((c)=>c.EXTENSION_NAME)),z=Z.getRoot().listExtensionsUsed().filter((c)=>G.has(c.extensionName)).sort((c,w)=>c.extensionName>w.extensionName?1:-1),v=Z.getRoot().listExtensionsRequired().filter((c)=>G.has(c.extensionName)).sort((c,w)=>c.extensionName>w.extensionName?1:-1);if(z.length<Z.getRoot().listExtensionsUsed().length)W.warn("Some extensions were not registered for I/O, and will not be written.");for(let c of z){let w=c.prewriteTypes.filter((B)=>!Nw1.has(B));if(w.length)W.warn(`Prewrite hooks for some types (${w.join()}), requested by extension ${c.extensionName}, are unsupported. Please file an issue or a PR.`);for(let B of c.writeDependencies)c.install(B,J.dependencies[B])}function H(c,w,B,j){let L=[],R=0;for(let P of c){let O=K.createAccessorDef(P);O.bufferView=Y.bufferViews.length;let _=P.getArray(),k=E0.pad(E0.toView(_));O.byteOffset=R,R+=k.byteLength,L.push(k),K.accessorIndexMap.set(P,Y.accessors.length),Y.accessors.push(O)}let M=E0.concat(L),N={buffer:w,byteOffset:B,byteLength:M.byteLength};if(j)N.target=j;return Y.bufferViews.push(N),{buffers:L,byteLength:R}}function V(c,w,B){let j=c[0].getCount(),L=0;for(let O of c){let _=K.createAccessorDef(O);_.bufferView=Y.bufferViews.length,_.byteOffset=L;let k=O.getElementSize(),h=O.getComponentSize();L+=E0.padNumber(k*h),K.accessorIndexMap.set(O,Y.accessors.length),Y.accessors.push(_)}let R=j*L,M=new ArrayBuffer(R),N=new DataView(M);for(let O=0;O<j;O++){let _=0;for(let k of c){let h=k.getElementSize(),f=k.getComponentSize(),C=k.getComponentType(),b=k.getArray();for(let I=0;I<h;I++){let a=O*L+_+I*f,s=b[O*h+I];switch(C){case K0.ComponentType.FLOAT:N.setFloat32(a,s,!0);break;case K0.ComponentType.BYTE:N.setInt8(a,s);break;case K0.ComponentType.SHORT:N.setInt16(a,s,!0);break;case K0.ComponentType.UNSIGNED_BYTE:N.setUint8(a,s);break;case K0.ComponentType.UNSIGNED_SHORT:N.setUint16(a,s,!0);break;case K0.ComponentType.UNSIGNED_INT:N.setUint32(a,s,!0);break;default:throw new Error("Unexpected component type: "+C)}}_+=E0.padNumber(h*f)}}let P={buffer:w,byteOffset:B,byteLength:R,byteStride:L,target:c4.BufferViewTarget.ARRAY_BUFFER};return Y.bufferViews.push(P),{byteLength:R,buffers:[new Uint8Array(M)]}}function q(c,w,B){let j=[],L=0,R=new Map,M=-1/0,N=!1;for(let C of c){let b=K.createAccessorDef(C);Y.accessors.push(b),K.accessorIndexMap.set(C,Y.accessors.length-1);let I=[],a=[],s=[],Z0=new Array(C.getElementSize()).fill(0);for(let m0=0,N1=C.getCount();m0<N1;m0++){if(C.getElement(m0,s),I0.eq(s,Z0,0))continue;M=Math.max(m0,M),I.push(m0);for(let s0=0;s0<s.length;s0++)a.push(s[s0])}let o=I.length,M0={accessorDef:b,count:o};if(R.set(C,M0),o===0)continue;if(o>C.getCount()/2)N=!0;let R0=hJ[C.getComponentType()];M0.indices=I,M0.values=new R0(a)}if(!Number.isFinite(M))return{buffers:j,byteLength:L};if(N)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let P=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,O=M<255?Rw1:M<65535?Mw1:Dw1,_={buffer:w,byteOffset:B+L,byteLength:0};for(let C of c){let b=R.get(C);if(b.count===0)continue;b.indicesByteOffset=_.byteLength;let I=E0.pad(E0.toView(new P(b.indices)));j.push(I),L+=I.byteLength,_.byteLength+=I.byteLength}Y.bufferViews.push(_);let k=Y.bufferViews.length-1,h={buffer:w,byteOffset:B+L,byteLength:0};for(let C of c){let b=R.get(C);if(b.count===0)continue;b.valuesByteOffset=h.byteLength;let I=E0.pad(E0.toView(b.values));j.push(I),L+=I.byteLength,h.byteLength+=I.byteLength}Y.bufferViews.push(h);let f=Y.bufferViews.length-1;for(let C of c){let b=R.get(C);if(b.count===0)continue;b.accessorDef.sparse={count:b.count,indices:{bufferView:k,byteOffset:b.indicesByteOffset,componentType:O},values:{bufferView:f,byteOffset:b.valuesByteOffset}}}return{buffers:j,byteLength:L}}if(Y.accessors=[],Y.bufferViews=[],Y.samplers=[],Y.textures=[],Y.images=$.listTextures().map((c,w)=>{let B=K.createPropertyDef(c);if(c.getMimeType())B.mimeType=c.getMimeType();let j=c.getImage();if(j)K.createImageData(B,j,c);return K.imageIndexMap.set(c,w),B}),z.filter((c)=>c.prewriteTypes.includes(i.ACCESSOR)).forEach((c)=>c.prewrite(K,i.ACCESSOR)),$.listAccessors().forEach((c)=>{let{accessorUsageGroupedByParent:w,accessorParents:B}=K;if(K.accessorIndexMap.has(c))return;let j=K.getAccessorUsage(c);if(K.addAccessorToUsageGroup(c,j),w.has(j)){let L=X.listParents(c).find((R)=>R.propertyType!==i.ROOT);B.set(c,L)}}),z.filter((c)=>c.prewriteTypes.includes(i.BUFFER)).forEach((c)=>c.prewrite(K,i.BUFFER)),($.listAccessors().length>0||K.otherBufferViews.size>0||$.listTextures().length>0&&J.format===$Z.GLB)&&$.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");if(Y.buffers=[],$.listBuffers().forEach((c,w)=>{let B=K.createPropertyDef(c),j=K.accessorUsageGroupedByParent,L=c.listParents().filter((h)=>h instanceof K0),R=new Set(L.map((h)=>K.accessorParents.get(h))),M=new Map(Array.from(R).map((h,f)=>[h,f])),N={};for(let h of L){var P;if(K.accessorIndexMap.has(h))continue;let f=K.getAccessorUsage(h),C=f;if(j.has(f)){let b=K.accessorParents.get(h);C+=`:${M.get(b)}`}N[P=C]||(N[P]={usage:f,accessors:[]}),N[C].accessors.push(h)}let O=[],_=Y.buffers.length,k=0;for(let{usage:h,accessors:f}of Object.values(N))if(h===dF.ARRAY_BUFFER&&J.vertexLayout===nF.INTERLEAVED){let C=V(f,_,k);k+=C.byteLength;for(let b of C.buffers)O.push(b)}else if(h===dF.ARRAY_BUFFER)for(let C of f){let b=V([C],_,k);k+=b.byteLength;for(let I of b.buffers)O.push(I)}else if(h===dF.SPARSE){let C=q(f,_,k);k+=C.byteLength;for(let b of C.buffers)O.push(b)}else if(h===dF.ELEMENT_ARRAY_BUFFER){let C=c4.BufferViewTarget.ELEMENT_ARRAY_BUFFER,b=H(f,_,k,C);k+=b.byteLength;for(let I of b.buffers)O.push(I)}else{let C=H(f,_,k);k+=C.byteLength;for(let b of C.buffers)O.push(b)}if(K.imageBufferViews.length&&w===0){for(let h=0;h<K.imageBufferViews.length;h++)if(Y.bufferViews[Y.images[h].bufferView].byteOffset=k,k+=K.imageBufferViews[h].byteLength,O.push(K.imageBufferViews[h]),k%8){let f=8-k%8;k+=f,O.push(new Uint8Array(f))}}if(K.otherBufferViews.has(c))for(let h of K.otherBufferViews.get(c))Y.bufferViews.push({buffer:_,byteOffset:k,byteLength:h.byteLength}),K.otherBufferViewsIndexMap.set(h,Y.bufferViews.length-1),k+=h.byteLength,O.push(h);if(k){let h;if(J.format===$Z.GLB)h=k$;else h=K.bufferURIGenerator.createURI(c,"bin"),B.uri=h;B.byteLength=k,K.assignResourceURI(h,E0.concat(O),!0)}Y.buffers.push(B),K.bufferIndexMap.set(c,w)}),$.listAccessors().find((c)=>!c.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");z.filter((c)=>c.prewriteTypes.includes(i.MATERIAL)).forEach((c)=>c.prewrite(K,i.MATERIAL)),Y.materials=$.listMaterials().map((c,w)=>{let B=K.createPropertyDef(c);if(c.getAlphaMode()!==Q7.AlphaMode.OPAQUE)B.alphaMode=c.getAlphaMode();if(c.getAlphaMode()===Q7.AlphaMode.MASK)B.alphaCutoff=c.getAlphaCutoff();if(c.getDoubleSided())B.doubleSided=!0;if(B.pbrMetallicRoughness={},!I0.eq(c.getBaseColorFactor(),[1,1,1,1]))B.pbrMetallicRoughness.baseColorFactor=c.getBaseColorFactor();if(!I0.eq(c.getEmissiveFactor(),[0,0,0]))B.emissiveFactor=c.getEmissiveFactor();if(c.getRoughnessFactor()!==1)B.pbrMetallicRoughness.roughnessFactor=c.getRoughnessFactor();if(c.getMetallicFactor()!==1)B.pbrMetallicRoughness.metallicFactor=c.getMetallicFactor();if(c.getBaseColorTexture()){let j=c.getBaseColorTexture(),L=c.getBaseColorTextureInfo();B.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(j,L)}if(c.getEmissiveTexture()){let j=c.getEmissiveTexture(),L=c.getEmissiveTextureInfo();B.emissiveTexture=K.createTextureInfoDef(j,L)}if(c.getNormalTexture()){let j=c.getNormalTexture(),L=c.getNormalTextureInfo(),R=K.createTextureInfoDef(j,L);if(c.getNormalScale()!==1)R.scale=c.getNormalScale();B.normalTexture=R}if(c.getOcclusionTexture()){let j=c.getOcclusionTexture(),L=c.getOcclusionTextureInfo(),R=K.createTextureInfoDef(j,L);if(c.getOcclusionStrength()!==1)R.strength=c.getOcclusionStrength();B.occlusionTexture=R}if(c.getMetallicRoughnessTexture()){let j=c.getMetallicRoughnessTexture(),L=c.getMetallicRoughnessTextureInfo();B.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(j,L)}return K.materialIndexMap.set(c,w),B}),z.filter((c)=>c.prewriteTypes.includes(i.MESH)).forEach((c)=>c.prewrite(K,i.MESH)),Y.meshes=$.listMeshes().map((c,w)=>{let B=K.createPropertyDef(c),j=null;if(B.primitives=c.listPrimitives().map((L)=>{let R={attributes:{}};R.mode=L.getMode();let M=L.getMaterial();if(M)R.material=K.materialIndexMap.get(M);if(Object.keys(L.getExtras()).length)R.extras=L.getExtras();let N=L.getIndices();if(N)R.indices=K.accessorIndexMap.get(N);for(let P of L.listSemantics())R.attributes[P]=K.accessorIndexMap.get(L.getAttribute(P));for(let P of L.listTargets()){let O={};for(let _ of P.listSemantics())O[_]=K.accessorIndexMap.get(P.getAttribute(_));R.targets=R.targets||[],R.targets.push(O)}if(L.listTargets().length&&!j)j=L.listTargets().map((P)=>P.getName());return R}),c.getWeights().length)B.weights=c.getWeights();if(j)B.extras=B.extras||{},B.extras.targetNames=j;return K.meshIndexMap.set(c,w),B}),Y.cameras=$.listCameras().map((c,w)=>{let B=K.createPropertyDef(c);if(B.type=c.getType(),B.type===E$.Type.PERSPECTIVE){B.perspective={znear:c.getZNear(),zfar:c.getZFar(),yfov:c.getYFov()};let j=c.getAspectRatio();if(j!==null)B.perspective.aspectRatio=j}else B.orthographic={znear:c.getZNear(),zfar:c.getZFar(),xmag:c.getXMag(),ymag:c.getYMag()};return K.cameraIndexMap.set(c,w),B}),Y.nodes=$.listNodes().map((c,w)=>{let B=K.createPropertyDef(c);if(!I0.eq(c.getTranslation(),[0,0,0]))B.translation=c.getTranslation();if(!I0.eq(c.getRotation(),[0,0,0,1]))B.rotation=c.getRotation();if(!I0.eq(c.getScale(),[1,1,1]))B.scale=c.getScale();if(c.getWeights().length)B.weights=c.getWeights();return K.nodeIndexMap.set(c,w),B}),Y.skins=$.listSkins().map((c,w)=>{let B=K.createPropertyDef(c),j=c.getInverseBindMatrices();if(j)B.inverseBindMatrices=K.accessorIndexMap.get(j);let L=c.getSkeleton();if(L)B.skeleton=K.nodeIndexMap.get(L);return B.joints=c.listJoints().map((R)=>K.nodeIndexMap.get(R)),K.skinIndexMap.set(c,w),B}),$.listNodes().forEach((c,w)=>{let B=Y.nodes[w],j=c.getMesh();if(j)B.mesh=K.meshIndexMap.get(j);let L=c.getCamera();if(L)B.camera=K.cameraIndexMap.get(L);let R=c.getSkin();if(R)B.skin=K.skinIndexMap.get(R);if(c.listChildren().length>0)B.children=c.listChildren().map((M)=>K.nodeIndexMap.get(M))}),Y.animations=$.listAnimations().map((c,w)=>{let B=K.createPropertyDef(c),j=new Map;return B.samplers=c.listSamplers().map((L,R)=>{let M=K.createPropertyDef(L);return M.input=K.accessorIndexMap.get(L.getInput()),M.output=K.accessorIndexMap.get(L.getOutput()),M.interpolation=L.getInterpolation(),j.set(L,R),M}),B.channels=c.listChannels().map((L)=>{let R=K.createPropertyDef(L);return R.sampler=j.get(L.getSampler()),R.target={node:K.nodeIndexMap.get(L.getTargetNode()),path:L.getTargetPath()},R}),K.animationIndexMap.set(c,w),B}),Y.scenes=$.listScenes().map((c,w)=>{let B=K.createPropertyDef(c);return B.nodes=c.listChildren().map((j)=>K.nodeIndexMap.get(j)),K.sceneIndexMap.set(c,w),B});let x=$.getDefaultScene();if(x)Y.scene=$.listScenes().indexOf(x);return Y.extensionsUsed=z.map((c)=>c.extensionName),Y.extensionsRequired=v.map((c)=>c.extensionName),z.forEach((c)=>c.write(K)),Ow1(Y),Q}}function Ow1(Z){let J=[];for(let X in Z){let $=Z[X];if(Array.isArray($)&&$.length===0)J.push(X);else if($===null||$==="")J.push(X);else if($&&typeof $==="object"&&Object.keys($).length===0)J.push(X)}for(let X of J)delete Z[X]}var oF;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(oF||(oF={}));class Tg{constructor(){this._logger=z5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=nF.INTERLEAVED,this.lastReadBytes=0,this.lastWriteBytes=0}setLogger(Z){return this._logger=Z,this}registerExtensions(Z){for(let J of Z)this._extensions.add(J),J.register();return this}registerDependencies(Z){return Object.assign(this._dependencies,Z),this}setVertexLayout(Z){return this._vertexLayout=Z,this}async read(Z){return await this.readJSON(await this.readAsJSON(Z))}async readAsJSON(Z){let J=await this.readURI(Z,"view");this.lastReadBytes=J.byteLength;let X=Ug(J)?this._binaryToJSON(J):{json:JSON.parse(E0.decodeText(J)),resources:{}};return await this._readResourcesExternal(X,this.dirname(Z)),this._readResourcesInternal(X),X}async readJSON(Z){return Z=this._copyJSON(Z),this._readResourcesInternal(Z),Og.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(E0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some(($)=>Pw1(J,$)))throw new Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some(($)=>Tw1(J,$)))throw new Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(E0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===$Z.GLB&&Z.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Pg.write(Z,{format:J.format||$Z.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:m6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:$Z.GLB}),$=new Uint32Array([1179937895,2,12]),Y=JSON.stringify(J),Q=E0.pad(E0.encodeText(Y),32),K=E0.toView(new Uint32Array([Q.byteLength,1313821514])),W=E0.concat([K,Q]);$[$.length-1]+=W.byteLength;let G=Object.values(X)[0];if(!G||!G.byteLength)return E0.concat([E0.toView($),W]);let z=E0.pad(G,0),v=E0.toView(new Uint32Array([z.byteLength,5130562])),H=E0.concat([v,z]);return $[$.length-1]+=H.byteLength,E0.concat([E0.toView($),W,H])}async _readResourcesExternal(Z,J){var X=this;let $=Z.json.images||[],Y=Z.json.buffers||[],Q=[...$,...Y].map(async function(K){let W=K.uri;if(!W||W.match(/data:/))return Promise.resolve();Z.resources[W]=await X.readURI(X.resolve(J,W),"view"),X.lastReadBytes+=Z.resources[W].byteLength});await Promise.all(Q)}_readResourcesInternal(Z){function J(Y){if(!Y.uri)return;if(Y.uri in Z.resources){E0.assertView(Z.resources[Y.uri]);return}if(Y.uri.match(/data:/)){let Q=`__${Rg()}.${YZ.extension(Y.uri)}`;Z.resources[Q]=E0.createBufferFromDataURI(Y.uri),Y.uri=Q}}(Z.json.images||[]).forEach((Y)=>{if(Y.bufferView===void 0&&Y.uri===void 0)throw new Error("Missing resource URI or buffer view.");J(Y)}),(Z.json.buffers||[]).forEach(J)}_copyJSON(Z){let{images:J,buffers:X}=Z.json;if(Z={json:m6({},Z.json),resources:m6({},Z.resources)},J)Z.json.images=J.map(($)=>m6({},$));if(X)Z.json.buffers=X.map(($)=>m6({},$));return Z}_binaryToJSON(Z){if(!Ug(Z))throw new Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==oF.JSON)throw new Error("Missing required GLB JSON chunk.");let X=20,$=J[0],Y=E0.decodeText(E0.toView(Z,X,$)),Q=JSON.parse(Y),K=X+$;if(Z.byteLength<=K)return{json:Q,resources:{}};let W=new Uint32Array(Z.buffer,Z.byteOffset+K,2);if(W[1]!==oF.BIN)return{json:Q,resources:{}};let G=W[0],z=E0.toView(Z,K+8,G);return{json:Q,resources:{[k$]:z}}}}function Pw1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function Tw1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Ug(Z){if(Z.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let J=new Uint32Array(Z.buffer,Z.byteOffset,3);return J[0]===1179937895&&J[1]===2}class xR extends Tg{constructor(Z=null,J=x4.DEFAULT_INIT){super();this._fetch=void 0,this._fetchConfig=void 0,this._init=void 0,this._fetchEnabled=!1,this._fetch=Z,this._fetchConfig=J,this._init=this.init()}async init(){if(this._init)return this._init;return Promise.all([import("fs"),import("path")]).then(([Z,J])=>{this._fs=Z.promises,this._path=J})}setAllowNetwork(Z){if(Z&&!this._fetch)throw new Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),x4.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw new Error("Network request blocked. Allow HTTP requests explicitly, if needed.");let X=await this._fetch(Z,this._fetchConfig);switch(J){case"view":return new Uint8Array(await X.arrayBuffer());case"text":return X.text()}}else switch(J){case"view":return this._fs.readFile(Z);case"text":return this._fs.readFile(Z,"utf8")}}resolve(Z,J){if(x4.isAbsoluteURL(Z)||x4.isAbsoluteURL(J))return x4.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(x4.isAbsoluteURL(Z))return x4.dirname(Z);return this._path.dirname(Z)}async write(Z,J){await this.init(),await(!!Z.match(/\.glb$/)?this._writeGLB(Z,J):this._writeGLTF(Z,J))}async _writeGLTF(Z,J){var X=this;this.lastWriteBytes=0;let{json:$,resources:Y}=await this.writeJSON(J,{format:$Z.GLTF,basename:YZ.basename(Z)}),{_fs:Q,_path:K}=this,W=K.dirname(Z),G=JSON.stringify($,null,2);await Q.writeFile(Z,G),this.lastWriteBytes+=G.length;for(let z of Cw1(Object.keys(Y),10))await Promise.all(z.map(async function(v){if(x4.isAbsoluteURL(v)){if(x4.extension(v)==="bin")throw new Error(`Cannot write buffer to path "${v}".`);return}let H=K.join(W,decodeURIComponent(v));await Q.mkdir(K.dirname(H),{recursive:!0}),await Q.writeFile(H,Y[v]),X.lastWriteBytes+=Y[v].byteLength}))}async _writeGLB(Z,J){let X=await this.writeBinary(J);await this._fs.writeFile(Z,X),this.lastWriteBytes=X.byteLength}}function Cw1(Z,J){let X=[];for(let $=0,Y=Z.length;$<Y;$+=J){let Q=[];for(let K=0;K<J&&$+K<Y;K++)Q.push(Z[$+K]);X.push(Q)}return X}var Nn=t(cR(),1),On=t(Gn(),1),DL1=t(Rn(),1);async function ML1(Z,J){if(!(Z instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:$}=await On.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return Nn.default(new Uint8Array(X),[$.width,$.height,4],[4,4*$.width|0,1],0)}async function Pn(Z,J){return ML1(Z)}var Cn=163,fn=166;function RL1(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class U3{constructor(Z,J,X,$){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(Z.buffer,Z.byteOffset+J,X),this._littleEndian=$,this._offset=0}_nextUint8(){let Z=this._dataView.getUint8(this._offset);return this._offset+=1,Z}_nextUint16(){let Z=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,Z}_nextUint32(){let Z=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,Z}_nextUint64(){let Z=this._dataView.getUint32(this._offset,this._littleEndian),J=this._dataView.getUint32(this._offset+4,this._littleEndian),X=Z+4294967296*J;return this._offset+=8,X}_nextInt32(){let Z=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,Z}_nextUint8Array(Z){let J=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,Z);return this._offset+=Z,J}_skip(Z){return this._offset+=Z,this}_scan(Z,J=0){let X=this._offset,$=0;while(this._dataView.getUint8(this._offset)!==J&&$<Z)$++,this._offset++;if($<Z)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+X,$)}}var pN6=new Uint8Array([0]),p6=[171,75,84,88,32,50,48,187,13,10,26,10];function Tn(Z){return new TextDecoder().decode(Z)}function Lx(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,p6.length);if(J[0]!==p6[0]||J[1]!==p6[1]||J[2]!==p6[2]||J[3]!==p6[3]||J[4]!==p6[4]||J[5]!==p6[5]||J[6]!==p6[6]||J[7]!==p6[7]||J[8]!==p6[8]||J[9]!==p6[9]||J[10]!==p6[10]||J[11]!==p6[11])throw new Error("Missing KTX 2.0 identifier.");let X=RL1(),$=17*Uint32Array.BYTES_PER_ELEMENT,Y=new U3(Z,p6.length,$,!0);X.vkFormat=Y._nextUint32(),X.typeSize=Y._nextUint32(),X.pixelWidth=Y._nextUint32(),X.pixelHeight=Y._nextUint32(),X.pixelDepth=Y._nextUint32(),X.layerCount=Y._nextUint32(),X.faceCount=Y._nextUint32(),X.levelCount=Y._nextUint32(),X.supercompressionScheme=Y._nextUint32();let Q=Y._nextUint32(),K=Y._nextUint32(),W=Y._nextUint32(),G=Y._nextUint32(),z=Y._nextUint64(),v=Y._nextUint64(),H=Math.max(X.levelCount,1)*3*8,V=new U3(Z,p6.length+$,H,!0);for(let P8=0,q6=Math.max(X.levelCount,1);P8<q6;P8++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+V._nextUint64(),V._nextUint64()),uncompressedByteLength:V._nextUint64()});let q=new U3(Z,Q,K,!0);q._skip(4);let F=q._nextUint16(),x=q._nextUint16(),c=q._nextUint16(),w=q._nextUint16(),B=q._nextUint8(),j=q._nextUint8(),L=q._nextUint8(),R=q._nextUint8(),M=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],N=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],O={vendorId:F,descriptorType:x,versionNumber:c,colorModel:B,colorPrimaries:j,transferFunction:L,flags:R,texelBlockDimension:M,bytesPlane:N,samples:[]},_=6,k=4,h=(w/4-_)/k;for(let P8=0;P8<h;P8++){let q6={bitOffset:q._nextUint16(),bitLength:q._nextUint8(),channelType:q._nextUint8(),samplePosition:[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(q6.channelType&64)q6.sampleLower=q._nextInt32(),q6.sampleUpper=q._nextInt32();else q6.sampleLower=q._nextUint32(),q6.sampleUpper=q._nextUint32();O.samples[P8]=q6}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(O);let f=new U3(Z,W,G,!0);while(f._offset<G){let P8=f._nextUint32(),q6=f._scan(P8),CH=Tn(q6);if(X.keyValue[CH]=f._nextUint8Array(P8-q6.byteLength-1),CH.match(/^ktx/i)){let qA=Tn(X.keyValue[CH]);X.keyValue[CH]=qA.substring(0,qA.lastIndexOf("\x00"))}let uW1=P8%4?4-P8%4:0;f._skip(uW1)}if(v<=0)return X;let C=new U3(Z,z,v,!0),b=C._nextUint16(),I=C._nextUint16(),a=C._nextUint32(),s=C._nextUint32(),Z0=C._nextUint32(),o=C._nextUint32(),M0=[];for(let P8=0,q6=Math.max(X.levelCount,1);P8<q6;P8++)M0.push({imageFlags:C._nextUint32(),rgbSliceByteOffset:C._nextUint32(),rgbSliceByteLength:C._nextUint32(),alphaSliceByteOffset:C._nextUint32(),alphaSliceByteLength:C._nextUint32()});let R0=z+C._offset,m0=R0+a,N1=m0+s,s0=N1+Z0,B1=new Uint8Array(Z.buffer,Z.byteOffset+R0,a),W4=new Uint8Array(Z.buffer,Z.byteOffset+m0,s),RJ=new Uint8Array(Z.buffer,Z.byteOffset+N1,Z0),IQ=new Uint8Array(Z.buffer,Z.byteOffset+s0,o);return X.globalData={endpointCount:b,selectorCount:I,imageDescs:M0,endpointsData:B1,selectorsData:W4,tablesData:RJ,extendedData:IQ},X}var GZ="EXT_mesh_gpu_instancing",X6="EXT_meshopt_compression",hG="EXT_texture_webp",SG="EXT_texture_avif",s1="KHR_draco_mesh_compression",B4="KHR_lights_punctual",zZ="KHR_materials_anisotropy",vZ="KHR_materials_clearcoat",VZ="KHR_materials_diffuse_transmission",HZ="KHR_materials_dispersion",qZ="KHR_materials_emissive_strength",FZ="KHR_materials_ior",xZ="KHR_materials_iridescence",cZ="KHR_materials_pbrSpecularGlossiness",wZ="KHR_materials_sheen",UZ="KHR_materials_specular",BZ="KHR_materials_transmission",pJ="KHR_materials_unlit",jZ="KHR_materials_volume",U6="KHR_materials_variants",pn="KHR_mesh_quantization",AG="KHR_texture_basisu",LZ="KHR_texture_transform",j4="KHR_xmp_json_ld",pR="INSTANCE_ATTRIBUTE";class gR extends O1{init(){this.extensionName=GZ,this.propertyType="InstancedMesh",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:pR})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}gR.EXTENSION_NAME=GZ;class Rx extends P1{constructor(...Z){super(...Z);this.extensionName=GZ,this.provideTypes=[i.NODE],this.prewriteTypes=[i.ACCESSOR]}createInstancedMesh(){return new gR(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[GZ])return;let Q=$.extensions[GZ],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[Y].setExtension(GZ,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(pR);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,pR);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let $=X.getExtension(GZ);if($){let Y=Z.nodeIndexMap.get(X),Q=J.json.nodes[Y],K={attributes:{}};$.listSemantics().forEach((W)=>{let G=$.getAttribute(W);K.attributes[W]=Z.accessorIndexMap.get(G)}),Q.extensions=Q.extensions||{},Q.extensions[GZ]=K}}),this}}Rx.EXTENSION_NAME=GZ;function DZ(){return DZ=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},DZ.apply(null,arguments)}var mG;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(mG||(mG={}));var B3;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(B3||(B3={}));var $8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})($8||($8={}));function NL1(Z){if(!Z.extensions||!Z.extensions[X6])return!1;return!!Z.extensions[X6].fallback}var{BYTE:OL1,SHORT:kn,FLOAT:PL1}=K0.ComponentType,{encodeNormalizedInt:En,decodeNormalizedInt:iR}=I0;function TL1(Z,J,X,$){let{filter:Y,bits:Q}=$,K={array:Z.getArray(),byteStride:Z.getElementSize()*Z.getComponentSize(),componentType:Z.getComponentType(),normalized:Z.getNormalized()};if(X!==B3.ATTRIBUTES)return K;if(Y!==$8.NONE){let W=Z.getNormalized()?CL1(Z):new Float32Array(K.array);switch(Y){case $8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=PL1,K.normalized=!1,K.array=J.encodeFilterExp(W,Z.getCount(),K.byteStride,Q);break;case $8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?kn:OL1,K.normalized=!0,W=Z.getElementSize()===3?kL1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case $8.QUATERNION:K.byteStride=8,K.componentType=kn,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw new Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>iR(G,Z.getComponentType())),K.max=K.max.map((G)=>iR(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>En(G,K.componentType)),K.max=K.max.map((G)=>En(G,K.componentType))}else if(K.byteStride%4)K.array=fL1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function CL1(Z){let J=Z.getComponentType(),X=Z.getArray(),$=new Float32Array(X.length);for(let Y=0;Y<X.length;Y++)$[Y]=iR(X[Y],J);return $}function fL1(Z,J){let $=E0.padNumber(Z.BYTES_PER_ELEMENT*J)/Z.BYTES_PER_ELEMENT,Y=Z.length/J,Q=new Z.constructor(Y*$);for(let K=0;K*J<Z.length;K++)for(let W=0;W<J;W++)Q[K*$+W]=Z[K*J+W];return Q}function kL1(Z){let J=new Float32Array(Z.length*4/3);for(let X=0,$=Z.length/3;X<$;X++)J[X*4]=Z[X*3],J[X*4+1]=Z[X*3+1],J[X*4+2]=Z[X*3+2];return J}function EL1(Z,J){if(J===c4.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some(($)=>{return $ instanceof g1&&$.getMode()===g1.Mode.TRIANGLES})?B3.TRIANGLES:B3.INDICES;return B3.ATTRIBUTES}function IL1(Z,J){let X=J.getGraph().listParentEdges(Z).filter(($)=>!($.getParent()instanceof W3));for(let $ of X){let Y=$.getName(),Q=$.getAttributes().key||"",K=$.getParent().propertyType===i.PRIMITIVE_TARGET;if(Y==="indices")return{filter:$8.NONE};if(Y==="attributes"){if(Q==="POSITION")return{filter:$8.NONE};if(Q==="TEXCOORD_0")return{filter:$8.NONE};if(Q.startsWith("JOINTS_"))return{filter:$8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:$8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:$8.NONE}:{filter:$8.OCTAHEDRAL,bits:8}}if(Y==="output"){let W=gn(Z);if(W==="rotation")return{filter:$8.QUATERNION,bits:16};if(W==="translation")return{filter:$8.EXPONENTIAL,bits:12};if(W==="scale")return{filter:$8.EXPONENTIAL,bits:12};return{filter:$8.NONE}}if(Y==="input")return{filter:$8.NONE};if(Y==="inverseBindMatrices")return{filter:$8.NONE}}return{filter:$8.NONE}}function gn(Z){for(let J of Z.listParents()){if(!(J instanceof SJ))continue;for(let X of J.listParents()){if(!(X instanceof QZ))continue;return X.getTargetPath()}}return null}var In={method:mG.QUANTIZE};class lG extends P1{constructor(...Z){super(...Z);this.extensionName=X6,this.prereadTypes=[i.BUFFER,i.PRIMITIVE],this.prewriteTypes=[i.BUFFER,i.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=In,this._encoderFallbackBuffer=null,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={}}install(Z,J){if(Z==="meshopt.decoder")this._decoder=J;if(Z==="meshopt.encoder")this._encoder=J;return this}setEncoderOptions(Z){return this._encoderOptions=DZ({},In,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${X6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${X6}]: Missing WASM support.`)}if(J===i.BUFFER)this._prereadBuffers(Z);else if(J===i.PRIMITIVE)this._prereadPrimitives(Z);return this}_prereadBuffers(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[X6])return;let Q=$.extensions[X6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,z=Q.byteStride,v=new Uint8Array(G*z),H=J.json.buffers[Q.buffer],V=H.uri?J.resources[H.uri]:J.resources[k$],q=E0.toView(V,K,W);this._decoder.decodeGltfBuffer(v,G,z,q,Q.mode,Q.filter),Z.bufferViews[Y]=v})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach(($)=>{if(!$.extensions||!$.extensions[X6])return;let Y=$.extensions[X6],Q=Z.buffers[Y.buffer],K=Z.buffers[$.buffer],W=J.json.buffers[$.buffer];if(NL1(W))this._decoderFallbackBufferMap.set(K,Q)})}read(Z){if(!this.isRequired())return this;for(let[J,X]of this._decoderFallbackBufferMap){for(let $ of J.listParents())if($ instanceof K0)$.swap(J,X);J.dispose()}return this}prewrite(Z,J){if(J===i.ACCESSOR)this._prewriteAccessors(Z);else if(J===i.BUFFER)this._prewriteBuffers(Z);return this}_prewriteAccessors(Z){let J=Z.jsonDoc.json,X=this._encoder,$=this._encoderOptions,Y=this.document.getGraph(),Q=this.document.createBuffer(),K=this.document.getRoot().listBuffers().indexOf(Q),W=1,G=new Map,z=(v)=>{for(let H of Y.listParents(v)){if(H.propertyType===i.ROOT)continue;let V=G.get(v);if(V===void 0)G.set(v,V=W++);return V}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let v of this.document.getRoot().listAccessors()){if(gn(v)==="weights")continue;if(v.getSparse())continue;let H=Z.getAccessorUsage(v),V=Z.accessorUsageGroupedByParent.has(H)?z(v):null,q=EL1(v,H),F=$.method===mG.FILTER?IL1(v,this.document):{filter:$8.NONE},x=TL1(v,X,q,F),{array:c,byteStride:w}=x,B=v.getBuffer();if(!B)throw new Error(`${X6}: Missing buffer for accessor.`);let j=this.document.getRoot().listBuffers().indexOf(B),L=[H,V,q,F.filter,w,j].join(":"),R=this._encoderBufferViews[L],M=this._encoderBufferViewData[L],N=this._encoderBufferViewAccessors[L];if(!R||!M)N=this._encoderBufferViewAccessors[L]=[],M=this._encoderBufferViewData[L]=[],R=this._encoderBufferViews[L]={buffer:K,target:c4.USAGE_TO_TARGET[H],byteOffset:0,byteLength:0,byteStride:H===c4.BufferViewUsage.ARRAY_BUFFER?w:void 0,extensions:{[X6]:{buffer:j,byteOffset:0,byteLength:0,mode:q,filter:F.filter!==$8.NONE?F.filter:void 0,byteStride:w,count:0}}};let P=Z.createAccessorDef(v);if(P.componentType=x.componentType,P.normalized=x.normalized,P.byteOffset=R.byteLength,P.min&&x.min)P.min=x.min;if(P.max&&x.max)P.max=x.max;Z.accessorIndexMap.set(v,J.accessors.length),J.accessors.push(P),N.push(P),M.push(new Uint8Array(c.buffer,c.byteOffset,c.byteLength)),R.byteLength+=c.byteLength,R.extensions.EXT_meshopt_compression.count+=v.getCount()}}_prewriteBuffers(Z){let J=this._encoder;for(let X in this._encoderBufferViews){let $=this._encoderBufferViews[X],Y=this._encoderBufferViewData[X],Q=this.document.getRoot().listBuffers()[$.extensions[X6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:z}=$.extensions[X6],v=E0.concat(Y),H=J.encodeGltfBuffer(v,W,G,z),V=E0.pad(H);$.extensions[X6].byteLength=H.byteLength,Y.length=0,Y.push(V),K.push(V),Z.otherBufferViews.set(Q,K)}}write(Z){let J=0;for(let Q in this._encoderBufferViews){let K=this._encoderBufferViews[Q],W=this._encoderBufferViewData[Q][0],G=Z.otherBufferViewsIndexMap.get(W),z=this._encoderBufferViewAccessors[Q];for(let q of z)q.bufferView=G;let v=Z.jsonDoc.json.bufferViews[G],H=v.byteOffset||0;Object.assign(v,K),v.byteOffset=J;let V=v.extensions[X6];V.byteOffset=H,J+=E0.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,$=Z.bufferIndexMap.get(X),Y=Z.jsonDoc.json.buffers[$];return Y.byteLength=J,Y.extensions={[X6]:{fallback:!0}},X.dispose(),this}}lG.EXTENSION_NAME=X6;lG.EncoderMethod=mG;class dn{match(Z){return Z.length>=12&&E0.decodeText(Z.slice(4,12))==="ftypavif"}getSize(Z){if(!this.match(Z))return null;let J=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),X=_n(J,0);if(!X)return null;let $=X.end;while(X=_n(J,$))if(X.type==="meta")$=X.start+4;else if(X.type==="iprp"||X.type==="ipco")$=X.start;else if(X.type==="ispe")return[J.getUint32(X.start+4),J.getUint32(X.start+8)];else if(X.type==="mdat")break;else $=X.end;return null}getChannels(Z){return 4}}class Nx extends P1{constructor(...Z){super(...Z);this.extensionName=SG,this.prereadTypes=[i.TEXTURE]}static register(){E5.registerFormat("image/avif",new dn)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[SG])X.source=X.extensions[SG].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/avif"){let $=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===$)Q.extensions=Q.extensions||{},Q.extensions[SG]={source:Q.source},delete Q.source})}}),this}}Nx.EXTENSION_NAME=SG;function _n(Z,J){if(Z.byteLength<4+J)return null;let X=Z.getUint32(J);if(Z.byteLength<X+J||X<8)return null;return{type:E0.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}class an{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=E0.decodeText(Z.slice(0,4)),X=E0.decodeText(Z.slice(8,12));if(J!=="RIFF"||X!=="WEBP")return null;let $=new DataView(Z.buffer,Z.byteOffset),Y=12;while(Y<$.byteLength){let Q=E0.decodeText(new Uint8Array([$.getUint8(Y),$.getUint8(Y+1),$.getUint8(Y+2),$.getUint8(Y+3)])),K=$.getUint32(Y+4,!0);if(Q==="VP8 "){let W=$.getInt16(Y+14,!0)&16383,G=$.getInt16(Y+16,!0)&16383;return[W,G]}else if(Q==="VP8L"){let W=$.getUint8(Y+9),G=$.getUint8(Y+10),z=$.getUint8(Y+11),v=$.getUint8(Y+12),H=1+((G&63)<<8|W),V=1+((v&15)<<10|z<<2|(G&192)>>6);return[H,V]}Y+=8+K+K%2}return null}getChannels(Z){return 4}}class Ox extends P1{constructor(...Z){super(...Z);this.extensionName=hG,this.prereadTypes=[i.TEXTURE]}static register(){E5.registerFormat("image/webp",new an)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[hG])X.source=X.extensions[hG].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/webp"){let $=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===$)Q.extensions=Q.extensions||{},Q.extensions[hG]={source:Q.source},delete Q.source})}}),this}}Ox.EXTENSION_NAME=hG;var h8,nn,sn;function _L1(Z,J){let X=new h8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==h8.TRIANGULAR_MESH)throw new Error(`[${s1}] Unknown geometry type.`);let Y=new h8.Mesh;if(!Z.DecodeBufferToMesh(X,Y).ok()||Y.ptr===0)throw new Error(`[${s1}] Decoding failure.`);return Y}finally{h8.destroy(X)}}function bL1(Z,J){let $=J.num_faces()*3,Y,Q;if(J.num_points()<=65534){let K=$*Uint16Array.BYTES_PER_ELEMENT;Y=h8._malloc(K),Z.GetTrianglesUInt16Array(J,K,Y),Q=new Uint16Array(h8.HEAPU16.buffer,Y,$).slice()}else{let K=$*Uint32Array.BYTES_PER_ELEMENT;Y=h8._malloc(K),Z.GetTrianglesUInt32Array(J,K,Y),Q=new Uint32Array(h8.HEAPU32.buffer,Y,$).slice()}return h8._free(Y),Q}function hL1(Z,J,X,$){let Y=sn[$.componentType],Q=nn[$.componentType],K=X.num_components(),G=J.num_points()*K,z=G*Q.BYTES_PER_ELEMENT,v=h8._malloc(z);Z.GetAttributeDataArrayForAllPoints(J,X,Y,z,v);let H=new Q(h8.HEAPF32.buffer,v,G).slice();return h8._free(v),H}function SL1(Z){h8=Z,nn={[K0.ComponentType.FLOAT]:Float32Array,[K0.ComponentType.UNSIGNED_INT]:Uint32Array,[K0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[K0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[K0.ComponentType.SHORT]:Int16Array,[K0.ComponentType.BYTE]:Int8Array},sn={[K0.ComponentType.FLOAT]:h8.DT_FLOAT32,[K0.ComponentType.UNSIGNED_INT]:h8.DT_UINT32,[K0.ComponentType.UNSIGNED_SHORT]:h8.DT_UINT16,[K0.ComponentType.UNSIGNED_BYTE]:h8.DT_UINT8,[K0.ComponentType.SHORT]:h8.DT_INT16,[K0.ComponentType.BYTE]:h8.DT_INT8}}var U4,uG;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(uG||(uG={}));var L4;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(L4||(L4={}));var on={[L4.POSITION]:14,[L4.NORMAL]:10,[L4.COLOR]:8,[L4.TEX_COORD]:12,[L4.GENERIC]:12},bn={decodeSpeed:5,encodeSpeed:5,method:uG.EDGEBREAKER,quantizationBits:on,quantizationVolume:"mesh"};function AL1(Z){U4=Z}function mL1(Z,J=bn){let X=DZ({},bn,J);X.quantizationBits=DZ({},on,J.quantizationBits);let $=new U4.MeshBuilder,Y=new U4.Mesh,Q=new U4.ExpertEncoder(Y),K={},W=new U4.DracoInt8Array,G=Z.listTargets().length>0,z=!1;for(let x of Z.listSemantics()){let c=Z.getAttribute(x);if(c.getSparse()){z=!0;continue}let w=uL1(x),B=lL1($,c.getComponentType(),Y,U4[w],c.getCount(),c.getElementSize(),c.getArray());if(B===-1)throw new Error(`Error compressing "${x}" attribute.`);if(K[x]=B,X.quantizationVolume==="mesh"||x!=="POSITION")Q.SetAttributeQuantization(B,X.quantizationBits[w]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:j}=X,L=Math.max(j.max[0]-j.min[0],j.max[1]-j.min[1],j.max[2]-j.min[2]);Q.SetAttributeExplicitQuantization(B,X.quantizationBits[w],c.getElementSize(),j.min,L)}else throw new Error("Invalid quantization volume state.")}let v=Z.getIndices();if(!v)throw new Dx("Primitive must have indices.");if($.AddFacesToMesh(Y,v.getCount()/3,v.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===uG.SEQUENTIAL||G||z)Q.SetEncodingMethod(U4.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(U4.MESH_EDGEBREAKER_ENCODING);let H=Q.EncodeToDracoBuffer(!(G||z),W);if(H<=0)throw new Dx("Error applying Draco compression.");let V=new Uint8Array(H);for(let x=0;x<H;++x)V[x]=W.GetValue(x);let q=Q.GetNumberOfEncodedPoints(),F=Q.GetNumberOfEncodedFaces()*3;return U4.destroy(W),U4.destroy(Y),U4.destroy($),U4.destroy(Q),{numVertices:q,numIndices:F,data:V,attributeIDs:K}}function uL1(Z){if(Z==="POSITION")return L4.POSITION;else if(Z==="NORMAL")return L4.NORMAL;else if(Z.startsWith("COLOR_"))return L4.COLOR;else if(Z.startsWith("TEXCOORD_"))return L4.TEX_COORD;return L4.GENERIC}function lL1(Z,J,X,$,Y,Q,K){switch(J){case K0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,$,Y,Q,K);case K0.ComponentType.BYTE:return Z.AddInt8Attribute(X,$,Y,Q,K);case K0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,$,Y,Q,K);case K0.ComponentType.SHORT:return Z.AddInt16Attribute(X,$,Y,Q,K);case K0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,$,Y,Q,K);case K0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,$,Y,Q,K);default:throw new Error(`Unexpected component type, "${J}".`)}}class Dx extends Error{}class yG extends P1{constructor(...Z){super(...Z);this.extensionName=s1,this.prereadTypes=[i.PRIMITIVE],this.prewriteTypes=[i.ACCESSOR],this.readDependencies=["draco3d.decoder"],this.writeDependencies=["draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(Z,J){if(Z==="draco3d.decoder")this._decoderModule=J,SL1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,AL1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw new Error(`[${s1}] Please install extension dependency, "draco3d.decoder".`);let J=this.document.getLogger(),X=Z.jsonDoc,$=new Map;try{let Y=X.json.meshes||[];for(let Q of Y)for(let K of Q.primitives){if(!K.extensions||!K.extensions[s1])continue;let W=K.extensions[s1],[G,z]=$.get(W.bufferView)||[];if(!z||!G){let v=X.json.bufferViews[W.bufferView],H=X.json.buffers[v.buffer],V=H.uri?X.resources[H.uri]:X.resources[k$],q=v.byteOffset||0,F=v.byteLength,x=E0.toView(V,q,F);G=new this._decoderModule.Decoder,z=_L1(G,x),$.set(W.bufferView,[G,z]),J.debug(`[${s1}] Decompressed ${x.byteLength} bytes.`)}for(let v in W.attributes){let H=Z.jsonDoc.json.accessors[K.attributes[v]],V=G.GetAttributeByUniqueId(z,W.attributes[v]),q=hL1(G,z,V,H);Z.accessors[K.attributes[v]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(bL1(G,z))}}finally{for(let[Y,Q]of Array.from($.values()))this._decoderModule.destroy(Y),this._decoderModule.destroy(Q)}return this}read(Z){return this}prewrite(Z,J){if(!this._encoderModule)throw new Error(`[${s1}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${s1}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let $=yL1(this.document),Y=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${s1}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=RG(this.document.getRoot().listScenes().pop());for(let K of Array.from($.keys())){let W=$.get(K);if(!W)throw new Error("Unexpected primitive.");if(Y.has(W)){Y.set(W,Y.get(W));continue}let G=K.getIndices(),z=Z.jsonDoc.json.accessors,v;try{v=mL1(K,DZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof Dx){X.warn(`[${s1}]: ${q.message} Skipping primitive compression.`);continue}throw q}Y.set(W,v);let H=Z.createAccessorDef(G);if(H.count=v.numIndices,Z.accessorIndexMap.set(G,z.length),z.push(H),v.numVertices>65534&&K0.getComponentSize(H.componentType)<=2)H.componentType=K0.ComponentType.UNSIGNED_INT;else if(v.numVertices>254&&K0.getComponentSize(H.componentType)<=1)H.componentType=K0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let F=K.getAttribute(q);if(v.attributeIDs[q]===void 0)continue;let x=Z.createAccessorDef(F);x.count=v.numVertices,Z.accessorIndexMap.set(F,z.length),z.push(x)}let V=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(V))Z.otherBufferViews.set(V,[]);Z.otherBufferViews.get(V).push(v.data)}return X.debug(`[${s1}] Compressed ${$.size} primitives.`),Z.extensionData[s1]={primitiveHashMap:$,primitiveEncodingMap:Y},this}write(Z){let J=Z.extensionData[s1];for(let X of this.document.getRoot().listMeshes()){let $=Z.jsonDoc.json.meshes[Z.meshIndexMap.get(X)];for(let Y=0;Y<X.listPrimitives().length;Y++){let Q=X.listPrimitives()[Y],K=$.primitives[Y],W=J.primitiveHashMap.get(Q);if(!W)continue;let G=J.primitiveEncodingMap.get(W);if(!G)continue;K.extensions=K.extensions||{},K.extensions[s1]={bufferView:Z.otherBufferViewsIndexMap.get(G.data),attributes:G.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter(($)=>$!==s1),X.extensionsRequired=(X.extensionsRequired||[]).filter(($)=>$!==s1)}return this}}yG.EXTENSION_NAME=s1;yG.EncoderMethod=uG;function yL1(Z){let J=Z.getLogger(),X=new Set,$=new Set,Y=0,Q=0;for(let H of Z.getRoot().listMeshes())for(let V of H.listPrimitives())if(!V.getIndices())$.add(V),Y++;else if(V.getMode()!==g1.Mode.TRIANGLES)$.add(V),Q++;else X.add(V);if(Y>0)J.warn(`[${s1}] Skipping Draco compression of ${Y} non-indexed primitives.`);if(Q>0)J.warn(`[${s1}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),W=new Map;for(let H=0;H<K.length;H++)W.set(K[H],H);let G=new Map,z=new Set,v=new Map;for(let H of Array.from(X)){let V=hn(H,W);if(z.has(V)){v.set(H,V);continue}if(G.has(H.getIndices())){let q=H.getIndices(),F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}for(let q of H.listAttributes())if(G.has(q)){let F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}V=hn(H,W),z.add(V),v.set(H,V),G.set(H.getIndices(),V);for(let q of H.listAttributes())G.set(q,V)}for(let H of Array.from(G.keys())){let V=new Set(H.listParents().map((q)=>q.propertyType));if(V.size!==2||!V.has(i.PRIMITIVE)||!V.has(i.ROOT))throw new Error(`[${s1}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let H of Array.from(X)){let V=v.get(H),q=H.getIndices();if(G.get(q)!==V||H.listAttributes().some((F)=>G.get(F)!==V))throw new Error(`[${s1}] Draco primitives must share all, or no, accessors.`)}for(let H of Array.from($)){let V=H.getIndices();if(G.has(V)||H.listAttributes().some((q)=>G.has(q)))throw new Error(`[${s1}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return v}function hn(Z,J){let X=[],$=Z.getIndices();X.push(J.get($));for(let Y of Z.listAttributes())X.push(J.get(Y));return X.sort().join("|")}class j3 extends O1{init(){this.extensionName=B4,this.propertyType="Light",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:j3.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(Z){return this.set("color",Z)}getIntensity(){return this.get("intensity")}setIntensity(Z){return this.set("intensity",Z)}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getRange(){return this.get("range")}setRange(Z){return this.set("range",Z)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(Z){return this.set("innerConeAngle",Z)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(Z){return this.set("outerConeAngle",Z)}}j3.EXTENSION_NAME=B4;j3.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};class dR extends P1{constructor(...Z){super(...Z);this.extensionName=B4}createLight(Z=""){return new j3(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[B4])return this;let Y=(J.json.extensions[B4].lights||[]).map((Q)=>{var K,W;let G=this.createLight().setName(Q.name||"").setType(Q.type);if(Q.color!==void 0)G.setColor(Q.color);if(Q.intensity!==void 0)G.setIntensity(Q.intensity);if(Q.range!==void 0)G.setRange(Q.range);if(((K=Q.spot)==null?void 0:K.innerConeAngle)!==void 0)G.setInnerConeAngle(Q.spot.innerConeAngle);if(((W=Q.spot)==null?void 0:W.outerConeAngle)!==void 0)G.setOuterConeAngle(Q.spot.outerConeAngle);return G});return J.json.nodes.forEach((Q,K)=>{if(!Q.extensions||!Q.extensions[B4])return;let W=Q.extensions[B4];Z.nodes[K].setExtension(B4,Y[W.light])}),this}write(Z){let J=Z.jsonDoc;if(this.properties.size===0)return this;let X=[],$=new Map;for(let Y of this.properties){let Q=Y,K={type:Q.getType()};if(!I0.eq(Q.getColor(),[1,1,1]))K.color=Q.getColor();if(Q.getIntensity()!==1)K.intensity=Q.getIntensity();if(Q.getRange()!=null)K.range=Q.getRange();if(Q.getName())K.name=Q.getName();if(Q.getType()===j3.Type.SPOT)K.spot={innerConeAngle:Q.getInnerConeAngle(),outerConeAngle:Q.getOuterConeAngle()};X.push(K),$.set(Q,X.length-1)}return this.document.getRoot().listNodes().forEach((Y)=>{let Q=Y.getExtension(B4);if(Q){let K=Z.nodeIndexMap.get(Y),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[B4]={light:$.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[B4]={lights:X},this}}dR.EXTENSION_NAME=B4;var{R:pL1,G:iL1,B:gL1}=v5;class aR extends O1{init(){this.extensionName=zZ,this.propertyType="Anisotropy",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new F1(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(Z){return this.set("anisotropyStrength",Z)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(Z){return this.set("anisotropyRotation",Z)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(Z){return this.setRef("anisotropyTexture",Z,{channels:pL1|iL1|gL1})}}aR.EXTENSION_NAME=zZ;class nR extends P1{constructor(...Z){super(...Z);this.extensionName=zZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createAnisotropy(){return new aR(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[zZ]){let K=this.createAnisotropy();Z.materials[Q].setExtension(zZ,K);let W=Y.extensions[zZ];if(W.anisotropyStrength!==void 0)K.setAnisotropyStrength(W.anisotropyStrength);if(W.anisotropyRotation!==void 0)K.setAnisotropyRotation(W.anisotropyRotation);if(W.anisotropyTexture!==void 0){let G=W.anisotropyTexture,z=Z.textures[$[G.index].source];K.setAnisotropyTexture(z),Z.setTextureInfo(K.getAnisotropyTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(zZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[zZ]={};if($.getAnisotropyStrength()>0)K.anisotropyStrength=$.getAnisotropyStrength();if($.getAnisotropyRotation()!==0)K.anisotropyRotation=$.getAnisotropyRotation();if($.getAnisotropyTexture()){let W=$.getAnisotropyTexture(),G=$.getAnisotropyTextureInfo();K.anisotropyTexture=Z.createTextureInfoDef(W,G)}}}),this}}nR.EXTENSION_NAME=zZ;var{R:Sn,G:An,B:dL1}=v5;class sR extends O1{init(){this.extensionName=vZ,this.propertyType="Clearcoat",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new F1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new F1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new F1(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(Z){return this.set("clearcoatFactor",Z)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(Z){return this.setRef("clearcoatTexture",Z,{channels:Sn})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(Z){return this.set("clearcoatRoughnessFactor",Z)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(Z){return this.setRef("clearcoatRoughnessTexture",Z,{channels:An})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(Z){return this.set("clearcoatNormalScale",Z)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(Z){return this.setRef("clearcoatNormalTexture",Z,{channels:Sn|An|dL1})}}sR.EXTENSION_NAME=vZ;class oR extends P1{constructor(...Z){super(...Z);this.extensionName=vZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createClearcoat(){return new sR(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[vZ]){let K=this.createClearcoat();Z.materials[Q].setExtension(vZ,K);let W=Y.extensions[vZ];if(W.clearcoatFactor!==void 0)K.setClearcoatFactor(W.clearcoatFactor);if(W.clearcoatRoughnessFactor!==void 0)K.setClearcoatRoughnessFactor(W.clearcoatRoughnessFactor);if(W.clearcoatTexture!==void 0){let G=W.clearcoatTexture,z=Z.textures[$[G.index].source];K.setClearcoatTexture(z),Z.setTextureInfo(K.getClearcoatTextureInfo(),G)}if(W.clearcoatRoughnessTexture!==void 0){let G=W.clearcoatRoughnessTexture,z=Z.textures[$[G.index].source];K.setClearcoatRoughnessTexture(z),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),G)}if(W.clearcoatNormalTexture!==void 0){let G=W.clearcoatNormalTexture,z=Z.textures[$[G.index].source];if(K.setClearcoatNormalTexture(z),Z.setTextureInfo(K.getClearcoatNormalTextureInfo(),G),G.scale!==void 0)K.setClearcoatNormalScale(G.scale)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(vZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[vZ]={clearcoatFactor:$.getClearcoatFactor(),clearcoatRoughnessFactor:$.getClearcoatRoughnessFactor()};if($.getClearcoatTexture()){let W=$.getClearcoatTexture(),G=$.getClearcoatTextureInfo();K.clearcoatTexture=Z.createTextureInfoDef(W,G)}if($.getClearcoatRoughnessTexture()){let W=$.getClearcoatRoughnessTexture(),G=$.getClearcoatRoughnessTextureInfo();K.clearcoatRoughnessTexture=Z.createTextureInfoDef(W,G)}if($.getClearcoatNormalTexture()){let W=$.getClearcoatNormalTexture(),G=$.getClearcoatNormalTextureInfo();if(K.clearcoatNormalTexture=Z.createTextureInfoDef(W,G),$.getClearcoatNormalScale()!==1)K.clearcoatNormalTexture.scale=$.getClearcoatNormalScale()}}}),this}}oR.EXTENSION_NAME=vZ;var{R:aL1,G:nL1,B:sL1,A:oL1}=v5;class rR extends O1{init(){this.extensionName=VZ,this.propertyType="DiffuseTransmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new F1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new F1(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(Z){return this.set("diffuseTransmissionFactor",Z)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(Z){return this.setRef("diffuseTransmissionTexture",Z,{channels:oL1})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(Z){return this.set("diffuseTransmissionColorFactor",Z)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(Z){return this.setRef("diffuseTransmissionColorTexture",Z,{channels:aL1|nL1|sL1})}}rR.EXTENSION_NAME=VZ;class tR extends P1{constructor(...Z){super(...Z);this.extensionName=VZ}createDiffuseTransmission(){return new rR(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[VZ]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(VZ,K);let W=Y.extensions[VZ];if(W.diffuseTransmissionFactor!==void 0)K.setDiffuseTransmissionFactor(W.diffuseTransmissionFactor);if(W.diffuseTransmissionColorFactor!==void 0)K.setDiffuseTransmissionColorFactor(W.diffuseTransmissionColorFactor);if(W.diffuseTransmissionTexture!==void 0){let G=W.diffuseTransmissionTexture,z=Z.textures[$[G.index].source];K.setDiffuseTransmissionTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),G)}if(W.diffuseTransmissionColorTexture!==void 0){let G=W.diffuseTransmissionColorTexture,z=Z.textures[$[G.index].source];K.setDiffuseTransmissionColorTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),G)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let $=X.getExtension(VZ);if(!$)continue;let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[VZ]={diffuseTransmissionFactor:$.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:$.getDiffuseTransmissionColorFactor()};if($.getDiffuseTransmissionTexture()){let W=$.getDiffuseTransmissionTexture(),G=$.getDiffuseTransmissionTextureInfo();K.diffuseTransmissionTexture=Z.createTextureInfoDef(W,G)}if($.getDiffuseTransmissionColorTexture()){let W=$.getDiffuseTransmissionColorTexture(),G=$.getDiffuseTransmissionColorTextureInfo();K.diffuseTransmissionColorTexture=Z.createTextureInfoDef(W,G)}}return this}}tR.EXTENSION_NAME=VZ;class eR extends O1{init(){this.extensionName=HZ,this.propertyType="Dispersion",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}eR.EXTENSION_NAME=HZ;class ZN extends P1{constructor(...Z){super(...Z);this.extensionName=HZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createDispersion(){return new eR(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[HZ]){let Q=this.createDispersion();Z.materials[Y].setExtension(HZ,Q);let K=$.extensions[HZ];if(K.dispersion!==void 0)Q.setDispersion(K.dispersion)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(HZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[HZ]={dispersion:$.getDispersion()}}}),this}}ZN.EXTENSION_NAME=HZ;class JN extends O1{init(){this.extensionName=qZ,this.propertyType="EmissiveStrength",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}JN.EXTENSION_NAME=qZ;class XN extends P1{constructor(...Z){super(...Z);this.extensionName=qZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createEmissiveStrength(){return new JN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[qZ]){let Q=this.createEmissiveStrength();Z.materials[Y].setExtension(qZ,Q);let K=$.extensions[qZ];if(K.emissiveStrength!==void 0)Q.setEmissiveStrength(K.emissiveStrength)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(qZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[qZ]={emissiveStrength:$.getEmissiveStrength()}}}),this}}XN.EXTENSION_NAME=qZ;class $N extends O1{init(){this.extensionName=FZ,this.propertyType="IOR",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}$N.EXTENSION_NAME=FZ;class Px extends P1{constructor(...Z){super(...Z);this.extensionName=FZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIOR(){return new $N(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[FZ]){let Q=this.createIOR();Z.materials[Y].setExtension(FZ,Q);let K=$.extensions[FZ];if(K.ior!==void 0)Q.setIOR(K.ior)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(FZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[FZ]={ior:$.getIOR()}}}),this}}Px.EXTENSION_NAME=FZ;var{R:rL1,G:tL1}=v5;class YN extends O1{init(){this.extensionName=xZ,this.propertyType="Iridescence",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new F1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new F1(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(Z){return this.set("iridescenceFactor",Z)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(Z){return this.setRef("iridescenceTexture",Z,{channels:rL1})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(Z){return this.set("iridescenceIOR",Z)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(Z){return this.set("iridescenceThicknessMinimum",Z)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(Z){return this.set("iridescenceThicknessMaximum",Z)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(Z){return this.setRef("iridescenceThicknessTexture",Z,{channels:tL1})}}YN.EXTENSION_NAME=xZ;class QN extends P1{constructor(...Z){super(...Z);this.extensionName=xZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIridescence(){return new YN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[xZ]){let K=this.createIridescence();Z.materials[Q].setExtension(xZ,K);let W=Y.extensions[xZ];if(W.iridescenceFactor!==void 0)K.setIridescenceFactor(W.iridescenceFactor);if(W.iridescenceIor!==void 0)K.setIridescenceIOR(W.iridescenceIor);if(W.iridescenceThicknessMinimum!==void 0)K.setIridescenceThicknessMinimum(W.iridescenceThicknessMinimum);if(W.iridescenceThicknessMaximum!==void 0)K.setIridescenceThicknessMaximum(W.iridescenceThicknessMaximum);if(W.iridescenceTexture!==void 0){let G=W.iridescenceTexture,z=Z.textures[$[G.index].source];K.setIridescenceTexture(z),Z.setTextureInfo(K.getIridescenceTextureInfo(),G)}if(W.iridescenceThicknessTexture!==void 0){let G=W.iridescenceThicknessTexture,z=Z.textures[$[G.index].source];K.setIridescenceThicknessTexture(z),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(xZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[xZ]={};if($.getIridescenceFactor()>0)K.iridescenceFactor=$.getIridescenceFactor();if($.getIridescenceIOR()!==1.3)K.iridescenceIor=$.getIridescenceIOR();if($.getIridescenceThicknessMinimum()!==100)K.iridescenceThicknessMinimum=$.getIridescenceThicknessMinimum();if($.getIridescenceThicknessMaximum()!==400)K.iridescenceThicknessMaximum=$.getIridescenceThicknessMaximum();if($.getIridescenceTexture()){let W=$.getIridescenceTexture(),G=$.getIridescenceTextureInfo();K.iridescenceTexture=Z.createTextureInfoDef(W,G)}if($.getIridescenceThicknessTexture()){let W=$.getIridescenceThicknessTexture(),G=$.getIridescenceThicknessTextureInfo();K.iridescenceThicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}QN.EXTENSION_NAME=xZ;var{R:mn,G:un,B:ln,A:yn}=v5;class KN extends O1{init(){this.extensionName=cZ,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new F1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new F1(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(Z){return this.set("diffuseFactor",Z)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(Z){return this.setRef("diffuseTexture",Z,{channels:mn|un|ln|yn,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(Z){return this.set("specularFactor",Z)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(Z){return this.set("glossinessFactor",Z)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(Z){return this.setRef("specularGlossinessTexture",Z,{channels:mn|un|ln|yn})}}KN.EXTENSION_NAME=cZ;class Tx extends P1{constructor(...Z){super(...Z);this.extensionName=cZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createPBRSpecularGlossiness(){return new KN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[cZ]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(cZ,K);let W=Y.extensions[cZ];if(W.diffuseFactor!==void 0)K.setDiffuseFactor(W.diffuseFactor);if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.glossinessFactor!==void 0)K.setGlossinessFactor(W.glossinessFactor);if(W.diffuseTexture!==void 0){let G=W.diffuseTexture,z=Z.textures[$[G.index].source];K.setDiffuseTexture(z),Z.setTextureInfo(K.getDiffuseTextureInfo(),G)}if(W.specularGlossinessTexture!==void 0){let G=W.specularGlossinessTexture,z=Z.textures[$[G.index].source];K.setSpecularGlossinessTexture(z),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(cZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[cZ]={diffuseFactor:$.getDiffuseFactor(),specularFactor:$.getSpecularFactor(),glossinessFactor:$.getGlossinessFactor()};if($.getDiffuseTexture()){let W=$.getDiffuseTexture(),G=$.getDiffuseTextureInfo();K.diffuseTexture=Z.createTextureInfoDef(W,G)}if($.getSpecularGlossinessTexture()){let W=$.getSpecularGlossinessTexture(),G=$.getSpecularGlossinessTextureInfo();K.specularGlossinessTexture=Z.createTextureInfoDef(W,G)}}}),this}}Tx.EXTENSION_NAME=cZ;var{R:eL1,G:ZD1,B:JD1,A:XD1}=v5;class WN extends O1{init(){this.extensionName=wZ,this.propertyType="Sheen",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new F1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new F1(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(Z){return this.set("sheenColorFactor",Z)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(Z){return this.setRef("sheenColorTexture",Z,{channels:eL1|ZD1|JD1,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(Z){return this.set("sheenRoughnessFactor",Z)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(Z){return this.setRef("sheenRoughnessTexture",Z,{channels:XD1})}}WN.EXTENSION_NAME=wZ;class GN extends P1{constructor(...Z){super(...Z);this.extensionName=wZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSheen(){return new WN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[wZ]){let K=this.createSheen();Z.materials[Q].setExtension(wZ,K);let W=Y.extensions[wZ];if(W.sheenColorFactor!==void 0)K.setSheenColorFactor(W.sheenColorFactor);if(W.sheenRoughnessFactor!==void 0)K.setSheenRoughnessFactor(W.sheenRoughnessFactor);if(W.sheenColorTexture!==void 0){let G=W.sheenColorTexture,z=Z.textures[$[G.index].source];K.setSheenColorTexture(z),Z.setTextureInfo(K.getSheenColorTextureInfo(),G)}if(W.sheenRoughnessTexture!==void 0){let G=W.sheenRoughnessTexture,z=Z.textures[$[G.index].source];K.setSheenRoughnessTexture(z),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(wZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[wZ]={sheenColorFactor:$.getSheenColorFactor(),sheenRoughnessFactor:$.getSheenRoughnessFactor()};if($.getSheenColorTexture()){let W=$.getSheenColorTexture(),G=$.getSheenColorTextureInfo();K.sheenColorTexture=Z.createTextureInfoDef(W,G)}if($.getSheenRoughnessTexture()){let W=$.getSheenRoughnessTexture(),G=$.getSheenRoughnessTextureInfo();K.sheenRoughnessTexture=Z.createTextureInfoDef(W,G)}}}),this}}GN.EXTENSION_NAME=wZ;var{R:$D1,G:YD1,B:QD1,A:KD1}=v5;class zN extends O1{init(){this.extensionName=UZ,this.propertyType="Specular",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new F1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new F1(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(Z){return this.set("specularFactor",Z)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(Z){return this.set("specularColorFactor",Z)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(Z){return this.setRef("specularTexture",Z,{channels:KD1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:$D1|YD1|QD1,isColor:!0})}}zN.EXTENSION_NAME=UZ;class Cx extends P1{constructor(...Z){super(...Z);this.extensionName=UZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSpecular(){return new zN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[UZ]){let K=this.createSpecular();Z.materials[Q].setExtension(UZ,K);let W=Y.extensions[UZ];if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.specularColorFactor!==void 0)K.setSpecularColorFactor(W.specularColorFactor);if(W.specularTexture!==void 0){let G=W.specularTexture,z=Z.textures[$[G.index].source];K.setSpecularTexture(z),Z.setTextureInfo(K.getSpecularTextureInfo(),G)}if(W.specularColorTexture!==void 0){let G=W.specularColorTexture,z=Z.textures[$[G.index].source];K.setSpecularColorTexture(z),Z.setTextureInfo(K.getSpecularColorTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(UZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[UZ]={};if($.getSpecularFactor()!==1)K.specularFactor=$.getSpecularFactor();if(!I0.eq($.getSpecularColorFactor(),[1,1,1]))K.specularColorFactor=$.getSpecularColorFactor();if($.getSpecularTexture()){let W=$.getSpecularTexture(),G=$.getSpecularTextureInfo();K.specularTexture=Z.createTextureInfoDef(W,G)}if($.getSpecularColorTexture()){let W=$.getSpecularColorTexture(),G=$.getSpecularColorTextureInfo();K.specularColorTexture=Z.createTextureInfoDef(W,G)}}}),this}}Cx.EXTENSION_NAME=UZ;var{R:WD1}=v5;class vN extends O1{init(){this.extensionName=BZ,this.propertyType="Transmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new F1(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(Z){return this.set("transmissionFactor",Z)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(Z){return this.setRef("transmissionTexture",Z,{channels:WD1})}}vN.EXTENSION_NAME=BZ;class VN extends P1{constructor(...Z){super(...Z);this.extensionName=BZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createTransmission(){return new vN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[BZ]){let K=this.createTransmission();Z.materials[Q].setExtension(BZ,K);let W=Y.extensions[BZ];if(W.transmissionFactor!==void 0)K.setTransmissionFactor(W.transmissionFactor);if(W.transmissionTexture!==void 0){let G=W.transmissionTexture,z=Z.textures[$[G.index].source];K.setTransmissionTexture(z),Z.setTextureInfo(K.getTransmissionTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(BZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[BZ]={transmissionFactor:$.getTransmissionFactor()};if($.getTransmissionTexture()){let W=$.getTransmissionTexture(),G=$.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}VN.EXTENSION_NAME=BZ;class HN extends O1{init(){this.extensionName=pJ,this.propertyType="Unlit",this.parentTypes=[i.MATERIAL]}}HN.EXTENSION_NAME=pJ;class fx extends P1{constructor(...Z){super(...Z);this.extensionName=pJ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createUnlit(){return new HN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((X,$)=>{if(X.extensions&&X.extensions[pJ])Z.materials[$].setExtension(pJ,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(pJ)){let $=Z.materialIndexMap.get(X),Y=J.json.materials[$];Y.extensions=Y.extensions||{},Y.extensions[pJ]={}}}),this}}fx.EXTENSION_NAME=pJ;class qN extends O1{init(){this.extensionName=U6,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new x1})}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}addVariant(Z){return this.addRef("variants",Z)}removeVariant(Z){return this.removeRef("variants",Z)}listVariants(){return this.listRefs("variants")}}qN.EXTENSION_NAME=U6;class FN extends O1{init(){this.extensionName=U6,this.propertyType="MappingList",this.parentTypes=[i.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new x1})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}FN.EXTENSION_NAME=U6;class Mx extends O1{init(){this.extensionName=U6,this.propertyType="Variant",this.parentTypes=["MappingList"]}}Mx.EXTENSION_NAME=U6;class xN extends P1{constructor(...Z){super(...Z);this.extensionName=U6}createMappingList(){return new FN(this.document.getGraph())}createVariant(Z=""){return new Mx(this.document.getGraph(),Z)}createMapping(){return new qN(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof Mx)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[U6])return this;let Y=(J.json.extensions[U6].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((v,H)=>{if(!v.extensions||!v.extensions[U6])return;let V=this.createMappingList(),q=v.extensions[U6];for(let F of q.mappings){let x=this.createMapping();if(F.material!==void 0)x.setMaterial(Z.materials[F.material]);for(let c of F.variants||[])x.addVariant(Y[c]);V.addMapping(x)}G.listPrimitives()[H].setExtension(U6,V)})}),this}write(Z){let J=Z.jsonDoc,X=this.listVariants();if(!X.length)return this;let $=[],Y=new Map;for(let Q of X)Y.set(Q,$.length),$.push(Z.createPropertyDef(Q));for(let Q of this.document.getRoot().listMeshes()){let K=Z.meshIndexMap.get(Q);Q.listPrimitives().forEach((W,G)=>{let z=W.getExtension(U6);if(!z)return;let v=Z.jsonDoc.json.meshes[K].primitives[G],H=z.listMappings().map((V)=>{let q=Z.createPropertyDef(V),F=V.getMaterial();if(F)q.material=Z.materialIndexMap.get(F);return q.variants=V.listVariants().map((x)=>Y.get(x)),q});v.extensions=v.extensions||{},v.extensions[U6]={mappings:H}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[U6]={variants:$},this}}xN.EXTENSION_NAME=U6;var{G:GD1}=v5;class cN extends O1{init(){this.extensionName=jZ,this.propertyType="Volume",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new F1(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(Z){return this.set("thicknessFactor",Z)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(Z){return this.setRef("thicknessTexture",Z,{channels:GD1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}cN.EXTENSION_NAME=jZ;class wN extends P1{constructor(...Z){super(...Z);this.extensionName=jZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createVolume(){return new cN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[jZ]){let K=this.createVolume();Z.materials[Q].setExtension(jZ,K);let W=Y.extensions[jZ];if(W.thicknessFactor!==void 0)K.setThicknessFactor(W.thicknessFactor);if(W.attenuationDistance!==void 0)K.setAttenuationDistance(W.attenuationDistance);if(W.attenuationColor!==void 0)K.setAttenuationColor(W.attenuationColor);if(W.thicknessTexture!==void 0){let G=W.thicknessTexture,z=Z.textures[$[G.index].source];K.setThicknessTexture(z),Z.setTextureInfo(K.getThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(jZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[jZ]={};if($.getThicknessFactor()>0)K.thicknessFactor=$.getThicknessFactor();if(Number.isFinite($.getAttenuationDistance()))K.attenuationDistance=$.getAttenuationDistance();if(!I0.eq($.getAttenuationColor(),[1,1,1]))K.attenuationColor=$.getAttenuationColor();if($.getThicknessTexture()){let W=$.getThicknessTexture(),G=$.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}wN.EXTENSION_NAME=jZ;class pG extends P1{constructor(...Z){super(...Z);this.extensionName=pn}read(Z){return this}write(Z){return this}}pG.EXTENSION_NAME=pn;class rn{match(Z){return Z[0]===171&&Z[1]===75&&Z[2]===84&&Z[3]===88&&Z[4]===32&&Z[5]===50&&Z[6]===48&&Z[7]===187&&Z[8]===13&&Z[9]===10&&Z[10]===26&&Z[11]===10}getSize(Z){let J=Lx(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=Lx(Z).dataFormatDescriptor[0];if(X.colorModel===Cn)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===fn)return(X.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=Lx(Z),X=this.getChannels(Z)>3,$=0;for(let Y=0;Y<J.levels.length;Y++){let Q=J.levels[Y];if(Q.uncompressedByteLength)$+=Q.uncompressedByteLength;else{let K=Math.max(1,Math.floor(J.pixelWidth/Math.pow(2,Y))),W=Math.max(1,Math.floor(J.pixelHeight/Math.pow(2,Y))),G=X?16:8;$+=K/4*(W/4)*G}}return $}}class UN extends P1{constructor(...Z){super(...Z);this.extensionName=AG,this.prereadTypes=[i.TEXTURE]}static register(){E5.registerFormat("image/ktx2",new rn)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[AG]){let X=J.extensions[AG];J.source=X.source}}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/ktx2"){let $=Z.imageIndexMap.get(X);J.json.textures.forEach((Y)=>{if(Y.source===$)Y.extensions=Y.extensions||{},Y.extensions[AG]={source:Y.source},delete Y.source})}}),this}}UN.EXTENSION_NAME=AG;class BN extends O1{init(){this.extensionName=LZ,this.propertyType="Transform",this.parentTypes=[i.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(Z){return this.set("offset",Z)}getRotation(){return this.get("rotation")}setRotation(Z){return this.set("rotation",Z)}getScale(){return this.get("scale")}setScale(Z){return this.set("scale",Z)}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}}BN.EXTENSION_NAME=LZ;class jN extends P1{constructor(...Z){super(...Z);this.extensionName=LZ}createTransform(){return new BN(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[LZ])continue;let $=this.createTransform(),Y=X.extensions[LZ];if(Y.offset!==void 0)$.setOffset(Y.offset);if(Y.rotation!==void 0)$.setRotation(Y.rotation);if(Y.scale!==void 0)$.setScale(Y.scale);if(Y.texCoord!==void 0)$.setTexCoord(Y.texCoord);J.setExtension(LZ,$)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,$]of J){let Y=X.getExtension(LZ);if(!Y)continue;$.extensions=$.extensions||{};let Q={},K=I0.eq;if(!K(Y.getOffset(),[0,0]))Q.offset=Y.getOffset();if(Y.getRotation()!==0)Q.rotation=Y.getRotation();if(!K(Y.getScale(),[1,1]))Q.scale=Y.getScale();if(Y.getTexCoord()!=null)Q.texCoord=Y.getTexCoord();$.extensions[LZ]=Q}return this}}jN.EXTENSION_NAME=LZ;var zD1=[i.ROOT,i.SCENE,i.NODE,i.MESH,i.MATERIAL,i.TEXTURE,i.ANIMATION];class LN extends O1{init(){this.extensionName=j4,this.propertyType="Packet",this.parentTypes=zD1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",DZ({},Z))}listProperties(){return Object.keys(this.get("properties"))}getProperty(Z){let J=this.get("properties");return Z in J?J[Z]:null}setProperty(Z,J){this._assertContext(Z);let X=DZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=yR(this.get("context")),J=yR(this.get("properties"));return DZ({"@context":Z},J)}fromJSONLD(Z){Z=yR(Z);let J=Z["@context"];if(J)this.set("context",J);return delete Z["@context"],this.set("properties",Z)}_assertContext(Z){if(!(Z.split(":")[0]in this.get("context")))throw new Error(`${j4}: Missing context for term, "${Z}".`)}}LN.EXTENSION_NAME=j4;function yR(Z){return JSON.parse(JSON.stringify(Z))}class DN extends P1{constructor(...Z){super(...Z);this.extensionName=j4}createPacket(){return new LN(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[j4];if(!X||!X.packets)return this;let $=Z.jsonDoc.json,Y=this.document.getRoot(),Q=X.packets.map((G)=>this.createPacket().fromJSONLD(G)),K=[[$.asset],$.scenes,$.nodes,$.meshes,$.materials,$.images,$.animations],W=[[Y],Y.listScenes(),Y.listNodes(),Y.listMeshes(),Y.listMaterials(),Y.listTextures(),Y.listAnimations()];for(let G=0;G<K.length;G++){let z=K[G]||[];for(let v=0;v<z.length;v++){let H=z[v];if(H.extensions&&H.extensions[j4]){let V=H.extensions[j4];W[G][v].setExtension(j4,Q[V.packet])}}}return this}write(Z){let{json:J}=Z.jsonDoc,X=[];for(let $ of this.properties){X.push($.toJSONLD());for(let Y of $.listParents()){let Q;switch(Y.propertyType){case i.ROOT:Q=J.asset;break;case i.SCENE:Q=J.scenes[Z.sceneIndexMap.get(Y)];break;case i.NODE:Q=J.nodes[Z.nodeIndexMap.get(Y)];break;case i.MESH:Q=J.meshes[Z.meshIndexMap.get(Y)];break;case i.MATERIAL:Q=J.materials[Z.materialIndexMap.get(Y)];break;case i.TEXTURE:Q=J.images[Z.imageIndexMap.get(Y)];break;case i.ANIMATION:Q=J.animations[Z.animationIndexMap.get(Y)];break;default:Q=null,this.document.getLogger().warn(`[${j4}]: Unsupported parent property, "${Y.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[j4]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[j4]={packets:X};return this}}DN.EXTENSION_NAME=j4;var vD1=[yG,dR,nR,oR,tR,ZN,XN,Px,QN,Tx,Cx,GN,VN,fx,xN,wN,pG,UN,jN,DN],aN6=[Rx,lG,Nx,Ox,...vD1];var VD1=t(cR(),1);function M3(){return M3=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},M3.apply(null,arguments)}var{POINTS:tn,LINES:kx,LINE_STRIP:HD1,LINE_LOOP:qD1,TRIANGLES:Ex,TRIANGLE_STRIP:FD1,TRIANGLE_FAN:xD1}=g1.Mode;function m$(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function RZ(Z,J){let X=M3({},Z);for(let $ in J)if(J[$]!==void 0)X[$]=J[$];return X}function cs(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case g1.Mode.POINTS:return J?J.getCount():X.getCount();case g1.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case g1.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case g1.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case g1.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case g1.Mode.TRIANGLE_STRIP:case g1.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw new Error("Unexpected mode: "+Z.getMode())}}var cD1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function NN(Z){return cD1.format(Z)}function wD1(Z,J,X=2){let $=Z>J?"–":"+",Y="%";return $+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function Sx(Z,J){return`${NN(Z)} → ${NN(J)} (${wD1(Z,J)})`}function Ax(Z){let J=[];for(let X of Z.listAttributes())J.push(X);for(let X of Z.listTargets())for(let $ of X.listAttributes())J.push($);return Array.from(new Set(J))}function UD1(Z,J,X){Z.swap(J,X);for(let $ of Z.listTargets())$.swap(J,X)}function ws(Z){let J=Z.getIndices(),X=Ax(Z);if(Z.dispose(),J&&!ON(J))J.dispose();for(let $ of X)if(!ON($))$.dispose()}function MZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function BD1(Z,J=Z){let X=IN(Z,J);for(let $=0;$<X.length;$++)X[$]=$;return X}function IN(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function ON(Z){return Z.listParents().some((J)=>J.propertyType!==i.ROOT)}function Us(Z){for(let J in Z)return!1;return!0}function Bs(Z){let J=c6.fromGraph(Z.getGraph()),X=Z.getMaterial(),$=J.getRoot().listMaterials().indexOf(X),Y=LD1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let z=Z.getAttribute(G),v=z.getElementSize(),H=z.getComponentType();return`${G}:${v}:${H}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((z)=>{let v=Z.getAttribute(z),H=v.getElementSize(),V=v.getComponentType();return`${z}:${H}:${V}`}).join("+")}).join("~");return`${$}|${Y}|${Q}|${K}|${W}`}function jD1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var LD1={[tn]:tn,[kx]:kx,[HD1]:kx,[qD1]:kx,[Ex]:Ex,[FD1]:Ex,[xD1]:Ex},L3="center",en={pivot:"center"};function js(Z=en){let J=RZ(en,Z);return m$(L3,(X)=>{let $=X.getLogger(),Y=X.getRoot(),Q=Y.listAnimations().length>0||Y.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{$.debug(`${L3}: Scene ${W+1} / ${Y.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let v=RG(K);if(G=[(v.max[0]-v.min[0])/2+v.min[0],(v.max[1]-v.min[1])/2+v.min[1],(v.max[2]-v.min[2])/2+v.min[2]],J.pivot==="above")G[1]=v.max[1];if(J.pivot==="below")G[1]=v.min[1]}else G=J.pivot;$.debug(`${L3}: Pivot "${G.join(", ")}".`);let z=[-1*G[0],-1*G[1],-1*G[2]];if(Q){$.debug(`${L3}: Model contains animation or skin. Adding a wrapper node.`);let v=X.createNode("Pivot").setTranslation(z);K.listChildren().forEach((H)=>v.addChild(H)),K.addChild(v)}else $.debug(`${L3}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((v)=>{let H=v.getTranslation();v.setTranslation([H[0]+z[0],H[1]+z[1],H[2]+z[2]])})}),$.debug(`${L3}: Complete.`)})}function DD1(Z){let J=new Set,X=Z,$;while($=X.getParentNode()){if(J.has($))throw new Error("Circular dependency in scene graph.");J.add($),X=$}return X.listParents().filter((Y)=>Y instanceof K3)}function MD1(Z){let J=DD1(Z),X=Z.getParentNode();if(!X)return Z;Z.setMatrix(Z.getWorldMatrix()),X.removeChild(Z);for(let $ of J)$.addChild(Z);return Z}var R3=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function RD1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=J[9],V=J[10],q=J[11],F=J[12],x=J[13],c=J[14],w=J[15],B=X*W-$*K,j=X*G-Y*K,L=X*z-Q*K,R=$*G-Y*W,M=$*z-Q*W,N=Y*z-Q*G,P=v*x-H*F,O=v*c-V*F,_=v*w-q*F,k=H*c-V*x,h=H*w-q*x,f=V*w-q*c,C=B*f-j*h+L*k+R*_-M*O+N*P;if(!C)return null;return C=1/C,Z[0]=(W*f-G*h+z*k)*C,Z[1]=(Y*h-$*f-Q*k)*C,Z[2]=(x*N-c*M+w*R)*C,Z[3]=(V*M-H*N-q*R)*C,Z[4]=(G*_-K*f-z*O)*C,Z[5]=(X*f-Y*_+Q*O)*C,Z[6]=(c*L-F*N-w*j)*C,Z[7]=(v*N-V*L+q*j)*C,Z[8]=(K*h-W*_+z*P)*C,Z[9]=($*_-X*h-Q*P)*C,Z[10]=(F*M-x*L+w*B)*C,Z[11]=(H*L-v*M-q*B)*C,Z[12]=(W*O-K*k-G*P)*C,Z[13]=(X*k-$*O+Y*P)*C,Z[14]=(x*j-F*R-c*B)*C,Z[15]=(v*R-H*j+V*B)*C,Z}function ND1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],x=Z[14],c=Z[15],w=J*K-X*Q,B=J*W-$*Q,j=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,N=z*F-v*q,P=z*x-H*q,O=z*c-V*q,_=v*x-H*F,k=v*c-V*F,h=H*c-V*x;return w*h-B*k+j*_+L*O-R*P+M*N}function Ls(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],x=J[12],c=J[13],w=J[14],B=J[15],j=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=j*$+L*W+R*H+M*x,Z[1]=j*Y+L*G+R*V+M*c,Z[2]=j*Q+L*z+R*q+M*w,Z[3]=j*K+L*v+R*F+M*B,j=X[4],L=X[5],R=X[6],M=X[7],Z[4]=j*$+L*W+R*H+M*x,Z[5]=j*Y+L*G+R*V+M*c,Z[6]=j*Q+L*z+R*q+M*w,Z[7]=j*K+L*v+R*F+M*B,j=X[8],L=X[9],R=X[10],M=X[11],Z[8]=j*$+L*W+R*H+M*x,Z[9]=j*Y+L*G+R*V+M*c,Z[10]=j*Q+L*z+R*q+M*w,Z[11]=j*K+L*v+R*F+M*B,j=X[12],L=X[13],R=X[14],M=X[15],Z[12]=j*$+L*W+R*H+M*x,Z[13]=j*Y+L*G+R*V+M*c,Z[14]=j*Q+L*z+R*q+M*w,Z[15]=j*K+L*v+R*F+M*B,Z}var B6;(function(Z){Z.RENDER="render",Z.RENDER_CACHED="render-cached",Z.UPLOAD="upload",Z.UPLOAD_NAIVE="upload-naive",Z.DISTINCT="distinct",Z.DISTINCT_POSITION="distinct-position",Z.UNUSED="unused"})(B6||(B6={}));function A$(Z,J){let X=Z.getAttribute("POSITION"),$=Z.getIndices();switch(J){case B6.RENDER:return $?$.getCount():X.getCount();case B6.RENDER_CACHED:return $?new Set($.getArray()).size:X.getCount();case B6.UPLOAD_NAIVE:case B6.UPLOAD:return X.getCount();case B6.DISTINCT:case B6.DISTINCT_POSITION:return OD1(J);case B6.UNUSED:return $?X.getCount()-new Set($.getArray()).size:0;default:return PD1(J)}}function OD1(Z){throw new Error(`Not implemented: ${Z}`)}function PD1(Z){throw new Error(`Unexpected value: ${Z}`)}var iJ=4294967295;class Ds{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of Ax(Z))J+=this._initAttribute(X);this.u8=new Uint8Array(J),this.u32=new Uint32Array(this.u8.buffer)}_initAttribute(Z){let J=Z.getArray(),X=new Uint8Array(J.buffer,J.byteOffset,J.byteLength),$=Z.getElementSize()*Z.getComponentSize(),Y=E0.padNumber($);return this.attributes.push({u8:X,byteStride:$,paddedByteStride:Y}),Y}hash(Z){let J=0;for(let{u8:X,byteStride:$,paddedByteStride:Y}of this.attributes){for(let Q=0;Q<Y;Q++)if(Q<$)this.u8[J+Q]=X[Z*$+Q];else this.u8[J+Q]=0;J+=Y}return TD1(0,this.u32)}equal(Z,J){for(let{u8:X,byteStride:$}of this.attributes)for(let Y=0;Y<$;Y++)if(X[Z*$+Y]!==X[J*$+Y])return!1;return!0}}function TD1(Z,J){for(let Y=0,Q=J.length;Y<Q;Y++){let K=J[Y];K=Math.imul(K,1540483477)>>>0,K=(K^K>>24)>>>0,K=Math.imul(K,1540483477)>>>0,Z=Math.imul(Z,1540483477)>>>0,Z=(Z^K)>>>0}return Z}function CD1(Z,J,X,$,Y=iJ){let Q=J-1,W=X.hash($)&Q;for(let G=0;G<=Q;G++){let z=Z[W];if(z===Y||X.equal(z,$))return W;W=W+G+1&Q}throw new Error("Hash table full.")}function gG(Z,J,X){let $=c6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=fD1(Z);let Y=Z.getIndices(),Q=Y?Y.getArray():null,K=A$(Z,B6.RENDER),W=$.createAccessor(),G=K,z=IN(G,X);for(let H=0;H<G;H++)z[H]=J[Q?Q[H]:H];Z.setIndices(W.setArray(z));let v=Ax(Z);for(let H of Z.listAttributes()){let V=MZ($,H);PN(H,Y,J,V,X),Z.swap(H,V)}for(let H of Z.listTargets())for(let V of H.listAttributes()){let q=MZ($,V);PN(V,Y,J,q,X),H.swap(V,q)}if(Y&&Y.listParents().length===1)Y.dispose();for(let H of v)if(H.listParents().length===1)H.dispose();return Z}function PN(Z,J,X,$,Y){let Q=Z.getElementSize(),K=Z.getArray(),W=J?J.getArray():null,G=J?J.getCount():Z.getCount(),z=new K.constructor(Y*Q),v=new Uint8Array(Y);for(let H=0;H<G;H++){let V=W?W[H]:H,q=X[V];if(v[q])continue;for(let F=0;F<Q;F++)z[q*Q+F]=K[V*Q+F];v[q]=1}return $.setArray(z)}function fD1(Z){let J=A$(Z,B6.UPLOAD),X=Z.getIndices(),$=X?X.getArray():null;if(!X||!$)return[BD1(J,1e6),J];let Y=new Uint32Array(J).fill(iJ),Q=0;for(let K=0;K<$.length;K++){let W=$[K];if(Y[W]===iJ)Y[W]=Q++}return[Y,Q]}function kD1(){var Z=new R3(9);if(R3!=Float32Array)Z[1]=0,Z[2]=0,Z[3]=0,Z[5]=0,Z[6]=0,Z[7]=0;return Z[0]=1,Z[4]=1,Z[8]=1,Z}function ED1(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[4],Z[4]=J[5],Z[5]=J[6],Z[6]=J[8],Z[7]=J[9],Z[8]=J[10],Z}function ID1(Z,J){if(Z===J){var X=J[1],$=J[2],Y=J[5];Z[1]=J[3],Z[2]=J[6],Z[3]=X,Z[5]=J[7],Z[6]=$,Z[7]=Y}else Z[0]=J[0],Z[1]=J[3],Z[2]=J[6],Z[3]=J[1],Z[4]=J[4],Z[5]=J[7],Z[6]=J[2],Z[7]=J[5],Z[8]=J[8];return Z}function _D1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=v*K-W*z,V=-v*Q+W*G,q=z*Q-K*G,F=X*H+$*V+Y*q;if(!F)return null;return F=1/F,Z[0]=H*F,Z[1]=(-v*$+Y*z)*F,Z[2]=(W*$-Y*K)*F,Z[3]=V*F,Z[4]=(v*X-Y*G)*F,Z[5]=(-W*X+Y*Q)*F,Z[6]=q*F,Z[7]=(-z*X+$*G)*F,Z[8]=(K*X-$*Q)*F,Z}function mx(){var Z=new R3(3);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function bD1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function Ms(Z,J){var X=J[0],$=J[1],Y=J[2],Q=X*X+$*$+Y*Y;if(Q>0)Q=1/Math.sqrt(Q);return Z[0]=J[0]*Q,Z[1]=J[1]*Q,Z[2]=J[2]*Q,Z}function hD1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=X[3]*$+X[7]*Y+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*$+X[4]*Y+X[8]*Q+X[12])/K,Z[1]=(X[1]*$+X[5]*Y+X[9]*Q+X[13])/K,Z[2]=(X[2]*$+X[6]*Y+X[10]*Q+X[14])/K,Z}function SD1(Z,J,X){var $=J[0],Y=J[1],Q=J[2];return Z[0]=$*X[0]+Y*X[3]+Q*X[6],Z[1]=$*X[1]+Y*X[4]+Q*X[7],Z[2]=$*X[2]+Y*X[5]+Q*X[8],Z}var AD1=bD1;(function(){var Z=mx();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=3;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();var TN="weld",_x={overwrite:!0};function _N(Z=_x){let J=RZ(_x,Z);return m$(TN,async(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes()){for(let Q of Y.listPrimitives())if(ux(Q,J),A$(Q,B6.RENDER)===0)ws(Q);if(Y.listPrimitives().length===0)Y.dispose()}$.debug(`${TN}: Complete.`)})}function ux(Z,J=_x){let X=Z.getGraph(),Y=c6.fromGraph(X).getLogger(),Q=M3({},_x,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===g1.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),W=Z.getIndices(),G=W==null?void 0:W.getArray(),z=W?W.getCount():K,v=new Ds(Z),H=jD1(K+K/4),V=new Uint32Array(H).fill(iJ),q=new Uint32Array(K).fill(iJ),F=0;for(let x=0;x<z;x++){let c=G?G[x]:x;if(q[c]!==iJ)continue;let w=CD1(V,H,v,c,iJ),B=V[w];if(B===iJ)V[w]=c,q[c]=F++;else q[c]=q[B]}Y.debug(`${TN}: ${Sx(K,F)} vertices.`),gG(Z,q,F)}var{FLOAT:mD1}=K0.ComponentType;function Rs(Z,J){let X=Z.getAttribute("POSITION");if(X)Zs(J,X);let $=Z.getAttribute("NORMAL");if($)Js(J,$);let Y=Z.getAttribute("TANGENT");if(Y)Xs(J,Y);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)Zs(J,K);let W=Q.getAttribute("NORMAL");if(W)Js(J,W);let G=Q.getAttribute("TANGENT");if(G)Xs(J,G)}if(ND1(J)<0)uD1(Z)}function Zs(Z,J){let X=J.getComponentType(),$=J.getNormalized(),Y=J.getArray(),Q=X===mD1?Y:new Float32Array(Y.length),K=mx();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=I0.decodeNormalizedInt(Y[W*3],X),K[1]=I0.decodeNormalizedInt(Y[W*3+1],X),K[2]=I0.decodeNormalizedInt(Y[W*3+2],X);else K[0]=Y[W*3],K[1]=Y[W*3+1],K[2]=Y[W*3+2];hD1(K,K,Z),Q[W*3]=K[0],Q[W*3+1]=K[1],Q[W*3+2]=K[2]}J.setArray(Q).setNormalized(!1)}function Js(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=kD1();ED1(Q,Z),_D1(Q,Q),ID1(Q,Q);let K=mx();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=I0.decodeNormalizedInt(X[W*3],Y),K[1]=I0.decodeNormalizedInt(X[W*3+1],Y),K[2]=I0.decodeNormalizedInt(X[W*3+2],Y);else K[0]=X[W*3],K[1]=X[W*3+1],K[2]=X[W*3+2];if(SD1(K,K,Q),Ms(K,K),$)X[W*3]=I0.decodeNormalizedInt(K[0],Y),X[W*3+1]=I0.decodeNormalizedInt(K[1],Y),X[W*3+2]=I0.decodeNormalizedInt(K[2],Y);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function Xs(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=mx();for(let K=0,W=J.getCount();K<W;K++){if($)Q[0]=I0.decodeNormalizedInt(X[K*4],Y),Q[1]=I0.decodeNormalizedInt(X[K*4+1],Y),Q[2]=I0.decodeNormalizedInt(X[K*4+2],Y);else Q[0]=X[K*4],Q[1]=X[K*4+1],Q[2]=X[K*4+2];if(Q[0]=Z[0]*Q[0]+Z[4]*Q[1]+Z[8]*Q[2],Q[1]=Z[1]*Q[0]+Z[5]*Q[1]+Z[9]*Q[2],Q[2]=Z[2]*Q[0]+Z[6]*Q[1]+Z[10]*Q[2],Ms(Q,Q),$)X[K*4]=I0.decodeNormalizedInt(Q[0],Y),X[K*4+1]=I0.decodeNormalizedInt(Q[1],Y),X[K*4+2]=I0.decodeNormalizedInt(Q[2],Y);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function uD1(Z){if(Z.getMode()!==g1.Mode.TRIANGLES)return;if(!Z.getIndices())ux(Z);let J=Z.getIndices();for(let X=0,$=J.getCount();X<$;X+=3){let Y=J.getScalar(X),Q=J.getScalar(X+2);J.setScalar(X,Q),J.setScalar(X+2,Y)}}function lD1(Z,J){for(let X of Z.listPrimitives()){let $=yD1(X,Z);if(X!==$)Z.removePrimitive(X).addPrimitive($)}for(let X of Z.listPrimitives())gG(X),Rs(X,J)}function yD1(Z,J){if(Z.listParents().some(($)=>$ instanceof NG&&$!==J))Z=Z.clone();for(let $ of Z.listTargets())if($.listParents().some((Q)=>Q instanceof g1&&Q!==Z))Z.removeTarget($).addTarget($.clone());return Z}var $s=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function Ns(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!I0.eq(X,$s))lD1(J,X);for(let $ of Z.listChildren()){let Y=$.getMatrix();Ls(Y,Y,X),$.setMatrix(Y)}return Z.setMatrix($s)}var{LINES:pD1,LINE_STRIP:iD1,LINE_LOOP:gD1,TRIANGLES:dD1,TRIANGLE_STRIP:aD1,TRIANGLE_FAN:nD1}=g1.Mode;function sD1(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())ux(Z);let $=Z.getIndices(),Y=$.getArray(),Q=cs(Z),W=new hJ[$.getComponentType()](Q*2),G=Z.getMode();if(G===iD1)for(let v=0;v<Q;v++)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else if(G===gD1)for(let v=0;v<Q;v++)if(v<Q-1)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else W[v*2]=Y[v],W[v*2+1]=Y[0];else throw new Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(pD1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,$).setArray(W));else $.setArray(W)}function Os(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())ux(Z);let $=Z.getIndices(),Y=$.getArray(),Q=cs(Z),W=new hJ[$.getComponentType()](Q*3),G=Z.getMode();if(G===aD1)for(let v=0,H=Y.length;v<H-2;v++)if(v%2)W[v*3]=Y[v+1],W[v*3+1]=Y[v],W[v*3+2]=Y[v+2];else W[v*3]=Y[v],W[v*3+1]=Y[v+1],W[v*3+2]=Y[v+2];else if(G===nD1)for(let v=0;v<Q;v++)W[v*3]=Y[0],W[v*3+1]=Y[v+1],W[v*3+2]=Y[v+2];else throw new Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(dD1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,$).setArray(W));else $.setArray(W)}var eN6={keepUniqueNames:!1,propertyTypes:[i.ACCESSOR,i.MESH,i.TEXTURE,i.MATERIAL,i.SKIN]};var Ys="dequantize",bx={pattern:/^((?!JOINTS_).)*$/};function Ps(Z=bx){let J=RZ(bx,Z);return m$(Ys,(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes())for(let Q of Y.listPrimitives())oD1(Q,J);X.createExtension(pG).dispose(),$.debug(`${Ys}: Complete.`)})}function oD1(Z,J=bx){let X=RZ(bx,J);for(let $ of Z.listSemantics())if(X.pattern.test($))CN(Z.getAttribute($));for(let $ of Z.listTargets())for(let Y of $.listSemantics())if(X.pattern.test(Y))CN($.getAttribute(Y))}function CN(Z){let J=Z.getArray();if(!J)return;let X=hx(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function hx(Z,J,X){let $=new Float32Array(Z.length);for(let Y=0,Q=Z.length;Y<Q;Y++)if(X)$[Y]=I0.decodeNormalizedInt(Z[Y],J);else $[Y]=Z[Y];return $}var{TEXTURE_INFO:Ts,ROOT:ZO6}=i;function Cs(Z){let J=new c6().setLogger(Z.getLogger()),X=bN(J,Z);return rD1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function rD1(Z,J,X){X||(X=bN(Z,J));for(let $ of J.getRoot().listExtensionsUsed()){let Y=Z.createExtension($.constructor);if($.isRequired())Y.setRequired(!0)}return tD1(Z,J,eD1(J),X)}function tD1(Z,J,X,$){$||($=bN(Z,J));let Y=new Map;for(let Q of X)if(!Y.has(Q)&&Q.propertyType!==Ts)Y.set(Q,$(Q));for(let[Q,K]of Y.entries())K.copy(Q,$);return Y}function bN(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return($)=>{if($.propertyType===Ts)return $;let Y=X.get($);if(!Y)Y=new $.constructor(Z.getGraph()),X.set($,Y);return Y}}function eD1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}function fs(){var Z=new R3(4);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function ZM1(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z[3]=J[3]+X[3],Z}function JM1(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z[2]=J[2]-X[2],Z[3]=J[3]-X[3],Z}function XM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z[3]=J[3]*X[3],Z}function $M1(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z}function YM1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3];return Math.hypot(J,X,$,Y)}var ks=JM1,QM1=XM1,Es=YM1;(function(){var Z=fs();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=4;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Z[3]=J[W+3],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2],J[W+3]=Z[3];return J}})();var KM1=/color|emissive|diffuse/i;function WM1(Z){return Z.getGraph().listParentEdges(Z).some((Y)=>{return Y.getAttributes().isColor||KM1.test(Y.getName())})?"srgb":null}function GM1(Z){let J=Z.getGraph(),X=new Set,$=new Set;function Y(Q){let K=new Set;for(let W of J.listChildEdges(Q))if(W.getChild()instanceof I$)K.add(W.getName()+"Info");for(let W of J.listChildEdges(Q)){let G=W.getChild();if(X.has(G))continue;if(X.add(G),G instanceof F1&&K.has(W.getName()))$.add(G);else if(G instanceof O1)Y(G)}}return Y(Z),Array.from($)}function zM1(Z){let X=c6.fromGraph(Z.getGraph()).getRoot(),$=Z.getGraph().listParentEdges(Z).filter((Y)=>Y.getParent()!==X).map((Y)=>Y.getName());return Array.from(new Set($))}var D3="prune",fN=0.011764705882352941,Qs={propertyTypes:[i.NODE,i.SKIN,i.MESH,i.CAMERA,i.PRIMITIVE,i.PRIMITIVE_TARGET,i.ANIMATION,i.MATERIAL,i.TEXTURE,i.ACCESSOR,i.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function Is(Z=Qs){let J=RZ(Qs,Z),X=new Set(J.propertyTypes),$=J.keepExtras;return m$(D3,async(Y)=>{let Q=Y.getLogger(),K=Y.getRoot(),W=Y.getGraph(),G=new _s,z=(v)=>G.dispose(v.target);if(W.addEventListener("node:dispose",z),X.has(i.MESH))for(let v of K.listMeshes()){if(v.listPrimitives().length>0)continue;v.dispose()}if(X.has(i.NODE)){if(!J.keepLeaves)for(let v of K.listScenes())bs(W,v,$);for(let v of K.listNodes())D4(v,$)}if(X.has(i.SKIN))for(let v of K.listSkins())D4(v,$);if(X.has(i.MESH))for(let v of K.listMeshes())D4(v,$);if(X.has(i.CAMERA))for(let v of K.listCameras())D4(v,$);if(X.has(i.PRIMITIVE))Ks(W,i.PRIMITIVE,$);if(X.has(i.PRIMITIVE_TARGET))Ks(W,i.PRIMITIVE_TARGET,$);if(!J.keepAttributes&&X.has(i.ACCESSOR)){let v=new Map;for(let H of K.listMeshes())for(let V of H.listPrimitives()){let q=V.getMaterial();if(!q)continue;let F=hs(Y,V,q),x=vM1(V,F);Ws(V,x),V.listTargets().forEach((c)=>Ws(c,x)),v.has(q)?v.get(q).add(V):v.set(q,new Set([V]))}for(let[H,V]of v)VM1(H,Array.from(V))}if(X.has(i.ANIMATION))for(let v of K.listAnimations()){for(let H of v.listChannels())if(!H.getTargetNode())H.dispose();if(!v.listChannels().length){let H=v.listSamplers();D4(v,$),H.forEach((V)=>D4(V,$))}else v.listSamplers().forEach((H)=>D4(H,$))}if(X.has(i.MATERIAL))K.listMaterials().forEach((v)=>D4(v,$));if(X.has(i.TEXTURE)){if(K.listTextures().forEach((v)=>D4(v,$)),!J.keepSolidTextures)await HM1(Y)}if(X.has(i.ACCESSOR))K.listAccessors().forEach((v)=>D4(v,$));if(X.has(i.BUFFER))K.listBuffers().forEach((v)=>D4(v,$));if(W.removeEventListener("node:dispose",z),!G.empty()){let v=G.entries().map(([H,V])=>`${H} (${V})`).join(", ");Q.info(`${D3}: Removed types... ${v}`)}else Q.debug(`${D3}: No unused properties found.`);Q.debug(`${D3}: Complete.`)})}class _s{constructor(){this.disposed={}}empty(){for(let Z in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(Z){this.disposed[Z.propertyType]=this.disposed[Z.propertyType]||0,this.disposed[Z.propertyType]++}}function D4(Z,J){let X=Z.listParents().filter((Y)=>!(Y instanceof W3||Y instanceof QZ)),$=J&&!Us(Z.getExtras());if(!X.length&&!$)Z.dispose()}function Ks(Z,J,X){for(let $ of Z.listEdges()){let Y=$.getParent();if(Y.propertyType===J)D4(Y,X)}}function bs(Z,J,X){if(J.listChildren().forEach((K)=>bs(Z,K,X)),J instanceof K3)return;let $=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==i.ROOT&&W!==i.SCENE&&W!==i.NODE}),Y=Z.listChildren(J).length===0,Q=X&&!Us(J.getExtras());if(Y&&!$&&!Q)J.dispose()}function Ws(Z,J){for(let X of J)Z.setAttribute(X,null)}function vM1(Z,J){let X=[];for(let $ of Z.listSemantics())if($==="NORMAL"&&!J.has($))X.push($);else if($==="TANGENT"&&!J.has($))X.push($);else if($.startsWith("TEXCOORD_")&&!J.has($))X.push($);else if($.startsWith("COLOR_")&&$!=="COLOR_0")X.push($);return X}function hs(Z,J,X,$=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let z of Q)if(z.getChild()instanceof I$)K.add(z.getName());for(let z of Q){let v=z.getName(),H=z.getChild();if(H instanceof F1){if(K.has(v.replace(/Info$/,"")))$.add(`TEXCOORD_${H.getTexCoord()}`)}if(H instanceof I$&&v.match(/normalTexture/i))$.add("TANGENT");if(H instanceof O1)hs(Z,J,H,$)}let W=X instanceof Q7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===g1.Mode.POINTS;if(W&&!G)$.add("NORMAL");return $}function VM1(Z,J){let X=GM1(Z),$=new Set(X.map((G)=>G.getTexCoord())),Y=Array.from($).sort(),Q=new Map(Y.map((G,z)=>[G,z])),K=new Map(Y.map((G,z)=>[`TEXCOORD_${G}`,`TEXCOORD_${z}`]));for(let G of X){let z=G.getTexCoord();G.setTexCoord(Q.get(z))}for(let G of J){let z=G.listSemantics().filter((v)=>v.startsWith("TEXCOORD_")).sort();W(G,z),G.listTargets().forEach((v)=>W(v,z))}function W(G,z){for(let v of z){let H=G.getAttribute(v);if(!H)continue;let V=K.get(v);if(V===v)continue;G.setAttribute(V,H),G.setAttribute(v,null)}}}async function HM1(Z){let J=Z.getRoot(),X=Z.getGraph(),$=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await FM1(K);if(!G)return;if(WM1(K)==="srgb")vR.convertSRGBToLinear(G,G);let z=K.getName()||K.getURI(),v=(W=K.getSize())==null?void 0:W.join("x"),H=zM1(K);for(let V of X.listParentEdges(K)){let q=V.getParent();if(q!==J&&qM1(q,G,V.getName(),$))V.dispose()}if(K.listParents().length===1)K.dispose(),$.debug(`${D3}: Removed solid-color texture "${z}" (${v}px ${H.join(", ")})`)});await Promise.all(Q)}function qM1(Z,J,X,$){if(Z instanceof Q7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(QM1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(AD1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=fN;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return Es(ks(fs(),J,[0.5,0.5,1,1]))<=fN}return $.warn(`${D3}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function FM1(Z){let J=await xM1(Z);if(!J)return null;let X=[1/0,1/0,1/0,1/0],$=[-1/0,-1/0,-1/0,-1/0],Y=[0,0,0,0],[Q,K]=J.shape;for(let W=0;W<Q;W++){for(let G=0;G<K;G++)for(let z=0;z<4;z++)X[z]=Math.min(X[z],J.get(W,G,z)),$[z]=Math.max($[z],J.get(W,G,z));if(Es(ks(Y,$,X))/255>fN)return null}return $M1(Y,ZM1(Y,$,X),0.00196078431372549)}async function xM1(Z){try{return await Pn(Z.getImage(),Z.getMimeType())}catch(J){return null}}var MN="flatten",Gs={cleanup:!0};function Ss(Z=Gs){let J=RZ(Gs,Z);return m$(MN,async(X)=>{let $=X.getRoot(),Y=X.getLogger(),Q=new Set;for(let z of $.listSkins())for(let v of z.listJoints())Q.add(v);let K=new Set;for(let z of $.listAnimations())for(let v of z.listChannels()){let H=v.getTargetNode();if(H&&v.getTargetPath()!=="weights")K.add(H)}let W=new Set,G=new Set;for(let z of $.listScenes())z.traverse((v)=>{let H=v.getParentNode();if(!H)return;if(Q.has(H)||W.has(H))W.add(v);if(K.has(H)||G.has(H))G.add(v)});for(let z of $.listScenes())z.traverse((v)=>{if(K.has(v))return;if(W.has(v))return;if(G.has(v))return;MD1(v)});if(K.size)Y.debug(`${MN}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(Is({propertyTypes:[i.NODE],keepLeaves:!1}));Y.debug(`${MN}: Complete.`)})}function As(Z){return RG(Z)}var cM1={skipValidation:!1},zs=4294967295,{LINE_STRIP:wM1,LINE_LOOP:UM1,TRIANGLE_STRIP:BM1,TRIANGLE_FAN:jM1}=g1.Mode;function LM1(Z,J={}){let X=RZ(cM1,J),$=Z[0],Y=c6.fromGraph($.getGraph());if(!X.skipValidation&&new Set(Z.map(Bs)).size>1)throw new Error("Requires >=2 Primitives, sharing the same Material and Mode, with compatible vertex attributes and indices.");for(let q of Z)switch(q.getMode()){case wM1:case UM1:sD1(q);break;case BM1:case jM1:Os(q);break}let Q=[],K=new Uint32Array(Z.length),W=0,G=0;for(let q=0;q<Z.length;q++){let F=Z[q],x=F.getIndices(),c=F.getAttribute("POSITION").getCount(),w=x?x.getArray():null,B=x?x.getCount():c,j=new Uint32Array(c).fill(zs);for(let L=0;L<B;L++){let R=w?w[L]:L;if(j[R]===zs)j[R]=W++,K[q]++}Q.push(j),G+=B}let z=Y.createPrimitive().setMode($.getMode()).setMaterial($.getMaterial());for(let q of $.listSemantics()){let F=$.getAttribute(q),x=hJ[F.getComponentType()],c=MZ(Y,F).setArray(new x(W*F.getElementSize()));z.setAttribute(q,c)}let v=$.getIndices(),H=v?MZ(Y,v).setArray(IN(G,W)):null;z.setIndices(H);let V=0;for(let q=0;q<Q.length;q++){let F=Z[q],x=F.getIndices(),c=x?x.getCount():-1,w=Q[q];if(x&&H)MM1(x,w,H,V),V+=c;for(let B of z.listSemantics()){let j=F.getAttribute(B),L=z.getAttribute(B);DM1(j,x,w,L)}}return z}function DM1(Z,J,X,$){let Y=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),W=Z.getArray(),G=$.getArray(),z=new Uint8Array(Z.getCount());for(let v=0,H=J?J.getCount():K;v<H;v++){let V=Q?Q[v]:v,q=X[V];if(z[q])continue;for(let F=0;F<Y;F++)G[q*Y+F]=W[V*Y+F];z[q]=1}}function MM1(Z,J,X,$){let Y=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let W=0;W<Y;W++){let G=Q[W],z=J[G];K[$+W]=z}}var kN="join",{ROOT:RM1,NODE:NM1,MESH:OM1,PRIMITIVE:PM1,ACCESSOR:TM1}=i,RN=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],vs={keepMeshes:!1,keepNamed:!1,cleanup:!0,filter:()=>!0};function ms(Z=vs){let J=RZ(vs,Z);return m$(kN,async(X)=>{let $=X.getRoot(),Y=X.getLogger();for(let Q of $.listScenes())Vs(X,Q,J),Q.traverse((K)=>Vs(X,K,J));if(J.cleanup)await X.transform(Is({propertyTypes:[NM1,OM1,PM1,TM1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));Y.debug(`${kN}: Complete.`)})}function Vs(Z,J,X){let $=Z.getLogger(),Y={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let z=Q[G];if(!X.filter(z))continue;if(z.listParents().some((V)=>V instanceof QZ))continue;let H=z.getMesh();if(!H)continue;if(z.getExtension("EXT_mesh_gpu_instancing"))continue;if(z.getSkin())continue;for(let V of H.listPrimitives()){if(V.listTargets().length>0)continue;let q=V.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;gG(V),fM1(V);let F=Bs(V),x=H.getName()||z.getName();if(X.keepMeshes||X.keepNamed&&x)F+=`|${G}`;if(!(F in Y))Y[F]={prims:[],primMeshes:[],primNodes:[],dstNode:z,dstMesh:void 0};let c=Y[F];c.prims.push(V),c.primNodes.push(z)}}let K=Object.values(Y).filter(({prims:G})=>G.length>1),W=new Set(K.flatMap((G)=>G.primNodes));for(let G of W){let z=G.getMesh();if(z.listParents().some((H)=>{return H.propertyType!==RM1&&G!==H}))G.setMesh(z.clone())}for(let G of K){let{dstNode:z,primNodes:v}=G;G.dstMesh=z.getMesh(),G.primMeshes=v.map((H)=>H.getMesh())}for(let G of K){let{prims:z,primNodes:v,primMeshes:H,dstNode:V,dstMesh:q}=G,F=V.getMatrix();for(let w=0;w<z.length;w++){let B=v[w],j=H[w],L=z[w];if(j.removePrimitive(L),ON(L))L=z[w]=CM1(z[w]);if(B!==V)Ls(RN,RD1(RN,F),B.getMatrix()),Rs(L,RN)}let x=LM1(z),c=x.listAttributes()[0].getCount();q.addPrimitive(x),$.debug(`${kN}: Joined Primitives (${z.length}) containing ${NN(c)} vertices under Node "${V.getName()}".`)}}function CM1(Z){let J=Z.clone();for(let $ of J.listSemantics())J.setAttribute($,J.getAttribute($).clone());let X=J.getIndices();if(X)J.setIndices(X.clone());return J}function fM1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)CN(X)}}var{TRANSLATION:JO6,ROTATION:XO6,SCALE:$O6,WEIGHTS:YO6}=QZ.TargetPath;var kM1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var QO6=M3({level:"high"},kM1);var EM1="unweld";function IM1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let $=Z.getGraph(),Y=c6.fromGraph($),Q=Y.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,Hs(Y,G,X,J)),G.listParents().length===1)G.dispose();for(let G of Z.listTargets())for(let z of G.listAttributes())if(G.swap(z,Hs(Y,z,X,J)),z.listParents().length===1)z.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${EM1}: ${Sx(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function Hs(Z,J,X,$){if($.has(J)&&$.get(J).has(X))return $.get(J).get(X);let Y=J.getArray(),K=new Y.constructor(X.getCount()*J.getElementSize()),W=X.getArray(),G=J.getElementSize();for(let v=0,H=X.getCount();v<H;v++)for(let V=0;V<G;V++)K[v*G+V]=Y[W[v]*G+V];if(!$.has(J))$.set(J,new Map);let z=MZ(Z,J).setArray(K);return $.get(J).set(X,z),z}var qs;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(qs||(qs={}));var _M1=0.000001;function bM1(Z,J,X,$=0.0001){let Y=J.length/Z.length,Q=new Array(Y).fill(0),K=new Array(Y).fill(0),W=new Array(Y).fill(0),G=new Array(Y).fill(0),z=Z.length-1,v=1;for(let H=1;H<z;++H){let V=Z[v-1],q=Z[H],F=Z[H+1],x=(q-V)/(F-V),c=!1;if(q!==F&&(H!==1||q!==Z[0])){if(iG(J,v-1,G),iG(J,H,K),iG(J,H+1,W),X==="slerp"){let w=AM1(Q,G,W,x),B=xs(G,K)+xs(K,W);c=!Ix(K,w,$)||B+Number.EPSILON>=Math.PI}else if(X==="lerp"){let w=SM1(Q,G,W,x);c=!Ix(K,w,$)}else if(X==="step")c=!Ix(K,G)||!Ix(K,W)}if(c){if(H!==v)Z[v]=Z[H],Fs(J,v,iG(J,H,Q));v++}}if(z>0)Z[v]=Z[z],Fs(J,v,iG(J,z,Q)),v++;return v}function iG(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)X[$]=Z[J*Y+$];return X}function Fs(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)Z[J*Y+$]=X[$]}function Ix(Z,J,X=0){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>X)return!1;return!0}function hM1(Z,J,X){return Z*(1-X)+J*X}function SM1(Z,J,X,$){for(let Y=0;Y<J.length;Y++)Z[Y]=hM1(J[Y],X[Y],$);return Z}function AM1(Z,J,X,$){let Y=J[0],Q=J[1],K=J[2],W=J[3],G=X[0],z=X[1],v=X[2],H=X[3],V,q,F,x,c;if(q=Y*G+Q*z+K*v+W*H,q<0)q=-q,G=-G,z=-z,v=-v,H=-H;if(1-q>_M1)V=Math.acos(q),F=Math.sin(V),x=Math.sin((1-$)*V)/F,c=Math.sin($*V)/F;else x=1-$,c=$;return Z[0]=x*Y+c*G,Z[1]=x*Q+c*z,Z[2]=x*K+c*v,Z[3]=x*W+c*H,Z}function xs(Z,J){let X=mM1(Z,J);return Math.acos(2*X*X-1)}function mM1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var KO6=new Float32Array(0),WO6={ready:Promise.resolve(),resample:bM1,tolerance:0.0001,cleanup:!0};var S$="simplify",{POINTS:us,LINES:uM1,LINE_STRIP:lM1,LINE_LOOP:yM1,TRIANGLES:pM1,TRIANGLE_STRIP:ls,TRIANGLE_FAN:ys}=g1.Mode,ps={ratio:0,error:0.0001,lockBorder:!1};function is(Z){let J=RZ(ps,Z),X=J.simplifier;if(!X)throw new Error(`${S$}: simplifier dependency required — install "meshoptimizer".`);return m$(S$,async($)=>{let Y=$.getLogger();await X.ready,await $.transform(_N({overwrite:!1}));let Q=0;for(let K of $.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G!==pM1&&G!==ls&&G!==ys&&G!==us){Q++;continue}if(iM1(W,J),A$(W,B6.RENDER)===0)ws(W)}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)Y.warn(`${S$}: Skipped ${Q} primitives: Unsupported draw mode.`);Y.debug(`${S$}: Complete.`)})}function iM1(Z,J){let X=M3({},ps,J),$=X.simplifier,Y=Z.getGraph(),Q=c6.fromGraph(Y),K=Q.getLogger();switch(Z.getMode()){case us:return gM1(Q,Z,X);case uM1:case lM1:case yM1:return K.warn(`${S$}: Skipping primitive simplification: Unsupported draw mode.`),Z;case ls:case ys:Os(Z);break}let W=A$(Z,B6.UPLOAD),G=A$(Z,B6.RENDER);if(G<W/2)gG(Z);let z=Z.getAttribute("POSITION"),v=Z.getIndices(),H=z.getArray(),V=v.getArray();if(!(H instanceof Float32Array))H=hx(H,z.getComponentType(),z.getNormalized());if(!(V instanceof Uint32Array))V=new Uint32Array(V);let q=Math.floor(X.ratio*G/3)*3,F=X.lockBorder?["LockBorder"]:[],[x,c]=$.simplify(V,H,3,q,X.error,F);if(Z.setIndices(MZ(Q,v).setArray(x)),v.listParents().length===1)v.dispose();gG(Z);let w=A$(Z,B6.UPLOAD);if(w<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${S$}: ${Sx(W,w)} vertices, error: ${c.toFixed(4)}.`),Z}function gM1(Z,J,X){let $=X.simplifier,Y=Z.getLogger();if(J.getIndices())IM1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),z=K.getArray(),v=W?W.getArray():void 0,H=W?W.getComponentSize():void 0;if(!(z instanceof Float32Array))z=hx(z,K.getComponentType(),K.getNormalized());if(v&&!(v instanceof Float32Array))v=hx(v,K.getComponentType(),K.getNormalized());let V=Math.floor(X.ratio*G),q=$.simplifyPoints(z,3,V,v,H),[F,x]=$.compactMesh(q);Y.debug(`${S$}: ${Sx(K.getCount(),x)} vertices.`);for(let c of Ax(J)){let w=MZ(Z,c);if(PN(c,null,F,w,x),UD1(J,c,w),c.listParents().length===1)c.dispose()}return J}var EN;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(EN||(EN={}));var GO6={resizeFilter:EN.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var rs=t(os(),1);var N3={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DIRECTORIES:[(()=>{try{return h5.dirname(g.resolve("@hytopia.com/assets"))}catch{return null}})(),h5.resolve(process.cwd(),"assets")].filter(Boolean),OPTIMIZER_RUNS:[{suffix:"",options:["--compress","false","--instance","false","--simplify","false"]},{suffix:"-named-nodes",options:["--compress","false","--instance","false","--simplify","false","--join","true","--join-named","false"]}]};class j6{static instance=new j6;optimize=!0;optimizeEveryStart=!1;_modelUriDocuments=new Map;_modelUriBoundingBoxes=new Map;_modelUriNodeNames=new Map;_modelUriTrimeshes=new Map;constructor(){}async preloadModels(){let Z=await this._getAbsoluteModelPaths();console.log(`ModelRegistry.preloadModels(): Preloading ${Z.length} models...`);for(let J of Z){if(this.optimize)await this._resolveOptimizedModelPath(J);await this._loadModelData(J)}console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models!`)}getAnimationNames(Z){let J=this._modelUriDocuments.get(Z);if(!J)p.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J.getRoot().listAnimations().map(($)=>$.getName())}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)p.fatalError(`ModelRegistry.getBoundingBox(): Model ${Z} not found!`);return J}getDepth(Z){let J=this.getBoundingBox(Z);return J.max.z-J.min.z}getHeight(Z){let J=this.getBoundingBox(Z);return J.max.y-J.min.y}getNodeNames(Z){let J=this._modelUriNodeNames.get(Z);if(!J)p.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){p.error(`ModelRegistry.getTrimesh(): Model ${Z} not found!`);return}let $=X.vertices;if(J!==1){$=new Float32Array($.length);for(let Y=0;Y<$.length;Y++)$[Y]=X.vertices[Y]*J}return{vertices:$,indices:X.indices}}getWidth(Z){let J=this.getBoundingBox(Z);return J.max.x-J.min.x}modelHasNode(Z,J){let X=this._modelUriNodeNames.get(Z);if(!X)p.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=h5.normalize(Z);for(let X of N3.DIRECTORIES){let $=h5.normalize(X);if(J.startsWith($))return h5.relative($,J).replace(/\\/g,"/")}return h5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of N3.DIRECTORIES){let X=h5.resolve(process.cwd(),J);if(!gJ.existsSync(X))continue;let $=await AF("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let Y of $)Z.push(h5.join(X,Y))}return Z}async _loadModelData(Z){let J=await new xR().read(Z),X=As(J.getRoot().listScenes()[0]),$=J.getRoot().listNodes().map((Q)=>Q.getName()),Y=this._absoluteModelPathToModelUri(Z);this._modelUriDocuments.set(Y,J),this._modelUriBoundingBoxes.set(Y,{min:{x:X.min[0],y:X.min[1],z:X.min[2]},max:{x:X.max[0],y:X.max[1],z:X.max[2]}}),this._modelUriNodeNames.set(Y,$),this._modelUriTrimeshes.set(Y,await this._buildTrimesh(Y))}async _resolveOptimizedModelPath(Z){let J=this._buildOptimizedModelPath(Z);if(!this.optimizeEveryStart&&this._isOptimizedVersionValid(Z))return J;return await this._optimizeModel(Z,J)}_isOptimizedVersionValid(Z){let J=`${this._buildOptimizedModelPath(Z)}${N3.CHECKSUM_EXT}`;if(!gJ.existsSync(J))return!1;let X=this._calculateChecksum(Z),$=gJ.readFileSync(J,"utf8");return X===$}_calculateChecksum(Z){if(!gJ.existsSync(Z))return"";let J=gJ.readFileSync(Z);return oM1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=h5.basename(Z),X=J.replace(/\.[^/.]+$/,""),$=h5.dirname(Z),Y=h5.join($,N3.OPTIMIZED_DIR,X);return h5.join(Y,J)}async _buildTrimesh(Z,J=1,X=0.001){let $=this._modelUriDocuments.get(Z);if(!$)p.fatalError(`ModelRegistry._buildTrimesh(): Model ${Z} not found!`);let Y=Cs($);Y.setLogger(new z5(DG.WARN)),await Y.transform(js({pivot:"center"}),Ss(),ms(),_N(),is({simplifier:rs.MeshoptSimplifier,ratio:J,error:X}),Ps());for(let z of Y.getRoot().listScenes())for(let v of z.listChildren())Ns(v);let Q=Y.getRoot().listMeshes()[0];if(!Q){p.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root mesh!`);return}let K=Q.listPrimitives()[0];if(!K){p.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root primitive!`);return}let W=K.getAttribute("POSITION"),G=K.getIndices();if(!W||!G){p.error(`ModelRegistry._buildTrimesh(): Model ${Z} missing required geometry data!`);return}return{vertices:W.getArray(),indices:G.getArray()}}async _optimizeModel(Z,J){let X=h5.dirname(J);gJ.rmSync(X,{recursive:!0,force:!0}),gJ.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let $ of N3.OPTIMIZER_RUNS){let Y=J.replace(/(\.[^/.]+)$/,`${$.suffix}$1`),{stderr:Q}=await Hi("npx",["@gltf-transform/cli","optimize",Z,Y,...$.options]);if(Q)return p.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return gJ.writeFileSync(`${J}${N3.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var oG;((Y)=>{Y.DYNAMIC="dynamic";Y.FIXED="fixed";Y.KINEMATIC_POSITION="kinematic_position";Y.KINEMATIC_VELOCITY="kinematic_velocity"})(oG||={});var uN=0.001,ts="dynamic";class u$ extends B0{_additionalMass=0;_colliders=new Set;_explicitSleep=!1;_enabledPositions={x:!0,y:!0,z:!0};_enabledRotations={x:!0,y:!0,z:!0};_rigidBody;_rigidBodyDesc;_rigidBodyType;_simulation;constructor(Z){super();Z.type??=ts,this._rigidBodyDesc=this._createRigidBodyDesc(Z),this._rigidBodyType=Z.type,this._applyRigidBodyOptions(Z),this._autoAddToSimulation(Z)}get additionalMass(){if(!this._requireNotRemoved("additionalMass"))return 0;return this._additionalMass}get additionalSolverIterations(){if(!this._requireNotRemoved("additionalSolverIterations"))return 0;return this._rigidBody?this._rigidBody.additionalSolverIterations():this._rigidBodyDesc.additionalSolverIterations}get angularDamping(){if(!this._requireNotRemoved("angularDamping"))return 0;return this._rigidBody?this._rigidBody.angularDamping():this._rigidBodyDesc.angularDamping}get angularVelocity(){if(!this._requireNotRemoved("angularVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.angvel():this._rigidBodyDesc.angvel}get colliders(){return this._colliders}get dominanceGroup(){if(!this._requireNotRemoved("dominanceGroup"))return 0;return this._rigidBody?this._rigidBody.dominanceGroup():this._rigidBodyDesc.dominanceGroup}get directionFromRotation(){let{x:Z,y:J,z:X,w:$}=this.rotation;return{x:-2*(Z*X+$*J),y:-2*(J*X-$*Z),z:-(1-2*(Z*Z+J*J))}}get effectiveAngularInertia(){if(!this._requireNotRemoved("effectiveAngularInertia"))return;return this._rigidBody?this._rigidBody.effectiveAngularInertia():void 0}get effectiveInverseMass(){if(!this._requireNotRemoved("effectiveInverseMass"))return;return this._rigidBody?this._rigidBody.effectiveInvMass():void 0}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("effectiveWorldInversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.effectiveWorldInvInertiaSqrt():void 0}get enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get inversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("inversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.invPrincipalInertiaSqrt():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(Z){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(Z,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(Z)}setAdditionalMassProperties(Z){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:J,centerOfMass:X,principalAngularInertia:$,principalAngularInertiaLocalFrame:Y}=Z;this._rigidBody?this._rigidBody.setAdditionalMassProperties(J,X,$,Y,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMassProperties(J,X,$,Y)}setAdditionalSolverIterations(Z){if(!this._requireDynamic("setAdditionalSolverIterations"))return;if(!this._requireNotRemoved("setAdditionalSolverIterations"))return;this._rigidBody?this._rigidBody.setAdditionalSolverIterations(Z):this._rigidBodyDesc.setAdditionalSolverIterations(Z)}setAngularDamping(Z){if(!this._requireDynamic("setAngularDamping"))return;if(!this._requireNotRemoved("setAngularDamping"))return;this._rigidBody?this._rigidBody.setAngularDamping(Z):this._rigidBodyDesc.setAngularDamping(Z)}setAngularVelocity(Z){if(!this._requireNotKinematicPositionBased("setAngularVelocity"))return;if(!this._requireNotRemoved("setAngularVelocity"))return;this._rigidBody?this._rigidBody.setAngvel(Z,!this._explicitSleep):this._rigidBodyDesc.setAngvel(Z)}setCcdEnabled(Z){if(!this._requireDynamic("setCcdEnabled"))return;if(!this._requireNotRemoved("setCcdEnabled"))return;this._rigidBody?this._rigidBody.enableCcd(Z):this._rigidBodyDesc.setCcdEnabled(Z)}setDominanceGroup(Z){if(!this._requireDynamic("setDominanceGroup"))return;if(!this._requireNotRemoved("setDominanceGroup"))return;this._rigidBody?this._rigidBody.setDominanceGroup(Z):this._rigidBodyDesc.setDominanceGroup(Z)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._rigidBody?this._rigidBody.setEnabled(Z):this._rigidBodyDesc.setEnabled(Z)}setEnabledPositions(Z){if(!this._requireDynamic("setEnabledPositions"))return;if(!this._requireNotRemoved("setEnabledPositions"))return;this._rigidBody?this._rigidBody.setEnabledTranslations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledTranslations(Z.x,Z.y,Z.z),this._enabledPositions=Z}setEnabledRotations(Z){if(!this._requireDynamic("setEnabledRotations"))return;if(!this._requireNotRemoved("setEnabledRotations"))return;this._rigidBody?this._rigidBody.setEnabledRotations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledRotations(Z.x,Z.y,Z.z),this._enabledRotations=Z}setGravityScale(Z){if(!this._requireDynamic("setGravityScale"))return;if(!this._requireNotRemoved("setGravityScale"))return;this._rigidBody?this._rigidBody.setGravityScale(Z,!this._explicitSleep):this._rigidBodyDesc.setGravityScale(Z)}setLinearDamping(Z){if(!this._requireDynamic("setLinearDamping"))return;if(!this._requireNotRemoved("setLinearDamping"))return;this._rigidBody?this._rigidBody.setLinearDamping(Z):this._rigidBodyDesc.setLinearDamping(Z)}setLinearVelocity(Z){if(!this._requireNotKinematicPositionBased("setLinearVelocity"))return;if(!this._requireNotRemoved("setLinearVelocity"))return;this._rigidBody?this._rigidBody.setLinvel(Z,!this._explicitSleep):this._rigidBodyDesc.setLinvel(Z.x,Z.y,Z.z)}setNextKinematicRotation(Z){if(!this._requireKinematic("setNextKinematicRotation"))return;if(!this._requireNotRemoved("setNextKinematicRotation"))return;this._rigidBody?this._rigidBody.setNextKinematicRotation(Z):this._rigidBodyDesc.setRotation(Z)}setNextKinematicPosition(Z){if(!this._requireKinematic("setNextKinematicPosition"))return;if(!this._requireNotRemoved("setNextKinematicPosition"))return;this._rigidBody?this._rigidBody.setNextKinematicTranslation(Z):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setPosition(Z){if(!this._requireNotRemoved("setPosition"))return;this._rigidBody?this._rigidBody.setTranslation(Z,!this._explicitSleep):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setRotation(Z){if(!this._requireNotRemoved("setRotation"))return;this._rigidBody?this._rigidBody.setRotation(Z,!this._explicitSleep):this._rigidBodyDesc.setRotation(Z)}setSleeping(Z){if(!this._requireDynamic("setSleeping"))return;if(!this._requireNotRemoved("setSleeping"))return;this._rigidBody?Z?this._rigidBody.sleep():this._rigidBody.wakeUp():this._rigidBodyDesc.sleeping=Z,this._explicitSleep=Z}setSoftCcdPrediction(Z){if(!this._requireDynamic("setSoftCcdPrediction"))return;if(!this._requireNotRemoved("setSoftCcdPrediction"))return;this._rigidBody?this._rigidBody.setSoftCcdPrediction(Z):this._rigidBodyDesc.setSoftCcdPrediction(Z)}setCollisionGroupsForSolidColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSolidColliders"))return;this._colliders.forEach((J)=>{if(J.isSensor)return;J.setCollisionGroups(Z)})}setCollisionGroupsForSensorColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSensorColliders"))return;this._colliders.forEach((J)=>{if(!J.isSensor)return;J.setCollisionGroups(Z)})}setType(Z){if(!this._requireNotRemoved("setType"))return;let X={["dynamic"]:X1.RigidBodyType.Dynamic,["fixed"]:X1.RigidBodyType.Fixed,["kinematic_position"]:X1.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:X1.RigidBodyType.KinematicVelocityBased}[Z];if(X===void 0)return p.error(`Invalid RigidBodyType: ${Z}`);this._rigidBody?this._rigidBody.setBodyType(X,!this._explicitSleep):this._rigidBodyDesc.status=X,this._rigidBodyType=Z}addForce(Z){if(!this._requireNotRemoved("addForce"))return;if(!this._requireCreated("addForce"))return;if(!this._requireDynamic("addForce"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addForce(Z,!this._explicitSleep)}addTorque(Z){if(!this._requireNotRemoved("addTorque"))return;if(!this._requireCreated("addTorque"))return;if(!this._requireDynamic("addTorque"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addTorque(Z,!this._explicitSleep)}addChildColliderToSimulation(Z){if(!this._requireNotRemoved("addChildColliderToSimulation"))return;if(!this._requireCreated("addChildColliderToSimulation"))return;Z.addToSimulation(this._simulation,this)}addToSimulation(Z){if(!this._requireNotRemoved("addToSimulation"))return;if(this._rigidBody)return p.error("RigidBody.addToSimulation(): Rigid body already exists in the simulation!");this._simulation=Z,this._rigidBody=this._simulation.createRawRigidBody(this._rigidBodyDesc),this._colliders.forEach((J)=>{if(!J.isSimulated)J.addToSimulation(Z,this)})}applyImpulse(Z){if(!this._requireNotRemoved("applyImpulse"))return;if(!this._requireCreated("applyImpulse"))return;if(!this._requireDynamic("applyImpulse"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulse(Z,!this._explicitSleep)}applyImpulseAtPoint(Z,J){if(!this._requireNotRemoved("applyImpulseAtPoint"))return;if(!this._requireCreated("applyImpulseAtPoint"))return;if(!this._requireDynamic("applyImpulseAtPoint"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulseAtPoint(Z,J,!this._explicitSleep)}applyTorqueImpulse(Z){if(!this._requireNotRemoved("applyTorqueImpulse"))return;if(!this._requireCreated("applyTorqueImpulse"))return;if(!this._requireDynamic("applyTorqueImpulse"))return;this._rigidBody.applyTorqueImpulse(Z,!this._explicitSleep)}createAndAddChildCollider(Z){if(!this._requireNotRemoved("createAndAddChildCollider"))return null;return this._simulation?new S5({...Z,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(Z)}createAndAddChildColliders(Z){let J=[];return Z.forEach((X)=>{let $=this.createAndAddChildCollider(X);if($)J.push($)}),J}getCollidersByTag(Z){let J=[];for(let X of this._colliders)if(X.tag===Z)J.push(X);return J}linkCollider(Z){if(!this._requireNotRemoved("linkCollider"))return;if(Z.parentRigidBody!==this)return p.error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(Z)}lockAllRotations(){if(!this._requireNotRemoved("lockAllRotations"))return;this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){if(!this._requireNotRemoved("lockAllPositions"))return;this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._rigidBody)return p.error("RigidBody.removeFromSimulation(): Rigid body does not exist in the simulation!");this._colliders.forEach((Z)=>{Z.removeFromSimulation()}),this._simulation.removeRawRigidBody(this._rigidBody),this._simulation=void 0,this._rigidBody=void 0}unlinkCollider(Z){if(!this._requireNotRemoved("unlinkCollider"))return;if(!Z.isRemoved)return p.error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(Z)}resetAngularVelocity(){if(!this._requireNotRemoved("resetAngularVelocity"))return;if(!this._requireCreated("resetAngularVelocity"))return;this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){if(!this._requireNotRemoved("resetForces"))return;if(!this._requireCreated("resetForces"))return;this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){if(!this._requireNotRemoved("resetLinearVelocity"))return;if(!this._requireCreated("resetLinearVelocity"))return;this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){if(!this._requireNotRemoved("resetTorques"))return;if(!this._requireCreated("resetTorques"))return;this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){if(!this._requireNotRemoved("sleep"))return;this.setSleeping(!0)}wakeUp(){if(!this._requireNotRemoved("wakeUp"))return;this.setSleeping(!1)}_applyRigidBodyOptions(Z){[["additionalMass",this.setAdditionalMass.bind(this)],["additionalMassProperties",this.setAdditionalMassProperties.bind(this)],["additionalSolverIterations",this.setAdditionalSolverIterations.bind(this)],["angularDamping",this.setAngularDamping.bind(this)],["angularVelocity",this.setAngularVelocity.bind(this)],["dominanceGroup",this.setDominanceGroup.bind(this)],["ccdEnabled",this.setCcdEnabled.bind(this)],["enabled",this.setEnabled.bind(this)],["enabledPositions",this.setEnabledPositions.bind(this)],["enabledRotations",this.setEnabledRotations.bind(this)],["gravityScale",this.setGravityScale.bind(this)],["linearDamping",this.setLinearDamping.bind(this)],["linearVelocity",this.setLinearVelocity.bind(this)],["position",this.setPosition.bind(this)],["rotation",this.setRotation.bind(this)],["sleeping",this.setSleeping.bind(this)],["softCcdPrediction",this.setSoftCcdPrediction.bind(this)]].forEach(([X,$])=>{if(X in Z)$(Z[X])})}_autoAddToSimulation(Z){if(Z.colliders)this._createAndAddPendingChildColliders(Z.colliders);if(Z.simulation)this.addToSimulation(Z.simulation)}_createAndAddPendingChildCollider(Z){if(!this._requireNotRemoved("createAndAddPendingChildCollider"))return null;if(!this._requireNotSimulated("createAndAddPendingChildCollider"))return null;let J=new S5(Z);return this._colliders.add(J),J}_createAndAddPendingChildColliders(Z){let J=[];return Z.forEach((X)=>{let $=this._createAndAddPendingChildCollider(X);if($)J.push($)}),J}_createRigidBodyDesc(Z){let J=Z.type??ts;return{["dynamic"]:()=>X1.RigidBodyDesc.dynamic(),["fixed"]:()=>X1.RigidBodyDesc.fixed(),["kinematic_position"]:()=>X1.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>X1.RigidBodyDesc.kinematicVelocityBased()}[J]()}_requireCreated(Z){if(!this._rigidBody||!this._simulation)p.error(`RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody&&!!this._simulation}_requireDynamic(Z){if(!this.isDynamic)p.error(`RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method: ${Z}()`);return this.isDynamic}_requireKinematic(Z){if(!this.isKinematic)p.error(`RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method: ${Z}()`);return this.isKinematic}_requireNotKinematicPositionBased(Z){if(this.isKinematicPositionBased)p.error(`RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method: ${Z}()`);return!this.isKinematicPositionBased}_requireNotRemoved(Z){if(!this._rigidBody&&!this._rigidBodyDesc)p.error(`RigidBody._requireNotRemoved(): Rigid body has been removed and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody||!!this._rigidBodyDesc}_requireNotSimulated(Z){if(this.isSimulated)p.error(`RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method: ${Z}()`);return!this.isSimulated}_isNegligibleVector(Z){return Math.abs(Z.x)<uN&&Math.abs(Z.y)<uN&&Math.abs(Z.z)<uN}}var lN;((Y)=>{Y[Y.Average=0]="Average";Y[Y.Min=1]="Min";Y[Y.Multiply=2]="Multiply";Y[Y.Max=3]="Max"})(lN||={});var O3;((v)=>{v.NONE="none";v.BALL="ball";v.BLOCK="block";v.CAPSULE="capsule";v.CONE="cone";v.CYLINDER="cylinder";v.ROUND_CYLINDER="round-cylinder";v.TRIMESH="trimesh";v.VOXELS="voxels";v.WEDGE="wedge"})(O3||={});class S5 extends B0{_collider;_colliderDesc;_onCollision;_parentRigidBody;_relativePosition={x:0,y:0,z:0};_relativeRotation={x:0,y:0,z:0,w:1};_shape;_simulation;_tag;constructor(Z){super();this._colliderDesc=this._createColliderDesc(Z),this._shape=Z.shape,this._applyColliderOptions(Z),this._autoAddToSimulation(Z)}static optionsFromBlockHalfExtents(Z){return{shape:"block",halfExtents:Z}}static optionsFromModelUri(Z,J=1,X){let $=j6.instance.getBoundingBox(Z),Y=$.max.x-$.min.x,Q=$.max.y-$.min.y,K=$.max.z-$.min.z,W=Math.max(Y,K),G=Math.min(Y,K),z=W/G,v=W/Q,H=W*J/2,V=(B)=>Math.max(0.01,B),q=()=>({shape:"block",halfExtents:{x:V(Y*J/2),y:V(Q*J/2),z:V(K*J/2)}}),F=()=>({shape:"round-cylinder",radius:V(H),halfHeight:V(Q*J/2),borderRadius:V(H*0.1)}),x=()=>{let B=j6.instance.getTrimesh(Z,J);if(!B)return;return{shape:"trimesh",vertices:B.vertices,indices:B.indices}},c=()=>({shape:"wedge",extents:{x:Y*J,y:Q*J,z:K*J}}),w=()=>({shape:"capsule",radius:V(H),halfHeight:V(Q*J/2-H)});if(X)switch(X){case"block":return q();case"capsule":return w();case"round-cylinder":return F();case"trimesh":{let B=x();if(!B){p.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return B}case"wedge":return c();default:p.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(z>2)return q();if(v>1.5)return F();return w()}get bounciness(){if(!this._requireNotRemoved("bounciness"))return 0;return this._collider?this._collider.restitution():this._colliderDesc.restitution}get bouncinessCombineRule(){if(!this._requireNotRemoved("bouncinessCombineRule"))return 0;return this._collider?this._collider.restitutionCombineRule():this._colliderDesc.restitutionCombineRule}get collisionGroups(){if(!this._requireNotRemoved("collisionGroups"))return{belongsTo:[],collidesWith:[]};return this._collider?v9.decodeRawCollisionGroups(this._collider.collisionGroups()):v9.decodeRawCollisionGroups(this._colliderDesc.collisionGroups)}get friction(){if(!this._requireNotRemoved("friction"))return 0;return this._collider?this._collider.friction():this._colliderDesc.friction}get frictionCombineRule(){if(!this._requireNotRemoved("frictionCombineRule"))return 0;return this._collider?this._collider.frictionCombineRule():this._colliderDesc.frictionCombineRule}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._collider?this._collider.isEnabled():this._colliderDesc.enabled}get isRemoved(){return!this._collider&&!this._colliderDesc}get isSensor(){if(!this._requireNotRemoved("isSensor"))return!1;return this._collider?this._collider.isSensor():this._colliderDesc.isSensor}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return!!this._collider}get parentRigidBody(){if(!this._requireNotRemoved("parentRigidBody"))return;return this._parentRigidBody}get rawCollider(){if(!this._requireNotRemoved("rawCollider"))return;return this._collider}get rawShape(){if(!this._requireNotRemoved("rawShape"))return;return this._collider?this._collider.shape:this._colliderDesc.shape}get relativePosition(){if(!this._requireNotRemoved("relativePosition"))return{x:0,y:0,z:0};return this._relativePosition}get relativeRotation(){if(!this._requireNotRemoved("relativeRotation"))return{x:0,y:0,z:0,w:1};return this._relativeRotation}get shape(){if(!this._requireNotRemoved("shape"))return"none";return this._shape}get tag(){if(!this._requireNotRemoved("tag"))return;return this._tag}setBounciness(Z){if(!this._requireNotRemoved("setBounciness"))return;this._collider?this._collider.setRestitution(Z):this._colliderDesc.setRestitution(Z)}setBouncinessCombineRule(Z){if(!this._requireNotRemoved("setBouncinessCombineRule"))return;this._collider?this._collider.setRestitutionCombineRule(Z):this._colliderDesc.setRestitutionCombineRule(Z)}setCollisionGroups(Z){if(!this._requireNotRemoved("setCollisionGroups"))return;let J=v9.buildRawCollisionGroups(Z);this._collider?this._collider.setCollisionGroups(J):this._colliderDesc.setCollisionGroups(J)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._collider?this._collider.setEnabled(Z):this._colliderDesc.setEnabled(Z)}setFriction(Z){if(!this._requireNotRemoved("setFriction"))return;this._collider?this._collider.setFriction(Z):this._colliderDesc.setFriction(Z)}setFrictionCombineRule(Z){if(!this._requireNotRemoved("setFrictionCombineRule"))return;this._collider?this._collider.setFrictionCombineRule(Z):this._colliderDesc.setFrictionCombineRule(Z)}setMass(Z){if(!this._requireNotRemoved("setMass"))return;this._collider?this._collider.setMass(Z):this._colliderDesc.setMass(Z)}setOnCollision(Z){if(!this._requireNotRemoved("setOnCollision"))return;if(this._onCollision=Z,this.isSimulated)if(this.enableCollisionEvents(!!Z),Z)this._simulation.colliderMap.setColliderCollisionCallback(this,Z);else this._simulation.colliderMap.removeColliderCollisionCallback(this)}setRelativeRotation(Z){if(!this._requireNotRemoved("setRelativeRotation"))return;this._relativeRotation=Z,this._collider?this._collider.parent()?this._collider.setRotationWrtParent(Z):this._collider.setRotation(Z):this._colliderDesc.setRotation(Z)}setRelativePosition(Z){if(!this._requireNotRemoved("setRelativePosition"))return;this._relativePosition=Z,this._collider?this._collider.parent()?this._collider.setTranslationWrtParent(Z):this._collider.setTranslation(Z):this._colliderDesc.setTranslation(Z.x,Z.y,Z.z)}setSensor(Z){if(!this._requireNotRemoved("setSensor"))return;this._collider?this._collider.setSensor(Z):this._colliderDesc.setSensor(Z)}setTag(Z){if(!this._requireNotRemoved("setTag"))return;this._tag=Z}setVoxel(Z,J){if(!this._requireNotRemoved("setVoxel"))return;if(!this._requireSimulated("setVoxel"))return;if(this.shape!=="voxels")return p.error("Collider.setVoxel(): Collider is not a voxels collider!");this._collider.setVoxel(Z.x,Z.y,Z.z,J)}addToSimulation(Z,J){if(!this._requireNotRemoved("addToSimulation"))return;if(!this._requireUnsimulated("addToSimulation"))return;if(J){if(!J.isSimulated)return p.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")p.warning("Collider.addToSimulation(): Trimesh colliders are strongly discouraged to be used with dynamic rigid bodies, they will not contribute any mass!")}if(this._simulation=Z,this._parentRigidBody=J,this._collider=this._simulation.createRawCollider(this._colliderDesc,J?.rawRigidBody),this._colliderDesc=void 0,J)J.linkCollider(this);if(this._onCollision)this.setOnCollision(this._onCollision)}combineVoxelStates(Z){if(!this._requireNotRemoved("combineVoxelStates"))return;if(!this._requireSimulated("combineVoxelStates"))return;if(!Z.isSimulated)return p.error("Collider.combineVoxelStates(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Other collider is not a voxels collider!");this._collider.combineVoxelStates(Z.rawCollider,0,0,0)}enableCollisionEvents(Z){if(!this._requireNotRemoved("enableCollisionEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|X1.ActiveEvents.COLLISION_EVENTS:J&~X1.ActiveEvents.COLLISION_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}enableContactForceEvents(Z){if(!this._requireNotRemoved("enableContactForceEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|X1.ActiveEvents.CONTACT_FORCE_EVENTS:J&~X1.ActiveEvents.CONTACT_FORCE_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}propagateVoxelChange(Z,J){if(!this._requireNotRemoved("propagateVoxelChange"))return;if(!this._requireSimulated("propagateVoxelChange"))return;if(!Z.isSimulated)return p.error("Collider.propagateVoxelChange(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Other collider is not a voxels collider!");this._collider.propagateVoxelChange(Z.rawCollider,J.x,J.y,J.z,0,0,0)}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._requireSimulated("removeFromSimulation"))return;if(this._simulation.removeRawCollider(this._collider),this._simulation=void 0,this._collider=void 0,this._parentRigidBody)this._parentRigidBody.unlinkCollider(this);this._parentRigidBody=void 0}scale(Z){if(!this._requireNotRemoved("scale"))return;switch(this.setRelativePosition({x:this.relativePosition.x*Z,y:this.relativePosition.y*Z,z:this.relativePosition.z*Z}),this._shape){case"ball":{if(this._collider)this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.radius*=Z;return}case"block":{if(this._collider){let J=this._collider.halfExtents();this._collider.setHalfExtents({x:J.x*Z,y:J.y*Z,z:J.z*Z})}else this._colliderDesc.shape.halfExtents.x*=Z,this._colliderDesc.shape.halfExtents.y*=Z,this._colliderDesc.shape.halfExtents.z*=Z;return}case"capsule":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cone":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"round-cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRoundRadius(this._collider.roundRadius()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight=this._colliderDesc.shape.halfHeight*Z,this._colliderDesc.shape.borderRadius=this._colliderDesc.shape.borderRadius*Z,this._colliderDesc.shape.radius=this._colliderDesc.shape.radius*Z;return}case"trimesh":{p.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"voxels":{p.error("Collider.setScale(): Voxels colliders cannot be scaled!");return}case"wedge":{p.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:p.fatalError(`Collider.setScale(): ${this._shape} is not a valid collider shape!`)}}_applyColliderOptions(Z){[["bounciness",this.setBounciness.bind(this)],["bouncinessCombineRule",this.setBouncinessCombineRule.bind(this)],["collisionGroups",this.setCollisionGroups.bind(this)],["enabled",this.setEnabled.bind(this)],["friction",this.setFriction.bind(this)],["frictionCombineRule",this.setFrictionCombineRule.bind(this)],["isSensor",this.setSensor.bind(this)],["mass",this.setMass.bind(this)],["onCollision",this.setOnCollision.bind(this)],["relativePosition",this.setRelativePosition.bind(this)],["relativeRotation",this.setRelativeRotation.bind(this)],["tag",this.setTag.bind(this)]].forEach(([X,$])=>{if(Z[X]!==void 0)$.call(this,Z[X])})}_autoAddToSimulation(Z){if(Z.simulation)this.addToSimulation(Z.simulation,Z.parentRigidBody)}_buildWedgeConvexHullVertices(Z){let{x:J,y:X,z:$}=Z,Y=J/2,Q=$/2,K=X/2;return new Float32Array([-Y,0-K,-Q,Y,0-K,-Q,Y,0-K,Q,-Y,0-K,Q,-Y,X-K,-Q,Y,X-K,-Q])}_createColliderDesc(Z){let{shape:J,flags:X}=Z;switch(J){case"ball":{if(!Z.radius)p.fatalError("Ball collider must have a radius!");return X1.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)p.fatalError("Block collider must have halfExtents!");return X1.ColliderDesc.cuboid(Z.halfExtents.x,Z.halfExtents.y,Z.halfExtents.z)}case"capsule":{if(!Z.halfHeight||!Z.radius)p.fatalError("Capsule collider must have halfHeight and radius!");return X1.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cone collider must have radius and halfHeight!");return X1.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cylinder collider must have radius and halfHeight!");return X1.ColliderDesc.cylinder(Z.halfHeight,Z.radius)}case"round-cylinder":{if(!Z.radius||!Z.halfHeight||!Z.borderRadius)p.fatalError("Round cylinder collider must have radius, halfHeight, and borderRadius!");return X1.ColliderDesc.roundCylinder(Z.halfHeight,Z.radius,Z.borderRadius)}case"trimesh":{if(!Z.indices||!Z.vertices)p.fatalError("Trimesh collider must have vertices and indices!");return X1.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)p.fatalError("Voxels collider must have coordinates and size!");return X1.ColliderDesc.voxels(this._coordinatesToInt32Array(Z.coordinates),Z.size)}case"wedge":{if(!Z.extents)p.fatalError("Wedge collider must have extents!");let $=this._buildWedgeConvexHullVertices(Z.extents),Y=X1.ColliderDesc.convexHull($);if(!Y)throw p.fatalError("Failed to create convex hull for wedge collider!"),new Error("Convex hull creation failed");return Y}default:p.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)p.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)p.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)p.error(`Collider._requireNotRemoved(): Collider is removed, invoked method: ${Z}()`);return!this.isRemoved}_setActiveCollisionTypes(){(this._collider??this._colliderDesc).setActiveCollisionTypes(X1.ActiveCollisionTypes.DYNAMIC_DYNAMIC|X1.ActiveCollisionTypes.DYNAMIC_KINEMATIC|X1.ActiveCollisionTypes.DYNAMIC_FIXED|X1.ActiveCollisionTypes.KINEMATIC_KINEMATIC|X1.ActiveCollisionTypes.KINEMATIC_FIXED)}_coordinatesToInt32Array(Z){let J=new Int32Array(Z.length*3);for(let X=0;X<Z.length;X++){let $=Z[X],Y=X*3;J[Y]=Math.floor($.x),J[Y+1]=Math.floor($.y),J[Y+2]=Math.floor($.z)}return J}}var rM1={shape:"voxels"},yN;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(yN||={});class A5 extends B0{_id;_customColliderOptions;_halfExtents;_isLiquid;_lightLevel;_name;_textureUri;constructor(Z={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(Z.id<0)p.fatalError("BlockType.constructor(): BlockType id not set.");super();this._id=Z.id,this._customColliderOptions=Z.customColliderOptions,this._halfExtents=Z.halfExtents??{x:0.5,y:0.5,z:0.5},this._isLiquid=Z.isLiquid??!1,this._name=Z.name,this._textureUri=Z.textureUri,this._lightLevel=Math.min(Z.lightLevel??0,15)}get id(){return this._id}get colliderOptions(){return{...this._customColliderOptions,...rM1}}get halfExtents(){return this._halfExtents}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}get lightLevel(){return this._lightLevel}get name(){return this._name}get size(){return{x:this._halfExtents.x*2,y:this._halfExtents.y*2,z:this._halfExtents.z*2}}get textureUri(){return this._textureUri}createCollider(Z){let J=new S5({...this.colliderOptions,coordinates:Z,size:this.size});if(this.isLiquid)J.setSensor(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_COLLISION")||this.isLiquid)J.enableCollisionEvents(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))J.enableContactForceEvents(!0);if(v9.isDefaultCollisionGroups(J.collisionGroups))J.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return J}serialize(){return T0.serializeBlockType(this)}}var pN;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(pN||={});class rG extends B0{_blockTypes=new Map;_world;constructor(Z){super();this._world=Z}get world(){return this._world}getAllBlockTypes(){return Array.from(this._blockTypes.values())}getBlockType(Z){let J=this._blockTypes.get(Z);if(!J)p.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends A5{constructor($=Z){super($)}};return this.registerBlockType(X),X}registerBlockType(Z){this._blockTypes.set(Z.id,Z),this.emitWithWorld(this._world,"BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE",{blockTypeRegistry:this,id:Z.id,blockType:Z})}serialize(){return T0.serializeBlockTypeRegistry(this)}}var jP={};_Q(jP,{worldSchema:()=>BP,worldPacketDefinition:()=>d00,vectorSchema:()=>W1,vectorBooleanSchema:()=>sk1,uiSchema:()=>wP,uiPacketDefinition:()=>i00,uiDatasSchema:()=>UP,uiDatasPacketDefinition:()=>g00,uiDataSendPacketDefinition:()=>C00,uiDataSchema:()=>Lz,syncResponseSchema:()=>cP,syncResponsePacketDefinition:()=>p00,syncRequestSchema:()=>iO,syncRequestPacketDefinition:()=>T00,stateRequestSchema:()=>pO,stateRequestPacketDefinition:()=>P00,sceneUIsSchema:()=>xP,sceneUIsPacketDefinition:()=>y00,sceneUISchema:()=>FP,rgbColorSchema:()=>D6,registeredPackets:()=>fc,quaternionSchema:()=>XP,playersSchema:()=>qP,playersPacketDefinition:()=>l00,playerSchema:()=>HP,physicsDebugRenderSchema:()=>VP,physicsDebugRenderPacketDefinition:()=>m00,physicsDebugRaycastsSchema:()=>vP,physicsDebugRaycastsPacketDefinition:()=>u00,physicsDebugRaycastSchema:()=>zP,particleEmittersSchema:()=>GP,particleEmittersPacketDefinition:()=>A00,particleEmitterSchema:()=>WP,outboundPackets:()=>Cc,modelNodeOverrideSchema:()=>JP,lightsSchema:()=>KP,lightsPacketDefinition:()=>S00,lightSchema:()=>QP,isValidPacket:()=>rk1,inputSchema:()=>yO,inputPacketDefinition:()=>O00,inboundPackets:()=>Tc,hexColorSchema:()=>uO,heartbeatSchema:()=>mO,heartbeatPacketDefinition:()=>M00,entitySchema:()=>$P,entitiesSchema:()=>YP,entitiesPacketDefinition:()=>h00,definePacket:()=>f0,debugConfigSchema:()=>lO,debugConfigPacketDefinition:()=>N00,createPacket:()=>mk1,connectionSchema:()=>AO,connectionPacketDefinition:()=>D00,chunksSchema:()=>ZP,chunksPacketDefinition:()=>b00,chunkSchema:()=>eO,chatMessagesSchema:()=>tO,chatMessagesPacketDefinition:()=>_00,chatMessageSendPacketDefinition:()=>R00,chatMessageSchema:()=>jz,cameraSchema:()=>rO,cameraPacketDefinition:()=>I00,blocksSchema:()=>nO,blocksPacketDefinition:()=>k00,blockTypesSchema:()=>oO,blockTypesPacketDefinition:()=>E00,blockTypeSchema:()=>sO,blockSchema:()=>aO,bidirectionalPackets:()=>Pc,audiosSchema:()=>dO,audiosPacketDefinition:()=>f00,audioSchema:()=>gO,PacketId:()=>C1});var Pc={};_Q(Pc,{heartbeatPacketDefinition:()=>M00,connectionPacketDefinition:()=>D00});var hO=t(j00(),1);class SO extends hO.default{static instance=new hO.default}var C1;((O)=>{O[O.SYNC_REQUEST=0]="SYNC_REQUEST";O[O.INPUT=1]="INPUT";O[O.STATE_REQUEST=2]="STATE_REQUEST";O[O.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";O[O.UI_DATA_SEND=4]="UI_DATA_SEND";O[O.SYNC_RESPONSE=32]="SYNC_RESPONSE";O[O.AUDIOS=33]="AUDIOS";O[O.BLOCKS=34]="BLOCKS";O[O.BLOCK_TYPES=35]="BLOCK_TYPES";O[O.CHAT_MESSAGES=36]="CHAT_MESSAGES";O[O.CHUNKS=37]="CHUNKS";O[O.ENTITIES=38]="ENTITIES";O[O.WORLD=39]="WORLD";O[O.CAMERA=40]="CAMERA";O[O.UI=41]="UI";O[O.UI_DATAS=42]="UI_DATAS";O[O.SCENE_UIS=43]="SCENE_UIS";O[O.LIGHTS=44]="LIGHTS";O[O.PLAYERS=45]="PLAYERS";O[O.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";O[O.CONNECTION=116]="CONNECTION";O[O.HEARTBEAT=117]="HEARTBEAT";O[O.DEBUG_CONFIG=128]="DEBUG_CONFIG";O[O.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";O[O.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(C1||={});function mk1(Z,J,X){if(!Z.validate(J))throw new Error(`Invalid payload for packet with id ${Z.id}. Error: ${SO.instance.errorsText(Z.validate.errors)}`);let $=[Z.id,J];if(typeof X==="number")$.push(X);return $}function f0(Z,J){return{id:Z,schema:J,validate:SO.instance.compile(J)}}var uk1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},L00={type:"object",properties:{role:{type:"string",enum:["auto","client","server"],nullable:!0},fingerprints:{type:"array",items:{type:"object",properties:{algorithm:{type:"string",enum:["sha-1","sha-224","sha-256","sha-384","sha-512"]},value:{type:"string"}},required:["algorithm","value"]}}},required:["fingerprints"],additionalProperties:!1},lk1={type:"object",properties:{foundation:{type:"string"},priority:{type:"number"},ip:{type:"string"},address:{type:"string"},protocol:{type:"string",enum:["udp","tcp"]},port:{type:"number"},type:{type:"string",enum:["host"]},tcpType:{type:"string",enum:["passive"],nullable:!0}},required:["foundation","priority","ip","address","protocol","port","type"],additionalProperties:!1},yk1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},pk1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},ik1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},gk1={type:"object",properties:{streamId:{type:"number"},ordered:{type:"boolean",nullable:!0},maxPacketLifeTime:{type:"number",nullable:!0},maxRetransmits:{type:"number",nullable:!0}},required:["streamId"],additionalProperties:!1},dk1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:yk1,ic:{type:"array",items:lk1},d:L00,s:ik1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},ak1={type:"object",properties:{i:{type:"string"},d:L00},required:["i","d"],additionalProperties:!1},nk1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:gk1},required:["l","s"],additionalProperties:!1},AO={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},c:{...ak1,nullable:!0},ca:{...uk1,nullable:!0},d:{type:"array",items:{...nk1},nullable:!0},pa:{...pk1,nullable:!0},t:{type:"array",items:{...dk1},nullable:!0}},additionalProperties:!1};var D00=f0(116,AO);var mO={type:"null",nullable:!0};var M00=f0(117,mO);var Tc={};_Q(Tc,{uiDataSendPacketDefinition:()=>C00,syncRequestPacketDefinition:()=>T00,stateRequestPacketDefinition:()=>P00,inputPacketDefinition:()=>O00,debugConfigPacketDefinition:()=>N00,chatMessageSendPacketDefinition:()=>R00});var uO={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var jz={type:"object",properties:{m:{type:"string"},c:{...uO,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var R00=f0(3,jz);var lO={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var N00=f0(128,lO);var yO={type:"object",properties:{"1":{type:"boolean",nullable:!0},"2":{type:"boolean",nullable:!0},"3":{type:"boolean",nullable:!0},"4":{type:"boolean",nullable:!0},"5":{type:"boolean",nullable:!0},"6":{type:"boolean",nullable:!0},"7":{type:"boolean",nullable:!0},"8":{type:"boolean",nullable:!0},"9":{type:"boolean",nullable:!0},"0":{type:"boolean",nullable:!0},w:{type:"boolean",nullable:!0},a:{type:"boolean",nullable:!0},s:{type:"boolean",nullable:!0},d:{type:"boolean",nullable:!0},q:{type:"boolean",nullable:!0},e:{type:"boolean",nullable:!0},r:{type:"boolean",nullable:!0},f:{type:"boolean",nullable:!0},z:{type:"boolean",nullable:!0},x:{type:"boolean",nullable:!0},c:{type:"boolean",nullable:!0},v:{type:"boolean",nullable:!0},u:{type:"boolean",nullable:!0},i:{type:"boolean",nullable:!0},o:{type:"boolean",nullable:!0},j:{type:"boolean",nullable:!0},k:{type:"boolean",nullable:!0},l:{type:"boolean",nullable:!0},n:{type:"boolean",nullable:!0},m:{type:"boolean",nullable:!0},sp:{type:"boolean",nullable:!0},sh:{type:"boolean",nullable:!0},tb:{type:"boolean",nullable:!0},ml:{type:"boolean",nullable:!0},mr:{type:"boolean",nullable:!0},cp:{type:"number",nullable:!0},cy:{type:"number",nullable:!0},sq:{type:"number",nullable:!0}},additionalProperties:!1};var O00=f0(1,yO);var pO={type:"object",properties:{},additionalProperties:!1};var P00=f0(2,pO);var iO={type:"null",nullable:!0};var T00=f0(0,iO);var Lz={type:"object",properties:{},additionalProperties:!0};var C00=f0(4,Lz);var Cc={};_Q(Cc,{worldPacketDefinition:()=>d00,uiPacketDefinition:()=>i00,uiDatasPacketDefinition:()=>g00,syncResponsePacketDefinition:()=>p00,sceneUIsPacketDefinition:()=>y00,playersPacketDefinition:()=>l00,physicsDebugRenderPacketDefinition:()=>m00,physicsDebugRaycastsPacketDefinition:()=>u00,particleEmittersPacketDefinition:()=>A00,lightsPacketDefinition:()=>S00,entitiesPacketDefinition:()=>h00,chunksPacketDefinition:()=>b00,chatMessagesPacketDefinition:()=>_00,cameraPacketDefinition:()=>I00,blocksPacketDefinition:()=>k00,blockTypesPacketDefinition:()=>E00,audiosPacketDefinition:()=>f00});var W1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var gO={type:"object",properties:{i:{type:"number"},a:{type:"string",nullable:!0},cd:{type:"number",nullable:!0},d:{type:"number",nullable:!0},de:{type:"number",nullable:!0},di:{type:"number",minimum:0,nullable:!0},e:{type:"number",nullable:!0},l:{type:"boolean",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pl:{type:"boolean",nullable:!0},pr:{type:"number",minimum:0,nullable:!0},r:{type:"boolean",nullable:!0},rd:{type:"number",nullable:!0},s:{type:"number",nullable:!0},v:{type:"number",minimum:0,maximum:1,nullable:!0}},required:["i"],additionalProperties:!1};var dO={type:"array",items:{...gO}};var f00=f0(33,dO);var aO={type:"object",properties:{i:{type:"number"},c:W1},required:["i","c"],additionalProperties:!1};var nO={type:"array",items:{...aO}};var k00=f0(34,nO);var sO={type:"object",properties:{i:{type:"number"},l:{type:"boolean",nullable:!0},ll:{type:"number",nullable:!0},n:{type:"string",nullable:!0},t:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var oO={type:"array",items:{...sO}};var E00=f0(35,oO);var rO={type:"object",properties:{m:{type:"number",nullable:!0},e:{type:"number",nullable:!0},et:{type:"number",nullable:!0},fo:{type:"number",nullable:!0},ffo:{type:"number",nullable:!0},fv:{type:"number",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pt:{...W1,nullable:!0},pl:{...W1,nullable:!0},s:{type:"array",items:{type:"string"},nullable:!0},sa:{type:"number",nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var tO={type:"array",items:{...jz}};var eO={type:"object",properties:{c:W1,b:{type:"array",items:{type:"number",minimum:0,maximum:255},minItems:4096,maxItems:4096,nullable:!0},rm:{type:"boolean",nullable:!0}},required:["c"],additionalProperties:!1};var ZP={type:"array",items:{...eO}};var D6={type:"array",items:[{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255}],minItems:3,maxItems:3};var JP={type:"object",properties:{n:{type:"string"},h:{type:"boolean",nullable:!0},o:{type:"number",minimum:0,maximum:1,nullable:!0},r:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},t:{...D6,nullable:!0}},required:["n"],additionalProperties:!1};var XP={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var $P={type:"object",properties:{i:{type:"number"},al:{type:"array",items:{type:"string"},nullable:!0},ao:{type:"array",items:{type:"string"},nullable:!0},ap:{type:"number",nullable:!0},as:{type:"array",items:{type:"string"},nullable:!0},bh:{...W1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...JP},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...XP,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...D6,nullable:!0}},required:["i"],additionalProperties:!1};var YP={type:"array",items:{...$P}};var QP={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...D6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",minimum:0,maximum:1,nullable:!0},rm:{type:"boolean",nullable:!0},t:{type:"number",nullable:!0},te:{type:"number",nullable:!0},tp:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var KP={type:"array",items:{...QP}};var WP={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},b:{type:"number",nullable:!0},ce:{...D6,nullable:!0},cev:{...D6,nullable:!0},cs:{...D6,nullable:!0},csv:{...D6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...W1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...W1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pv:{...W1,nullable:!0},r:{type:"number",nullable:!0},rv:{type:"number",nullable:!0},rm:{type:"boolean",nullable:!0},se:{type:"number",nullable:!0},sev:{type:"number",nullable:!0},ss:{type:"number",nullable:!0},ssv:{type:"number",nullable:!0},t:{type:"boolean",nullable:!0},tu:{type:"string",nullable:!0},v:{...W1,nullable:!0},vv:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var GP={type:"array",items:{...WP}};var zP={type:"object",properties:{o:{...W1},d:{...W1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var vP={type:"array",items:{...zP}};var VP={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var HP={type:"object",properties:{i:{type:"string"},p:{type:"string",nullable:!0},rm:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var qP={type:"array",items:{...HP}};var FP={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"object",nullable:!0},t:{type:"string",nullable:!0},v:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var xP={type:"array",items:{...FP}};var cP={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var wP={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var UP={type:"array",items:{...Lz}};var sk1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var BP={type:"object",properties:{i:{type:"number"},ac:{...D6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...D6,nullable:!0},di:{type:"number",nullable:!0},dp:{...W1,nullable:!0},fc:{...D6,nullable:!0},ff:{type:"number",nullable:!0},fn:{type:"number",nullable:!0},n:{type:"string",nullable:!0},s:{type:"string",nullable:!0},si:{type:"number",nullable:!0},t:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var I00=f0(40,rO);var _00=f0(36,tO);var b00=f0(37,ZP);var h00=f0(38,YP);var S00=f0(44,KP);var A00=f0(46,GP);var m00=f0(192,VP);var u00=f0(193,vP);var l00=f0(45,qP);var y00=f0(43,xP);var p00=f0(32,cP);var i00=f0(41,wP);var g00=f0(42,UP);var d00=f0(39,BP);var fc=new Map,ok1={...Pc,...Tc,...Cc};for(let Z of Object.values(ok1))if("id"in Z&&"schema"in Z){let J=Z;if(fc.has(J.id))throw new Error(`Packet with id ${J.id} is already registered.`);fc.set(J.id,J)}function rk1(Z){if(typeof Z!=="object"||Z===null||typeof Z[0]!=="number"||Z[0]<0||Z[1]===void 0||Z[2]!==void 0&&(typeof Z[2]!=="number"||Z[2]<0))return!1;let J=fc.get(Z[0]);return!!J&&J.validate(Z[1])}var Y0=jP;import t$ from"fs";import D80 from"path";var xI1=t(l10(),1),cI1=t(OP(),1),wI1=t(TP(),1),r$=t(lc(),1),bP=t(n10(),1);var s10=r$.default;function w5(Z){if(Z===null)return"null";if(Array.isArray(Z))return"array";return typeof Z}function XX(Z){return w5(Z)==="object"}function UI1(Z){return Array.isArray(Z)&&Z.length>0&&Z.every((J)=>("message"in J))}function hP(Z,J){return Z.length<124?Z:J}var o10="graphql-transport-ws";var u5=((Z)=>{return Z[Z.InternalServerError=4500]="InternalServerError",Z[Z.InternalClientError=4005]="InternalClientError",Z[Z.BadRequest=4400]="BadRequest",Z[Z.BadResponse=4004]="BadResponse",Z[Z.Unauthorized=4401]="Unauthorized",Z[Z.Forbidden=4403]="Forbidden",Z[Z.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",Z[Z.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",Z[Z.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",Z[Z.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",Z[Z.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",Z})(u5||{}),l5=((Z)=>{return Z.ConnectionInit="connection_init",Z.ConnectionAck="connection_ack",Z.Ping="ping",Z.Pong="pong",Z.Subscribe="subscribe",Z.Next="next",Z.Error="error",Z.Complete="complete",Z})(l5||{});function r10(Z){if(!XX(Z))throw new Error(`Message is expected to be an object, but got ${w5(Z)}`);if(!Z.type)throw new Error("Message is missing the 'type' property");if(typeof Z.type!=="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${w5(Z.type)}`);switch(Z.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(Z.payload!=null&&!XX(Z.payload))throw new Error(`"${Z.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${Z.payload}"`);break}case"subscribe":{if(typeof Z.id!=="string")throw new Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${w5(Z.id)}`);if(!Z.id)throw new Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!XX(Z.payload))throw new Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${w5(Z.payload)}`);if(typeof Z.payload.query!=="string")throw new Error(`"${Z.type}" message payload expects the 'query' property to be a string, but got ${w5(Z.payload.query)}`);if(Z.payload.variables!=null&&!XX(Z.payload.variables))throw new Error(`"${Z.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${w5(Z.payload.variables)}`);if(Z.payload.operationName!=null&&w5(Z.payload.operationName)!=="string")throw new Error(`"${Z.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${w5(Z.payload.operationName)}`);if(Z.payload.extensions!=null&&!XX(Z.payload.extensions))throw new Error(`"${Z.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${w5(Z.payload.extensions)}`);break}case"next":{if(typeof Z.id!=="string")throw new Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${w5(Z.id)}`);if(!Z.id)throw new Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!XX(Z.payload))throw new Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${w5(Z.payload)}`);break}case"error":{if(typeof Z.id!=="string")throw new Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${w5(Z.id)}`);if(!Z.id)throw new Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!UI1(Z.payload))throw new Error(`"${Z.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(Z.payload)}`);break}case"complete":{if(typeof Z.id!=="string")throw new Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${w5(Z.id)}`);if(!Z.id)throw new Error(`"${Z.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${Z.type}"`)}return Z}function t10(Z,J){return r10(typeof Z==="string"?JSON.parse(Z,J):Z)}function i3(Z,J){return r10(Z),JSON.stringify(Z,J)}function AP(Z){let{url:J,connectionParams:X,lazy:$=!0,onNonLazyError:Y=console.error,lazyCloseTimeout:Q=0,keepAlive:K=0,disablePong:W,connectionAckWaitTimeout:G=0,retryAttempts:z=5,retryWait:v=async function C(b){let I=Math.pow(2,b);await new Promise((a)=>setTimeout(a,I*1000+Math.floor(Math.random()*2700+300)))},shouldRetry:H=SP,on:V,webSocketImpl:q,generateID:F=function C(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(b)=>{let I=Math.random()*16|0;return(b=="x"?I:I&3|8).toString(16)})},jsonMessageReplacer:x,jsonMessageReviver:c}=Z,w;if(q){if(!jI1(q))throw new Error("Invalid WebSocket implementation provided");w=q}else if(typeof WebSocket!=="undefined")w=WebSocket;else if(typeof global!=="undefined")w=global.WebSocket||global.MozWebSocket;else if(typeof window!=="undefined")w=window.WebSocket||window.MozWebSocket;if(!w)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let B=w,j=(()=>{let C=(()=>{let I={};return{on(a,s){return I[a]=s,()=>{delete I[a]}},emit(a){if("id"in a)I[a.id]?.(a)}}})(),b={connecting:V?.connecting?[V.connecting]:[],opened:V?.opened?[V.opened]:[],connected:V?.connected?[V.connected]:[],ping:V?.ping?[V.ping]:[],pong:V?.pong?[V.pong]:[],message:V?.message?[C.emit,V.message]:[C.emit],closed:V?.closed?[V.closed]:[],error:V?.error?[V.error]:[]};return{onMessage:C.on,on(I,a){let s=b[I];return s.push(a),()=>{s.splice(s.indexOf(a),1)}},emit(I,...a){for(let s of[...b[I]])s(...a)}}})();function L(C){let b=[j.on("error",(I)=>{b.forEach((a)=>a()),C(I)}),j.on("closed",(I)=>{b.forEach((a)=>a()),C(I)})]}let R,M=0,N,P=!1,O=0,_=!1;async function k(){clearTimeout(N);let[C,b]=await(R??(R=new Promise((s,Z0)=>(async()=>{if(P){if(await v(O),!M)return R=void 0,Z0({code:1000,reason:"All Subscriptions Gone"});O++}j.emit("connecting",P);let o=new B(typeof J==="function"?await J():J,o10),M0,R0;function m0(){if(isFinite(K)&&K>0)clearTimeout(R0),R0=setTimeout(()=>{if(o.readyState===B.OPEN)o.send(i3({type:l5.Ping})),j.emit("ping",!1,void 0)},K)}L((s0)=>{if(R=void 0,clearTimeout(M0),clearTimeout(R0),Z0(s0),s0 instanceof pc)o.close(4499,"Terminated"),o.onerror=null,o.onclose=null}),o.onerror=(s0)=>j.emit("error",s0),o.onclose=(s0)=>j.emit("closed",s0),o.onopen=async()=>{try{j.emit("opened",o);let s0=typeof X==="function"?await X():X;if(o.readyState!==B.OPEN)return;if(o.send(i3(s0?{type:l5.ConnectionInit,payload:s0}:{type:l5.ConnectionInit},x)),isFinite(G)&&G>0)M0=setTimeout(()=>{o.close(u5.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},G);m0()}catch(s0){j.emit("error",s0),o.close(u5.InternalClientError,hP(s0 instanceof Error?s0.message:String(s0),"Internal client error"))}};let N1=!1;o.onmessage=({data:s0})=>{try{let B1=t10(s0,c);if(j.emit("message",B1),B1.type==="ping"||B1.type==="pong"){if(j.emit(B1.type,!0,B1.payload),B1.type==="pong")m0();else if(!W)o.send(i3(B1.payload?{type:l5.Pong,payload:B1.payload}:{type:l5.Pong})),j.emit("pong",!1,B1.payload);return}if(N1)return;if(B1.type!==l5.ConnectionAck)throw new Error(`First message cannot be of type ${B1.type}`);clearTimeout(M0),N1=!0,j.emit("connected",o,B1.payload,P),P=!1,O=0,s([o,new Promise((W4,RJ)=>L(RJ))])}catch(B1){o.onmessage=null,j.emit("error",B1),o.close(u5.BadResponse,hP(B1 instanceof Error?B1.message:String(B1),"Bad response"))}}})())));if(C.readyState===B.CLOSING)await b;let I=()=>{},a=new Promise((s)=>I=s);return[C,I,Promise.race([a.then(()=>{if(!M){let s=()=>C.close(1000,"Normal Closure");if(isFinite(Q)&&Q>0)N=setTimeout(()=>{if(C.readyState===B.OPEN)s()},Q);else s()}}),b])]}function h(C){if(SP(C)&&(BI1(C.code)||[u5.InternalServerError,u5.InternalClientError,u5.BadRequest,u5.BadResponse,u5.Unauthorized,u5.SubprotocolNotAcceptable,u5.SubscriberAlreadyExists,u5.TooManyInitialisationRequests].includes(C.code)))throw C;if(_)return!1;if(SP(C)&&C.code===1000)return M>0;if(!z||O>=z)throw C;if(!H(C))throw C;return P=!0}if(!$)(async()=>{M++;for(;;)try{let[,,C]=await k();await C}catch(C){try{if(!h(C))return}catch(b){return Y?.(b)}}})();function f(C,b){let I=F(C),a=!1,s=!1,Z0=()=>{M--,a=!0};return(async()=>{M++;for(;;)try{let[o,M0,R0]=await k();if(a)return M0();let m0=j.onMessage(I,(N1)=>{switch(N1.type){case l5.Next:{b.next(N1.payload);return}case l5.Error:{s=!0,a=!0,b.error(N1.payload),Z0();return}case l5.Complete:{a=!0,Z0();return}}});o.send(i3({id:I,type:l5.Subscribe,payload:C},x)),Z0=()=>{if(!a&&o.readyState===B.OPEN)o.send(i3({id:I,type:l5.Complete},x));M--,a=!0,M0()},await R0.finally(m0);return}catch(o){if(!h(o))return}})().then(()=>{if(!s)b.complete()}).catch((o)=>{b.error(o)}),()=>{if(!a)Z0()}}return{on:j.on,subscribe:f,iterate(C){let b=[],I={done:!1,error:null,resolve:()=>{}},a=f(C,{next(Z0){b.push(Z0),I.resolve()},error(Z0){I.done=!0,I.error=Z0,I.resolve()},complete(){I.done=!0,I.resolve()}}),s=async function*Z0(){for(;;){if(!b.length)await new Promise((o)=>I.resolve=o);while(b.length)yield b.shift();if(I.error)throw I.error;if(I.done)return}}();return s.throw=async(Z0)=>{if(!I.done)I.done=!0,I.error=Z0,I.resolve();return{done:!0,value:void 0}},s.return=async()=>{return a(),{done:!0,value:void 0}},s},async dispose(){if(_=!0,R){let[C]=await R;C.close(1000,"Normal Closure")}},terminate(){if(R)j.emit("closed",new pc)}}}class pc extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function SP(Z){return XX(Z)&&"code"in Z&&"reason"in Z}function BI1(Z){if([1000,1001,1006,1005,1012,1013,1014].includes(Z))return!1;return Z>=1000&&Z<=1999}function jI1(Z){return typeof Z==="function"&&"constructor"in Z&&"CLOSED"in Z&&"CLOSING"in Z&&"CONNECTING"in Z&&"OPEN"in Z}var M80=t(L80(),1);var kz="./dev/persistence";class O4{static instance=new O4;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;_gqlWs;constructor(){this._gqlWs=AP({url:"wss://prod.gql.hytopia.com/graphql",webSocketImpl:s10});try{this._creativeGateway=new M80.CreativeGateway}catch{console.warn(["━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","\uD83D\uDEA8 HYTOPIA PLATFORM GATEWAY IS NOT INITIALIZED \uD83D\uDEA8","","\uD83D\uDD27 Local development is still possible, but these features will be disabled:"," • \uD83D\uDC64 Player Accounts"," • \uD83C\uDFAD Player Cosmetics"," • \uD83D\uDC1B Crash Analytics & Debug Logs","","\uD83D\uDCA1 These features will be enabled but modified:"," • \uD83D\uDCBE Player & Global Persisted Data - Data will be persisted"," locally in the ./dev/persistence directory of your project."," Player ids for data persistence will begin at 1 for the first "," player to join your local server, and increments for each"," additional player. This means that if you restart your"," server, the first player id will be 1 again. This is to ensure"," that data persistence across server restarts can be easily"," tested and debugged in local development.","","To enable the HYTOPIA Platform Gateway locally:"," 1. Set these environment variables:"," HYTOPIA_API_KEY, HYTOPIA_GAME_ID, HYTOPIA_LOBBY_ID"," 2. You can find these values at: https://create.hytopia.com","","Note: In production, these environment variables will be auto-populated ","& the HYTOPIA Platform Gateway will automatically be initialized \uD83D\uDE80","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",""].join(`
399
+ >>> no match, partial?`,Z,H,J,V),H===W)return!0}return!1}let F;if(typeof z==="string")F=v===z,this.debug("string match",z,v,F);else F=z.test(v),this.debug("pattern match",z,v,F);if(!F)return!1}if(Q===W&&K===G)return!0;else if(Q===W)return X;else if(K===G)return Q===W-1&&Z[Q]==="";else throw new Error("wtf?")}braceExpand(){return hi(this.pattern,this.options)}parse(Z){QG(Z);let J=this.options;if(Z==="**")return J6;if(Z==="")return"";let X,$=null;if(X=Z.match(ex1))$=J.dot?Jc1:Zc1;else if(X=Z.match(px1))$=(J.nocase?J.dot?ax1:dx1:J.dot?gx1:ix1)(X[1]);else if(X=Z.match(Xc1))$=(J.nocase?J.dot?Yc1:$c1:J.dot?Qc1:Kc1)(X);else if(X=Z.match(nx1))$=J.dot?ox1:sx1;else if(X=Z.match(rx1))$=tx1;let Y=Z6.fromGlob(Z,this.options).toMMPattern();if($&&typeof Y==="object")Reflect.defineProperty(Y,"test",{value:$});return Y}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Z=this.set;if(!Z.length)return this.regexp=!1,this.regexp;let J=this.options,X=J.noglobstar?zc1:J.dot?vc1:Vc1,$=new Set(J.nocase?["i"]:[]),Y=Z.map((W)=>{let G=W.map((z)=>{if(z instanceof RegExp)for(let v of z.flags.split(""))$.add(v);return typeof z==="string"?cc1(z):z===J6?J6:z._src});return G.forEach((z,v)=>{let H=G[v+1],V=G[v-1];if(z!==J6||V===J6)return;if(V===void 0)if(H!==void 0&&H!==J6)G[v+1]="(?:\\/|"+X+"\\/)?"+H;else G[v]=X;else if(H===void 0)G[v-1]=V+"(?:\\/|"+X+")?";else if(H!==J6)G[v-1]=V+"(?:\\/|\\/"+X+"\\/)"+H,G[v+1]=J6}),G.filter((z)=>z!==J6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if(Y="^"+Q+Y+K+"$",this.negate)Y="^(?!"+Y+").+$";try{this.regexp=new RegExp(Y,[...$].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit(Z){if(this.preserveMultipleSlashes)return Z.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Z))return["",...Z.split(/\/+/)];else return Z.split(/\/+/)}match(Z,J=this.partial){if(this.debug("match",Z,this.pattern),this.comment)return!1;if(this.empty)return Z==="";if(Z==="/"&&J)return!0;let X=this.options;if(this.isWindows)Z=Z.split("\\").join("/");let $=this.slashSplit(Z);this.debug(this.pattern,"split",$);let Y=this.set;this.debug(this.pattern,"set",Y);let Q=$[$.length-1];if(!Q)for(let K=$.length-2;!Q&&K>=0;K--)Q=$[K];for(let K=0;K<Y.length;K++){let W=Y[K],G=$;if(X.matchBase&&W.length===1)G=[Q];if(this.matchOne(G,W,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return b6.defaults(Z).Minimatch}}b6.AST=Z6;b6.Minimatch=H4;b6.escape=Z3;b6.unescape=F9;import{fileURLToPath as nc1}from"node:url";var J3=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,Ai=new Set,yM=typeof process==="object"&&!!process?process:{},mi=(Z,J,X,$)=>{typeof yM.emitWarning==="function"?yM.emitWarning(Z,J,X,$):console.error(`[${X}] ${J}: ${Z}`)},RF=globalThis.AbortController,Si=globalThis.AbortSignal;if(typeof RF==="undefined"){Si=class X{onabort;_onabort=[];reason;aborted=!1;addEventListener($,Y){this._onabort.push(Y)}},RF=class X{constructor(){J()}signal=new Si;abort($){if(this.signal.aborted)return;this.signal.reason=$,this.signal.aborted=!0;for(let Y of this.signal._onabort)Y($);this.signal.onabort?.($)}};let Z=yM.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,mi("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",J)}}var wc1=(Z)=>!Ai.has(Z),oM6=Symbol("type"),EJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),ui=(Z)=>!EJ(Z)?null:Z<=Math.pow(2,8)?Uint8Array:Z<=Math.pow(2,16)?Uint16Array:Z<=Math.pow(2,32)?Uint32Array:Z<=Number.MAX_SAFE_INTEGER?WG:null;class WG extends Array{constructor(Z){super(Z);this.fill(0)}}class X3{heap;length;static#Z=!1;static create(Z){let J=ui(Z);if(!J)return[];X3.#Z=!0;let X=new X3(Z,J);return X3.#Z=!1,X}constructor(Z,J){if(!X3.#Z)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new J(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}}class GG{#Z;#J;#$;#X;#Y;#v;#H;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#z;#V;#Q;#F;#c;#x;#U;#P;#B;#T;#D;#L;#j;#N;#w;#f;static unsafeExposeInternals(Z){return{starts:Z.#D,ttls:Z.#L,sizes:Z.#T,keyMap:Z.#z,keyList:Z.#V,valList:Z.#Q,next:Z.#F,prev:Z.#c,get head(){return Z.#x},get tail(){return Z.#U},free:Z.#P,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,$,Y)=>Z.#b(J,X,$,Y),moveToTail:(J)=>Z.#A(J),indexes:(J)=>Z.#O(J),rindexes:(J)=>Z.#C(J),isStale:(J)=>Z.#R(J)}}get max(){return this.#Z}get maxSize(){return this.#J}get calculatedSize(){return this.#G}get size(){return this.#W}get fetchMethod(){return this.#v}get memoMethod(){return this.#H}get dispose(){return this.#$}get onInsert(){return this.#X}get disposeAfter(){return this.#Y}constructor(Z){let{max:J=0,ttl:X,ttlResolution:$=1,ttlAutopurge:Y,updateAgeOnGet:Q,updateAgeOnHas:K,allowStale:W,dispose:G,onInsert:z,disposeAfter:v,noDisposeOnSet:H,noUpdateTTL:V,maxSize:q=0,maxEntrySize:F=0,sizeCalculation:x,fetchMethod:c,memoMethod:w,noDeleteOnFetchRejection:B,noDeleteOnStaleGet:j,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:R,ignoreFetchAbort:M}=Z;if(J!==0&&!EJ(J))throw new TypeError("max option must be a nonnegative integer");let N=J?ui(J):Array;if(!N)throw new Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=F||this.#J,this.sizeCalculation=x,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw new TypeError("sizeCalculation set to non-function")}if(w!==void 0&&typeof w!=="function")throw new TypeError("memoMethod must be a function if defined");if(this.#H=w,c!==void 0&&typeof c!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#v=c,this.#N=!!c,this.#z=new Map,this.#V=new Array(J).fill(void 0),this.#Q=new Array(J).fill(void 0),this.#F=new N(J),this.#c=new N(J),this.#x=0,this.#U=0,this.#P=X3.create(J),this.#W=0,this.#G=0,typeof G==="function")this.#$=G;if(typeof z==="function")this.#X=z;if(typeof v==="function")this.#Y=v,this.#B=[];else this.#Y=void 0,this.#B=void 0;if(this.#j=!!this.#$,this.#f=!!this.#X,this.#w=!!this.#Y,this.noDisposeOnSet=!!H,this.noUpdateTTL=!!V,this.noDeleteOnFetchRejection=!!B,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!EJ(this.#J))throw new TypeError("maxSize must be a positive integer if specified")}if(!EJ(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#u()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!j,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=EJ($)||$===0?$:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!EJ(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(wc1("LRU_CACHE_UNBOUNDED"))Ai.add("LRU_CACHE_UNBOUNDED"),mi("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",GG)}}getRemainingTTL(Z){return this.#z.has(Z)?1/0:0}#K(){let Z=new WG(this.#Z),J=new WG(this.#Z);this.#L=Z,this.#D=J,this.#k=(Y,Q,K=J3.now())=>{if(J[Y]=Q!==0?K:0,Z[Y]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#R(Y))this.#E(this.#V[Y],"expire")},Q+1);if(W.unref)W.unref()}},this.#I=(Y)=>{J[Y]=Z[Y]!==0?J3.now():0},this.#M=(Y,Q)=>{if(Z[Q]){let K=Z[Q],W=J[Q];if(!K||!W)return;Y.ttl=K,Y.start=W,Y.now=X||$();let G=Y.now-W;Y.remainingTTL=K-G}};let X=0,$=()=>{let Y=J3.now();if(this.ttlResolution>0){X=Y;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return Y};this.getRemainingTTL=(Y)=>{let Q=this.#z.get(Y);if(Q===void 0)return 0;let K=Z[Q],W=J[Q];if(!K||!W)return 1/0;let G=(X||$())-W;return K-G},this.#R=(Y)=>{let Q=J[Y],K=Z[Y];return!!K&&!!Q&&(X||$())-Q>K}}#I=()=>{};#M=()=>{};#k=()=>{};#R=()=>!1;#u(){let Z=new WG(this.#Z);this.#G=0,this.#T=Z,this.#_=(J)=>{this.#G-=Z[J],Z[J]=0},this.#l=(J,X,$,Y)=>{if(this.#q(X))return 0;if(!EJ($))if(Y){if(typeof Y!=="function")throw new TypeError("sizeCalculation must be a function");if($=Y(X,J),!EJ($))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return $},this.#h=(J,X,$)=>{if(Z[J]=X,this.#J){let Y=this.#J-Z[J];while(this.#G>Y)this.#S(!0)}if(this.#G+=Z[J],$)$.entrySize=X,$.totalCalculatedSize=this.#G}}#_=(Z)=>{};#h=(Z,J,X)=>{};#l=(Z,J,X,$)=>{if(X||$)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#U;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#x)break;else J=this.#c[J]}}*#C({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#x;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#U)break;else J=this.#F[J]}}#y(Z){return Z!==void 0&&this.#z.get(this.#V[Z])===Z}*entries(){for(let Z of this.#O())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#C())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*keys(){for(let Z of this.#O()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#C()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#O())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#C())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,J={}){for(let X of this.#O()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;if(Z(Y,this.#V[X],this))return this.get(this.#V[X],J)}}forEach(Z,J=this){for(let X of this.#O()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#V[X],this)}}rforEach(Z,J=this){for(let X of this.#C()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#V[X],this)}}purgeStale(){let Z=!1;for(let J of this.#C({allowStale:!0}))if(this.#R(J))this.#E(this.#V[J],"expire"),Z=!0;return Z}info(Z){let J=this.#z.get(Z);if(J===void 0)return;let X=this.#Q[J],$=this.#q(X)?X.__staleWhileFetching:X;if($===void 0)return;let Y={value:$};if(this.#L&&this.#D){let Q=this.#L[J],K=this.#D[J];if(Q&&K){let W=Q-(J3.now()-K);Y.ttl=W,Y.start=Date.now()}}if(this.#T)Y.size=this.#T[J];return Y}dump(){let Z=[];for(let J of this.#O({allowStale:!0})){let X=this.#V[J],$=this.#Q[J],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0||X===void 0)continue;let Q={value:Y};if(this.#L&&this.#D){Q.ttl=this.#L[J];let K=J3.now()-this.#D[J];Q.start=Math.floor(Date.now()-K)}if(this.#T)Q.size=this.#T[J];Z.unshift([X,Q])}return Z}load(Z){this.clear();for(let[J,X]of Z){if(X.start){let $=Date.now()-X.start;X.start=J3.now()-$}this.set(J,X.value,X)}}set(Z,J,X={}){if(J===void 0)return this.delete(Z),this;let{ttl:$=this.ttl,start:Y,noDisposeOnSet:Q=this.noDisposeOnSet,sizeCalculation:K=this.sizeCalculation,status:W}=X,{noUpdateTTL:G=this.noUpdateTTL}=X,z=this.#l(Z,J,X.size||0,K);if(this.maxEntrySize&&z>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#E(Z,"set"),this}let v=this.#W===0?void 0:this.#z.get(Z);if(v===void 0){if(v=this.#W===0?this.#U:this.#P.length!==0?this.#P.pop():this.#W===this.#Z?this.#S(!1):this.#W,this.#V[v]=Z,this.#Q[v]=J,this.#z.set(Z,v),this.#F[this.#U]=v,this.#c[v]=this.#U,this.#U=v,this.#W++,this.#h(v,z,W),W)W.set="add";if(G=!1,this.#f)this.#X?.(J,Z,"add")}else{this.#A(v);let H=this.#Q[v];if(J!==H){if(this.#N&&this.#q(H)){H.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:V}=H;if(V!==void 0&&!Q){if(this.#j)this.#$?.(V,Z,"set");if(this.#w)this.#B?.push([V,Z,"set"])}}else if(!Q){if(this.#j)this.#$?.(H,Z,"set");if(this.#w)this.#B?.push([H,Z,"set"])}if(this.#_(v),this.#h(v,z,W),this.#Q[v]=J,W){W.set="replace";let V=H&&this.#q(H)?H.__staleWhileFetching:H;if(V!==void 0)W.oldValue=V}}else if(W)W.set="update";if(this.#f)this.onInsert?.(J,Z,J===H?"update":"replace")}if($!==0&&!this.#L)this.#K();if(this.#L){if(!G)this.#k(v,$,Y);if(W)this.#M(W,v)}if(!Q&&this.#w&&this.#B){let H=this.#B,V;while(V=H?.shift())this.#Y?.(...V)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#x];if(this.#S(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#w&&this.#B){let Z=this.#B,J;while(J=Z?.shift())this.#Y?.(...J)}}}#S(Z){let J=this.#x,X=this.#V[J],$=this.#Q[J];if(this.#N&&this.#q($))$.__abortController.abort(new Error("evicted"));else if(this.#j||this.#w){if(this.#j)this.#$?.($,X,"evict");if(this.#w)this.#B?.push([$,X,"evict"])}if(this.#_(J),Z)this.#V[J]=void 0,this.#Q[J]=void 0,this.#P.push(J);if(this.#W===1)this.#x=this.#U=0,this.#P.length=0;else this.#x=this.#F[J];return this.#z.delete(X),this.#W--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:$}=J,Y=this.#z.get(Z);if(Y!==void 0){let Q=this.#Q[Y];if(this.#q(Q)&&Q.__staleWhileFetching===void 0)return!1;if(!this.#R(Y)){if(X)this.#I(Y);if($)$.has="hit",this.#M($,Y);return!0}else if($)$.has="stale",this.#M($,Y)}else if($)$.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,$=this.#z.get(Z);if($===void 0||!X&&this.#R($))return;let Y=this.#Q[$];return this.#q(Y)?Y.__staleWhileFetching:Y}#b(Z,J,X,$){let Y=J===void 0?void 0:this.#Q[J];if(this.#q(Y))return Y;let Q=new RF,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:$},G=(F,x=!1)=>{let{aborted:c}=Q.signal,w=X.ignoreFetchAbort&&F!==void 0;if(X.status)if(c&&!x){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,w)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(c&&!w&&!x)return v(Q.signal.reason);let B=V;if(this.#Q[J]===V)if(F===void 0)if(B.__staleWhileFetching)this.#Q[J]=B.__staleWhileFetching;else this.#E(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,F,W.options)}return F},z=(F)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=F;return v(F)},v=(F)=>{let{aborted:x}=Q.signal,c=x&&X.allowStaleOnFetchAbort,w=c||X.allowStaleOnFetchRejection,B=w||X.noDeleteOnFetchRejection,j=V;if(this.#Q[J]===V){if(!B||j.__staleWhileFetching===void 0)this.#E(Z,"fetch");else if(!c)this.#Q[J]=j.__staleWhileFetching}if(w){if(X.status&&j.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return j.__staleWhileFetching}else if(j.__returned===j)throw F},H=(F,x)=>{let c=this.#v?.(Z,Y,W);if(c&&c instanceof Promise)c.then((w)=>F(w===void 0?void 0:w),x);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(F(void 0),X.allowStaleOnFetchAbort)F=(w)=>G(w,!0)}})};if(X.status)X.status.fetchDispatched=!0;let V=new Promise(H).then(G,z),q=Object.assign(V,{__abortController:Q,__staleWhileFetching:Y,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#z.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#N)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof RF}async fetch(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,ttl:Q=this.ttl,noDisposeOnSet:K=this.noDisposeOnSet,size:W=0,sizeCalculation:G=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:v=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:H=this.allowStaleOnFetchRejection,ignoreFetchAbort:V=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:F,forceRefresh:x=!1,status:c,signal:w}=J;if(!this.#N){if(c)c.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,status:c})}let B={allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:z,noDeleteOnFetchRejection:v,allowStaleOnFetchRejection:H,allowStaleOnFetchAbort:q,ignoreFetchAbort:V,status:c,signal:w},j=this.#z.get(Z);if(j===void 0){if(c)c.fetch="miss";let L=this.#b(Z,j,B,F);return L.__returned=L}else{let L=this.#Q[j];if(this.#q(L)){let O=X&&L.__staleWhileFetching!==void 0;if(c){if(c.fetch="inflight",O)c.returnedStale=!0}return O?L.__staleWhileFetching:L.__returned=L}let R=this.#R(j);if(!x&&!R){if(c)c.fetch="hit";if(this.#A(j),$)this.#I(j);if(c)this.#M(c,j);return L}let M=this.#b(Z,j,B,F),P=M.__staleWhileFetching!==void 0&&X;if(c){if(c.fetch=R?"stale":"refresh",P&&R)c.returnedStale=!0}return P?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw new Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#H;if(!X)throw new Error("no memoMethod provided to constructor");let{context:$,forceRefresh:Y,...Q}=J,K=this.get(Z,Q);if(!Y&&K!==void 0)return K;let W=X(Z,K,{options:Q,context:$});return this.set(Z,W,Q),W}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,status:Q}=J,K=this.#z.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#M(Q,K);if(this.#R(K)){if(Q)Q.get="stale";if(!G){if(!Y)this.#E(Z,"expire");if(Q&&X)Q.returnedStale=!0;return X?W:void 0}else{if(Q&&X&&W.__staleWhileFetching!==void 0)Q.returnedStale=!0;return X?W.__staleWhileFetching:void 0}}else{if(Q)Q.get="hit";if(G)return W.__staleWhileFetching;if(this.#A(K),$)this.#I(K);return W}}else if(Q)Q.get="miss"}#p(Z,J){this.#c[J]=Z,this.#F[Z]=J}#A(Z){if(Z!==this.#U){if(Z===this.#x)this.#x=this.#F[Z];else this.#p(this.#c[Z],this.#F[Z]);this.#p(this.#U,Z),this.#U=Z}}delete(Z){return this.#E(Z,"delete")}#E(Z,J){let X=!1;if(this.#W!==0){let $=this.#z.get(Z);if($!==void 0)if(X=!0,this.#W===1)this.#m(J);else{this.#_($);let Y=this.#Q[$];if(this.#q(Y))Y.__abortController.abort(new Error("deleted"));else if(this.#j||this.#w){if(this.#j)this.#$?.(Y,Z,J);if(this.#w)this.#B?.push([Y,Z,J])}if(this.#z.delete(Z),this.#V[$]=void 0,this.#Q[$]=void 0,$===this.#U)this.#U=this.#c[$];else if($===this.#x)this.#x=this.#F[$];else{let Q=this.#c[$];this.#F[Q]=this.#F[$];let K=this.#F[$];this.#c[K]=this.#c[$]}this.#W--,this.#P.push($)}}if(this.#w&&this.#B?.length){let $=this.#B,Y;while(Y=$?.shift())this.#Y?.(...Y)}return X}clear(){return this.#m("delete")}#m(Z){for(let J of this.#C({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(new Error("deleted"));else{let $=this.#V[J];if(this.#j)this.#$?.(X,$,Z);if(this.#w)this.#B?.push([X,$,Z])}}if(this.#z.clear(),this.#Q.fill(void 0),this.#V.fill(void 0),this.#L&&this.#D)this.#L.fill(0),this.#D.fill(0);if(this.#T)this.#T.fill(0);if(this.#x=0,this.#U=0,this.#P.length=0,this.#G=0,this.#W=0,this.#w&&this.#B){let J=this.#B,X;while(X=J?.shift())this.#Y?.(...X)}}}import{posix as Tc1,win32 as tM}from"node:path";import{fileURLToPath as Cc1}from"node:url";import{lstatSync as fc1,readdir as kc1,readdirSync as Ec1,readlinkSync as Ic1,realpathSync as _c1}from"fs";import*as bc1 from"node:fs";import{lstat as Sc1,readdir as Ac1,readlink as mc1,realpath as uc1}from"node:fs/promises";import{EventEmitter as nM}from"node:events";import gi from"node:stream";import{StringDecoder as Uc1}from"node:string_decoder";var li=typeof process==="object"&&process?process:{stdout:null,stderr:null},Bc1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof T$||Z instanceof gi||jc1(Z)||Lc1(Z)),jc1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof nM&&typeof Z.pipe==="function"&&Z.pipe!==gi.Writable.prototype.pipe,Lc1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof nM&&typeof Z.write==="function"&&typeof Z.end==="function",ZZ=Symbol("EOF"),JZ=Symbol("maybeEmitEnd"),IJ=Symbol("emittedEnd"),NF=Symbol("emittingEnd"),zG=Symbol("emittedError"),OF=Symbol("closed"),yi=Symbol("read"),PF=Symbol("flush"),pi=Symbol("flushChunk"),x9=Symbol("encoding"),$3=Symbol("decoder"),y8=Symbol("flowing"),vG=Symbol("paused"),Y3=Symbol("resume"),p8=Symbol("buffer"),h6=Symbol("pipes"),i8=Symbol("bufferLength"),pM=Symbol("bufferPush"),TF=Symbol("bufferShift"),x6=Symbol("objectMode"),w8=Symbol("destroyed"),iM=Symbol("error"),gM=Symbol("emitData"),ii=Symbol("emitEnd"),dM=Symbol("emitEnd2"),X7=Symbol("async"),aM=Symbol("abort"),CF=Symbol("aborted"),VG=Symbol("signal"),P$=Symbol("dataListeners"),k5=Symbol("discarded"),HG=(Z)=>Promise.resolve().then(Z),Dc1=(Z)=>Z(),Mc1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",Rc1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,Nc1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class sM{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[Y3](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(Z){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class di extends sM{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Z,J,X){super(Z,J,X);this.proxyErrors=($)=>J.emit("error",$),Z.on("error",this.proxyErrors)}}var Oc1=(Z)=>!!Z.objectMode,Pc1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class T$ extends nM{[y8]=!1;[vG]=!1;[h6]=[];[p8]=[];[x6];[x9];[X7];[$3];[ZZ]=!1;[IJ]=!1;[NF]=!1;[OF]=!1;[zG]=null;[i8]=0;[w8]=!1;[VG];[CF]=!1;[P$]=0;[k5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(Oc1(J))this[x6]=!0,this[x9]=null;else if(Pc1(J))this[x9]=J.encoding,this[x6]=!1;else this[x6]=!1,this[x9]=null;if(this[X7]=!!J.async,this[$3]=this[x9]?new Uc1(this[x9]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[p8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[h6]});let{signal:X}=J;if(X)if(this[VG]=X,X.aborted)this[aM]();else X.addEventListener("abort",()=>this[aM]())}get bufferLength(){return this[i8]}get encoding(){return this[x9]}set encoding(Z){throw new Error("Encoding must be set at instantiation time")}setEncoding(Z){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[x6]}set objectMode(Z){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[X7]}set["async"](Z){this[X7]=this[X7]||!!Z}[aM](){this[CF]=!0,this.emit("abort",this[VG]?.reason),this.destroy(this[VG]?.reason)}get aborted(){return this[CF]}set aborted(Z){}write(Z,J,X){if(this[CF])return!1;if(this[ZZ])throw new Error("write after end");if(this[w8])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof J==="function")X=J,J="utf8";if(!J)J="utf8";let $=this[X7]?HG:Dc1;if(!this[x6]&&!Buffer.isBuffer(Z)){if(Nc1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(Rc1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[x6]){if(this[y8]&&this[i8]!==0)this[PF](!0);if(this[y8])this.emit("data",Z);else this[pM](Z);if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}if(!Z.length){if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}if(typeof Z==="string"&&!(J===this[x9]&&!this[$3]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[x9])Z=this[$3].write(Z);if(this[y8]&&this[i8]!==0)this[PF](!0);if(this[y8])this.emit("data",Z);else this[pM](Z);if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}read(Z){if(this[w8])return null;if(this[k5]=!1,this[i8]===0||Z===0||Z&&Z>this[i8])return this[JZ](),null;if(this[x6])Z=null;if(this[p8].length>1&&!this[x6])this[p8]=[this[x9]?this[p8].join(""):Buffer.concat(this[p8],this[i8])];let J=this[yi](Z||null,this[p8][0]);return this[JZ](),J}[yi](Z,J){if(this[x6])this[TF]();else{let X=J;if(Z===X.length||Z===null)this[TF]();else if(typeof X==="string")this[p8][0]=X.slice(Z),J=X.slice(0,Z),this[i8]-=Z;else this[p8][0]=X.subarray(Z),J=X.subarray(0,Z),this[i8]-=Z}if(this.emit("data",J),!this[p8].length&&!this[ZZ])this.emit("drain");return J}end(Z,J,X){if(typeof Z==="function")X=Z,Z=void 0;if(typeof J==="function")X=J,J="utf8";if(Z!==void 0)this.write(Z,J);if(X)this.once("end",X);if(this[ZZ]=!0,this.writable=!1,this[y8]||!this[vG])this[JZ]();return this}[Y3](){if(this[w8])return;if(!this[P$]&&!this[h6].length)this[k5]=!0;if(this[vG]=!1,this[y8]=!0,this.emit("resume"),this[p8].length)this[PF]();else if(this[ZZ])this[JZ]();else this.emit("drain")}resume(){return this[Y3]()}pause(){this[y8]=!1,this[vG]=!0,this[k5]=!1}get destroyed(){return this[w8]}get flowing(){return this[y8]}get paused(){return this[vG]}[pM](Z){if(this[x6])this[i8]+=1;else this[i8]+=Z.length;this[p8].push(Z)}[TF](){if(this[x6])this[i8]-=1;else this[i8]-=this[p8][0].length;return this[p8].shift()}[PF](Z=!1){do;while(this[pi](this[TF]())&&this[p8].length);if(!Z&&!this[p8].length&&!this[ZZ])this.emit("drain")}[pi](Z){return this.emit("data",Z),this[y8]}pipe(Z,J){if(this[w8])return Z;this[k5]=!1;let X=this[IJ];if(J=J||{},Z===li.stdout||Z===li.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[h6].push(!J.proxyErrors?new sM(this,Z,J):new di(this,Z,J)),this[X7])HG(()=>this[Y3]());else this[Y3]();return Z}unpipe(Z){let J=this[h6].find((X)=>X.dest===Z);if(J){if(this[h6].length===1){if(this[y8]&&this[P$]===0)this[y8]=!1;this[h6]=[]}else this[h6].splice(this[h6].indexOf(J),1);J.unpipe()}}addListener(Z,J){return this.on(Z,J)}on(Z,J){let X=super.on(Z,J);if(Z==="data"){if(this[k5]=!1,this[P$]++,!this[h6].length&&!this[y8])this[Y3]()}else if(Z==="readable"&&this[i8]!==0)super.emit("readable");else if(Mc1(Z)&&this[IJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[zG]){let $=J;if(this[X7])HG(()=>$.call(this,this[zG]));else $.call(this,this[zG])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[P$]=this.listeners("data").length,this[P$]===0&&!this[k5]&&!this[h6].length)this[y8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[P$]=0,!this[k5]&&!this[h6].length)this[y8]=!1}return J}get emittedEnd(){return this[IJ]}[JZ](){if(!this[NF]&&!this[IJ]&&!this[w8]&&this[p8].length===0&&this[ZZ]){if(this[NF]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[OF])this.emit("close");this[NF]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==w8&&this[w8])return!1;else if(Z==="data")return!this[x6]&&!X?!1:this[X7]?(HG(()=>this[gM](X)),!0):this[gM](X);else if(Z==="end")return this[ii]();else if(Z==="close"){if(this[OF]=!0,!this[IJ]&&!this[w8])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Z==="error"){this[zG]=X,super.emit(iM,X);let Y=!this[VG]||this.listeners("error").length?super.emit("error",X):!1;return this[JZ](),Y}else if(Z==="resume"){let Y=super.emit("resume");return this[JZ](),Y}else if(Z==="finish"||Z==="prefinish"){let Y=super.emit(Z);return this.removeAllListeners(Z),Y}let $=super.emit(Z,...J);return this[JZ](),$}[gM](Z){for(let X of this[h6])if(X.dest.write(Z)===!1)this.pause();let J=this[k5]?!1:super.emit("data",Z);return this[JZ](),J}[ii](){if(this[IJ])return!1;return this[IJ]=!0,this.readable=!1,this[X7]?(HG(()=>this[dM]()),!0):this[dM]()}[dM](){if(this[$3]){let J=this[$3].end();if(J){for(let X of this[h6])X.dest.write(J);if(!this[k5])super.emit("data",J)}}for(let J of this[h6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[x6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[x6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[x6])throw new Error("cannot concat in objectMode");let Z=await this.collect();return this[x9]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(w8,()=>J(new Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[k5]=!1;let Z=!1,J=async()=>{return this.pause(),Z=!0,{value:void 0,done:!0}};return{next:()=>{if(Z)return J();let $=this.read();if($!==null)return Promise.resolve({done:!1,value:$});if(this[ZZ])return J();let Y,Q,K=(v)=>{this.off("data",W),this.off("end",G),this.off(w8,z),J(),Q(v)},W=(v)=>{this.off("error",K),this.off("end",G),this.off(w8,z),this.pause(),Y({value:v,done:!!this[ZZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(w8,z),J(),Y({done:!0,value:void 0})},z=()=>K(new Error("stream destroyed"));return new Promise((v,H)=>{Q=H,Y=v,this.once(w8,z),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[k5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(iM,J),this.off(w8,J),this.off("end",J),Z=!0,{done:!0,value:void 0}},X=()=>{if(Z)return J();let $=this.read();return $===null?J():{done:!1,value:$}};return this.once("end",J),this.once(iM,J),this.once(w8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[w8]){if(Z)this.emit("error",Z);else this.emit(w8);return this}this[w8]=!0,this[k5]=!0,this[p8].length=0,this[i8]=0;let J=this;if(typeof J.close==="function"&&!this[OF])J.close();if(Z)this.emit("error",Z);else this.emit(w8);return this}static get isStream(){return Bc1}}var hc1=_c1.native,FG={lstatSync:fc1,readdir:kc1,readdirSync:Ec1,readlinkSync:Ic1,realpathSync:hc1,promises:{lstat:Sc1,readdir:Ac1,readlink:mc1,realpath:uc1}},ri=(Z)=>!Z||Z===FG||Z===bc1?FG:{...FG,...Z,promises:{...FG.promises,...Z.promises||{}}},ti=/^\\\\\?\\([a-z]:)\\?$/i,lc1=(Z)=>Z.replace(/\//g,"\\").replace(ti,"$1\\"),yc1=/[\\\/]/,F4=0,ei=1,Zg=2,$7=4,Jg=6,Xg=8,C$=10,$g=12,q4=15,qG=~q4,oM=16,ai=32,xG=64,c9=128,fF=256,EF=512,ni=xG|c9|EF,pc1=1023,rM=(Z)=>Z.isFile()?Xg:Z.isDirectory()?$7:Z.isSymbolicLink()?C$:Z.isCharacterDevice()?Zg:Z.isBlockDevice()?Jg:Z.isSocket()?$g:Z.isFIFO()?ei:F4,si=new Map,cG=(Z)=>{let J=si.get(Z);if(J)return J;let X=Z.normalize("NFKD");return si.set(Z,X),X},oi=new Map,kF=(Z)=>{let J=oi.get(Z);if(J)return J;let X=cG(Z.toLowerCase());return oi.set(Z,X),X};class eM extends GG{constructor(){super({max:256})}}class Yg extends GG{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var Qg=Symbol("PathScurry setAsCwd");class S6{name;root;roots;parent;nocase;isCWD=!1;#Z;#J;get dev(){return this.#J}#$;get mode(){return this.#$}#X;get nlink(){return this.#X}#Y;get uid(){return this.#Y}#v;get gid(){return this.#v}#H;get rdev(){return this.#H}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#z;get size(){return this.#z}#V;get blocks(){return this.#V}#Q;get atimeMs(){return this.#Q}#F;get mtimeMs(){return this.#F}#c;get ctimeMs(){return this.#c}#x;get birthtimeMs(){return this.#x}#U;get atime(){return this.#U}#P;get mtime(){return this.#P}#B;get ctime(){return this.#B}#T;get birthtime(){return this.#T}#D;#L;#j;#N;#w;#f;#K;#I;#M;#k;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=F4,X,$,Y,Q,K){if(this.name=Z,this.#D=Y?kF(Z):cG(Z),this.#K=J&pc1,this.nocase=Y,this.roots=$,this.root=X||this,this.#I=Q,this.#j=K.fullpath,this.#w=K.relative,this.#f=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=ri(K.fs)}depth(){if(this.#L!==void 0)return this.#L;if(!this.parent)return this.#L=0;return this.#L=this.parent.depth()+1}childrenCache(){return this.#I}resolve(Z){if(!Z)return this;let J=this.getRootString(Z),$=Z.substring(J.length).split(this.splitSep);return J?this.getRoot(J).#R($):this.#R($)}#R(Z){let J=this;for(let X of Z)J=J.child(X);return J}children(){let Z=this.#I.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#I.set(this,J),this.#K&=~oM,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),$=this.nocase?kF(Z):cG(Z);for(let W of X)if(W.#D===$)return W;let Y=this.parent?this.sep:"",Q=this.#j?this.#j+Y+Z:void 0,K=this.newChild(Z,F4,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=c9;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#w!==void 0)return this.#w;let Z=this.name,J=this.parent;if(!J)return this.#w=this.name;let X=J.relative();return X+(!X||!J.parent?"":this.sep)+Z}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#f!==void 0)return this.#f;let Z=this.name,J=this.parent;if(!J)return this.#f=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#j!==void 0)return this.#j;let Z=this.name,J=this.parent;if(!J)return this.#j=this.name;let $=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#j=$}fullpathPosix(){if(this.#N!==void 0)return this.#N;if(this.sep==="/")return this.#N=this.fullpath();if(!this.parent){let $=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test($))return this.#N=`//?/${$}`;else return this.#N=$}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#N=X}isUnknown(){return(this.#K&q4)===F4}isType(Z){return this[`is${Z}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#K&q4)===Xg}isDirectory(){return(this.#K&q4)===$7}isCharacterDevice(){return(this.#K&q4)===Zg}isBlockDevice(){return(this.#K&q4)===Jg}isFIFO(){return(this.#K&q4)===ei}isSocket(){return(this.#K&q4)===$g}isSymbolicLink(){return(this.#K&C$)===C$}lstatCached(){return this.#K&ai?this:void 0}readlinkCached(){return this.#M}realpathCached(){return this.#k}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#M)return!0;if(!this.parent)return!1;let Z=this.#K&q4;return!(Z!==F4&&Z!==C$||this.#K&fF||this.#K&c9)}calledReaddir(){return!!(this.#K&oM)}isENOENT(){return!!(this.#K&c9)}isNamed(Z){return!this.nocase?this.#D===cG(Z):this.#D===kF(Z)}async readlink(){let Z=this.#M;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=await this.#Z.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(J);if(X)return this.#M=X}catch(J){this.#S(J.code);return}}readlinkSync(){let Z=this.#M;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=this.#Z.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(J);if(X)return this.#M=X}catch(J){this.#S(J.code);return}}#u(Z){this.#K|=oM;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#_()}}#_(){if(this.#K&c9)return;this.#K=(this.#K|c9)&qG,this.#h()}#h(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#_()}#l(){this.#K|=EF,this.#O()}#O(){if(this.#K&xG)return;let Z=this.#K;if((Z&q4)===$7)Z&=qG;this.#K=Z|xG,this.#h()}#C(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#O();else if(Z==="ENOENT")this.#_();else this.children().provisional=0}#y(Z=""){if(Z==="ENOTDIR")this.parent.#O();else if(Z==="ENOENT")this.#_()}#S(Z=""){let J=this.#K;if(J|=fF,Z==="ENOENT")J|=c9;if(Z==="EINVAL"||Z==="UNKNOWN")J&=qG;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#O()}#b(Z,J){return this.#p(Z,J)||this.#q(Z,J)}#q(Z,J){let X=rM(Z),$=this.newChild(Z.name,X,{parent:this}),Y=$.#K&q4;if(Y!==$7&&Y!==C$&&Y!==F4)$.#K|=xG;return J.unshift($),J.provisional++,$}#p(Z,J){for(let X=J.provisional;X<J.length;X++){let $=J[X];if((this.nocase?kF(Z.name):cG(Z.name))!==$.#D)continue;return this.#A(Z,$,X,J)}}#A(Z,J,X,$){let Y=J.name;if(J.#K=J.#K&qG|rM(Z),Y!==Z.name)J.name=Z.name;if(X!==$.provisional){if(X===$.length-1)$.pop();else $.splice(X,1);$.unshift(J)}return $.provisional++,J}async lstat(){if((this.#K&c9)===0)try{return this.#E(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#y(Z.code)}}lstatSync(){if((this.#K&c9)===0)try{return this.#E(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#y(Z.code)}}#E(Z){let{atime:J,atimeMs:X,birthtime:$,birthtimeMs:Y,blksize:Q,blocks:K,ctime:W,ctimeMs:G,dev:z,gid:v,ino:H,mode:V,mtime:q,mtimeMs:F,nlink:x,rdev:c,size:w,uid:B}=Z;this.#U=J,this.#Q=X,this.#T=$,this.#x=Y,this.#W=Q,this.#V=K,this.#B=W,this.#c=G,this.#J=z,this.#v=v,this.#G=H,this.#$=V,this.#P=q,this.#F=F,this.#X=x,this.#H=c,this.#z=w,this.#Y=B;let j=rM(Z);if(this.#K=this.#K&qG|j|ai,j!==F4&&j!==$7&&j!==C$)this.#K|=xG}#m=[];#g=!1;#d(Z){this.#g=!1;let J=this.#m.slice();this.#m.length=0,J.forEach((X)=>X(null,Z))}readdirCB(Z,J=!1){if(!this.canReaddir()){if(J)Z(null,[]);else queueMicrotask(()=>Z(null,[]));return}let X=this.children();if(this.calledReaddir()){let Y=X.slice(0,X.provisional);if(J)Z(null,Y);else queueMicrotask(()=>Z(null,Y));return}if(this.#m.push(Z),this.#g)return;this.#g=!0;let $=this.fullpath();this.#Z.readdir($,{withFileTypes:!0},(Y,Q)=>{if(Y)this.#C(Y.code),X.provisional=0;else{for(let K of Q)this.#b(K,X);this.#u(X)}this.#d(X.slice(0,X.provisional));return})}#i;async readdir(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();if(this.#i)await this.#i;else{let X=()=>{};this.#i=new Promise(($)=>X=$);try{for(let $ of await this.#Z.promises.readdir(J,{withFileTypes:!0}))this.#b($,Z);this.#u(Z)}catch($){this.#C($.code),Z.provisional=0}this.#i=void 0,X()}return Z.slice(0,Z.provisional)}readdirSync(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();try{for(let X of this.#Z.readdirSync(J,{withFileTypes:!0}))this.#b(X,Z);this.#u(Z)}catch(X){this.#C(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&ni)return!1;let Z=q4&this.#K;if(!(Z===F4||Z===$7||Z===C$))return!1;return!0}shouldWalk(Z,J){return(this.#K&$7)===$7&&!(this.#K&ni)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#k)return this.#k;if((EF|fF|c9)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}realpathSync(){if(this.#k)return this.#k;if((EF|fF|c9)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}[Qg](Z){if(Z===this)return;Z.isCWD=!1,this.isCWD=!0;let J=new Set([]),X=[],$=this;while($&&$.parent)J.add($),$.#w=X.join(this.sep),$.#f=X.join("/"),$=$.parent,X.push("..");$=Z;while($&&$.parent&&!J.has($))$.#w=void 0,$.#f=void 0,$=$.parent}}class IF extends S6{sep="\\";splitSep=yc1;constructor(Z,J=F4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}newChild(Z,J=F4,X={}){return new IF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return tM.parse(Z).root}getRoot(Z){if(Z=lc1(Z.toUpperCase()),Z===this.root.name)return this.root;for(let[J,X]of Object.entries(this.roots))if(this.sameRoot(Z,J))return this.roots[Z]=X;return this.roots[Z]=new wG(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(ti,"$1\\"),Z===J}}class _F extends S6{splitSep="/";sep="/";constructor(Z,J=F4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=F4,X={}){return new _F(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class ZR{root;rootPath;roots;cwd;#Z;#J;#$;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:$,childrenCacheSize:Y=16384,fs:Q=FG}={}){if(this.#X=ri(Q),Z instanceof URL||Z.startsWith("file://"))Z=Cc1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new eM,this.#J=new eM,this.#$=new Yg(Y);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if($===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=$,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let G=this.root,z=W.length-1,v=J.sep,H=this.rootPath,V=!1;for(let q of W){let F=z--;G=G.child(q,{relative:new Array(F).fill("..").join(v),relativePosix:new Array(F).fill("..").join("/"),fullpath:H+=(V?"":v)+q}),V=!0}this.cwd=G}depth(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.depth()}childrenCache(){return this.#$}resolve(...Z){let J="";for(let Y=Z.length-1;Y>=0;Y--){let Q=Z[Y];if(!Q||Q===".")continue;if(J=J?`${Q}/${J}`:Q,this.isAbsolute(Q))break}let X=this.#Z.get(J);if(X!==void 0)return X;let $=this.cwd.resolve(J).fullpath();return this.#Z.set(J,$),$}resolvePosix(...Z){let J="";for(let Y=Z.length-1;Y>=0;Y--){let Q=Z[Y];if(!Q||Q===".")continue;if(J=J?`${Q}/${J}`:Q,this.isAbsolute(Q))break}let X=this.#J.get(J);if(X!==void 0)return X;let $=this.cwd.resolve(J).fullpathPosix();return this.#J.set(J,$),$}relative(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.relative()}relativePosix(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.relativePosix()}basename(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.name}dirname(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return(Z.parent||Z).fullpath()}async readdir(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X}=J;if(!Z.canReaddir())return[];else{let $=await Z.readdir();return X?$:$.map((Y)=>Y.name)}}readdirSync(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0}=J;if(!Z.canReaddir())return[];else if(X)return Z.readdirSync();else return Z.readdirSync().map(($)=>$.name)}async lstat(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.lstat()}lstatSync(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.lstatSync()}async readlink(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.readlink();return J?X:X?.fullpath()}readlinkSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z.withFileTypes,Z=this.cwd;let X=Z.readlinkSync();return J?X:X?.fullpath()}async realpath(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.realpath();return J?X:X?.fullpath()}realpathSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z.withFileTypes,Z=this.cwd;let X=Z.realpathSync();return J?X:X?.fullpath()}async walk(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=[];if(!Y||Y(Z))K.push(X?Z:Z.fullpath());let W=new Set,G=(v,H)=>{W.add(v),v.readdirCB((V,q)=>{if(V)return H(V);let F=q.length;if(!F)return H();let x=()=>{if(--F===0)H()};for(let c of q){if(!Y||Y(c))K.push(X?c:c.fullpath());if($&&c.isSymbolicLink())c.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(W,Q)?G(w,x):x());else if(c.shouldWalk(W,Q))G(c,x);else x()}},!0)},z=Z;return new Promise((v,H)=>{G(z,(V)=>{if(V)return H(V);v(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=[];if(!Y||Y(Z))K.push(X?Z:Z.fullpath());let W=new Set([Z]);for(let G of W){let z=G.readdirSync();for(let v of z){if(!Y||Y(v))K.push(X?v:v.fullpath());let H=v;if(v.isSymbolicLink()){if(!($&&(H=v.realpathSync())))continue;if(H.isUnknown())H.lstatSync()}if(H.shouldWalk(W,Q))W.add(H)}}return K}[Symbol.asyncIterator](){return this.iterate()}iterate(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;return this.stream(Z,J)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J;if(!Y||Y(Z))yield X?Z:Z.fullpath();let K=new Set([Z]);for(let W of K){let G=W.readdirSync();for(let z of G){if(!Y||Y(z))yield X?z:z.fullpath();let v=z;if(z.isSymbolicLink()){if(!($&&(v=z.realpathSync())))continue;if(v.isUnknown())v.lstatSync()}if(v.shouldWalk(K,Q))K.add(v)}}}stream(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new T$({objectMode:!0});if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=(x,c,w=!1)=>{if(x)return K.emit("error",x);if($&&!w){let B=[];for(let j of c)if(j.isSymbolicLink())B.push(j.realpath().then((L)=>L?.isUnknown()?L.lstat():L));if(B.length){Promise.all(B).then(()=>q(null,c,!0));return}}for(let B of c)if(B&&(!Y||Y(B))){if(!K.write(X?B:B.fullpath()))H=!0}z--;for(let B of c){let j=B.realpathCached()||B;if(j.shouldWalk(W,Q))G.push(j)}if(H&&!K.flowing)K.once("drain",v);else if(!F)v()},F=!0;V.readdirCB(q,!0),F=!1}};return v(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof S6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new T$({objectMode:!0}),W=new Set;if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=V.readdirSync();for(let F of q)if(!Y||Y(F)){if(!K.write(X?F:F.fullpath()))H=!0}z--;for(let F of q){let x=F;if(F.isSymbolicLink()){if(!($&&(x=F.realpathSync())))continue;if(x.isUnknown())x.lstatSync()}if(x.shouldWalk(W,Q))G.push(x)}}if(H&&!K.flowing)K.once("drain",v)};return v(),K}chdir(Z=this.cwd){let J=this.cwd;this.cwd=typeof Z==="string"?this.cwd.resolve(Z):Z,this.cwd[Qg](J)}}class wG extends ZR{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,tM,"\\",{...J,nocase:X});this.nocase=X;for(let $=this.cwd;$;$=$.parent)$.nocase=this.nocase}parseRootPath(Z){return tM.parse(Z).root.toUpperCase()}newRoot(Z){return new IF(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class UG extends ZR{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,Tc1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new _F(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class bF extends UG{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var GR6=process.platform==="win32"?IF:_F,Kg=process.platform==="win32"?wG:process.platform==="darwin"?bF:UG;var ic1=(Z)=>Z.length>=1,gc1=(Z)=>Z.length>=1;class Q3{#Z;#J;#$;length;#X;#Y;#v;#H;#W;#G;#z=!0;constructor(Z,J,X,$){if(!ic1(Z))throw new TypeError("empty pattern list");if(!gc1(J))throw new TypeError("empty glob list");if(J.length!==Z.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw new TypeError("index out of range");if(this.#Z=Z,this.#J=J,this.#$=X,this.#X=$,this.#$===0){if(this.isUNC()){let[Y,Q,K,W,...G]=this.#Z,[z,v,H,V,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let F=[Y,Q,K,W,""].join("/"),x=[z,v,H,V,""].join("/");this.#Z=[F,...G],this.#J=[x,...q],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[Y,...Q]=this.#Z,[K,...W]=this.#J;if(Q[0]==="")Q.shift(),W.shift();let G=Y+"/",z=K+"/";this.#Z=[G,...Q],this.#J=[z,...W],this.length=this.#Z.length}}}pattern(){return this.#Z[this.#$]}isString(){return typeof this.#Z[this.#$]==="string"}isGlobstar(){return this.#Z[this.#$]===J6}isRegExp(){return this.#Z[this.#$]instanceof RegExp}globString(){return this.#v=this.#v||(this.#$===0?this.isAbsolute()?this.#J[0]+this.#J.slice(1).join("/"):this.#J.join("/"):this.#J.slice(this.#$).join("/"))}hasMore(){return this.length>this.#$+1}rest(){if(this.#Y!==void 0)return this.#Y;if(!this.hasMore())return this.#Y=null;return this.#Y=new Q3(this.#Z,this.#J,this.#$+1,this.#X),this.#Y.#G=this.#G,this.#Y.#W=this.#W,this.#Y.#H=this.#H,this.#Y}isUNC(){let Z=this.#Z;return this.#W!==void 0?this.#W:this.#W=this.#X==="win32"&&this.#$===0&&Z[0]===""&&Z[1]===""&&typeof Z[2]==="string"&&!!Z[2]&&typeof Z[3]==="string"&&!!Z[3]}isDrive(){let Z=this.#Z;return this.#H!==void 0?this.#H:this.#H=this.#X==="win32"&&this.#$===0&&this.length>1&&typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0])}isAbsolute(){let Z=this.#Z;return this.#G!==void 0?this.#G:this.#G=Z[0]===""&&Z.length>1||this.isDrive()||this.isUNC()}root(){let Z=this.#Z[0];return typeof Z==="string"&&this.isAbsolute()&&this.#$===0?Z:""}checkFollowGlobstar(){return!(this.#$===0||!this.isGlobstar()||!this.#z)}markFollowGlobstar(){if(this.#$===0||!this.isGlobstar()||!this.#z)return!1;return this.#z=!1,!0}}var dc1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class BG{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:$,noglobstar:Y,platform:Q=dc1}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=Q,this.mmopts={dot:!0,nobrace:J,nocase:X,noext:$,noglobstar:Y,optimizationLevel:2,platform:Q,nocomment:!0,nonegate:!0};for(let K of Z)this.add(K)}add(Z){let J=new H4(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let $=J.set[X],Y=J.globParts[X];if(!$||!Y)throw new Error("invalid pattern object");while($[0]==="."&&Y[0]===".")$.shift(),Y.shift();let Q=new Q3($,Y,0,this.platform),K=new H4(Q.globString(),this.mmopts),W=Y[Y.length-1]==="**",G=Q.isAbsolute();if(G)this.absolute.push(K);else this.relative.push(K);if(W)if(G)this.absoluteChildren.push(K);else this.relativeChildren.push(K)}}ignored(Z){let J=Z.fullpath(),X=`${J}/`,$=Z.relative()||".",Y=`${$}/`;for(let Q of this.relative)if(Q.match($)||Q.match(Y))return!0;for(let Q of this.absolute)if(Q.match(J)||Q.match(X))return!0;return!1}childrenIgnored(Z){let J=Z.fullpath()+"/",X=(Z.relative()||".")+"/";for(let $ of this.relativeChildren)if($.match(X))return!0;for(let $ of this.absoluteChildren)if($.match(J))return!0;return!1}}class JR{store;constructor(Z=new Map){this.store=Z}copy(){return new JR(new Map(this.store))}hasWalked(Z,J){return this.store.get(Z.fullpath())?.has(J.globString())}storeWalked(Z,J){let X=Z.fullpath(),$=this.store.get(X);if($)$.add(J.globString());else this.store.set(X,new Set([J.globString()]))}}class Wg{store=new Map;add(Z,J,X){let $=(J?2:0)|(X?1:0),Y=this.store.get(Z);this.store.set(Z,Y===void 0?$:$&Y)}entries(){return[...this.store.entries()].map(([Z,J])=>[Z,!!(J&2),!!(J&1)])}}class Gg{store=new Map;add(Z,J){if(!Z.canReaddir())return;let X=this.store.get(Z);if(X){if(!X.find(($)=>$.globString()===J.globString()))X.push(J)}else this.store.set(Z,[J])}get(Z){let J=this.store.get(Z);if(!J)throw new Error("attempting to walk unknown path");return J}entries(){return this.keys().map((Z)=>[Z,this.store.get(Z)])}keys(){return[...this.store.keys()].filter((Z)=>Z.canReaddir())}}class jG{hasWalkedCache;matches=new Wg;subwalks=new Gg;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new JR}processPatterns(Z,J){this.patterns=J;let X=J.map(($)=>[Z,$]);for(let[$,Y]of X){this.hasWalkedCache.storeWalked($,Y);let Q=Y.root(),K=Y.isAbsolute()&&this.opts.absolute!==!1;if(Q){$=$.resolve(Q==="/"&&this.opts.root!==void 0?this.opts.root:Q);let v=Y.rest();if(!v){this.matches.add($,!0,!1);continue}else Y=v}if($.isENOENT())continue;let W,G,z=!1;while(typeof(W=Y.pattern())==="string"&&(G=Y.rest()))$=$.resolve(W),Y=G,z=!0;if(W=Y.pattern(),G=Y.rest(),z){if(this.hasWalkedCache.hasWalked($,Y))continue;this.hasWalkedCache.storeWalked($,Y)}if(typeof W==="string"){let v=W===".."||W===""||W===".";this.matches.add($.resolve(W),K,v);continue}else if(W===J6){if(!$.isSymbolicLink()||this.follow||Y.checkFollowGlobstar())this.subwalks.add($,Y);let v=G?.pattern(),H=G?.rest();if(!G||(v===""||v===".")&&!H)this.matches.add($,K,v===""||v===".");else if(v===".."){let V=$.parent||$;if(!H)this.matches.add(V,K,!0);else if(!this.hasWalkedCache.hasWalked(V,H))this.subwalks.add(V,H)}}else if(W instanceof RegExp)this.subwalks.add($,Y)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new jG(this.opts,this.hasWalkedCache)}filterEntries(Z,J){let X=this.subwalks.get(Z),$=this.child();for(let Y of J)for(let Q of X){let K=Q.isAbsolute(),W=Q.pattern(),G=Q.rest();if(W===J6)$.testGlobstar(Y,Q,G,K);else if(W instanceof RegExp)$.testRegExp(Y,W,G,K);else $.testString(Y,W,G,K)}return $}testGlobstar(Z,J,X,$){if(this.dot||!Z.name.startsWith(".")){if(!J.hasMore())this.matches.add(Z,$,!1);if(Z.canReaddir()){if(this.follow||!Z.isSymbolicLink())this.subwalks.add(Z,J);else if(Z.isSymbolicLink()){if(X&&J.checkFollowGlobstar())this.subwalks.add(Z,X);else if(J.markFollowGlobstar())this.subwalks.add(Z,J)}}}if(X){let Y=X.pattern();if(typeof Y==="string"&&Y!==".."&&Y!==""&&Y!==".")this.testString(Z,Y,X.rest(),$);else if(Y===".."){let Q=Z.parent||Z;this.subwalks.add(Q,X)}else if(Y instanceof RegExp)this.testRegExp(Z,Y,X.rest(),$)}}testRegExp(Z,J,X,$){if(!J.test(Z.name))return;if(!X)this.matches.add(Z,$,!1);else this.subwalks.add(Z,X)}testString(Z,J,X,$){if(!Z.isNamed(J))return;if(!X)this.matches.add(Z,$,!1);else this.subwalks.add(Z,X)}}var ac1=(Z,J)=>typeof Z==="string"?new BG([Z],J):Array.isArray(Z)?new BG(Z,J):Z;class XR{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#J;#$;signal;maxDepth;includeChildMatches;constructor(Z,J,X){if(this.patterns=Z,this.path=J,this.opts=X,this.#$=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#J=ac1(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw new Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#X(Z){return this.seen.has(Z)||!!this.#J?.ignored?.(Z)}#Y(Z){return!!this.#J?.childrenIgnored?.(Z)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Z=void 0;while(!this.paused&&(Z=this.#Z.shift()))Z()}onResume(Z){if(this.signal?.aborted)return;if(!this.paused)Z();else this.#Z.push(Z)}async matchCheck(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||await Z.realpath(),!X)return;Z=X}let Y=Z.isUnknown()||this.opts.stat?await Z.lstat():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=await Y.realpath();if(Q&&(Q.isUnknown()||this.opts.stat))await Q.lstat()}return this.matchCheckTest(Y,J)}matchCheckTest(Z,J){return Z&&(this.maxDepth===1/0||Z.depth()<=this.maxDepth)&&(!J||Z.canReaddir())&&(!this.opts.nodir||!Z.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Z.isSymbolicLink()||!Z.realpathCached()?.isDirectory())&&!this.#X(Z)?Z:void 0}matchCheckSync(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||Z.realpathSync(),!X)return;Z=X}let Y=Z.isUnknown()||this.opts.stat?Z.lstatSync():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=Y.realpathSync();if(Q&&(Q?.isUnknown()||this.opts.stat))Q.lstatSync()}return this.matchCheckTest(Y,J)}matchFinish(Z,J){if(this.#X(Z))return;if(!this.includeChildMatches&&this.#J?.add){let Y=`${Z.relativePosix()}/**`;this.#J.add(Y)}let X=this.opts.absolute===void 0?J:this.opts.absolute;this.seen.add(Z);let $=this.opts.mark&&Z.isDirectory()?this.#$:"";if(this.opts.withFileTypes)this.matchEmit(Z);else if(X){let Y=this.opts.posix?Z.fullpathPosix():Z.fullpath();this.matchEmit(Y+$)}else{let Y=this.opts.posix?Z.relativePosix():Z.relative(),Q=this.opts.dotRelative&&!Y.startsWith(".."+this.#$)?"."+this.#$:"";this.matchEmit(!Y?"."+$:Q+Y+$)}}async match(Z,J,X){let $=await this.matchCheck(Z,X);if($)this.matchFinish($,J)}matchSync(Z,J,X){let $=this.matchCheckSync(Z,X);if($)this.matchFinish($,J)}walkCB(Z,J,X){if(this.signal?.aborted)X();this.walkCB2(Z,J,new jG(this.opts),X)}walkCB2(Z,J,X,$){if(this.#Y(Z))return $();if(this.signal?.aborted)$();if(this.paused){this.onResume(()=>this.walkCB2(Z,J,X,$));return}X.processPatterns(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;Y++,this.match(K,W,G).then(()=>Q())}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;Y++;let W=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,W,X,Q);else K.readdirCB((G,z)=>this.walkCB3(K,z,X,Q),!0)}Q()}walkCB3(Z,J,X,$){X=X.filterEntries(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;Y++,this.match(K,W,G).then(()=>Q())}for(let[K,W]of X.subwalks.entries())Y++,this.walkCB2(K,W,X.child(),Q);Q()}walkCBSync(Z,J,X){if(this.signal?.aborted)X();this.walkCB2Sync(Z,J,new jG(this.opts),X)}walkCB2Sync(Z,J,X,$){if(this.#Y(Z))return $();if(this.signal?.aborted)$();if(this.paused){this.onResume(()=>this.walkCB2Sync(Z,J,X,$));return}X.processPatterns(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;Y++;let W=K.readdirSync();this.walkCB3Sync(K,W,X,Q)}Q()}walkCB3Sync(Z,J,X,$){X=X.filterEntries(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let[K,W]of X.subwalks.entries())Y++,this.walkCB2Sync(K,W,X.child(),Q);Q()}}class hF extends XR{matches=new Set;constructor(Z,J,X){super(Z,J,X)}matchEmit(Z){this.matches.add(Z)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Z,J)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)J(this.signal.reason);else Z(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class SF extends XR{results;constructor(Z,J,X){super(Z,J,X);this.results=new T$({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(Z){if(this.results.write(Z),!this.results.flowing)this.pause()}stream(){let Z=this.path;if(Z.isUnknown())Z.lstat().then(()=>{this.walkCB(Z,this.patterns,()=>this.results.end())});else this.walkCB(Z,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var sc1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Y7{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Z,J){if(!J)throw new TypeError("glob options required");if(this.withFileTypes=!!J.withFileTypes,this.signal=J.signal,this.follow=!!J.follow,this.dot=!!J.dot,this.dotRelative=!!J.dotRelative,this.nodir=!!J.nodir,this.mark=!!J.mark,!J.cwd)this.cwd="";else if(J.cwd instanceof URL||J.cwd.startsWith("file://"))J.cwd=nc1(J.cwd);if(this.cwd=J.cwd||"",this.root=J.root,this.magicalBraces=!!J.magicalBraces,this.nobrace=!!J.nobrace,this.noext=!!J.noext,this.realpath=!!J.realpath,this.absolute=J.absolute,this.includeChildMatches=J.includeChildMatches!==!1,this.noglobstar=!!J.noglobstar,this.matchBase=!!J.matchBase,this.maxDepth=typeof J.maxDepth==="number"?J.maxDepth:1/0,this.stat=!!J.stat,this.ignore=J.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof Z==="string")Z=[Z];if(this.windowsPathsNoEscape=!!J.windowsPathsNoEscape||J.allowWindowsEscape===!1,this.windowsPathsNoEscape)Z=Z.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(J.noglobstar)throw new TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||sc1,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?wG:J.platform==="darwin"?bF:J.platform?UG:Kg;this.scurry=new W(this.cwd,{nocase:J.nocase,fs:J.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",$={...J,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:X,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},Y=this.pattern.map((W)=>new H4(W,$)),[Q,K]=Y.reduce((W,G)=>{return W[0].push(...G.set),W[1].push(...G.globParts),W},[[],[]]);this.patterns=Q.map((W,G)=>{let z=K[G];if(!z)throw new Error("invalid pattern object");return new Q3(W,z,0,this.platform)})}async walk(){return[...await new hF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new hF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new SF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new SF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var $R=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new H4(X,J).hasMagic())return!0;return!1};function mF(Z,J={}){return new Y7(Z,J).streamSync()}function vg(Z,J={}){return new Y7(Z,J).stream()}function Vg(Z,J={}){return new Y7(Z,J).walkSync()}async function zg(Z,J={}){return new Y7(Z,J).walk()}function uF(Z,J={}){return new Y7(Z,J).iterateSync()}function Hg(Z,J={}){return new Y7(Z,J).iterate()}var oc1=mF,rc1=Object.assign(vg,{sync:mF}),tc1=uF,ec1=Object.assign(Hg,{sync:uF}),Zw1=Object.assign(Vg,{stream:mF,iterate:uF}),AF=Object.assign(zg,{glob:zg,globSync:Vg,sync:Zw1,globStream:vg,stream:rc1,globStreamSync:mF,streamSync:oc1,globIterate:Hg,iterate:ec1,globIterateSync:uF,iterateSync:tc1,Glob:Y7,hasMagic:$R,escape:Z3,unescape:F9});AF.glob=AF;class YR{constructor(){this._listeners={}}addEventListener(Z,J){let X=this._listeners;if(X[Z]===void 0)X[Z]=[];if(X[Z].indexOf(J)===-1)X[Z].push(J);return this}removeEventListener(Z,J){let $=this._listeners[Z];if($!==void 0){let Y=$.indexOf(J);if(Y!==-1)$.splice(Y,1)}return this}dispatchEvent(Z){let X=this._listeners[Z.type];if(X!==void 0){let $=X.slice(0);for(let Y=0,Q=$.length;Y<Q;Y++)$[Y].call(this,Z)}return this}dispose(){for(let Z in this._listeners)delete this._listeners[Z]}}class XZ{constructor(Z,J,X,$={}){if(this._name=void 0,this._parent=void 0,this._child=void 0,this._attributes=void 0,this._disposed=!1,this._name=Z,this._parent=J,this._child=X,this._attributes=$,!J.isOnGraph(X))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(Z){return this._child=Z,this}getAttributes(){return this._attributes}dispose(){if(this._disposed)return;this._parent._destroyRef(this),this._disposed=!0}isDisposed(){return this._disposed}}class lF extends YR{constructor(...Z){super(...Z);this._emptySet=new Set,this._edges=new Set,this._parentEdges=new Map,this._childEdges=new Map}listEdges(){return Array.from(this._edges)}listParentEdges(Z){return Array.from(this._childEdges.get(Z)||this._emptySet)}listParents(Z){let J=new Set;for(let X of this.listParentEdges(Z))J.add(X.getParent());return Array.from(J)}listChildEdges(Z){return Array.from(this._parentEdges.get(Z)||this._emptySet)}listChildren(Z){let J=new Set;for(let X of this.listChildEdges(Z))J.add(X.getChild());return Array.from(J)}disconnectParents(Z,J){for(let X of this.listParentEdges(Z))if(!J||J(X.getParent()))X.dispose();return this}_createEdge(Z,J,X,$){let Y=new XZ(Z,J,X,$);this._edges.add(Y);let Q=Y.getParent();if(!this._parentEdges.has(Q))this._parentEdges.set(Q,new Set);this._parentEdges.get(Q).add(Y);let K=Y.getChild();if(!this._childEdges.has(K))this._childEdges.set(K,new Set);return this._childEdges.get(K).add(Y),Y}_destroyEdge(Z){return this._edges.delete(Z),this._parentEdges.get(Z.getParent()).delete(Z),this._childEdges.get(Z.getChild()).delete(Z),this}}function LG(){return LG=Object.assign||function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)if(Object.prototype.hasOwnProperty.call(X,$))Z[$]=X[$]}return Z},LG.apply(this,arguments)}class w9{constructor(Z){if(this.list=[],Z)for(let J of Z)this.list.push(J)}add(Z){this.list.push(Z)}remove(Z){let J=this.list.indexOf(Z);if(J>=0)this.list.splice(J,1)}removeChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);for(let X of J)this.remove(X);return J}listRefsByChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);return J}values(){return this.list}}class x1{constructor(Z){if(this.set=new Set,this.map=new Map,Z)for(let J of Z)this.add(J)}add(Z){let J=Z.getChild();this.removeChild(J),this.set.add(Z),this.map.set(J,Z)}remove(Z){this.set.delete(Z),this.map.delete(Z.getChild())}removeChild(Z){let J=this.map.get(Z)||null;if(J)this.remove(J);return J}getRefByChild(Z){return this.map.get(Z)||null}values(){return Array.from(this.set)}}class A6{constructor(Z){if(this.map={},Z)Object.assign(this.map,Z)}set(Z,J){this.map[Z]=J}delete(Z){delete this.map[Z]}get(Z){return this.map[Z]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}}var H1=Symbol("attributes"),_J=Symbol("immutableKeys");class yF extends YR{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[H1]=void 0,this[_J]=void 0,this.graph=Z,this[_J]=new Set,this[H1]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let $=Z[X];if($ instanceof yF){let Y=this.graph._createEdge(X,this,$);this[_J].add(X),J[X]=Y}else J[X]=$}return J}isOnGraph(Z){return this.graph===Z.graph}isDisposed(){return this._disposed}dispose(){if(this._disposed)return;this.graph.listChildEdges(this).forEach((Z)=>Z.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"})}detach(){return this.graph.disconnectParents(this),this}swap(Z,J){for(let X in this[H1]){let $=this[H1][X];if($ instanceof XZ){let Y=$;if(Y.getChild()===Z)this.setRef(X,J,Y.getAttributes())}else if($ instanceof w9)for(let Y of $.listRefsByChild(Z)){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if($ instanceof x1){let Y=$.getRefByChild(Z);if(Y){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if($ instanceof A6)for(let Y of $.keys()){let Q=$.get(Y);if(Q.getChild()===Z)this.setRefMap(X,Y,J,Q.getAttributes())}}return this}get(Z){return this[H1][Z]}set(Z,J){return this[H1][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[H1][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[_J].has(Z))throw new Error(`Cannot overwrite immutable attribute, "${Z}".`);let $=this[H1][Z];if($)$.dispose();if(!J)return this;let Y=this.graph._createEdge(Z,this,J,X);return this[H1][Z]=Y,this.dispatchEvent({type:"change",attribute:Z})}listRefs(Z){return this.assertRefList(Z).values().map((X)=>X.getChild())}addRef(Z,J,X){let $=this.graph._createEdge(Z,this,J,X);return this.assertRefList(Z).add($),this.dispatchEvent({type:"change",attribute:Z})}removeRef(Z,J){let X=this.assertRefList(Z);if(X instanceof w9)for(let $ of X.listRefsByChild(J))$.dispose();else{let $=X.getRefByChild(J);if($)$.dispose()}return this}assertRefList(Z){let J=this[H1][Z];if(J instanceof w9||J instanceof x1)return J;throw new Error(`Expected RefList or RefSet for attribute "${Z}"`)}listRefMapKeys(Z){return this.assertRefMap(Z).keys()}listRefMapValues(Z){return this.assertRefMap(Z).values().map((J)=>J.getChild())}getRefMap(Z,J){let $=this.assertRefMap(Z).get(J);return $?$.getChild():null}setRefMap(Z,J,X,$){let Y=this.assertRefMap(Z),Q=Y.get(J);if(Q)Q.dispose();if(!X)return this;$=Object.assign($||{},{key:J});let K=this.graph._createEdge(Z,this,X,LG({},$,{key:J}));return Y.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[H1][Z];if(J instanceof A6)return J;throw new Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(LG({},Z,{target:this})),this.graph.dispatchEvent(LG({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[H1][J]===Z){if(this[H1][J]=null,this[_J].has(J))Z.getChild().dispose()}else if(this[H1][J]instanceof w9)this[H1][J].remove(Z);else if(this[H1][J]instanceof x1)this[H1][J].remove(Z);else if(this[H1][J]instanceof A6){let X=this[H1][J];for(let $ of X.keys())if(X.get($)===Z)X.delete($)}else return;this.graph._destroyEdge(Z),this.dispatchEvent({type:"change",attribute:J})}}var Bg="v4.2.1",k$="@glb.bin",i;(function(Z){Z.ACCESSOR="Accessor",Z.ANIMATION="Animation",Z.ANIMATION_CHANNEL="AnimationChannel",Z.ANIMATION_SAMPLER="AnimationSampler",Z.BUFFER="Buffer",Z.CAMERA="Camera",Z.MATERIAL="Material",Z.MESH="Mesh",Z.PRIMITIVE="Primitive",Z.PRIMITIVE_TARGET="PrimitiveTarget",Z.NODE="Node",Z.ROOT="Root",Z.SCENE="Scene",Z.SKIN="Skin",Z.TEXTURE="Texture",Z.TEXTURE_INFO="TextureInfo"})(i||(i={}));var nF;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(nF||(nF={}));var I5;(function(Z){Z.ARRAY_BUFFER="ARRAY_BUFFER",Z.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",Z.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",Z.OTHER="OTHER",Z.SPARSE="SPARSE"})(I5||(I5={}));var v5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(v5||(v5={}));var $Z;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})($Z||($Z={}));var hJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array};class E0{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let $=0;$<J.length;$++)X[$]=J.charCodeAt($);return X}else{let J=Z.split(",")[1],X=Z.indexOf("base64")>=0;return Buffer.from(J,X?"base64":"utf8")}}static encodeText(Z){return new TextEncoder().encode(Z)}static decodeText(Z){return new TextDecoder().decode(Z)}static concat(Z){let J=0;for(let Y of Z)J+=Y.byteLength;let X=new Uint8Array(J),$=0;for(let Y of Z)X.set(Y,$),$+=Y.byteLength;return X}static pad(Z,J=0){let X=this.padNumber(Z.byteLength);if(X===Z.byteLength)return Z;let $=new Uint8Array(X);if($.set(Z),J!==0)for(let Y=Z.byteLength;Y<X;Y++)$[Y]=J;return $}static padNumber(Z){return Math.ceil(Z/4)*4}static equals(Z,J){if(Z===J)return!0;if(Z.byteLength!==J.byteLength)return!1;let X=Z.byteLength;while(X--)if(Z[X]!==J[X])return!1;return!0}static toView(Z,J=0,X=1/0){return new Uint8Array(Z.buffer,Z.byteOffset+J,Math.min(Z.byteLength,X))}static assertView(Z){if(Z&&!ArrayBuffer.isView(Z))throw new Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class vR{static hexToFactor(Z,J){Z=Math.floor(Z);let X=J;return X[0]=(Z>>16&255)/255,X[1]=(Z>>8&255)/255,X[2]=(Z&255)/255,this.convertSRGBToLinear(J,J)}static factorToHex(Z){let J=[...Z],[X,$,Y]=this.convertLinearToSRGB(Z,J);return X*255<<16^$*255<<8^Y*255<<0}static convertSRGBToLinear(Z,J){let X=Z,$=J;for(let Y=0;Y<3;Y++)$[Y]=X[Y]<0.04045?X[Y]*0.0773993808:Math.pow(X[Y]*0.9478672986+0.0521327014,2.4);return J}static convertLinearToSRGB(Z,J){let X=Z,$=J;for(let Y=0;Y<3;Y++)$[Y]=X[Y]<0.0031308?X[Y]*12.92:1.055*Math.pow(X[Y],0.41666)-0.055;return J}}class jg{match(Z){return Z.length>=3&&Z[0]===255&&Z[1]===216&&Z[2]===255}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset+4),X,$;while(J.byteLength){if(X=J.getUint16(0,!1),Jw1(J,X),$=J.getUint8(X+1),$===192||$===193||$===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class rF{match(Z){return Z.length>=8&&Z[0]===137&&Z[1]===80&&Z[2]===78&&Z[3]===71&&Z[4]===13&&Z[5]===10&&Z[6]===26&&Z[7]===10}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset);if(E0.decodeText(Z.slice(12,16))===rF.PNG_FRIED_CHUNK_NAME)return[J.getUint32(32,!1),J.getUint32(36,!1)];return[J.getUint32(16,!1),J.getUint32(20,!1)]}getChannels(Z){return 4}}rF.PNG_FRIED_CHUNK_NAME="CgBI";class E5{static registerFormat(Z,J){this.impls[Z]=J}static getMimeType(Z){for(let J in this.impls)if(this.impls[J].match(Z))return J;return null}static getSize(Z,J){if(!this.impls[J])return null;return this.impls[J].getSize(Z)}static getChannels(Z,J){if(!this.impls[J])return null;return this.impls[J].getChannels(Z)}static getVRAMByteLength(Z,J){if(!this.impls[J])return null;if(this.impls[J].getVRAMByteLength)return this.impls[J].getVRAMByteLength(Z);let X=0,$=4,Y=this.getSize(Z,J);if(!Y)return null;while(Y[0]>1||Y[1]>1)X+=Y[0]*Y[1]*$,Y[0]=Math.max(Math.floor(Y[0]/2),1),Y[1]=Math.max(Math.floor(Y[1]/2),1);return X+=1*$,X}static mimeTypeToExtension(Z){if(Z==="image/jpeg")return"jpg";return Z.split("/").pop()}static extensionToMimeType(Z){if(Z==="jpg")return"image/jpeg";if(!Z)return"";return`image/${Z}`}}E5.impls={"image/jpeg":new jg,"image/png":new rF};function Jw1(Z,J){if(J>Z.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return Z}class YZ{static basename(Z){let J=Z.split(/[\\/]/).pop();return J.substring(0,J.lastIndexOf("."))}static extension(Z){if(Z.startsWith("data:image/")){let J=Z.match(/data:(image\/\w+)/)[1];return E5.mimeTypeToExtension(J)}else if(Z.startsWith("data:model/gltf+json"))return"gltf";else if(Z.startsWith("data:model/gltf-binary"))return"glb";else if(Z.startsWith("data:application/"))return"bin";return Z.split(/[\\/]/).pop().split(/[.]/).pop()}}var KR=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function Xw1(){var Z=new KR(3);if(KR!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function QR(Z){var J=Z[0],X=Z[1],$=Z[2];return Math.hypot(J,X,$)}function $w1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=X[3]*$+X[7]*Y+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*$+X[4]*Y+X[8]*Q+X[12])/K,Z[1]=(X[1]*$+X[5]*Y+X[9]*Q+X[13])/K,Z[2]=(X[2]*$+X[6]*Y+X[10]*Q+X[14])/K,Z}(function(){var Z=Xw1();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=3;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();function RG(Z){let J=Lg(),X=Z.propertyType===i.NODE?[Z]:Z.listChildren();for(let $ of X)$.traverse((Y)=>{let Q=Y.getMesh();if(!Q)return;let K=Yw1(Q,Y.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))WR(K.min,J),WR(K.max,J)});return J}function Yw1(Z,J){let X=Lg();for(let $ of Z.listPrimitives()){let Y=$.getAttribute("POSITION"),Q=$.getIndices();if(!Y)continue;let K=[0,0,0],W=[0,0,0];for(let G=0,z=Q?Q.getCount():Y.getCount();G<z;G++){let v=Q?Q.getScalar(G):G;K=Y.getElement(v,K),W=$w1(W,K,J),WR(W,X)}}return X}function WR(Z,J){for(let X=0;X<3;X++)J.min[X]=Math.min(Z[X],J.min[X]),J.max[X]=Math.max(Z[X],J.max[X])}function Lg(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}var qg="https://null.example";class x4{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return YZ.basename(new URL(Z,qg).pathname)}static extension(Z){return YZ.extension(new URL(Z,qg).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),$=J.split("/");X.pop();for(let Y=0;Y<$.length;Y++){if($[Y]===".")continue;if($[Y]==="..")X.pop();else X.push($[Y])}return X.join("/")}static isAbsoluteURL(Z){return this.PROTOCOL_REGEXP.test(Z)}static isRelativePath(Z){return!/^(?:[a-zA-Z]+:)?\//.test(Z)}}x4.DEFAULT_INIT={};x4.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;function Fg(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function f$(Z){if(Fg(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Fg(X)===!1)return!1;if(Object.hasOwn(X,"isPrototypeOf")===!1)return!1;return!0}var GR,DG;(function(Z){Z[Z.SILENT=4]="SILENT",Z[Z.ERROR=3]="ERROR",Z[Z.WARN=2]="WARN",Z[Z.INFO=1]="INFO",Z[Z.DEBUG=0]="DEBUG"})(DG||(DG={}));class z5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=z5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=z5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=z5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=z5.Verbosity.ERROR)console.error(Z)}}GR=z5;z5.Verbosity=DG;z5.DEFAULT_INSTANCE=new GR(GR.Verbosity.INFO);function Qw1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],x=Z[14],c=Z[15],w=J*K-X*Q,B=J*W-$*Q,j=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,N=z*F-v*q,P=z*x-H*q,O=z*c-V*q,_=v*x-H*F,k=v*c-V*F,h=H*c-V*x;return w*h-B*k+j*_+L*O-R*P+M*N}function Kw1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],x=J[12],c=J[13],w=J[14],B=J[15],j=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=j*$+L*W+R*H+M*x,Z[1]=j*Y+L*G+R*V+M*c,Z[2]=j*Q+L*z+R*q+M*w,Z[3]=j*K+L*v+R*F+M*B,j=X[4],L=X[5],R=X[6],M=X[7],Z[4]=j*$+L*W+R*H+M*x,Z[5]=j*Y+L*G+R*V+M*c,Z[6]=j*Q+L*z+R*q+M*w,Z[7]=j*K+L*v+R*F+M*B,j=X[8],L=X[9],R=X[10],M=X[11],Z[8]=j*$+L*W+R*H+M*x,Z[9]=j*Y+L*G+R*V+M*c,Z[10]=j*Q+L*z+R*q+M*w,Z[11]=j*K+L*v+R*F+M*B,j=X[12],L=X[13],R=X[14],M=X[15],Z[12]=j*$+L*W+R*H+M*x,Z[13]=j*Y+L*G+R*V+M*c,Z[14]=j*Q+L*z+R*q+M*w,Z[15]=j*K+L*v+R*F+M*B,Z}function Ww1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],z=J[9],v=J[10];return Z[0]=Math.hypot(X,$,Y),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,z,v),Z}function Gw1(Z,J){var X=new KR(3);Ww1(X,J);var $=1/X[0],Y=1/X[1],Q=1/X[2],K=J[0]*$,W=J[1]*Y,G=J[2]*Q,z=J[4]*$,v=J[5]*Y,H=J[6]*Q,V=J[8]*$,q=J[9]*Y,F=J[10]*Q,x=K+v+F,c=0;if(x>0)c=Math.sqrt(x+1)*2,Z[3]=0.25*c,Z[0]=(H-q)/c,Z[1]=(V-G)/c,Z[2]=(W-z)/c;else if(K>v&&K>F)c=Math.sqrt(1+K-v-F)*2,Z[3]=(H-q)/c,Z[0]=0.25*c,Z[1]=(W+z)/c,Z[2]=(V+G)/c;else if(v>F)c=Math.sqrt(1+v-K-F)*2,Z[3]=(V-G)/c,Z[0]=(W+z)/c,Z[1]=0.25*c,Z[2]=(H+q)/c;else c=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/c,Z[0]=(V+G)/c,Z[1]=(H+q)/c,Z[2]=0.25*c;return Z}class I0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(I0.clamp(Z,0,1)*65535);case 5121:return Math.round(I0.clamp(Z,0,1)*255);case 5122:return Math.round(I0.clamp(Z,-1,1)*32767);case 5120:return Math.round(I0.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,$){let Y=QR([Z[0],Z[1],Z[2]]),Q=QR([Z[4],Z[5],Z[6]]),K=QR([Z[8],Z[9],Z[10]]);if(Qw1(Z)<0)Y=-Y;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),z=1/Y,v=1/Q,H=1/K;G[0]*=z,G[1]*=z,G[2]*=z,G[4]*=v,G[5]*=v,G[6]*=v,G[8]*=H,G[9]*=H,G[10]*=H,Gw1(X,G),$[0]=Y,$[1]=Q,$[2]=K}static compose(Z,J,X,$){let Y=$,Q=J[0],K=J[1],W=J[2],G=J[3],z=Q+Q,v=K+K,H=W+W,V=Q*z,q=Q*v,F=Q*H,x=K*v,c=K*H,w=W*H,B=G*z,j=G*v,L=G*H,R=X[0],M=X[1],N=X[2];return Y[0]=(1-(x+w))*R,Y[1]=(q+L)*R,Y[2]=(F-j)*R,Y[3]=0,Y[4]=(q-L)*M,Y[5]=(1-(V+w))*M,Y[6]=(c+B)*M,Y[7]=0,Y[8]=(F+j)*N,Y[9]=(c-B)*N,Y[10]=(1-(V+x))*N,Y[11]=0,Y[12]=Z[0],Y[13]=Z[1],Y[14]=Z[2],Y[15]=1,Y}}function zw1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),$=J.getChild();return X===$||X.equals($)}function vw1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),$=J.values();if(X.length!==$.length)return!1;for(let Y=0;Y<X.length;Y++){let Q=X[Y],K=$[Y];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function Vw1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),$=J.keys();if(X.length!==$.length)return!1;for(let Y of X){let Q=Z.get(Y),K=J.get(Y);if(!!Q!==!!K)return!1;let W=Q.getChild(),G=K.getChild();if(W===G)continue;if(!W.equals(G))return!1}return!0}function Dg(Z,J){if(Z===J)return!0;if(!!Z!==!!J||!Z||!J)return!1;if(Z.length!==J.length)return!1;for(let X=0;X<Z.length;X++)if(Z[X]!==J[X])return!1;return!0}function Mg(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!f$(Z)||!f$(J))return Z===J;let X=Z,$=J,Y=0,Q=0,K;for(K in X)Y++;for(K in $)Q++;if(Y!==Q)return!1;for(K in X){let W=X[K],G=$[K];if(sF(W)&&sF(G)){if(!Dg(W,G))return!1}else if(f$(W)&&f$(G)){if(!Mg(W,G))return!1}else if(W!==G)return!1}return!0}function sF(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var xg="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",Hw1=999,qw1=6,cg=new Set,Fw1=function Z(){let J="";for(let X=0;X<qw1;X++)J+=xg.charAt(Math.floor(Math.random()*xg.length));return J},Rg=function Z(){for(let J=0;J<Hw1;J++){let X=Fw1();if(!cg.has(X))return cg.add(X),X}return""},bJ=(Z)=>Z,xw1=new Set;class tF extends yF{constructor(Z,J=""){super(Z);this[H1].name=J,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(Z,J){if(Array.isArray(J))J=J.slice();return super.set(Z,J)}getName(){return this.get("name")}setName(Z){return this.set("name",Z)}getExtras(){return this.get("extras")}setExtras(Z){return this.set("extras",Z)}clone(){return new this.constructor(this.graph).copy(this,bJ)}copy(Z,J=bJ){for(let X in this[H1]){let $=this[H1][X];if($ instanceof XZ){if(!this[_J].has(X))$.dispose()}else if($ instanceof w9||$ instanceof x1)for(let Y of $.values())Y.dispose();else if($ instanceof A6)for(let Y of $.values())Y.dispose()}for(let X in Z[H1]){let $=this[H1][X],Y=Z[H1][X];if(Y instanceof XZ)if(this[_J].has(X))$.getChild().copy(J(Y.getChild()),J);else this.setRef(X,J(Y.getChild()),Y.getAttributes());else if(Y instanceof x1||Y instanceof w9)for(let Q of Y.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if(Y instanceof A6)for(let Q of Y.keys()){let K=Y.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(f$(Y))this[H1][X]=JSON.parse(JSON.stringify(Y));else if(Array.isArray(Y)||Y instanceof ArrayBuffer||ArrayBuffer.isView(Y))this[H1][X]=Y.slice();else this[H1][X]=Y}return this}equals(Z,J=xw1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[H1]){if(J.has(X))continue;let $=this[H1][X],Y=Z[H1][X];if($ instanceof XZ||Y instanceof XZ){if(!zw1($,Y))return!1}else if($ instanceof x1||Y instanceof x1||$ instanceof w9||Y instanceof w9){if(!vw1($,Y))return!1}else if($ instanceof A6||Y instanceof A6){if(!Vw1($,Y))return!1}else if(f$($)||f$(Y)){if(!Mg($,Y))return!1}else if(sF($)||sF(Y)){if(!Dg($,Y))return!1}else if($!==Y)return!1}return!0}detach(){return this.graph.disconnectParents(this,(Z)=>Z.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}}class w6 extends tF{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new A6})}getExtension(Z){return this.getRefMap("extensions",Z)}setExtension(Z,J){if(J)J._validateParent(this);return this.setRefMap("extensions",Z,J)}listExtensions(){return this.listRefMapValues("extensions")}}class K0 extends w6{init(){this.propertyType=i.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:K0.Type.SCALAR,componentType:K0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case K0.Type.SCALAR:return 1;case K0.Type.VEC2:return 2;case K0.Type.VEC3:return 3;case K0.Type.VEC4:return 4;case K0.Type.MAT2:return 4;case K0.Type.MAT3:return 9;case K0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case K0.ComponentType.BYTE:return 1;case K0.ComponentType.UNSIGNED_BYTE:return 1;case K0.ComponentType.SHORT:return 2;case K0.ComponentType.UNSIGNED_SHORT:return 2;case K0.ComponentType.UNSIGNED_INT:return 4;case K0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMin(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=I0.decodeNormalizedInt(Z[Y],$);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),$=this.getElementSize();for(let Y=0;Y<$;Y++)Z[Y]=1/0;for(let Y=0;Y<X*$;Y+=$)for(let Q=0;Q<$;Q++){let K=J[Y+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMax(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=I0.decodeNormalizedInt(Z[Y],$);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),$=this.getElementSize();for(let Y=0;Y<$;Y++)Z[Y]=-1/0;for(let Y=0;Y<X*$;Y+=$)for(let Q=0;Q<$;Q++){let K=J[Y+Q];if(Number.isFinite(K))Z[Q]=Math.max(Z[Q],K)}return Z}getCount(){let Z=this.get("array");return Z?Z.length/this.getElementSize():0}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getElementSize(){return K0.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(Z){return this.set("normalized",Z)}getScalar(Z){let J=this.getElementSize(),X=this.getComponentType(),$=this.getArray();if(this.getNormalized())return I0.decodeNormalizedInt($[Z*J],X);return $[Z*J]}setScalar(Z,J){let X=this.getElementSize(),$=this.getComponentType(),Y=this.getArray();if(this.getNormalized())Y[Z*X]=I0.encodeNormalizedInt(J,$);else Y[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),$=this.getElementSize(),Y=this.getComponentType(),Q=this.getArray();for(let K=0;K<$;K++)if(X)J[K]=I0.decodeNormalizedInt(Q[Z*$+K],Y);else J[K]=Q[Z*$+K];return J}setElement(Z,J){let X=this.getNormalized(),$=this.getElementSize(),Y=this.getComponentType(),Q=this.getArray();for(let K=0;K<$;K++)if(X)Q[Z*$+K]=I0.encodeNormalizedInt(J[K],Y);else Q[Z*$+K]=J[K];return this}getSparse(){return this.get("sparse")}setSparse(Z){return this.set("sparse",Z)}getBuffer(){return this.getRef("buffer")}setBuffer(Z){return this.setRef("buffer",Z)}getArray(){return this.get("array")}setArray(Z){return this.set("componentType",Z?cw1(Z):K0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}K0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};K0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function cw1(Z){switch(Z.constructor){case Float32Array:return K0.ComponentType.FLOAT;case Uint32Array:return K0.ComponentType.UNSIGNED_INT;case Uint16Array:return K0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return K0.ComponentType.UNSIGNED_BYTE;case Int16Array:return K0.ComponentType.SHORT;case Int8Array:return K0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class VR extends w6{init(){this.propertyType=i.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new x1,samplers:new x1})}addChannel(Z){return this.addRef("channels",Z)}removeChannel(Z){return this.removeRef("channels",Z)}listChannels(){return this.listRefs("channels")}addSampler(Z){return this.addRef("samplers",Z)}removeSampler(Z){return this.removeRef("samplers",Z)}listSamplers(){return this.listRefs("samplers")}}class QZ extends w6{init(){this.propertyType=i.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(Z){return this.set("targetPath",Z)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(Z){return this.setRef("targetNode",Z)}getSampler(){return this.getRef("sampler")}setSampler(Z){return this.setRef("sampler",Z)}}QZ.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class SJ extends w6{init(){this.propertyType=i.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:SJ.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(Z){return this.set("interpolation",Z)}getInput(){return this.getRef("input")}setInput(Z){return this.setRef("input",Z,{usage:I5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:I5.OTHER})}}SJ.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class HR extends w6{init(){this.propertyType=i.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class E$ extends w6{init(){this.propertyType=i.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:E$.Type.PERSPECTIVE,znear:0.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getZNear(){return this.get("znear")}setZNear(Z){return this.set("znear",Z)}getZFar(){return this.get("zfar")}setZFar(Z){return this.set("zfar",Z)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(Z){return this.set("aspectRatio",Z)}getYFov(){return this.get("yfov")}setYFov(Z){return this.set("yfov",Z)}getXMag(){return this.get("xmag")}setXMag(Z){return this.set("xmag",Z)}getYMag(){return this.get("ymag")}setYMag(Z){return this.set("ymag",Z)}}E$.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class O1 extends tF{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}O1.EXTENSION_NAME=void 0;class F1 extends w6{init(){this.propertyType=i.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:F1.WrapMode.REPEAT,wrapT:F1.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}getMagFilter(){return this.get("magFilter")}setMagFilter(Z){return this.set("magFilter",Z)}getMinFilter(){return this.get("minFilter")}setMinFilter(Z){return this.set("minFilter",Z)}getWrapS(){return this.get("wrapS")}setWrapS(Z){return this.set("wrapS",Z)}getWrapT(){return this.get("wrapT")}setWrapT(Z){return this.set("wrapT",Z)}}F1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};F1.MagFilter={NEAREST:9728,LINEAR:9729};F1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:pF,G:iF,B:gF,A:ww1}=v5;class Q7 extends w6{init(){this.propertyType=i.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:Q7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new F1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new F1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new F1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new F1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new F1(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(Z){return this.set("doubleSided",Z)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(Z){let J=this.get("baseColorFactor").slice();return J[3]=Z,this.set("baseColorFactor",J)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(Z){return this.set("alphaMode",Z)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(Z){return this.set("alphaCutoff",Z)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(Z){return this.set("baseColorFactor",Z)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(Z){return this.setRef("baseColorTexture",Z,{channels:pF|iF|gF|ww1,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(Z){return this.set("emissiveFactor",Z)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(Z){return this.setRef("emissiveTexture",Z,{channels:pF|iF|gF,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(Z){return this.set("normalScale",Z)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(Z){return this.setRef("normalTexture",Z,{channels:pF|iF|gF})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(Z){return this.set("occlusionStrength",Z)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(Z){return this.setRef("occlusionTexture",Z,{channels:pF})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(Z){return this.set("roughnessFactor",Z)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(Z){return this.set("metallicFactor",Z)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(Z){return this.setRef("metallicRoughnessTexture",Z,{channels:iF|gF})}}Q7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class NG extends w6{init(){this.propertyType=i.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new x1})}addPrimitive(Z){return this.addRef("primitives",Z)}removePrimitive(Z){return this.removeRef("primitives",Z)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}}class eF extends w6{init(){this.propertyType=i.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new x1})}copy(Z,J=bJ){if(J===bJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return I0.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),$=this.get("scale").slice();return I0.decompose(Z,J,X,$),this.set("translation",J).set("rotation",X).set("scale",$)}getWorldTranslation(){let Z=[0,0,0];return I0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return I0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return I0.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let $=this;$!=null;$=$.getParentNode())Z.push($);let J,X=Z.pop().getMatrix();while(J=Z.pop())Kw1(X,X,J.getMatrix());return X}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);for(let X of Z.listParents())if(X.propertyType===i.SCENE)X.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}getParentNode(){for(let Z of this.listParents())if(Z.propertyType===i.NODE)return Z;return null}getMesh(){return this.getRef("mesh")}setMesh(Z){return this.setRef("mesh",Z)}getCamera(){return this.getRef("camera")}setCamera(Z){return this.setRef("camera",Z)}getSkin(){return this.getRef("skin")}setSkin(Z){return this.setRef("skin",Z)}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}traverse(Z){Z(this);for(let J of this.listChildren())J.traverse(Z);return this}}class g1 extends w6{init(){this.propertyType=i.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:g1.Mode.TRIANGLES,material:null,indices:null,attributes:new A6,targets:new x1})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:I5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:I5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}getMode(){return this.get("mode")}setMode(Z){return this.set("mode",Z)}listTargets(){return this.listRefs("targets")}addTarget(Z){return this.addRef("targets",Z)}removeTarget(Z){return this.removeRef("targets",Z)}}g1.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class qR extends tF{init(){this.propertyType=i.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:I5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function m6(){return m6=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},m6.apply(null,arguments)}class K3 extends w6{init(){this.propertyType=i.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new x1})}copy(Z,J=bJ){if(J===bJ)throw new Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class FR extends w6{init(){this.propertyType=i.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new x1})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(Z){return this.setRef("skeleton",Z)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(Z){return this.setRef("inverseBindMatrices",Z,{usage:I5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class I$ extends w6{init(){this.propertyType=i.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||E5.extensionToMimeType(YZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=E5.extensionToMimeType(YZ.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",E0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return E5.getSize(Z,this.getMimeType())}}class W3 extends w6{init(){this.propertyType=i.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Bg}`,version:"2.0"},defaultScene:null,accessors:new x1,animations:new x1,buffers:new x1,cameras:new x1,materials:new x1,meshes:new x1,nodes:new x1,scenes:new x1,skins:new x1,textures:new x1})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(Z,J=bJ){if(J===bJ)throw new Error("Root cannot be copied.");this.set("asset",m6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(m6({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let $=Z.getExtension(X);this.setExtension(X,J($))}return this}_addChildOfRoot(Z){if(Z instanceof K3)this.addRef("scenes",Z);else if(Z instanceof eF)this.addRef("nodes",Z);else if(Z instanceof E$)this.addRef("cameras",Z);else if(Z instanceof FR)this.addRef("skins",Z);else if(Z instanceof NG)this.addRef("meshes",Z);else if(Z instanceof Q7)this.addRef("materials",Z);else if(Z instanceof I$)this.addRef("textures",Z);else if(Z instanceof VR)this.addRef("animations",Z);else if(Z instanceof K0)this.addRef("accessors",Z);else if(Z instanceof HR)this.addRef("buffers",Z);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((Z)=>Z.isRequired())}_enableExtension(Z){return this._extensions.add(Z),this}_disableExtension(Z){return this._extensions.delete(Z),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(Z){return this.setRef("defaultScene",Z)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class c6{static fromGraph(Z){return c6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new lF,this._root=new W3(this._graph),this._logger=z5.DEFAULT_INSTANCE,c6._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(($)=>$.extensionName===J)||new Z(this)}createScene(Z=""){return new K3(this._graph,Z)}createNode(Z=""){return new eF(this._graph,Z)}createCamera(Z=""){return new E$(this._graph,Z)}createSkin(Z=""){return new FR(this._graph,Z)}createMesh(Z=""){return new NG(this._graph,Z)}createPrimitive(){return new g1(this._graph)}createPrimitiveTarget(Z=""){return new qR(this._graph,Z)}createMaterial(Z=""){return new Q7(this._graph,Z)}createTexture(Z=""){return new I$(this._graph,Z)}createAnimation(Z=""){return new VR(this._graph,Z)}createAnimationChannel(Z=""){return new QZ(this._graph,Z)}createAnimationSampler(Z=""){return new SJ(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new K0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new HR(this._graph,Z)}}c6._GRAPH_DOCUMENTS=new WeakMap;class P1{constructor(Z){this.extensionName="",this.prereadTypes=[],this.prewriteTypes=[],this.readDependencies=[],this.writeDependencies=[],this.document=void 0,this.required=!1,this.properties=new Set,this._listener=void 0,this.document=Z,Z.getRoot()._enableExtension(this),this._listener=(X)=>{let $=X,Y=$.target;if(Y instanceof O1&&Y.extensionName===this.extensionName){if($.type==="node:create")this._addExtensionProperty(Y);if($.type==="node:dispose")this._removeExtensionProperty(Y)}};let J=Z.getGraph();J.addEventListener("node:create",this._listener),J.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let Z=this.document.getGraph();Z.removeEventListener("node:create",this._listener),Z.removeEventListener("node:dispose",this._listener);for(let J of this.properties)J.dispose()}static register(){}isRequired(){return this.required}setRequired(Z){return this.required=Z,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(Z){return this.properties.add(Z),this}_removeExtensionProperty(Z){return this.properties.delete(Z),this}install(Z,J){return this}preread(Z,J){return this}prewrite(Z,J){return this}}P1.EXTENSION_NAME=void 0;class Ng{constructor(Z){this.jsonDoc=void 0,this.buffers=[],this.bufferViews=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.textureInfos=new Map,this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[],this.jsonDoc=Z}setTextureInfo(Z,J){if(this.textureInfos.set(Z,J),J.texCoord!==void 0)Z.setTexCoord(J.texCoord);if(J.extras!==void 0)Z.setExtras(J.extras);let X=this.jsonDoc.json.textures[J.index];if(X.sampler===void 0)return;let $=this.jsonDoc.json.samplers[X.sampler];if($.magFilter!==void 0)Z.setMagFilter($.magFilter);if($.minFilter!==void 0)Z.setMinFilter($.minFilter);if($.wrapS!==void 0)Z.setWrapS($.wrapS);if($.wrapT!==void 0)Z.setWrapT($.wrapT)}}var wg={logger:z5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},Uw1=new Set([i.BUFFER,i.TEXTURE,i.MATERIAL,i.MESH,i.PRIMITIVE,i.NODE,i.SCENE]);class Og{static read(Z,J=wg){let X=m6({},wg,J),{json:$}=Z,Y=new c6().setLogger(X.logger);this.validate(Z,X);let Q=new Ng(Z),K=$.asset,W=Y.getRoot().getAsset();if(K.copyright)W.copyright=K.copyright;if(K.extras)W.extras=K.extras;if($.extras!==void 0)Y.getRoot().setExtras(m6({},$.extras));let G=$.extensionsUsed||[],z=$.extensionsRequired||[];X.extensions.sort((M,N)=>M.EXTENSION_NAME>N.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let N=Y.createExtension(M).setRequired(z.includes(M.EXTENSION_NAME)),P=N.prereadTypes.filter((O)=>!Uw1.has(O));if(P.length)X.logger.warn(`Preread hooks for some types (${P.join()}), requested by extension ${N.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of N.readDependencies)N.install(O,X.dependencies[O])}let v=$.buffers||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.BUFFER)).forEach((M)=>M.preread(Q,i.BUFFER)),Q.buffers=v.map((M)=>{let N=Y.createBuffer(M.name);if(M.extras)N.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)N.setURI(M.uri);return N});let H=$.bufferViews||[];Q.bufferViewBuffers=H.map((M,N)=>{if(!Q.bufferViews[N]){let P=Z.json.buffers[M.buffer],O=P.uri?Z.resources[P.uri]:Z.resources[k$],_=M.byteOffset||0;Q.bufferViews[N]=E0.toView(O,_,M.byteLength)}return Q.buffers[M.buffer]});let V=$.accessors||[];Q.accessors=V.map((M)=>{let N=Q.bufferViewBuffers[M.bufferView],P=Y.createAccessor(M.name,N).setType(M.type);if(M.extras)P.setExtras(M.extras);if(M.normalized!==void 0)P.setNormalized(M.normalized);if(M.bufferView===void 0)return P;return P.setArray(aF(M,Q)),P});let q=$.images||[],F=$.textures||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.TEXTURE)).forEach((M)=>M.preread(Q,i.TEXTURE)),Q.textures=q.map((M)=>{let N=Y.createTexture(M.name);if(M.extras)N.setExtras(M.extras);if(M.bufferView!==void 0){let P=$.bufferViews[M.bufferView],O=Z.json.buffers[P.buffer],_=O.uri?Z.resources[O.uri]:Z.resources[k$],k=P.byteOffset||0,h=P.byteLength,f=_.slice(k,k+h);N.setImage(f)}else if(M.uri!==void 0){if(N.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)N.setURI(M.uri)}if(M.mimeType!==void 0)N.setMimeType(M.mimeType);else if(M.uri){let P=YZ.extension(M.uri);N.setMimeType(E5.extensionToMimeType(P))}return N}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MATERIAL)).forEach((M)=>M.preread(Q,i.MATERIAL));let x=$.materials||[];Q.materials=x.map((M)=>{let N=Y.createMaterial(M.name);if(M.extras)N.setExtras(M.extras);if(M.alphaMode!==void 0)N.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)N.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)N.setDoubleSided(M.doubleSided);let P=M.pbrMetallicRoughness||{};if(P.baseColorFactor!==void 0)N.setBaseColorFactor(P.baseColorFactor);if(M.emissiveFactor!==void 0)N.setEmissiveFactor(M.emissiveFactor);if(P.metallicFactor!==void 0)N.setMetallicFactor(P.metallicFactor);if(P.roughnessFactor!==void 0)N.setRoughnessFactor(P.roughnessFactor);if(P.baseColorTexture!==void 0){let O=P.baseColorTexture,_=Q.textures[F[O.index].source];N.setBaseColorTexture(_),Q.setTextureInfo(N.getBaseColorTextureInfo(),O)}if(M.emissiveTexture!==void 0){let O=M.emissiveTexture,_=Q.textures[F[O.index].source];N.setEmissiveTexture(_),Q.setTextureInfo(N.getEmissiveTextureInfo(),O)}if(M.normalTexture!==void 0){let O=M.normalTexture,_=Q.textures[F[O.index].source];if(N.setNormalTexture(_),Q.setTextureInfo(N.getNormalTextureInfo(),O),M.normalTexture.scale!==void 0)N.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let O=M.occlusionTexture,_=Q.textures[F[O.index].source];if(N.setOcclusionTexture(_),Q.setTextureInfo(N.getOcclusionTextureInfo(),O),M.occlusionTexture.strength!==void 0)N.setOcclusionStrength(M.occlusionTexture.strength)}if(P.metallicRoughnessTexture!==void 0){let O=P.metallicRoughnessTexture,_=Q.textures[F[O.index].source];N.setMetallicRoughnessTexture(_),Q.setTextureInfo(N.getMetallicRoughnessTextureInfo(),O)}return N}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MESH)).forEach((M)=>M.preread(Q,i.MESH));let c=$.meshes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.PRIMITIVE)).forEach((M)=>M.preread(Q,i.PRIMITIVE)),Q.meshes=c.map((M)=>{let N=Y.createMesh(M.name);if(M.extras)N.setExtras(M.extras);if(M.weights!==void 0)N.setWeights(M.weights);return(M.primitives||[]).forEach((O)=>{let _=Y.createPrimitive();if(O.extras)_.setExtras(O.extras);if(O.material!==void 0)_.setMaterial(Q.materials[O.material]);if(O.mode!==void 0)_.setMode(O.mode);for(let[f,C]of Object.entries(O.attributes||{}))_.setAttribute(f,Q.accessors[C]);if(O.indices!==void 0)_.setIndices(Q.accessors[O.indices]);let k=M.extras&&M.extras.targetNames||[];(O.targets||[]).forEach((f,C)=>{let b=k[C]||C.toString(),I=Y.createPrimitiveTarget(b);for(let[a,s]of Object.entries(f))I.setAttribute(a,Q.accessors[s]);_.addTarget(I)}),N.addPrimitive(_)}),N});let w=$.cameras||[];Q.cameras=w.map((M)=>{let N=Y.createCamera(M.name).setType(M.type);if(M.extras)N.setExtras(M.extras);if(M.type===E$.Type.PERSPECTIVE){let P=M.perspective;if(N.setYFov(P.yfov),N.setZNear(P.znear),P.zfar!==void 0)N.setZFar(P.zfar);if(P.aspectRatio!==void 0)N.setAspectRatio(P.aspectRatio)}else{let P=M.orthographic;N.setZNear(P.znear).setZFar(P.zfar).setXMag(P.xmag).setYMag(P.ymag)}return N});let B=$.nodes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.NODE)).forEach((M)=>M.preread(Q,i.NODE)),Q.nodes=B.map((M)=>{let N=Y.createNode(M.name);if(M.extras)N.setExtras(M.extras);if(M.translation!==void 0)N.setTranslation(M.translation);if(M.rotation!==void 0)N.setRotation(M.rotation);if(M.scale!==void 0)N.setScale(M.scale);if(M.matrix!==void 0){let P=[0,0,0],O=[0,0,0,1],_=[1,1,1];I0.decompose(M.matrix,P,O,_),N.setTranslation(P),N.setRotation(O),N.setScale(_)}if(M.weights!==void 0)N.setWeights(M.weights);return N});let j=$.skins||[];Q.skins=j.map((M)=>{let N=Y.createSkin(M.name);if(M.extras)N.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)N.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)N.setSkeleton(Q.nodes[M.skeleton]);for(let P of M.joints)N.addJoint(Q.nodes[P]);return N}),B.map((M,N)=>{let P=Q.nodes[N];if((M.children||[]).forEach((_)=>P.addChild(Q.nodes[_])),M.mesh!==void 0)P.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)P.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)P.setSkin(Q.skins[M.skin])});let L=$.animations||[];Q.animations=L.map((M)=>{let N=Y.createAnimation(M.name);if(M.extras)N.setExtras(M.extras);let O=(M.samplers||[]).map((k)=>{let h=Y.createAnimationSampler().setInput(Q.accessors[k.input]).setOutput(Q.accessors[k.output]).setInterpolation(k.interpolation||SJ.Interpolation.LINEAR);if(k.extras)h.setExtras(k.extras);return N.addSampler(h),h});return(M.channels||[]).forEach((k)=>{let h=Y.createAnimationChannel().setSampler(O[k.sampler]).setTargetPath(k.target.path);if(k.target.node!==void 0)h.setTargetNode(Q.nodes[k.target.node]);if(k.extras)h.setExtras(k.extras);N.addChannel(h)}),N});let R=$.scenes||[];if(Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.SCENE)).forEach((M)=>M.preread(Q,i.SCENE)),Q.scenes=R.map((M)=>{let N=Y.createScene(M.name);if(M.extras)N.setExtras(M.extras);return(M.nodes||[]).map((O)=>Q.nodes[O]).forEach((O)=>N.addChild(O)),N}),$.scene!==void 0)Y.getRoot().setDefaultScene(Q.scenes[$.scene]);return Y.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),V.forEach((M,N)=>{let P=Q.accessors[N],O=!!M.sparse,_=!M.bufferView&&!P.getArray();if(O||_)P.setSparse(!0).setArray(jw1(M,Q))}),Y}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let $ of X.extensionsRequired)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))throw new Error(`Missing required extension, "${$}".`)}if(X.extensionsUsed){for(let $ of X.extensionsUsed)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))J.logger.warn(`Missing optional extension, "${$}".`)}}}function Bw1(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=hJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,z=new Q(Z.count*K),v=new DataView($.buffer,$.byteOffset,$.byteLength),H=Y.byteStride;for(let V=0;V<Z.count;V++)for(let q=0;q<K;q++){let F=G+V*H+q*W,x;switch(Z.componentType){case K0.ComponentType.FLOAT:x=v.getFloat32(F,!0);break;case K0.ComponentType.UNSIGNED_INT:x=v.getUint32(F,!0);break;case K0.ComponentType.UNSIGNED_SHORT:x=v.getUint16(F,!0);break;case K0.ComponentType.UNSIGNED_BYTE:x=v.getUint8(F);break;case K0.ComponentType.SHORT:x=v.getInt16(F,!0);break;case K0.ComponentType.BYTE:x=v.getInt8(F);break;default:throw new Error(`Unexpected componentType "${Z.componentType}".`)}z[V*K+q]=x}return z}function aF(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=hJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if(Y.byteStride!==void 0&&Y.byteStride!==G)return Bw1(Z,J);let z=$.byteOffset+(Z.byteOffset||0),v=Z.count*K*W;return new Q($.buffer.slice(z,z+v))}function jw1(Z,J){let X=hJ[Z.componentType],$=K0.getElementSize(Z.type),Y;if(Z.bufferView!==void 0)Y=aF(Z,J);else Y=new X(Z.count*$);let Q=Z.sparse;if(!Q)return Y;let K=Q.count,W=m6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=m6({},Z,Q.values,{count:K}),z=aF(W,J),v=aF(G,J);for(let H=0;H<W.count;H++)for(let V=0;V<$;V++)Y[z[H]*$+V]=v[H*$+V];return Y}var MG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(MG||(MG={}));class c4{constructor(Z,J,X){this._doc=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this._accessorUsageMap=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this._doc=Z,this.jsonDoc=J,this.options=X;let $=Z.getRoot(),Y=$.listBuffers().length,Q=$.listTextures().length;this.bufferURIGenerator=new zR(Y>1,()=>X.basename||"buffer"),this.imageURIGenerator=new zR(Q>1,(K)=>Lw1(Z,K)||X.basename||"texture"),this.logger=Z.getLogger()}createTextureInfoDef(Z,J){let X={magFilter:J.getMagFilter()||void 0,minFilter:J.getMinFilter()||void 0,wrapS:J.getWrapS(),wrapT:J.getWrapT()},$=JSON.stringify(X);if(!this.samplerDefIndexMap.has($))this.samplerDefIndexMap.set($,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let Y={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get($)},Q=JSON.stringify(Y);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(Y);let K={index:this.textureDefIndexMap.get(Q)};if(J.getTexCoord()!==0)K.texCoord=J.getTexCoord();if(Object.keys(J.getExtras()).length>0)K.extras=J.getExtras();return this.textureInfoDefMap.set(J,K),K}createPropertyDef(Z){let J={};if(Z.getName())J.name=Z.getName();if(Object.keys(Z.getExtras()).length>0)J.extras=Z.getExtras();return J}createAccessorDef(Z){let J=this.createPropertyDef(Z);if(J.type=Z.getType(),J.componentType=Z.getComponentType(),J.count=Z.getCount(),this._doc.getGraph().listParentEdges(Z).some(($)=>$.getName()==="attributes"&&$.getAttributes().key==="POSITION"||$.getName()==="input"))J.max=Z.getMax([]).map(Math.fround),J.min=Z.getMin([]).map(Math.fround);if(Z.getNormalized())J.normalized=Z.getNormalized();return J}createImageData(Z,J,X){if(this.options.format===$Z.GLB)this.imageBufferViews.push(J),Z.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:J.byteLength});else{let $=E5.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,$),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let $=this.jsonDoc.resources;if(!(Z in $)){$[Z]=J;return}if(J===$[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let Y=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn(Y);return}throw new Error(Y)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return I5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:$}=X.getAttributes();if($)return $;if(X.getParent().propertyType!==i.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return I5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw new Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}c4.BufferViewTarget=MG;c4.BufferViewUsage=I5;c4.USAGE_TO_TARGET={[I5.ARRAY_BUFFER]:MG.ARRAY_BUFFER,[I5.ELEMENT_ARRAY_BUFFER]:MG.ELEMENT_ARRAY_BUFFER};class zR{constructor(Z,J){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=Z,this.basename=J}createURI(Z,J){if(Z.getURI())return Z.getURI();else if(!this.multiple)return`${this.basename(Z)}.${J}`;else{let X=this.basename(Z);return this.counter[X]=this.counter[X]||1,`${X}_${this.counter[X]++}.${J}`}}}function Lw1(Z,J){let X=Z.getGraph().listParentEdges(J).find(($)=>$.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:dF}=c4,{UNSIGNED_INT:Dw1,UNSIGNED_SHORT:Mw1,UNSIGNED_BYTE:Rw1}=K0.ComponentType,Nw1=new Set([i.ACCESSOR,i.BUFFER,i.MATERIAL,i.MESH]);class Pg{static write(Z,J){let X=Z.getGraph(),$=Z.getRoot(),Y={asset:m6({generator:`glTF-Transform ${Bg}`},$.getAsset()),extras:m6({},$.getExtras())},Q={json:Y,resources:{}},K=new c4(Z,Q,J),W=J.logger||z5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((c)=>c.EXTENSION_NAME)),z=Z.getRoot().listExtensionsUsed().filter((c)=>G.has(c.extensionName)).sort((c,w)=>c.extensionName>w.extensionName?1:-1),v=Z.getRoot().listExtensionsRequired().filter((c)=>G.has(c.extensionName)).sort((c,w)=>c.extensionName>w.extensionName?1:-1);if(z.length<Z.getRoot().listExtensionsUsed().length)W.warn("Some extensions were not registered for I/O, and will not be written.");for(let c of z){let w=c.prewriteTypes.filter((B)=>!Nw1.has(B));if(w.length)W.warn(`Prewrite hooks for some types (${w.join()}), requested by extension ${c.extensionName}, are unsupported. Please file an issue or a PR.`);for(let B of c.writeDependencies)c.install(B,J.dependencies[B])}function H(c,w,B,j){let L=[],R=0;for(let P of c){let O=K.createAccessorDef(P);O.bufferView=Y.bufferViews.length;let _=P.getArray(),k=E0.pad(E0.toView(_));O.byteOffset=R,R+=k.byteLength,L.push(k),K.accessorIndexMap.set(P,Y.accessors.length),Y.accessors.push(O)}let M=E0.concat(L),N={buffer:w,byteOffset:B,byteLength:M.byteLength};if(j)N.target=j;return Y.bufferViews.push(N),{buffers:L,byteLength:R}}function V(c,w,B){let j=c[0].getCount(),L=0;for(let O of c){let _=K.createAccessorDef(O);_.bufferView=Y.bufferViews.length,_.byteOffset=L;let k=O.getElementSize(),h=O.getComponentSize();L+=E0.padNumber(k*h),K.accessorIndexMap.set(O,Y.accessors.length),Y.accessors.push(_)}let R=j*L,M=new ArrayBuffer(R),N=new DataView(M);for(let O=0;O<j;O++){let _=0;for(let k of c){let h=k.getElementSize(),f=k.getComponentSize(),C=k.getComponentType(),b=k.getArray();for(let I=0;I<h;I++){let a=O*L+_+I*f,s=b[O*h+I];switch(C){case K0.ComponentType.FLOAT:N.setFloat32(a,s,!0);break;case K0.ComponentType.BYTE:N.setInt8(a,s);break;case K0.ComponentType.SHORT:N.setInt16(a,s,!0);break;case K0.ComponentType.UNSIGNED_BYTE:N.setUint8(a,s);break;case K0.ComponentType.UNSIGNED_SHORT:N.setUint16(a,s,!0);break;case K0.ComponentType.UNSIGNED_INT:N.setUint32(a,s,!0);break;default:throw new Error("Unexpected component type: "+C)}}_+=E0.padNumber(h*f)}}let P={buffer:w,byteOffset:B,byteLength:R,byteStride:L,target:c4.BufferViewTarget.ARRAY_BUFFER};return Y.bufferViews.push(P),{byteLength:R,buffers:[new Uint8Array(M)]}}function q(c,w,B){let j=[],L=0,R=new Map,M=-1/0,N=!1;for(let C of c){let b=K.createAccessorDef(C);Y.accessors.push(b),K.accessorIndexMap.set(C,Y.accessors.length-1);let I=[],a=[],s=[],Z0=new Array(C.getElementSize()).fill(0);for(let m0=0,N1=C.getCount();m0<N1;m0++){if(C.getElement(m0,s),I0.eq(s,Z0,0))continue;M=Math.max(m0,M),I.push(m0);for(let s0=0;s0<s.length;s0++)a.push(s[s0])}let o=I.length,M0={accessorDef:b,count:o};if(R.set(C,M0),o===0)continue;if(o>C.getCount()/2)N=!0;let R0=hJ[C.getComponentType()];M0.indices=I,M0.values=new R0(a)}if(!Number.isFinite(M))return{buffers:j,byteLength:L};if(N)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let P=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,O=M<255?Rw1:M<65535?Mw1:Dw1,_={buffer:w,byteOffset:B+L,byteLength:0};for(let C of c){let b=R.get(C);if(b.count===0)continue;b.indicesByteOffset=_.byteLength;let I=E0.pad(E0.toView(new P(b.indices)));j.push(I),L+=I.byteLength,_.byteLength+=I.byteLength}Y.bufferViews.push(_);let k=Y.bufferViews.length-1,h={buffer:w,byteOffset:B+L,byteLength:0};for(let C of c){let b=R.get(C);if(b.count===0)continue;b.valuesByteOffset=h.byteLength;let I=E0.pad(E0.toView(b.values));j.push(I),L+=I.byteLength,h.byteLength+=I.byteLength}Y.bufferViews.push(h);let f=Y.bufferViews.length-1;for(let C of c){let b=R.get(C);if(b.count===0)continue;b.accessorDef.sparse={count:b.count,indices:{bufferView:k,byteOffset:b.indicesByteOffset,componentType:O},values:{bufferView:f,byteOffset:b.valuesByteOffset}}}return{buffers:j,byteLength:L}}if(Y.accessors=[],Y.bufferViews=[],Y.samplers=[],Y.textures=[],Y.images=$.listTextures().map((c,w)=>{let B=K.createPropertyDef(c);if(c.getMimeType())B.mimeType=c.getMimeType();let j=c.getImage();if(j)K.createImageData(B,j,c);return K.imageIndexMap.set(c,w),B}),z.filter((c)=>c.prewriteTypes.includes(i.ACCESSOR)).forEach((c)=>c.prewrite(K,i.ACCESSOR)),$.listAccessors().forEach((c)=>{let{accessorUsageGroupedByParent:w,accessorParents:B}=K;if(K.accessorIndexMap.has(c))return;let j=K.getAccessorUsage(c);if(K.addAccessorToUsageGroup(c,j),w.has(j)){let L=X.listParents(c).find((R)=>R.propertyType!==i.ROOT);B.set(c,L)}}),z.filter((c)=>c.prewriteTypes.includes(i.BUFFER)).forEach((c)=>c.prewrite(K,i.BUFFER)),($.listAccessors().length>0||K.otherBufferViews.size>0||$.listTextures().length>0&&J.format===$Z.GLB)&&$.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");if(Y.buffers=[],$.listBuffers().forEach((c,w)=>{let B=K.createPropertyDef(c),j=K.accessorUsageGroupedByParent,L=c.listParents().filter((h)=>h instanceof K0),R=new Set(L.map((h)=>K.accessorParents.get(h))),M=new Map(Array.from(R).map((h,f)=>[h,f])),N={};for(let h of L){var P;if(K.accessorIndexMap.has(h))continue;let f=K.getAccessorUsage(h),C=f;if(j.has(f)){let b=K.accessorParents.get(h);C+=`:${M.get(b)}`}N[P=C]||(N[P]={usage:f,accessors:[]}),N[C].accessors.push(h)}let O=[],_=Y.buffers.length,k=0;for(let{usage:h,accessors:f}of Object.values(N))if(h===dF.ARRAY_BUFFER&&J.vertexLayout===nF.INTERLEAVED){let C=V(f,_,k);k+=C.byteLength;for(let b of C.buffers)O.push(b)}else if(h===dF.ARRAY_BUFFER)for(let C of f){let b=V([C],_,k);k+=b.byteLength;for(let I of b.buffers)O.push(I)}else if(h===dF.SPARSE){let C=q(f,_,k);k+=C.byteLength;for(let b of C.buffers)O.push(b)}else if(h===dF.ELEMENT_ARRAY_BUFFER){let C=c4.BufferViewTarget.ELEMENT_ARRAY_BUFFER,b=H(f,_,k,C);k+=b.byteLength;for(let I of b.buffers)O.push(I)}else{let C=H(f,_,k);k+=C.byteLength;for(let b of C.buffers)O.push(b)}if(K.imageBufferViews.length&&w===0){for(let h=0;h<K.imageBufferViews.length;h++)if(Y.bufferViews[Y.images[h].bufferView].byteOffset=k,k+=K.imageBufferViews[h].byteLength,O.push(K.imageBufferViews[h]),k%8){let f=8-k%8;k+=f,O.push(new Uint8Array(f))}}if(K.otherBufferViews.has(c))for(let h of K.otherBufferViews.get(c))Y.bufferViews.push({buffer:_,byteOffset:k,byteLength:h.byteLength}),K.otherBufferViewsIndexMap.set(h,Y.bufferViews.length-1),k+=h.byteLength,O.push(h);if(k){let h;if(J.format===$Z.GLB)h=k$;else h=K.bufferURIGenerator.createURI(c,"bin"),B.uri=h;B.byteLength=k,K.assignResourceURI(h,E0.concat(O),!0)}Y.buffers.push(B),K.bufferIndexMap.set(c,w)}),$.listAccessors().find((c)=>!c.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");z.filter((c)=>c.prewriteTypes.includes(i.MATERIAL)).forEach((c)=>c.prewrite(K,i.MATERIAL)),Y.materials=$.listMaterials().map((c,w)=>{let B=K.createPropertyDef(c);if(c.getAlphaMode()!==Q7.AlphaMode.OPAQUE)B.alphaMode=c.getAlphaMode();if(c.getAlphaMode()===Q7.AlphaMode.MASK)B.alphaCutoff=c.getAlphaCutoff();if(c.getDoubleSided())B.doubleSided=!0;if(B.pbrMetallicRoughness={},!I0.eq(c.getBaseColorFactor(),[1,1,1,1]))B.pbrMetallicRoughness.baseColorFactor=c.getBaseColorFactor();if(!I0.eq(c.getEmissiveFactor(),[0,0,0]))B.emissiveFactor=c.getEmissiveFactor();if(c.getRoughnessFactor()!==1)B.pbrMetallicRoughness.roughnessFactor=c.getRoughnessFactor();if(c.getMetallicFactor()!==1)B.pbrMetallicRoughness.metallicFactor=c.getMetallicFactor();if(c.getBaseColorTexture()){let j=c.getBaseColorTexture(),L=c.getBaseColorTextureInfo();B.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(j,L)}if(c.getEmissiveTexture()){let j=c.getEmissiveTexture(),L=c.getEmissiveTextureInfo();B.emissiveTexture=K.createTextureInfoDef(j,L)}if(c.getNormalTexture()){let j=c.getNormalTexture(),L=c.getNormalTextureInfo(),R=K.createTextureInfoDef(j,L);if(c.getNormalScale()!==1)R.scale=c.getNormalScale();B.normalTexture=R}if(c.getOcclusionTexture()){let j=c.getOcclusionTexture(),L=c.getOcclusionTextureInfo(),R=K.createTextureInfoDef(j,L);if(c.getOcclusionStrength()!==1)R.strength=c.getOcclusionStrength();B.occlusionTexture=R}if(c.getMetallicRoughnessTexture()){let j=c.getMetallicRoughnessTexture(),L=c.getMetallicRoughnessTextureInfo();B.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(j,L)}return K.materialIndexMap.set(c,w),B}),z.filter((c)=>c.prewriteTypes.includes(i.MESH)).forEach((c)=>c.prewrite(K,i.MESH)),Y.meshes=$.listMeshes().map((c,w)=>{let B=K.createPropertyDef(c),j=null;if(B.primitives=c.listPrimitives().map((L)=>{let R={attributes:{}};R.mode=L.getMode();let M=L.getMaterial();if(M)R.material=K.materialIndexMap.get(M);if(Object.keys(L.getExtras()).length)R.extras=L.getExtras();let N=L.getIndices();if(N)R.indices=K.accessorIndexMap.get(N);for(let P of L.listSemantics())R.attributes[P]=K.accessorIndexMap.get(L.getAttribute(P));for(let P of L.listTargets()){let O={};for(let _ of P.listSemantics())O[_]=K.accessorIndexMap.get(P.getAttribute(_));R.targets=R.targets||[],R.targets.push(O)}if(L.listTargets().length&&!j)j=L.listTargets().map((P)=>P.getName());return R}),c.getWeights().length)B.weights=c.getWeights();if(j)B.extras=B.extras||{},B.extras.targetNames=j;return K.meshIndexMap.set(c,w),B}),Y.cameras=$.listCameras().map((c,w)=>{let B=K.createPropertyDef(c);if(B.type=c.getType(),B.type===E$.Type.PERSPECTIVE){B.perspective={znear:c.getZNear(),zfar:c.getZFar(),yfov:c.getYFov()};let j=c.getAspectRatio();if(j!==null)B.perspective.aspectRatio=j}else B.orthographic={znear:c.getZNear(),zfar:c.getZFar(),xmag:c.getXMag(),ymag:c.getYMag()};return K.cameraIndexMap.set(c,w),B}),Y.nodes=$.listNodes().map((c,w)=>{let B=K.createPropertyDef(c);if(!I0.eq(c.getTranslation(),[0,0,0]))B.translation=c.getTranslation();if(!I0.eq(c.getRotation(),[0,0,0,1]))B.rotation=c.getRotation();if(!I0.eq(c.getScale(),[1,1,1]))B.scale=c.getScale();if(c.getWeights().length)B.weights=c.getWeights();return K.nodeIndexMap.set(c,w),B}),Y.skins=$.listSkins().map((c,w)=>{let B=K.createPropertyDef(c),j=c.getInverseBindMatrices();if(j)B.inverseBindMatrices=K.accessorIndexMap.get(j);let L=c.getSkeleton();if(L)B.skeleton=K.nodeIndexMap.get(L);return B.joints=c.listJoints().map((R)=>K.nodeIndexMap.get(R)),K.skinIndexMap.set(c,w),B}),$.listNodes().forEach((c,w)=>{let B=Y.nodes[w],j=c.getMesh();if(j)B.mesh=K.meshIndexMap.get(j);let L=c.getCamera();if(L)B.camera=K.cameraIndexMap.get(L);let R=c.getSkin();if(R)B.skin=K.skinIndexMap.get(R);if(c.listChildren().length>0)B.children=c.listChildren().map((M)=>K.nodeIndexMap.get(M))}),Y.animations=$.listAnimations().map((c,w)=>{let B=K.createPropertyDef(c),j=new Map;return B.samplers=c.listSamplers().map((L,R)=>{let M=K.createPropertyDef(L);return M.input=K.accessorIndexMap.get(L.getInput()),M.output=K.accessorIndexMap.get(L.getOutput()),M.interpolation=L.getInterpolation(),j.set(L,R),M}),B.channels=c.listChannels().map((L)=>{let R=K.createPropertyDef(L);return R.sampler=j.get(L.getSampler()),R.target={node:K.nodeIndexMap.get(L.getTargetNode()),path:L.getTargetPath()},R}),K.animationIndexMap.set(c,w),B}),Y.scenes=$.listScenes().map((c,w)=>{let B=K.createPropertyDef(c);return B.nodes=c.listChildren().map((j)=>K.nodeIndexMap.get(j)),K.sceneIndexMap.set(c,w),B});let x=$.getDefaultScene();if(x)Y.scene=$.listScenes().indexOf(x);return Y.extensionsUsed=z.map((c)=>c.extensionName),Y.extensionsRequired=v.map((c)=>c.extensionName),z.forEach((c)=>c.write(K)),Ow1(Y),Q}}function Ow1(Z){let J=[];for(let X in Z){let $=Z[X];if(Array.isArray($)&&$.length===0)J.push(X);else if($===null||$==="")J.push(X);else if($&&typeof $==="object"&&Object.keys($).length===0)J.push(X)}for(let X of J)delete Z[X]}var oF;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(oF||(oF={}));class Tg{constructor(){this._logger=z5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=nF.INTERLEAVED,this.lastReadBytes=0,this.lastWriteBytes=0}setLogger(Z){return this._logger=Z,this}registerExtensions(Z){for(let J of Z)this._extensions.add(J),J.register();return this}registerDependencies(Z){return Object.assign(this._dependencies,Z),this}setVertexLayout(Z){return this._vertexLayout=Z,this}async read(Z){return await this.readJSON(await this.readAsJSON(Z))}async readAsJSON(Z){let J=await this.readURI(Z,"view");this.lastReadBytes=J.byteLength;let X=Ug(J)?this._binaryToJSON(J):{json:JSON.parse(E0.decodeText(J)),resources:{}};return await this._readResourcesExternal(X,this.dirname(Z)),this._readResourcesInternal(X),X}async readJSON(Z){return Z=this._copyJSON(Z),this._readResourcesInternal(Z),Og.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(E0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some(($)=>Pw1(J,$)))throw new Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some(($)=>Tw1(J,$)))throw new Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(E0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===$Z.GLB&&Z.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Pg.write(Z,{format:J.format||$Z.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:m6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:$Z.GLB}),$=new Uint32Array([1179937895,2,12]),Y=JSON.stringify(J),Q=E0.pad(E0.encodeText(Y),32),K=E0.toView(new Uint32Array([Q.byteLength,1313821514])),W=E0.concat([K,Q]);$[$.length-1]+=W.byteLength;let G=Object.values(X)[0];if(!G||!G.byteLength)return E0.concat([E0.toView($),W]);let z=E0.pad(G,0),v=E0.toView(new Uint32Array([z.byteLength,5130562])),H=E0.concat([v,z]);return $[$.length-1]+=H.byteLength,E0.concat([E0.toView($),W,H])}async _readResourcesExternal(Z,J){var X=this;let $=Z.json.images||[],Y=Z.json.buffers||[],Q=[...$,...Y].map(async function(K){let W=K.uri;if(!W||W.match(/data:/))return Promise.resolve();Z.resources[W]=await X.readURI(X.resolve(J,W),"view"),X.lastReadBytes+=Z.resources[W].byteLength});await Promise.all(Q)}_readResourcesInternal(Z){function J(Y){if(!Y.uri)return;if(Y.uri in Z.resources){E0.assertView(Z.resources[Y.uri]);return}if(Y.uri.match(/data:/)){let Q=`__${Rg()}.${YZ.extension(Y.uri)}`;Z.resources[Q]=E0.createBufferFromDataURI(Y.uri),Y.uri=Q}}(Z.json.images||[]).forEach((Y)=>{if(Y.bufferView===void 0&&Y.uri===void 0)throw new Error("Missing resource URI or buffer view.");J(Y)}),(Z.json.buffers||[]).forEach(J)}_copyJSON(Z){let{images:J,buffers:X}=Z.json;if(Z={json:m6({},Z.json),resources:m6({},Z.resources)},J)Z.json.images=J.map(($)=>m6({},$));if(X)Z.json.buffers=X.map(($)=>m6({},$));return Z}_binaryToJSON(Z){if(!Ug(Z))throw new Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==oF.JSON)throw new Error("Missing required GLB JSON chunk.");let X=20,$=J[0],Y=E0.decodeText(E0.toView(Z,X,$)),Q=JSON.parse(Y),K=X+$;if(Z.byteLength<=K)return{json:Q,resources:{}};let W=new Uint32Array(Z.buffer,Z.byteOffset+K,2);if(W[1]!==oF.BIN)return{json:Q,resources:{}};let G=W[0],z=E0.toView(Z,K+8,G);return{json:Q,resources:{[k$]:z}}}}function Pw1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function Tw1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Ug(Z){if(Z.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let J=new Uint32Array(Z.buffer,Z.byteOffset,3);return J[0]===1179937895&&J[1]===2}class xR extends Tg{constructor(Z=null,J=x4.DEFAULT_INIT){super();this._fetch=void 0,this._fetchConfig=void 0,this._init=void 0,this._fetchEnabled=!1,this._fetch=Z,this._fetchConfig=J,this._init=this.init()}async init(){if(this._init)return this._init;return Promise.all([import("fs"),import("path")]).then(([Z,J])=>{this._fs=Z.promises,this._path=J})}setAllowNetwork(Z){if(Z&&!this._fetch)throw new Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),x4.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw new Error("Network request blocked. Allow HTTP requests explicitly, if needed.");let X=await this._fetch(Z,this._fetchConfig);switch(J){case"view":return new Uint8Array(await X.arrayBuffer());case"text":return X.text()}}else switch(J){case"view":return this._fs.readFile(Z);case"text":return this._fs.readFile(Z,"utf8")}}resolve(Z,J){if(x4.isAbsoluteURL(Z)||x4.isAbsoluteURL(J))return x4.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(x4.isAbsoluteURL(Z))return x4.dirname(Z);return this._path.dirname(Z)}async write(Z,J){await this.init(),await(!!Z.match(/\.glb$/)?this._writeGLB(Z,J):this._writeGLTF(Z,J))}async _writeGLTF(Z,J){var X=this;this.lastWriteBytes=0;let{json:$,resources:Y}=await this.writeJSON(J,{format:$Z.GLTF,basename:YZ.basename(Z)}),{_fs:Q,_path:K}=this,W=K.dirname(Z),G=JSON.stringify($,null,2);await Q.writeFile(Z,G),this.lastWriteBytes+=G.length;for(let z of Cw1(Object.keys(Y),10))await Promise.all(z.map(async function(v){if(x4.isAbsoluteURL(v)){if(x4.extension(v)==="bin")throw new Error(`Cannot write buffer to path "${v}".`);return}let H=K.join(W,decodeURIComponent(v));await Q.mkdir(K.dirname(H),{recursive:!0}),await Q.writeFile(H,Y[v]),X.lastWriteBytes+=Y[v].byteLength}))}async _writeGLB(Z,J){let X=await this.writeBinary(J);await this._fs.writeFile(Z,X),this.lastWriteBytes=X.byteLength}}function Cw1(Z,J){let X=[];for(let $=0,Y=Z.length;$<Y;$+=J){let Q=[];for(let K=0;K<J&&$+K<Y;K++)Q.push(Z[$+K]);X.push(Q)}return X}var Nn=t(cR(),1),On=t(Gn(),1),DL1=t(Rn(),1);async function ML1(Z,J){if(!(Z instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:$}=await On.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return Nn.default(new Uint8Array(X),[$.width,$.height,4],[4,4*$.width|0,1],0)}async function Pn(Z,J){return ML1(Z)}var Cn=163,fn=166;function RL1(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class U3{constructor(Z,J,X,$){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(Z.buffer,Z.byteOffset+J,X),this._littleEndian=$,this._offset=0}_nextUint8(){let Z=this._dataView.getUint8(this._offset);return this._offset+=1,Z}_nextUint16(){let Z=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,Z}_nextUint32(){let Z=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,Z}_nextUint64(){let Z=this._dataView.getUint32(this._offset,this._littleEndian),J=this._dataView.getUint32(this._offset+4,this._littleEndian),X=Z+4294967296*J;return this._offset+=8,X}_nextInt32(){let Z=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,Z}_nextUint8Array(Z){let J=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,Z);return this._offset+=Z,J}_skip(Z){return this._offset+=Z,this}_scan(Z,J=0){let X=this._offset,$=0;while(this._dataView.getUint8(this._offset)!==J&&$<Z)$++,this._offset++;if($<Z)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+X,$)}}var pN6=new Uint8Array([0]),p6=[171,75,84,88,32,50,48,187,13,10,26,10];function Tn(Z){return new TextDecoder().decode(Z)}function Lx(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,p6.length);if(J[0]!==p6[0]||J[1]!==p6[1]||J[2]!==p6[2]||J[3]!==p6[3]||J[4]!==p6[4]||J[5]!==p6[5]||J[6]!==p6[6]||J[7]!==p6[7]||J[8]!==p6[8]||J[9]!==p6[9]||J[10]!==p6[10]||J[11]!==p6[11])throw new Error("Missing KTX 2.0 identifier.");let X=RL1(),$=17*Uint32Array.BYTES_PER_ELEMENT,Y=new U3(Z,p6.length,$,!0);X.vkFormat=Y._nextUint32(),X.typeSize=Y._nextUint32(),X.pixelWidth=Y._nextUint32(),X.pixelHeight=Y._nextUint32(),X.pixelDepth=Y._nextUint32(),X.layerCount=Y._nextUint32(),X.faceCount=Y._nextUint32(),X.levelCount=Y._nextUint32(),X.supercompressionScheme=Y._nextUint32();let Q=Y._nextUint32(),K=Y._nextUint32(),W=Y._nextUint32(),G=Y._nextUint32(),z=Y._nextUint64(),v=Y._nextUint64(),H=Math.max(X.levelCount,1)*3*8,V=new U3(Z,p6.length+$,H,!0);for(let P8=0,q6=Math.max(X.levelCount,1);P8<q6;P8++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+V._nextUint64(),V._nextUint64()),uncompressedByteLength:V._nextUint64()});let q=new U3(Z,Q,K,!0);q._skip(4);let F=q._nextUint16(),x=q._nextUint16(),c=q._nextUint16(),w=q._nextUint16(),B=q._nextUint8(),j=q._nextUint8(),L=q._nextUint8(),R=q._nextUint8(),M=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],N=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],O={vendorId:F,descriptorType:x,versionNumber:c,colorModel:B,colorPrimaries:j,transferFunction:L,flags:R,texelBlockDimension:M,bytesPlane:N,samples:[]},_=6,k=4,h=(w/4-_)/k;for(let P8=0;P8<h;P8++){let q6={bitOffset:q._nextUint16(),bitLength:q._nextUint8(),channelType:q._nextUint8(),samplePosition:[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(q6.channelType&64)q6.sampleLower=q._nextInt32(),q6.sampleUpper=q._nextInt32();else q6.sampleLower=q._nextUint32(),q6.sampleUpper=q._nextUint32();O.samples[P8]=q6}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(O);let f=new U3(Z,W,G,!0);while(f._offset<G){let P8=f._nextUint32(),q6=f._scan(P8),CH=Tn(q6);if(X.keyValue[CH]=f._nextUint8Array(P8-q6.byteLength-1),CH.match(/^ktx/i)){let qA=Tn(X.keyValue[CH]);X.keyValue[CH]=qA.substring(0,qA.lastIndexOf("\x00"))}let uW1=P8%4?4-P8%4:0;f._skip(uW1)}if(v<=0)return X;let C=new U3(Z,z,v,!0),b=C._nextUint16(),I=C._nextUint16(),a=C._nextUint32(),s=C._nextUint32(),Z0=C._nextUint32(),o=C._nextUint32(),M0=[];for(let P8=0,q6=Math.max(X.levelCount,1);P8<q6;P8++)M0.push({imageFlags:C._nextUint32(),rgbSliceByteOffset:C._nextUint32(),rgbSliceByteLength:C._nextUint32(),alphaSliceByteOffset:C._nextUint32(),alphaSliceByteLength:C._nextUint32()});let R0=z+C._offset,m0=R0+a,N1=m0+s,s0=N1+Z0,B1=new Uint8Array(Z.buffer,Z.byteOffset+R0,a),W4=new Uint8Array(Z.buffer,Z.byteOffset+m0,s),RJ=new Uint8Array(Z.buffer,Z.byteOffset+N1,Z0),IQ=new Uint8Array(Z.buffer,Z.byteOffset+s0,o);return X.globalData={endpointCount:b,selectorCount:I,imageDescs:M0,endpointsData:B1,selectorsData:W4,tablesData:RJ,extendedData:IQ},X}var GZ="EXT_mesh_gpu_instancing",X6="EXT_meshopt_compression",hG="EXT_texture_webp",SG="EXT_texture_avif",s1="KHR_draco_mesh_compression",B4="KHR_lights_punctual",zZ="KHR_materials_anisotropy",vZ="KHR_materials_clearcoat",VZ="KHR_materials_diffuse_transmission",HZ="KHR_materials_dispersion",qZ="KHR_materials_emissive_strength",FZ="KHR_materials_ior",xZ="KHR_materials_iridescence",cZ="KHR_materials_pbrSpecularGlossiness",wZ="KHR_materials_sheen",UZ="KHR_materials_specular",BZ="KHR_materials_transmission",pJ="KHR_materials_unlit",jZ="KHR_materials_volume",U6="KHR_materials_variants",pn="KHR_mesh_quantization",AG="KHR_texture_basisu",LZ="KHR_texture_transform",j4="KHR_xmp_json_ld",pR="INSTANCE_ATTRIBUTE";class gR extends O1{init(){this.extensionName=GZ,this.propertyType="InstancedMesh",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:pR})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}gR.EXTENSION_NAME=GZ;class Rx extends P1{constructor(...Z){super(...Z);this.extensionName=GZ,this.provideTypes=[i.NODE],this.prewriteTypes=[i.ACCESSOR]}createInstancedMesh(){return new gR(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[GZ])return;let Q=$.extensions[GZ],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[Y].setExtension(GZ,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(pR);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,pR);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let $=X.getExtension(GZ);if($){let Y=Z.nodeIndexMap.get(X),Q=J.json.nodes[Y],K={attributes:{}};$.listSemantics().forEach((W)=>{let G=$.getAttribute(W);K.attributes[W]=Z.accessorIndexMap.get(G)}),Q.extensions=Q.extensions||{},Q.extensions[GZ]=K}}),this}}Rx.EXTENSION_NAME=GZ;function DZ(){return DZ=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},DZ.apply(null,arguments)}var mG;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(mG||(mG={}));var B3;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(B3||(B3={}));var $8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})($8||($8={}));function NL1(Z){if(!Z.extensions||!Z.extensions[X6])return!1;return!!Z.extensions[X6].fallback}var{BYTE:OL1,SHORT:kn,FLOAT:PL1}=K0.ComponentType,{encodeNormalizedInt:En,decodeNormalizedInt:iR}=I0;function TL1(Z,J,X,$){let{filter:Y,bits:Q}=$,K={array:Z.getArray(),byteStride:Z.getElementSize()*Z.getComponentSize(),componentType:Z.getComponentType(),normalized:Z.getNormalized()};if(X!==B3.ATTRIBUTES)return K;if(Y!==$8.NONE){let W=Z.getNormalized()?CL1(Z):new Float32Array(K.array);switch(Y){case $8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=PL1,K.normalized=!1,K.array=J.encodeFilterExp(W,Z.getCount(),K.byteStride,Q);break;case $8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?kn:OL1,K.normalized=!0,W=Z.getElementSize()===3?kL1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case $8.QUATERNION:K.byteStride=8,K.componentType=kn,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw new Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>iR(G,Z.getComponentType())),K.max=K.max.map((G)=>iR(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>En(G,K.componentType)),K.max=K.max.map((G)=>En(G,K.componentType))}else if(K.byteStride%4)K.array=fL1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function CL1(Z){let J=Z.getComponentType(),X=Z.getArray(),$=new Float32Array(X.length);for(let Y=0;Y<X.length;Y++)$[Y]=iR(X[Y],J);return $}function fL1(Z,J){let $=E0.padNumber(Z.BYTES_PER_ELEMENT*J)/Z.BYTES_PER_ELEMENT,Y=Z.length/J,Q=new Z.constructor(Y*$);for(let K=0;K*J<Z.length;K++)for(let W=0;W<J;W++)Q[K*$+W]=Z[K*J+W];return Q}function kL1(Z){let J=new Float32Array(Z.length*4/3);for(let X=0,$=Z.length/3;X<$;X++)J[X*4]=Z[X*3],J[X*4+1]=Z[X*3+1],J[X*4+2]=Z[X*3+2];return J}function EL1(Z,J){if(J===c4.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some(($)=>{return $ instanceof g1&&$.getMode()===g1.Mode.TRIANGLES})?B3.TRIANGLES:B3.INDICES;return B3.ATTRIBUTES}function IL1(Z,J){let X=J.getGraph().listParentEdges(Z).filter(($)=>!($.getParent()instanceof W3));for(let $ of X){let Y=$.getName(),Q=$.getAttributes().key||"",K=$.getParent().propertyType===i.PRIMITIVE_TARGET;if(Y==="indices")return{filter:$8.NONE};if(Y==="attributes"){if(Q==="POSITION")return{filter:$8.NONE};if(Q==="TEXCOORD_0")return{filter:$8.NONE};if(Q.startsWith("JOINTS_"))return{filter:$8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:$8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:$8.NONE}:{filter:$8.OCTAHEDRAL,bits:8}}if(Y==="output"){let W=gn(Z);if(W==="rotation")return{filter:$8.QUATERNION,bits:16};if(W==="translation")return{filter:$8.EXPONENTIAL,bits:12};if(W==="scale")return{filter:$8.EXPONENTIAL,bits:12};return{filter:$8.NONE}}if(Y==="input")return{filter:$8.NONE};if(Y==="inverseBindMatrices")return{filter:$8.NONE}}return{filter:$8.NONE}}function gn(Z){for(let J of Z.listParents()){if(!(J instanceof SJ))continue;for(let X of J.listParents()){if(!(X instanceof QZ))continue;return X.getTargetPath()}}return null}var In={method:mG.QUANTIZE};class lG extends P1{constructor(...Z){super(...Z);this.extensionName=X6,this.prereadTypes=[i.BUFFER,i.PRIMITIVE],this.prewriteTypes=[i.BUFFER,i.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=In,this._encoderFallbackBuffer=null,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={}}install(Z,J){if(Z==="meshopt.decoder")this._decoder=J;if(Z==="meshopt.encoder")this._encoder=J;return this}setEncoderOptions(Z){return this._encoderOptions=DZ({},In,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${X6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${X6}]: Missing WASM support.`)}if(J===i.BUFFER)this._prereadBuffers(Z);else if(J===i.PRIMITIVE)this._prereadPrimitives(Z);return this}_prereadBuffers(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[X6])return;let Q=$.extensions[X6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,z=Q.byteStride,v=new Uint8Array(G*z),H=J.json.buffers[Q.buffer],V=H.uri?J.resources[H.uri]:J.resources[k$],q=E0.toView(V,K,W);this._decoder.decodeGltfBuffer(v,G,z,q,Q.mode,Q.filter),Z.bufferViews[Y]=v})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach(($)=>{if(!$.extensions||!$.extensions[X6])return;let Y=$.extensions[X6],Q=Z.buffers[Y.buffer],K=Z.buffers[$.buffer],W=J.json.buffers[$.buffer];if(NL1(W))this._decoderFallbackBufferMap.set(K,Q)})}read(Z){if(!this.isRequired())return this;for(let[J,X]of this._decoderFallbackBufferMap){for(let $ of J.listParents())if($ instanceof K0)$.swap(J,X);J.dispose()}return this}prewrite(Z,J){if(J===i.ACCESSOR)this._prewriteAccessors(Z);else if(J===i.BUFFER)this._prewriteBuffers(Z);return this}_prewriteAccessors(Z){let J=Z.jsonDoc.json,X=this._encoder,$=this._encoderOptions,Y=this.document.getGraph(),Q=this.document.createBuffer(),K=this.document.getRoot().listBuffers().indexOf(Q),W=1,G=new Map,z=(v)=>{for(let H of Y.listParents(v)){if(H.propertyType===i.ROOT)continue;let V=G.get(v);if(V===void 0)G.set(v,V=W++);return V}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let v of this.document.getRoot().listAccessors()){if(gn(v)==="weights")continue;if(v.getSparse())continue;let H=Z.getAccessorUsage(v),V=Z.accessorUsageGroupedByParent.has(H)?z(v):null,q=EL1(v,H),F=$.method===mG.FILTER?IL1(v,this.document):{filter:$8.NONE},x=TL1(v,X,q,F),{array:c,byteStride:w}=x,B=v.getBuffer();if(!B)throw new Error(`${X6}: Missing buffer for accessor.`);let j=this.document.getRoot().listBuffers().indexOf(B),L=[H,V,q,F.filter,w,j].join(":"),R=this._encoderBufferViews[L],M=this._encoderBufferViewData[L],N=this._encoderBufferViewAccessors[L];if(!R||!M)N=this._encoderBufferViewAccessors[L]=[],M=this._encoderBufferViewData[L]=[],R=this._encoderBufferViews[L]={buffer:K,target:c4.USAGE_TO_TARGET[H],byteOffset:0,byteLength:0,byteStride:H===c4.BufferViewUsage.ARRAY_BUFFER?w:void 0,extensions:{[X6]:{buffer:j,byteOffset:0,byteLength:0,mode:q,filter:F.filter!==$8.NONE?F.filter:void 0,byteStride:w,count:0}}};let P=Z.createAccessorDef(v);if(P.componentType=x.componentType,P.normalized=x.normalized,P.byteOffset=R.byteLength,P.min&&x.min)P.min=x.min;if(P.max&&x.max)P.max=x.max;Z.accessorIndexMap.set(v,J.accessors.length),J.accessors.push(P),N.push(P),M.push(new Uint8Array(c.buffer,c.byteOffset,c.byteLength)),R.byteLength+=c.byteLength,R.extensions.EXT_meshopt_compression.count+=v.getCount()}}_prewriteBuffers(Z){let J=this._encoder;for(let X in this._encoderBufferViews){let $=this._encoderBufferViews[X],Y=this._encoderBufferViewData[X],Q=this.document.getRoot().listBuffers()[$.extensions[X6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:z}=$.extensions[X6],v=E0.concat(Y),H=J.encodeGltfBuffer(v,W,G,z),V=E0.pad(H);$.extensions[X6].byteLength=H.byteLength,Y.length=0,Y.push(V),K.push(V),Z.otherBufferViews.set(Q,K)}}write(Z){let J=0;for(let Q in this._encoderBufferViews){let K=this._encoderBufferViews[Q],W=this._encoderBufferViewData[Q][0],G=Z.otherBufferViewsIndexMap.get(W),z=this._encoderBufferViewAccessors[Q];for(let q of z)q.bufferView=G;let v=Z.jsonDoc.json.bufferViews[G],H=v.byteOffset||0;Object.assign(v,K),v.byteOffset=J;let V=v.extensions[X6];V.byteOffset=H,J+=E0.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,$=Z.bufferIndexMap.get(X),Y=Z.jsonDoc.json.buffers[$];return Y.byteLength=J,Y.extensions={[X6]:{fallback:!0}},X.dispose(),this}}lG.EXTENSION_NAME=X6;lG.EncoderMethod=mG;class dn{match(Z){return Z.length>=12&&E0.decodeText(Z.slice(4,12))==="ftypavif"}getSize(Z){if(!this.match(Z))return null;let J=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),X=_n(J,0);if(!X)return null;let $=X.end;while(X=_n(J,$))if(X.type==="meta")$=X.start+4;else if(X.type==="iprp"||X.type==="ipco")$=X.start;else if(X.type==="ispe")return[J.getUint32(X.start+4),J.getUint32(X.start+8)];else if(X.type==="mdat")break;else $=X.end;return null}getChannels(Z){return 4}}class Nx extends P1{constructor(...Z){super(...Z);this.extensionName=SG,this.prereadTypes=[i.TEXTURE]}static register(){E5.registerFormat("image/avif",new dn)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[SG])X.source=X.extensions[SG].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/avif"){let $=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===$)Q.extensions=Q.extensions||{},Q.extensions[SG]={source:Q.source},delete Q.source})}}),this}}Nx.EXTENSION_NAME=SG;function _n(Z,J){if(Z.byteLength<4+J)return null;let X=Z.getUint32(J);if(Z.byteLength<X+J||X<8)return null;return{type:E0.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}class an{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=E0.decodeText(Z.slice(0,4)),X=E0.decodeText(Z.slice(8,12));if(J!=="RIFF"||X!=="WEBP")return null;let $=new DataView(Z.buffer,Z.byteOffset),Y=12;while(Y<$.byteLength){let Q=E0.decodeText(new Uint8Array([$.getUint8(Y),$.getUint8(Y+1),$.getUint8(Y+2),$.getUint8(Y+3)])),K=$.getUint32(Y+4,!0);if(Q==="VP8 "){let W=$.getInt16(Y+14,!0)&16383,G=$.getInt16(Y+16,!0)&16383;return[W,G]}else if(Q==="VP8L"){let W=$.getUint8(Y+9),G=$.getUint8(Y+10),z=$.getUint8(Y+11),v=$.getUint8(Y+12),H=1+((G&63)<<8|W),V=1+((v&15)<<10|z<<2|(G&192)>>6);return[H,V]}Y+=8+K+K%2}return null}getChannels(Z){return 4}}class Ox extends P1{constructor(...Z){super(...Z);this.extensionName=hG,this.prereadTypes=[i.TEXTURE]}static register(){E5.registerFormat("image/webp",new an)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[hG])X.source=X.extensions[hG].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/webp"){let $=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===$)Q.extensions=Q.extensions||{},Q.extensions[hG]={source:Q.source},delete Q.source})}}),this}}Ox.EXTENSION_NAME=hG;var h8,nn,sn;function _L1(Z,J){let X=new h8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==h8.TRIANGULAR_MESH)throw new Error(`[${s1}] Unknown geometry type.`);let Y=new h8.Mesh;if(!Z.DecodeBufferToMesh(X,Y).ok()||Y.ptr===0)throw new Error(`[${s1}] Decoding failure.`);return Y}finally{h8.destroy(X)}}function bL1(Z,J){let $=J.num_faces()*3,Y,Q;if(J.num_points()<=65534){let K=$*Uint16Array.BYTES_PER_ELEMENT;Y=h8._malloc(K),Z.GetTrianglesUInt16Array(J,K,Y),Q=new Uint16Array(h8.HEAPU16.buffer,Y,$).slice()}else{let K=$*Uint32Array.BYTES_PER_ELEMENT;Y=h8._malloc(K),Z.GetTrianglesUInt32Array(J,K,Y),Q=new Uint32Array(h8.HEAPU32.buffer,Y,$).slice()}return h8._free(Y),Q}function hL1(Z,J,X,$){let Y=sn[$.componentType],Q=nn[$.componentType],K=X.num_components(),G=J.num_points()*K,z=G*Q.BYTES_PER_ELEMENT,v=h8._malloc(z);Z.GetAttributeDataArrayForAllPoints(J,X,Y,z,v);let H=new Q(h8.HEAPF32.buffer,v,G).slice();return h8._free(v),H}function SL1(Z){h8=Z,nn={[K0.ComponentType.FLOAT]:Float32Array,[K0.ComponentType.UNSIGNED_INT]:Uint32Array,[K0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[K0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[K0.ComponentType.SHORT]:Int16Array,[K0.ComponentType.BYTE]:Int8Array},sn={[K0.ComponentType.FLOAT]:h8.DT_FLOAT32,[K0.ComponentType.UNSIGNED_INT]:h8.DT_UINT32,[K0.ComponentType.UNSIGNED_SHORT]:h8.DT_UINT16,[K0.ComponentType.UNSIGNED_BYTE]:h8.DT_UINT8,[K0.ComponentType.SHORT]:h8.DT_INT16,[K0.ComponentType.BYTE]:h8.DT_INT8}}var U4,uG;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(uG||(uG={}));var L4;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(L4||(L4={}));var on={[L4.POSITION]:14,[L4.NORMAL]:10,[L4.COLOR]:8,[L4.TEX_COORD]:12,[L4.GENERIC]:12},bn={decodeSpeed:5,encodeSpeed:5,method:uG.EDGEBREAKER,quantizationBits:on,quantizationVolume:"mesh"};function AL1(Z){U4=Z}function mL1(Z,J=bn){let X=DZ({},bn,J);X.quantizationBits=DZ({},on,J.quantizationBits);let $=new U4.MeshBuilder,Y=new U4.Mesh,Q=new U4.ExpertEncoder(Y),K={},W=new U4.DracoInt8Array,G=Z.listTargets().length>0,z=!1;for(let x of Z.listSemantics()){let c=Z.getAttribute(x);if(c.getSparse()){z=!0;continue}let w=uL1(x),B=lL1($,c.getComponentType(),Y,U4[w],c.getCount(),c.getElementSize(),c.getArray());if(B===-1)throw new Error(`Error compressing "${x}" attribute.`);if(K[x]=B,X.quantizationVolume==="mesh"||x!=="POSITION")Q.SetAttributeQuantization(B,X.quantizationBits[w]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:j}=X,L=Math.max(j.max[0]-j.min[0],j.max[1]-j.min[1],j.max[2]-j.min[2]);Q.SetAttributeExplicitQuantization(B,X.quantizationBits[w],c.getElementSize(),j.min,L)}else throw new Error("Invalid quantization volume state.")}let v=Z.getIndices();if(!v)throw new Dx("Primitive must have indices.");if($.AddFacesToMesh(Y,v.getCount()/3,v.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===uG.SEQUENTIAL||G||z)Q.SetEncodingMethod(U4.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(U4.MESH_EDGEBREAKER_ENCODING);let H=Q.EncodeToDracoBuffer(!(G||z),W);if(H<=0)throw new Dx("Error applying Draco compression.");let V=new Uint8Array(H);for(let x=0;x<H;++x)V[x]=W.GetValue(x);let q=Q.GetNumberOfEncodedPoints(),F=Q.GetNumberOfEncodedFaces()*3;return U4.destroy(W),U4.destroy(Y),U4.destroy($),U4.destroy(Q),{numVertices:q,numIndices:F,data:V,attributeIDs:K}}function uL1(Z){if(Z==="POSITION")return L4.POSITION;else if(Z==="NORMAL")return L4.NORMAL;else if(Z.startsWith("COLOR_"))return L4.COLOR;else if(Z.startsWith("TEXCOORD_"))return L4.TEX_COORD;return L4.GENERIC}function lL1(Z,J,X,$,Y,Q,K){switch(J){case K0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,$,Y,Q,K);case K0.ComponentType.BYTE:return Z.AddInt8Attribute(X,$,Y,Q,K);case K0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,$,Y,Q,K);case K0.ComponentType.SHORT:return Z.AddInt16Attribute(X,$,Y,Q,K);case K0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,$,Y,Q,K);case K0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,$,Y,Q,K);default:throw new Error(`Unexpected component type, "${J}".`)}}class Dx extends Error{}class yG extends P1{constructor(...Z){super(...Z);this.extensionName=s1,this.prereadTypes=[i.PRIMITIVE],this.prewriteTypes=[i.ACCESSOR],this.readDependencies=["draco3d.decoder"],this.writeDependencies=["draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(Z,J){if(Z==="draco3d.decoder")this._decoderModule=J,SL1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,AL1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw new Error(`[${s1}] Please install extension dependency, "draco3d.decoder".`);let J=this.document.getLogger(),X=Z.jsonDoc,$=new Map;try{let Y=X.json.meshes||[];for(let Q of Y)for(let K of Q.primitives){if(!K.extensions||!K.extensions[s1])continue;let W=K.extensions[s1],[G,z]=$.get(W.bufferView)||[];if(!z||!G){let v=X.json.bufferViews[W.bufferView],H=X.json.buffers[v.buffer],V=H.uri?X.resources[H.uri]:X.resources[k$],q=v.byteOffset||0,F=v.byteLength,x=E0.toView(V,q,F);G=new this._decoderModule.Decoder,z=_L1(G,x),$.set(W.bufferView,[G,z]),J.debug(`[${s1}] Decompressed ${x.byteLength} bytes.`)}for(let v in W.attributes){let H=Z.jsonDoc.json.accessors[K.attributes[v]],V=G.GetAttributeByUniqueId(z,W.attributes[v]),q=hL1(G,z,V,H);Z.accessors[K.attributes[v]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(bL1(G,z))}}finally{for(let[Y,Q]of Array.from($.values()))this._decoderModule.destroy(Y),this._decoderModule.destroy(Q)}return this}read(Z){return this}prewrite(Z,J){if(!this._encoderModule)throw new Error(`[${s1}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${s1}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let $=yL1(this.document),Y=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${s1}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=RG(this.document.getRoot().listScenes().pop());for(let K of Array.from($.keys())){let W=$.get(K);if(!W)throw new Error("Unexpected primitive.");if(Y.has(W)){Y.set(W,Y.get(W));continue}let G=K.getIndices(),z=Z.jsonDoc.json.accessors,v;try{v=mL1(K,DZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof Dx){X.warn(`[${s1}]: ${q.message} Skipping primitive compression.`);continue}throw q}Y.set(W,v);let H=Z.createAccessorDef(G);if(H.count=v.numIndices,Z.accessorIndexMap.set(G,z.length),z.push(H),v.numVertices>65534&&K0.getComponentSize(H.componentType)<=2)H.componentType=K0.ComponentType.UNSIGNED_INT;else if(v.numVertices>254&&K0.getComponentSize(H.componentType)<=1)H.componentType=K0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let F=K.getAttribute(q);if(v.attributeIDs[q]===void 0)continue;let x=Z.createAccessorDef(F);x.count=v.numVertices,Z.accessorIndexMap.set(F,z.length),z.push(x)}let V=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(V))Z.otherBufferViews.set(V,[]);Z.otherBufferViews.get(V).push(v.data)}return X.debug(`[${s1}] Compressed ${$.size} primitives.`),Z.extensionData[s1]={primitiveHashMap:$,primitiveEncodingMap:Y},this}write(Z){let J=Z.extensionData[s1];for(let X of this.document.getRoot().listMeshes()){let $=Z.jsonDoc.json.meshes[Z.meshIndexMap.get(X)];for(let Y=0;Y<X.listPrimitives().length;Y++){let Q=X.listPrimitives()[Y],K=$.primitives[Y],W=J.primitiveHashMap.get(Q);if(!W)continue;let G=J.primitiveEncodingMap.get(W);if(!G)continue;K.extensions=K.extensions||{},K.extensions[s1]={bufferView:Z.otherBufferViewsIndexMap.get(G.data),attributes:G.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter(($)=>$!==s1),X.extensionsRequired=(X.extensionsRequired||[]).filter(($)=>$!==s1)}return this}}yG.EXTENSION_NAME=s1;yG.EncoderMethod=uG;function yL1(Z){let J=Z.getLogger(),X=new Set,$=new Set,Y=0,Q=0;for(let H of Z.getRoot().listMeshes())for(let V of H.listPrimitives())if(!V.getIndices())$.add(V),Y++;else if(V.getMode()!==g1.Mode.TRIANGLES)$.add(V),Q++;else X.add(V);if(Y>0)J.warn(`[${s1}] Skipping Draco compression of ${Y} non-indexed primitives.`);if(Q>0)J.warn(`[${s1}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),W=new Map;for(let H=0;H<K.length;H++)W.set(K[H],H);let G=new Map,z=new Set,v=new Map;for(let H of Array.from(X)){let V=hn(H,W);if(z.has(V)){v.set(H,V);continue}if(G.has(H.getIndices())){let q=H.getIndices(),F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}for(let q of H.listAttributes())if(G.has(q)){let F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}V=hn(H,W),z.add(V),v.set(H,V),G.set(H.getIndices(),V);for(let q of H.listAttributes())G.set(q,V)}for(let H of Array.from(G.keys())){let V=new Set(H.listParents().map((q)=>q.propertyType));if(V.size!==2||!V.has(i.PRIMITIVE)||!V.has(i.ROOT))throw new Error(`[${s1}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let H of Array.from(X)){let V=v.get(H),q=H.getIndices();if(G.get(q)!==V||H.listAttributes().some((F)=>G.get(F)!==V))throw new Error(`[${s1}] Draco primitives must share all, or no, accessors.`)}for(let H of Array.from($)){let V=H.getIndices();if(G.has(V)||H.listAttributes().some((q)=>G.has(q)))throw new Error(`[${s1}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return v}function hn(Z,J){let X=[],$=Z.getIndices();X.push(J.get($));for(let Y of Z.listAttributes())X.push(J.get(Y));return X.sort().join("|")}class j3 extends O1{init(){this.extensionName=B4,this.propertyType="Light",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:j3.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(Z){return this.set("color",Z)}getIntensity(){return this.get("intensity")}setIntensity(Z){return this.set("intensity",Z)}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getRange(){return this.get("range")}setRange(Z){return this.set("range",Z)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(Z){return this.set("innerConeAngle",Z)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(Z){return this.set("outerConeAngle",Z)}}j3.EXTENSION_NAME=B4;j3.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};class dR extends P1{constructor(...Z){super(...Z);this.extensionName=B4}createLight(Z=""){return new j3(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[B4])return this;let Y=(J.json.extensions[B4].lights||[]).map((Q)=>{var K,W;let G=this.createLight().setName(Q.name||"").setType(Q.type);if(Q.color!==void 0)G.setColor(Q.color);if(Q.intensity!==void 0)G.setIntensity(Q.intensity);if(Q.range!==void 0)G.setRange(Q.range);if(((K=Q.spot)==null?void 0:K.innerConeAngle)!==void 0)G.setInnerConeAngle(Q.spot.innerConeAngle);if(((W=Q.spot)==null?void 0:W.outerConeAngle)!==void 0)G.setOuterConeAngle(Q.spot.outerConeAngle);return G});return J.json.nodes.forEach((Q,K)=>{if(!Q.extensions||!Q.extensions[B4])return;let W=Q.extensions[B4];Z.nodes[K].setExtension(B4,Y[W.light])}),this}write(Z){let J=Z.jsonDoc;if(this.properties.size===0)return this;let X=[],$=new Map;for(let Y of this.properties){let Q=Y,K={type:Q.getType()};if(!I0.eq(Q.getColor(),[1,1,1]))K.color=Q.getColor();if(Q.getIntensity()!==1)K.intensity=Q.getIntensity();if(Q.getRange()!=null)K.range=Q.getRange();if(Q.getName())K.name=Q.getName();if(Q.getType()===j3.Type.SPOT)K.spot={innerConeAngle:Q.getInnerConeAngle(),outerConeAngle:Q.getOuterConeAngle()};X.push(K),$.set(Q,X.length-1)}return this.document.getRoot().listNodes().forEach((Y)=>{let Q=Y.getExtension(B4);if(Q){let K=Z.nodeIndexMap.get(Y),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[B4]={light:$.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[B4]={lights:X},this}}dR.EXTENSION_NAME=B4;var{R:pL1,G:iL1,B:gL1}=v5;class aR extends O1{init(){this.extensionName=zZ,this.propertyType="Anisotropy",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new F1(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(Z){return this.set("anisotropyStrength",Z)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(Z){return this.set("anisotropyRotation",Z)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(Z){return this.setRef("anisotropyTexture",Z,{channels:pL1|iL1|gL1})}}aR.EXTENSION_NAME=zZ;class nR extends P1{constructor(...Z){super(...Z);this.extensionName=zZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createAnisotropy(){return new aR(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[zZ]){let K=this.createAnisotropy();Z.materials[Q].setExtension(zZ,K);let W=Y.extensions[zZ];if(W.anisotropyStrength!==void 0)K.setAnisotropyStrength(W.anisotropyStrength);if(W.anisotropyRotation!==void 0)K.setAnisotropyRotation(W.anisotropyRotation);if(W.anisotropyTexture!==void 0){let G=W.anisotropyTexture,z=Z.textures[$[G.index].source];K.setAnisotropyTexture(z),Z.setTextureInfo(K.getAnisotropyTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(zZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[zZ]={};if($.getAnisotropyStrength()>0)K.anisotropyStrength=$.getAnisotropyStrength();if($.getAnisotropyRotation()!==0)K.anisotropyRotation=$.getAnisotropyRotation();if($.getAnisotropyTexture()){let W=$.getAnisotropyTexture(),G=$.getAnisotropyTextureInfo();K.anisotropyTexture=Z.createTextureInfoDef(W,G)}}}),this}}nR.EXTENSION_NAME=zZ;var{R:Sn,G:An,B:dL1}=v5;class sR extends O1{init(){this.extensionName=vZ,this.propertyType="Clearcoat",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new F1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new F1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new F1(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(Z){return this.set("clearcoatFactor",Z)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(Z){return this.setRef("clearcoatTexture",Z,{channels:Sn})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(Z){return this.set("clearcoatRoughnessFactor",Z)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(Z){return this.setRef("clearcoatRoughnessTexture",Z,{channels:An})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(Z){return this.set("clearcoatNormalScale",Z)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(Z){return this.setRef("clearcoatNormalTexture",Z,{channels:Sn|An|dL1})}}sR.EXTENSION_NAME=vZ;class oR extends P1{constructor(...Z){super(...Z);this.extensionName=vZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createClearcoat(){return new sR(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[vZ]){let K=this.createClearcoat();Z.materials[Q].setExtension(vZ,K);let W=Y.extensions[vZ];if(W.clearcoatFactor!==void 0)K.setClearcoatFactor(W.clearcoatFactor);if(W.clearcoatRoughnessFactor!==void 0)K.setClearcoatRoughnessFactor(W.clearcoatRoughnessFactor);if(W.clearcoatTexture!==void 0){let G=W.clearcoatTexture,z=Z.textures[$[G.index].source];K.setClearcoatTexture(z),Z.setTextureInfo(K.getClearcoatTextureInfo(),G)}if(W.clearcoatRoughnessTexture!==void 0){let G=W.clearcoatRoughnessTexture,z=Z.textures[$[G.index].source];K.setClearcoatRoughnessTexture(z),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),G)}if(W.clearcoatNormalTexture!==void 0){let G=W.clearcoatNormalTexture,z=Z.textures[$[G.index].source];if(K.setClearcoatNormalTexture(z),Z.setTextureInfo(K.getClearcoatNormalTextureInfo(),G),G.scale!==void 0)K.setClearcoatNormalScale(G.scale)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(vZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[vZ]={clearcoatFactor:$.getClearcoatFactor(),clearcoatRoughnessFactor:$.getClearcoatRoughnessFactor()};if($.getClearcoatTexture()){let W=$.getClearcoatTexture(),G=$.getClearcoatTextureInfo();K.clearcoatTexture=Z.createTextureInfoDef(W,G)}if($.getClearcoatRoughnessTexture()){let W=$.getClearcoatRoughnessTexture(),G=$.getClearcoatRoughnessTextureInfo();K.clearcoatRoughnessTexture=Z.createTextureInfoDef(W,G)}if($.getClearcoatNormalTexture()){let W=$.getClearcoatNormalTexture(),G=$.getClearcoatNormalTextureInfo();if(K.clearcoatNormalTexture=Z.createTextureInfoDef(W,G),$.getClearcoatNormalScale()!==1)K.clearcoatNormalTexture.scale=$.getClearcoatNormalScale()}}}),this}}oR.EXTENSION_NAME=vZ;var{R:aL1,G:nL1,B:sL1,A:oL1}=v5;class rR extends O1{init(){this.extensionName=VZ,this.propertyType="DiffuseTransmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new F1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new F1(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(Z){return this.set("diffuseTransmissionFactor",Z)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(Z){return this.setRef("diffuseTransmissionTexture",Z,{channels:oL1})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(Z){return this.set("diffuseTransmissionColorFactor",Z)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(Z){return this.setRef("diffuseTransmissionColorTexture",Z,{channels:aL1|nL1|sL1})}}rR.EXTENSION_NAME=VZ;class tR extends P1{constructor(...Z){super(...Z);this.extensionName=VZ}createDiffuseTransmission(){return new rR(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[VZ]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(VZ,K);let W=Y.extensions[VZ];if(W.diffuseTransmissionFactor!==void 0)K.setDiffuseTransmissionFactor(W.diffuseTransmissionFactor);if(W.diffuseTransmissionColorFactor!==void 0)K.setDiffuseTransmissionColorFactor(W.diffuseTransmissionColorFactor);if(W.diffuseTransmissionTexture!==void 0){let G=W.diffuseTransmissionTexture,z=Z.textures[$[G.index].source];K.setDiffuseTransmissionTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),G)}if(W.diffuseTransmissionColorTexture!==void 0){let G=W.diffuseTransmissionColorTexture,z=Z.textures[$[G.index].source];K.setDiffuseTransmissionColorTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),G)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let $=X.getExtension(VZ);if(!$)continue;let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[VZ]={diffuseTransmissionFactor:$.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:$.getDiffuseTransmissionColorFactor()};if($.getDiffuseTransmissionTexture()){let W=$.getDiffuseTransmissionTexture(),G=$.getDiffuseTransmissionTextureInfo();K.diffuseTransmissionTexture=Z.createTextureInfoDef(W,G)}if($.getDiffuseTransmissionColorTexture()){let W=$.getDiffuseTransmissionColorTexture(),G=$.getDiffuseTransmissionColorTextureInfo();K.diffuseTransmissionColorTexture=Z.createTextureInfoDef(W,G)}}return this}}tR.EXTENSION_NAME=VZ;class eR extends O1{init(){this.extensionName=HZ,this.propertyType="Dispersion",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}eR.EXTENSION_NAME=HZ;class ZN extends P1{constructor(...Z){super(...Z);this.extensionName=HZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createDispersion(){return new eR(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[HZ]){let Q=this.createDispersion();Z.materials[Y].setExtension(HZ,Q);let K=$.extensions[HZ];if(K.dispersion!==void 0)Q.setDispersion(K.dispersion)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(HZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[HZ]={dispersion:$.getDispersion()}}}),this}}ZN.EXTENSION_NAME=HZ;class JN extends O1{init(){this.extensionName=qZ,this.propertyType="EmissiveStrength",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}JN.EXTENSION_NAME=qZ;class XN extends P1{constructor(...Z){super(...Z);this.extensionName=qZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createEmissiveStrength(){return new JN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[qZ]){let Q=this.createEmissiveStrength();Z.materials[Y].setExtension(qZ,Q);let K=$.extensions[qZ];if(K.emissiveStrength!==void 0)Q.setEmissiveStrength(K.emissiveStrength)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(qZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[qZ]={emissiveStrength:$.getEmissiveStrength()}}}),this}}XN.EXTENSION_NAME=qZ;class $N extends O1{init(){this.extensionName=FZ,this.propertyType="IOR",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}$N.EXTENSION_NAME=FZ;class Px extends P1{constructor(...Z){super(...Z);this.extensionName=FZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIOR(){return new $N(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[FZ]){let Q=this.createIOR();Z.materials[Y].setExtension(FZ,Q);let K=$.extensions[FZ];if(K.ior!==void 0)Q.setIOR(K.ior)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(FZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[FZ]={ior:$.getIOR()}}}),this}}Px.EXTENSION_NAME=FZ;var{R:rL1,G:tL1}=v5;class YN extends O1{init(){this.extensionName=xZ,this.propertyType="Iridescence",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new F1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new F1(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(Z){return this.set("iridescenceFactor",Z)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(Z){return this.setRef("iridescenceTexture",Z,{channels:rL1})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(Z){return this.set("iridescenceIOR",Z)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(Z){return this.set("iridescenceThicknessMinimum",Z)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(Z){return this.set("iridescenceThicknessMaximum",Z)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(Z){return this.setRef("iridescenceThicknessTexture",Z,{channels:tL1})}}YN.EXTENSION_NAME=xZ;class QN extends P1{constructor(...Z){super(...Z);this.extensionName=xZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIridescence(){return new YN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[xZ]){let K=this.createIridescence();Z.materials[Q].setExtension(xZ,K);let W=Y.extensions[xZ];if(W.iridescenceFactor!==void 0)K.setIridescenceFactor(W.iridescenceFactor);if(W.iridescenceIor!==void 0)K.setIridescenceIOR(W.iridescenceIor);if(W.iridescenceThicknessMinimum!==void 0)K.setIridescenceThicknessMinimum(W.iridescenceThicknessMinimum);if(W.iridescenceThicknessMaximum!==void 0)K.setIridescenceThicknessMaximum(W.iridescenceThicknessMaximum);if(W.iridescenceTexture!==void 0){let G=W.iridescenceTexture,z=Z.textures[$[G.index].source];K.setIridescenceTexture(z),Z.setTextureInfo(K.getIridescenceTextureInfo(),G)}if(W.iridescenceThicknessTexture!==void 0){let G=W.iridescenceThicknessTexture,z=Z.textures[$[G.index].source];K.setIridescenceThicknessTexture(z),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(xZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[xZ]={};if($.getIridescenceFactor()>0)K.iridescenceFactor=$.getIridescenceFactor();if($.getIridescenceIOR()!==1.3)K.iridescenceIor=$.getIridescenceIOR();if($.getIridescenceThicknessMinimum()!==100)K.iridescenceThicknessMinimum=$.getIridescenceThicknessMinimum();if($.getIridescenceThicknessMaximum()!==400)K.iridescenceThicknessMaximum=$.getIridescenceThicknessMaximum();if($.getIridescenceTexture()){let W=$.getIridescenceTexture(),G=$.getIridescenceTextureInfo();K.iridescenceTexture=Z.createTextureInfoDef(W,G)}if($.getIridescenceThicknessTexture()){let W=$.getIridescenceThicknessTexture(),G=$.getIridescenceThicknessTextureInfo();K.iridescenceThicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}QN.EXTENSION_NAME=xZ;var{R:mn,G:un,B:ln,A:yn}=v5;class KN extends O1{init(){this.extensionName=cZ,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new F1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new F1(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(Z){return this.set("diffuseFactor",Z)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(Z){return this.setRef("diffuseTexture",Z,{channels:mn|un|ln|yn,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(Z){return this.set("specularFactor",Z)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(Z){return this.set("glossinessFactor",Z)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(Z){return this.setRef("specularGlossinessTexture",Z,{channels:mn|un|ln|yn})}}KN.EXTENSION_NAME=cZ;class Tx extends P1{constructor(...Z){super(...Z);this.extensionName=cZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createPBRSpecularGlossiness(){return new KN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[cZ]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(cZ,K);let W=Y.extensions[cZ];if(W.diffuseFactor!==void 0)K.setDiffuseFactor(W.diffuseFactor);if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.glossinessFactor!==void 0)K.setGlossinessFactor(W.glossinessFactor);if(W.diffuseTexture!==void 0){let G=W.diffuseTexture,z=Z.textures[$[G.index].source];K.setDiffuseTexture(z),Z.setTextureInfo(K.getDiffuseTextureInfo(),G)}if(W.specularGlossinessTexture!==void 0){let G=W.specularGlossinessTexture,z=Z.textures[$[G.index].source];K.setSpecularGlossinessTexture(z),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(cZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[cZ]={diffuseFactor:$.getDiffuseFactor(),specularFactor:$.getSpecularFactor(),glossinessFactor:$.getGlossinessFactor()};if($.getDiffuseTexture()){let W=$.getDiffuseTexture(),G=$.getDiffuseTextureInfo();K.diffuseTexture=Z.createTextureInfoDef(W,G)}if($.getSpecularGlossinessTexture()){let W=$.getSpecularGlossinessTexture(),G=$.getSpecularGlossinessTextureInfo();K.specularGlossinessTexture=Z.createTextureInfoDef(W,G)}}}),this}}Tx.EXTENSION_NAME=cZ;var{R:eL1,G:ZD1,B:JD1,A:XD1}=v5;class WN extends O1{init(){this.extensionName=wZ,this.propertyType="Sheen",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new F1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new F1(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(Z){return this.set("sheenColorFactor",Z)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(Z){return this.setRef("sheenColorTexture",Z,{channels:eL1|ZD1|JD1,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(Z){return this.set("sheenRoughnessFactor",Z)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(Z){return this.setRef("sheenRoughnessTexture",Z,{channels:XD1})}}WN.EXTENSION_NAME=wZ;class GN extends P1{constructor(...Z){super(...Z);this.extensionName=wZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSheen(){return new WN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[wZ]){let K=this.createSheen();Z.materials[Q].setExtension(wZ,K);let W=Y.extensions[wZ];if(W.sheenColorFactor!==void 0)K.setSheenColorFactor(W.sheenColorFactor);if(W.sheenRoughnessFactor!==void 0)K.setSheenRoughnessFactor(W.sheenRoughnessFactor);if(W.sheenColorTexture!==void 0){let G=W.sheenColorTexture,z=Z.textures[$[G.index].source];K.setSheenColorTexture(z),Z.setTextureInfo(K.getSheenColorTextureInfo(),G)}if(W.sheenRoughnessTexture!==void 0){let G=W.sheenRoughnessTexture,z=Z.textures[$[G.index].source];K.setSheenRoughnessTexture(z),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(wZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[wZ]={sheenColorFactor:$.getSheenColorFactor(),sheenRoughnessFactor:$.getSheenRoughnessFactor()};if($.getSheenColorTexture()){let W=$.getSheenColorTexture(),G=$.getSheenColorTextureInfo();K.sheenColorTexture=Z.createTextureInfoDef(W,G)}if($.getSheenRoughnessTexture()){let W=$.getSheenRoughnessTexture(),G=$.getSheenRoughnessTextureInfo();K.sheenRoughnessTexture=Z.createTextureInfoDef(W,G)}}}),this}}GN.EXTENSION_NAME=wZ;var{R:$D1,G:YD1,B:QD1,A:KD1}=v5;class zN extends O1{init(){this.extensionName=UZ,this.propertyType="Specular",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new F1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new F1(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(Z){return this.set("specularFactor",Z)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(Z){return this.set("specularColorFactor",Z)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(Z){return this.setRef("specularTexture",Z,{channels:KD1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:$D1|YD1|QD1,isColor:!0})}}zN.EXTENSION_NAME=UZ;class Cx extends P1{constructor(...Z){super(...Z);this.extensionName=UZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSpecular(){return new zN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[UZ]){let K=this.createSpecular();Z.materials[Q].setExtension(UZ,K);let W=Y.extensions[UZ];if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.specularColorFactor!==void 0)K.setSpecularColorFactor(W.specularColorFactor);if(W.specularTexture!==void 0){let G=W.specularTexture,z=Z.textures[$[G.index].source];K.setSpecularTexture(z),Z.setTextureInfo(K.getSpecularTextureInfo(),G)}if(W.specularColorTexture!==void 0){let G=W.specularColorTexture,z=Z.textures[$[G.index].source];K.setSpecularColorTexture(z),Z.setTextureInfo(K.getSpecularColorTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(UZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[UZ]={};if($.getSpecularFactor()!==1)K.specularFactor=$.getSpecularFactor();if(!I0.eq($.getSpecularColorFactor(),[1,1,1]))K.specularColorFactor=$.getSpecularColorFactor();if($.getSpecularTexture()){let W=$.getSpecularTexture(),G=$.getSpecularTextureInfo();K.specularTexture=Z.createTextureInfoDef(W,G)}if($.getSpecularColorTexture()){let W=$.getSpecularColorTexture(),G=$.getSpecularColorTextureInfo();K.specularColorTexture=Z.createTextureInfoDef(W,G)}}}),this}}Cx.EXTENSION_NAME=UZ;var{R:WD1}=v5;class vN extends O1{init(){this.extensionName=BZ,this.propertyType="Transmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new F1(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(Z){return this.set("transmissionFactor",Z)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(Z){return this.setRef("transmissionTexture",Z,{channels:WD1})}}vN.EXTENSION_NAME=BZ;class VN extends P1{constructor(...Z){super(...Z);this.extensionName=BZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createTransmission(){return new vN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[BZ]){let K=this.createTransmission();Z.materials[Q].setExtension(BZ,K);let W=Y.extensions[BZ];if(W.transmissionFactor!==void 0)K.setTransmissionFactor(W.transmissionFactor);if(W.transmissionTexture!==void 0){let G=W.transmissionTexture,z=Z.textures[$[G.index].source];K.setTransmissionTexture(z),Z.setTextureInfo(K.getTransmissionTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(BZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[BZ]={transmissionFactor:$.getTransmissionFactor()};if($.getTransmissionTexture()){let W=$.getTransmissionTexture(),G=$.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}VN.EXTENSION_NAME=BZ;class HN extends O1{init(){this.extensionName=pJ,this.propertyType="Unlit",this.parentTypes=[i.MATERIAL]}}HN.EXTENSION_NAME=pJ;class fx extends P1{constructor(...Z){super(...Z);this.extensionName=pJ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createUnlit(){return new HN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((X,$)=>{if(X.extensions&&X.extensions[pJ])Z.materials[$].setExtension(pJ,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(pJ)){let $=Z.materialIndexMap.get(X),Y=J.json.materials[$];Y.extensions=Y.extensions||{},Y.extensions[pJ]={}}}),this}}fx.EXTENSION_NAME=pJ;class qN extends O1{init(){this.extensionName=U6,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new x1})}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}addVariant(Z){return this.addRef("variants",Z)}removeVariant(Z){return this.removeRef("variants",Z)}listVariants(){return this.listRefs("variants")}}qN.EXTENSION_NAME=U6;class FN extends O1{init(){this.extensionName=U6,this.propertyType="MappingList",this.parentTypes=[i.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new x1})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}FN.EXTENSION_NAME=U6;class Mx extends O1{init(){this.extensionName=U6,this.propertyType="Variant",this.parentTypes=["MappingList"]}}Mx.EXTENSION_NAME=U6;class xN extends P1{constructor(...Z){super(...Z);this.extensionName=U6}createMappingList(){return new FN(this.document.getGraph())}createVariant(Z=""){return new Mx(this.document.getGraph(),Z)}createMapping(){return new qN(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof Mx)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[U6])return this;let Y=(J.json.extensions[U6].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((v,H)=>{if(!v.extensions||!v.extensions[U6])return;let V=this.createMappingList(),q=v.extensions[U6];for(let F of q.mappings){let x=this.createMapping();if(F.material!==void 0)x.setMaterial(Z.materials[F.material]);for(let c of F.variants||[])x.addVariant(Y[c]);V.addMapping(x)}G.listPrimitives()[H].setExtension(U6,V)})}),this}write(Z){let J=Z.jsonDoc,X=this.listVariants();if(!X.length)return this;let $=[],Y=new Map;for(let Q of X)Y.set(Q,$.length),$.push(Z.createPropertyDef(Q));for(let Q of this.document.getRoot().listMeshes()){let K=Z.meshIndexMap.get(Q);Q.listPrimitives().forEach((W,G)=>{let z=W.getExtension(U6);if(!z)return;let v=Z.jsonDoc.json.meshes[K].primitives[G],H=z.listMappings().map((V)=>{let q=Z.createPropertyDef(V),F=V.getMaterial();if(F)q.material=Z.materialIndexMap.get(F);return q.variants=V.listVariants().map((x)=>Y.get(x)),q});v.extensions=v.extensions||{},v.extensions[U6]={mappings:H}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[U6]={variants:$},this}}xN.EXTENSION_NAME=U6;var{G:GD1}=v5;class cN extends O1{init(){this.extensionName=jZ,this.propertyType="Volume",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new F1(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(Z){return this.set("thicknessFactor",Z)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(Z){return this.setRef("thicknessTexture",Z,{channels:GD1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}cN.EXTENSION_NAME=jZ;class wN extends P1{constructor(...Z){super(...Z);this.extensionName=jZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createVolume(){return new cN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[jZ]){let K=this.createVolume();Z.materials[Q].setExtension(jZ,K);let W=Y.extensions[jZ];if(W.thicknessFactor!==void 0)K.setThicknessFactor(W.thicknessFactor);if(W.attenuationDistance!==void 0)K.setAttenuationDistance(W.attenuationDistance);if(W.attenuationColor!==void 0)K.setAttenuationColor(W.attenuationColor);if(W.thicknessTexture!==void 0){let G=W.thicknessTexture,z=Z.textures[$[G.index].source];K.setThicknessTexture(z),Z.setTextureInfo(K.getThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(jZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[jZ]={};if($.getThicknessFactor()>0)K.thicknessFactor=$.getThicknessFactor();if(Number.isFinite($.getAttenuationDistance()))K.attenuationDistance=$.getAttenuationDistance();if(!I0.eq($.getAttenuationColor(),[1,1,1]))K.attenuationColor=$.getAttenuationColor();if($.getThicknessTexture()){let W=$.getThicknessTexture(),G=$.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}wN.EXTENSION_NAME=jZ;class pG extends P1{constructor(...Z){super(...Z);this.extensionName=pn}read(Z){return this}write(Z){return this}}pG.EXTENSION_NAME=pn;class rn{match(Z){return Z[0]===171&&Z[1]===75&&Z[2]===84&&Z[3]===88&&Z[4]===32&&Z[5]===50&&Z[6]===48&&Z[7]===187&&Z[8]===13&&Z[9]===10&&Z[10]===26&&Z[11]===10}getSize(Z){let J=Lx(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=Lx(Z).dataFormatDescriptor[0];if(X.colorModel===Cn)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===fn)return(X.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=Lx(Z),X=this.getChannels(Z)>3,$=0;for(let Y=0;Y<J.levels.length;Y++){let Q=J.levels[Y];if(Q.uncompressedByteLength)$+=Q.uncompressedByteLength;else{let K=Math.max(1,Math.floor(J.pixelWidth/Math.pow(2,Y))),W=Math.max(1,Math.floor(J.pixelHeight/Math.pow(2,Y))),G=X?16:8;$+=K/4*(W/4)*G}}return $}}class UN extends P1{constructor(...Z){super(...Z);this.extensionName=AG,this.prereadTypes=[i.TEXTURE]}static register(){E5.registerFormat("image/ktx2",new rn)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[AG]){let X=J.extensions[AG];J.source=X.source}}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/ktx2"){let $=Z.imageIndexMap.get(X);J.json.textures.forEach((Y)=>{if(Y.source===$)Y.extensions=Y.extensions||{},Y.extensions[AG]={source:Y.source},delete Y.source})}}),this}}UN.EXTENSION_NAME=AG;class BN extends O1{init(){this.extensionName=LZ,this.propertyType="Transform",this.parentTypes=[i.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(Z){return this.set("offset",Z)}getRotation(){return this.get("rotation")}setRotation(Z){return this.set("rotation",Z)}getScale(){return this.get("scale")}setScale(Z){return this.set("scale",Z)}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}}BN.EXTENSION_NAME=LZ;class jN extends P1{constructor(...Z){super(...Z);this.extensionName=LZ}createTransform(){return new BN(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[LZ])continue;let $=this.createTransform(),Y=X.extensions[LZ];if(Y.offset!==void 0)$.setOffset(Y.offset);if(Y.rotation!==void 0)$.setRotation(Y.rotation);if(Y.scale!==void 0)$.setScale(Y.scale);if(Y.texCoord!==void 0)$.setTexCoord(Y.texCoord);J.setExtension(LZ,$)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,$]of J){let Y=X.getExtension(LZ);if(!Y)continue;$.extensions=$.extensions||{};let Q={},K=I0.eq;if(!K(Y.getOffset(),[0,0]))Q.offset=Y.getOffset();if(Y.getRotation()!==0)Q.rotation=Y.getRotation();if(!K(Y.getScale(),[1,1]))Q.scale=Y.getScale();if(Y.getTexCoord()!=null)Q.texCoord=Y.getTexCoord();$.extensions[LZ]=Q}return this}}jN.EXTENSION_NAME=LZ;var zD1=[i.ROOT,i.SCENE,i.NODE,i.MESH,i.MATERIAL,i.TEXTURE,i.ANIMATION];class LN extends O1{init(){this.extensionName=j4,this.propertyType="Packet",this.parentTypes=zD1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",DZ({},Z))}listProperties(){return Object.keys(this.get("properties"))}getProperty(Z){let J=this.get("properties");return Z in J?J[Z]:null}setProperty(Z,J){this._assertContext(Z);let X=DZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=yR(this.get("context")),J=yR(this.get("properties"));return DZ({"@context":Z},J)}fromJSONLD(Z){Z=yR(Z);let J=Z["@context"];if(J)this.set("context",J);return delete Z["@context"],this.set("properties",Z)}_assertContext(Z){if(!(Z.split(":")[0]in this.get("context")))throw new Error(`${j4}: Missing context for term, "${Z}".`)}}LN.EXTENSION_NAME=j4;function yR(Z){return JSON.parse(JSON.stringify(Z))}class DN extends P1{constructor(...Z){super(...Z);this.extensionName=j4}createPacket(){return new LN(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[j4];if(!X||!X.packets)return this;let $=Z.jsonDoc.json,Y=this.document.getRoot(),Q=X.packets.map((G)=>this.createPacket().fromJSONLD(G)),K=[[$.asset],$.scenes,$.nodes,$.meshes,$.materials,$.images,$.animations],W=[[Y],Y.listScenes(),Y.listNodes(),Y.listMeshes(),Y.listMaterials(),Y.listTextures(),Y.listAnimations()];for(let G=0;G<K.length;G++){let z=K[G]||[];for(let v=0;v<z.length;v++){let H=z[v];if(H.extensions&&H.extensions[j4]){let V=H.extensions[j4];W[G][v].setExtension(j4,Q[V.packet])}}}return this}write(Z){let{json:J}=Z.jsonDoc,X=[];for(let $ of this.properties){X.push($.toJSONLD());for(let Y of $.listParents()){let Q;switch(Y.propertyType){case i.ROOT:Q=J.asset;break;case i.SCENE:Q=J.scenes[Z.sceneIndexMap.get(Y)];break;case i.NODE:Q=J.nodes[Z.nodeIndexMap.get(Y)];break;case i.MESH:Q=J.meshes[Z.meshIndexMap.get(Y)];break;case i.MATERIAL:Q=J.materials[Z.materialIndexMap.get(Y)];break;case i.TEXTURE:Q=J.images[Z.imageIndexMap.get(Y)];break;case i.ANIMATION:Q=J.animations[Z.animationIndexMap.get(Y)];break;default:Q=null,this.document.getLogger().warn(`[${j4}]: Unsupported parent property, "${Y.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[j4]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[j4]={packets:X};return this}}DN.EXTENSION_NAME=j4;var vD1=[yG,dR,nR,oR,tR,ZN,XN,Px,QN,Tx,Cx,GN,VN,fx,xN,wN,pG,UN,jN,DN],aN6=[Rx,lG,Nx,Ox,...vD1];var VD1=t(cR(),1);function M3(){return M3=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},M3.apply(null,arguments)}var{POINTS:tn,LINES:kx,LINE_STRIP:HD1,LINE_LOOP:qD1,TRIANGLES:Ex,TRIANGLE_STRIP:FD1,TRIANGLE_FAN:xD1}=g1.Mode;function m$(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function RZ(Z,J){let X=M3({},Z);for(let $ in J)if(J[$]!==void 0)X[$]=J[$];return X}function cs(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case g1.Mode.POINTS:return J?J.getCount():X.getCount();case g1.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case g1.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case g1.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case g1.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case g1.Mode.TRIANGLE_STRIP:case g1.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw new Error("Unexpected mode: "+Z.getMode())}}var cD1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function NN(Z){return cD1.format(Z)}function wD1(Z,J,X=2){let $=Z>J?"–":"+",Y="%";return $+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function Sx(Z,J){return`${NN(Z)} → ${NN(J)} (${wD1(Z,J)})`}function Ax(Z){let J=[];for(let X of Z.listAttributes())J.push(X);for(let X of Z.listTargets())for(let $ of X.listAttributes())J.push($);return Array.from(new Set(J))}function UD1(Z,J,X){Z.swap(J,X);for(let $ of Z.listTargets())$.swap(J,X)}function ws(Z){let J=Z.getIndices(),X=Ax(Z);if(Z.dispose(),J&&!ON(J))J.dispose();for(let $ of X)if(!ON($))$.dispose()}function MZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function BD1(Z,J=Z){let X=IN(Z,J);for(let $=0;$<X.length;$++)X[$]=$;return X}function IN(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function ON(Z){return Z.listParents().some((J)=>J.propertyType!==i.ROOT)}function Us(Z){for(let J in Z)return!1;return!0}function Bs(Z){let J=c6.fromGraph(Z.getGraph()),X=Z.getMaterial(),$=J.getRoot().listMaterials().indexOf(X),Y=LD1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let z=Z.getAttribute(G),v=z.getElementSize(),H=z.getComponentType();return`${G}:${v}:${H}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((z)=>{let v=Z.getAttribute(z),H=v.getElementSize(),V=v.getComponentType();return`${z}:${H}:${V}`}).join("+")}).join("~");return`${$}|${Y}|${Q}|${K}|${W}`}function jD1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var LD1={[tn]:tn,[kx]:kx,[HD1]:kx,[qD1]:kx,[Ex]:Ex,[FD1]:Ex,[xD1]:Ex},L3="center",en={pivot:"center"};function js(Z=en){let J=RZ(en,Z);return m$(L3,(X)=>{let $=X.getLogger(),Y=X.getRoot(),Q=Y.listAnimations().length>0||Y.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{$.debug(`${L3}: Scene ${W+1} / ${Y.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let v=RG(K);if(G=[(v.max[0]-v.min[0])/2+v.min[0],(v.max[1]-v.min[1])/2+v.min[1],(v.max[2]-v.min[2])/2+v.min[2]],J.pivot==="above")G[1]=v.max[1];if(J.pivot==="below")G[1]=v.min[1]}else G=J.pivot;$.debug(`${L3}: Pivot "${G.join(", ")}".`);let z=[-1*G[0],-1*G[1],-1*G[2]];if(Q){$.debug(`${L3}: Model contains animation or skin. Adding a wrapper node.`);let v=X.createNode("Pivot").setTranslation(z);K.listChildren().forEach((H)=>v.addChild(H)),K.addChild(v)}else $.debug(`${L3}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((v)=>{let H=v.getTranslation();v.setTranslation([H[0]+z[0],H[1]+z[1],H[2]+z[2]])})}),$.debug(`${L3}: Complete.`)})}function DD1(Z){let J=new Set,X=Z,$;while($=X.getParentNode()){if(J.has($))throw new Error("Circular dependency in scene graph.");J.add($),X=$}return X.listParents().filter((Y)=>Y instanceof K3)}function MD1(Z){let J=DD1(Z),X=Z.getParentNode();if(!X)return Z;Z.setMatrix(Z.getWorldMatrix()),X.removeChild(Z);for(let $ of J)$.addChild(Z);return Z}var R3=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function RD1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=J[9],V=J[10],q=J[11],F=J[12],x=J[13],c=J[14],w=J[15],B=X*W-$*K,j=X*G-Y*K,L=X*z-Q*K,R=$*G-Y*W,M=$*z-Q*W,N=Y*z-Q*G,P=v*x-H*F,O=v*c-V*F,_=v*w-q*F,k=H*c-V*x,h=H*w-q*x,f=V*w-q*c,C=B*f-j*h+L*k+R*_-M*O+N*P;if(!C)return null;return C=1/C,Z[0]=(W*f-G*h+z*k)*C,Z[1]=(Y*h-$*f-Q*k)*C,Z[2]=(x*N-c*M+w*R)*C,Z[3]=(V*M-H*N-q*R)*C,Z[4]=(G*_-K*f-z*O)*C,Z[5]=(X*f-Y*_+Q*O)*C,Z[6]=(c*L-F*N-w*j)*C,Z[7]=(v*N-V*L+q*j)*C,Z[8]=(K*h-W*_+z*P)*C,Z[9]=($*_-X*h-Q*P)*C,Z[10]=(F*M-x*L+w*B)*C,Z[11]=(H*L-v*M-q*B)*C,Z[12]=(W*O-K*k-G*P)*C,Z[13]=(X*k-$*O+Y*P)*C,Z[14]=(x*j-F*R-c*B)*C,Z[15]=(v*R-H*j+V*B)*C,Z}function ND1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],x=Z[14],c=Z[15],w=J*K-X*Q,B=J*W-$*Q,j=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,N=z*F-v*q,P=z*x-H*q,O=z*c-V*q,_=v*x-H*F,k=v*c-V*F,h=H*c-V*x;return w*h-B*k+j*_+L*O-R*P+M*N}function Ls(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],x=J[12],c=J[13],w=J[14],B=J[15],j=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=j*$+L*W+R*H+M*x,Z[1]=j*Y+L*G+R*V+M*c,Z[2]=j*Q+L*z+R*q+M*w,Z[3]=j*K+L*v+R*F+M*B,j=X[4],L=X[5],R=X[6],M=X[7],Z[4]=j*$+L*W+R*H+M*x,Z[5]=j*Y+L*G+R*V+M*c,Z[6]=j*Q+L*z+R*q+M*w,Z[7]=j*K+L*v+R*F+M*B,j=X[8],L=X[9],R=X[10],M=X[11],Z[8]=j*$+L*W+R*H+M*x,Z[9]=j*Y+L*G+R*V+M*c,Z[10]=j*Q+L*z+R*q+M*w,Z[11]=j*K+L*v+R*F+M*B,j=X[12],L=X[13],R=X[14],M=X[15],Z[12]=j*$+L*W+R*H+M*x,Z[13]=j*Y+L*G+R*V+M*c,Z[14]=j*Q+L*z+R*q+M*w,Z[15]=j*K+L*v+R*F+M*B,Z}var B6;(function(Z){Z.RENDER="render",Z.RENDER_CACHED="render-cached",Z.UPLOAD="upload",Z.UPLOAD_NAIVE="upload-naive",Z.DISTINCT="distinct",Z.DISTINCT_POSITION="distinct-position",Z.UNUSED="unused"})(B6||(B6={}));function A$(Z,J){let X=Z.getAttribute("POSITION"),$=Z.getIndices();switch(J){case B6.RENDER:return $?$.getCount():X.getCount();case B6.RENDER_CACHED:return $?new Set($.getArray()).size:X.getCount();case B6.UPLOAD_NAIVE:case B6.UPLOAD:return X.getCount();case B6.DISTINCT:case B6.DISTINCT_POSITION:return OD1(J);case B6.UNUSED:return $?X.getCount()-new Set($.getArray()).size:0;default:return PD1(J)}}function OD1(Z){throw new Error(`Not implemented: ${Z}`)}function PD1(Z){throw new Error(`Unexpected value: ${Z}`)}var iJ=4294967295;class Ds{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of Ax(Z))J+=this._initAttribute(X);this.u8=new Uint8Array(J),this.u32=new Uint32Array(this.u8.buffer)}_initAttribute(Z){let J=Z.getArray(),X=new Uint8Array(J.buffer,J.byteOffset,J.byteLength),$=Z.getElementSize()*Z.getComponentSize(),Y=E0.padNumber($);return this.attributes.push({u8:X,byteStride:$,paddedByteStride:Y}),Y}hash(Z){let J=0;for(let{u8:X,byteStride:$,paddedByteStride:Y}of this.attributes){for(let Q=0;Q<Y;Q++)if(Q<$)this.u8[J+Q]=X[Z*$+Q];else this.u8[J+Q]=0;J+=Y}return TD1(0,this.u32)}equal(Z,J){for(let{u8:X,byteStride:$}of this.attributes)for(let Y=0;Y<$;Y++)if(X[Z*$+Y]!==X[J*$+Y])return!1;return!0}}function TD1(Z,J){for(let Y=0,Q=J.length;Y<Q;Y++){let K=J[Y];K=Math.imul(K,1540483477)>>>0,K=(K^K>>24)>>>0,K=Math.imul(K,1540483477)>>>0,Z=Math.imul(Z,1540483477)>>>0,Z=(Z^K)>>>0}return Z}function CD1(Z,J,X,$,Y=iJ){let Q=J-1,W=X.hash($)&Q;for(let G=0;G<=Q;G++){let z=Z[W];if(z===Y||X.equal(z,$))return W;W=W+G+1&Q}throw new Error("Hash table full.")}function gG(Z,J,X){let $=c6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=fD1(Z);let Y=Z.getIndices(),Q=Y?Y.getArray():null,K=A$(Z,B6.RENDER),W=$.createAccessor(),G=K,z=IN(G,X);for(let H=0;H<G;H++)z[H]=J[Q?Q[H]:H];Z.setIndices(W.setArray(z));let v=Ax(Z);for(let H of Z.listAttributes()){let V=MZ($,H);PN(H,Y,J,V,X),Z.swap(H,V)}for(let H of Z.listTargets())for(let V of H.listAttributes()){let q=MZ($,V);PN(V,Y,J,q,X),H.swap(V,q)}if(Y&&Y.listParents().length===1)Y.dispose();for(let H of v)if(H.listParents().length===1)H.dispose();return Z}function PN(Z,J,X,$,Y){let Q=Z.getElementSize(),K=Z.getArray(),W=J?J.getArray():null,G=J?J.getCount():Z.getCount(),z=new K.constructor(Y*Q),v=new Uint8Array(Y);for(let H=0;H<G;H++){let V=W?W[H]:H,q=X[V];if(v[q])continue;for(let F=0;F<Q;F++)z[q*Q+F]=K[V*Q+F];v[q]=1}return $.setArray(z)}function fD1(Z){let J=A$(Z,B6.UPLOAD),X=Z.getIndices(),$=X?X.getArray():null;if(!X||!$)return[BD1(J,1e6),J];let Y=new Uint32Array(J).fill(iJ),Q=0;for(let K=0;K<$.length;K++){let W=$[K];if(Y[W]===iJ)Y[W]=Q++}return[Y,Q]}function kD1(){var Z=new R3(9);if(R3!=Float32Array)Z[1]=0,Z[2]=0,Z[3]=0,Z[5]=0,Z[6]=0,Z[7]=0;return Z[0]=1,Z[4]=1,Z[8]=1,Z}function ED1(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[4],Z[4]=J[5],Z[5]=J[6],Z[6]=J[8],Z[7]=J[9],Z[8]=J[10],Z}function ID1(Z,J){if(Z===J){var X=J[1],$=J[2],Y=J[5];Z[1]=J[3],Z[2]=J[6],Z[3]=X,Z[5]=J[7],Z[6]=$,Z[7]=Y}else Z[0]=J[0],Z[1]=J[3],Z[2]=J[6],Z[3]=J[1],Z[4]=J[4],Z[5]=J[7],Z[6]=J[2],Z[7]=J[5],Z[8]=J[8];return Z}function _D1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=v*K-W*z,V=-v*Q+W*G,q=z*Q-K*G,F=X*H+$*V+Y*q;if(!F)return null;return F=1/F,Z[0]=H*F,Z[1]=(-v*$+Y*z)*F,Z[2]=(W*$-Y*K)*F,Z[3]=V*F,Z[4]=(v*X-Y*G)*F,Z[5]=(-W*X+Y*Q)*F,Z[6]=q*F,Z[7]=(-z*X+$*G)*F,Z[8]=(K*X-$*Q)*F,Z}function mx(){var Z=new R3(3);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function bD1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function Ms(Z,J){var X=J[0],$=J[1],Y=J[2],Q=X*X+$*$+Y*Y;if(Q>0)Q=1/Math.sqrt(Q);return Z[0]=J[0]*Q,Z[1]=J[1]*Q,Z[2]=J[2]*Q,Z}function hD1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=X[3]*$+X[7]*Y+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*$+X[4]*Y+X[8]*Q+X[12])/K,Z[1]=(X[1]*$+X[5]*Y+X[9]*Q+X[13])/K,Z[2]=(X[2]*$+X[6]*Y+X[10]*Q+X[14])/K,Z}function SD1(Z,J,X){var $=J[0],Y=J[1],Q=J[2];return Z[0]=$*X[0]+Y*X[3]+Q*X[6],Z[1]=$*X[1]+Y*X[4]+Q*X[7],Z[2]=$*X[2]+Y*X[5]+Q*X[8],Z}var AD1=bD1;(function(){var Z=mx();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=3;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();var TN="weld",_x={overwrite:!0};function _N(Z=_x){let J=RZ(_x,Z);return m$(TN,async(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes()){for(let Q of Y.listPrimitives())if(ux(Q,J),A$(Q,B6.RENDER)===0)ws(Q);if(Y.listPrimitives().length===0)Y.dispose()}$.debug(`${TN}: Complete.`)})}function ux(Z,J=_x){let X=Z.getGraph(),Y=c6.fromGraph(X).getLogger(),Q=M3({},_x,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===g1.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),W=Z.getIndices(),G=W==null?void 0:W.getArray(),z=W?W.getCount():K,v=new Ds(Z),H=jD1(K+K/4),V=new Uint32Array(H).fill(iJ),q=new Uint32Array(K).fill(iJ),F=0;for(let x=0;x<z;x++){let c=G?G[x]:x;if(q[c]!==iJ)continue;let w=CD1(V,H,v,c,iJ),B=V[w];if(B===iJ)V[w]=c,q[c]=F++;else q[c]=q[B]}Y.debug(`${TN}: ${Sx(K,F)} vertices.`),gG(Z,q,F)}var{FLOAT:mD1}=K0.ComponentType;function Rs(Z,J){let X=Z.getAttribute("POSITION");if(X)Zs(J,X);let $=Z.getAttribute("NORMAL");if($)Js(J,$);let Y=Z.getAttribute("TANGENT");if(Y)Xs(J,Y);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)Zs(J,K);let W=Q.getAttribute("NORMAL");if(W)Js(J,W);let G=Q.getAttribute("TANGENT");if(G)Xs(J,G)}if(ND1(J)<0)uD1(Z)}function Zs(Z,J){let X=J.getComponentType(),$=J.getNormalized(),Y=J.getArray(),Q=X===mD1?Y:new Float32Array(Y.length),K=mx();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=I0.decodeNormalizedInt(Y[W*3],X),K[1]=I0.decodeNormalizedInt(Y[W*3+1],X),K[2]=I0.decodeNormalizedInt(Y[W*3+2],X);else K[0]=Y[W*3],K[1]=Y[W*3+1],K[2]=Y[W*3+2];hD1(K,K,Z),Q[W*3]=K[0],Q[W*3+1]=K[1],Q[W*3+2]=K[2]}J.setArray(Q).setNormalized(!1)}function Js(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=kD1();ED1(Q,Z),_D1(Q,Q),ID1(Q,Q);let K=mx();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=I0.decodeNormalizedInt(X[W*3],Y),K[1]=I0.decodeNormalizedInt(X[W*3+1],Y),K[2]=I0.decodeNormalizedInt(X[W*3+2],Y);else K[0]=X[W*3],K[1]=X[W*3+1],K[2]=X[W*3+2];if(SD1(K,K,Q),Ms(K,K),$)X[W*3]=I0.decodeNormalizedInt(K[0],Y),X[W*3+1]=I0.decodeNormalizedInt(K[1],Y),X[W*3+2]=I0.decodeNormalizedInt(K[2],Y);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function Xs(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=mx();for(let K=0,W=J.getCount();K<W;K++){if($)Q[0]=I0.decodeNormalizedInt(X[K*4],Y),Q[1]=I0.decodeNormalizedInt(X[K*4+1],Y),Q[2]=I0.decodeNormalizedInt(X[K*4+2],Y);else Q[0]=X[K*4],Q[1]=X[K*4+1],Q[2]=X[K*4+2];if(Q[0]=Z[0]*Q[0]+Z[4]*Q[1]+Z[8]*Q[2],Q[1]=Z[1]*Q[0]+Z[5]*Q[1]+Z[9]*Q[2],Q[2]=Z[2]*Q[0]+Z[6]*Q[1]+Z[10]*Q[2],Ms(Q,Q),$)X[K*4]=I0.decodeNormalizedInt(Q[0],Y),X[K*4+1]=I0.decodeNormalizedInt(Q[1],Y),X[K*4+2]=I0.decodeNormalizedInt(Q[2],Y);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function uD1(Z){if(Z.getMode()!==g1.Mode.TRIANGLES)return;if(!Z.getIndices())ux(Z);let J=Z.getIndices();for(let X=0,$=J.getCount();X<$;X+=3){let Y=J.getScalar(X),Q=J.getScalar(X+2);J.setScalar(X,Q),J.setScalar(X+2,Y)}}function lD1(Z,J){for(let X of Z.listPrimitives()){let $=yD1(X,Z);if(X!==$)Z.removePrimitive(X).addPrimitive($)}for(let X of Z.listPrimitives())gG(X),Rs(X,J)}function yD1(Z,J){if(Z.listParents().some(($)=>$ instanceof NG&&$!==J))Z=Z.clone();for(let $ of Z.listTargets())if($.listParents().some((Q)=>Q instanceof g1&&Q!==Z))Z.removeTarget($).addTarget($.clone());return Z}var $s=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function Ns(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!I0.eq(X,$s))lD1(J,X);for(let $ of Z.listChildren()){let Y=$.getMatrix();Ls(Y,Y,X),$.setMatrix(Y)}return Z.setMatrix($s)}var{LINES:pD1,LINE_STRIP:iD1,LINE_LOOP:gD1,TRIANGLES:dD1,TRIANGLE_STRIP:aD1,TRIANGLE_FAN:nD1}=g1.Mode;function sD1(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())ux(Z);let $=Z.getIndices(),Y=$.getArray(),Q=cs(Z),W=new hJ[$.getComponentType()](Q*2),G=Z.getMode();if(G===iD1)for(let v=0;v<Q;v++)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else if(G===gD1)for(let v=0;v<Q;v++)if(v<Q-1)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else W[v*2]=Y[v],W[v*2+1]=Y[0];else throw new Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(pD1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,$).setArray(W));else $.setArray(W)}function Os(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())ux(Z);let $=Z.getIndices(),Y=$.getArray(),Q=cs(Z),W=new hJ[$.getComponentType()](Q*3),G=Z.getMode();if(G===aD1)for(let v=0,H=Y.length;v<H-2;v++)if(v%2)W[v*3]=Y[v+1],W[v*3+1]=Y[v],W[v*3+2]=Y[v+2];else W[v*3]=Y[v],W[v*3+1]=Y[v+1],W[v*3+2]=Y[v+2];else if(G===nD1)for(let v=0;v<Q;v++)W[v*3]=Y[0],W[v*3+1]=Y[v+1],W[v*3+2]=Y[v+2];else throw new Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(dD1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,$).setArray(W));else $.setArray(W)}var eN6={keepUniqueNames:!1,propertyTypes:[i.ACCESSOR,i.MESH,i.TEXTURE,i.MATERIAL,i.SKIN]};var Ys="dequantize",bx={pattern:/^((?!JOINTS_).)*$/};function Ps(Z=bx){let J=RZ(bx,Z);return m$(Ys,(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes())for(let Q of Y.listPrimitives())oD1(Q,J);X.createExtension(pG).dispose(),$.debug(`${Ys}: Complete.`)})}function oD1(Z,J=bx){let X=RZ(bx,J);for(let $ of Z.listSemantics())if(X.pattern.test($))CN(Z.getAttribute($));for(let $ of Z.listTargets())for(let Y of $.listSemantics())if(X.pattern.test(Y))CN($.getAttribute(Y))}function CN(Z){let J=Z.getArray();if(!J)return;let X=hx(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function hx(Z,J,X){let $=new Float32Array(Z.length);for(let Y=0,Q=Z.length;Y<Q;Y++)if(X)$[Y]=I0.decodeNormalizedInt(Z[Y],J);else $[Y]=Z[Y];return $}var{TEXTURE_INFO:Ts,ROOT:ZO6}=i;function Cs(Z){let J=new c6().setLogger(Z.getLogger()),X=bN(J,Z);return rD1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function rD1(Z,J,X){X||(X=bN(Z,J));for(let $ of J.getRoot().listExtensionsUsed()){let Y=Z.createExtension($.constructor);if($.isRequired())Y.setRequired(!0)}return tD1(Z,J,eD1(J),X)}function tD1(Z,J,X,$){$||($=bN(Z,J));let Y=new Map;for(let Q of X)if(!Y.has(Q)&&Q.propertyType!==Ts)Y.set(Q,$(Q));for(let[Q,K]of Y.entries())K.copy(Q,$);return Y}function bN(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return($)=>{if($.propertyType===Ts)return $;let Y=X.get($);if(!Y)Y=new $.constructor(Z.getGraph()),X.set($,Y);return Y}}function eD1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}function fs(){var Z=new R3(4);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function ZM1(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z[3]=J[3]+X[3],Z}function JM1(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z[2]=J[2]-X[2],Z[3]=J[3]-X[3],Z}function XM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z[3]=J[3]*X[3],Z}function $M1(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z}function YM1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3];return Math.hypot(J,X,$,Y)}var ks=JM1,QM1=XM1,Es=YM1;(function(){var Z=fs();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=4;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Z[3]=J[W+3],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2],J[W+3]=Z[3];return J}})();var KM1=/color|emissive|diffuse/i;function WM1(Z){return Z.getGraph().listParentEdges(Z).some((Y)=>{return Y.getAttributes().isColor||KM1.test(Y.getName())})?"srgb":null}function GM1(Z){let J=Z.getGraph(),X=new Set,$=new Set;function Y(Q){let K=new Set;for(let W of J.listChildEdges(Q))if(W.getChild()instanceof I$)K.add(W.getName()+"Info");for(let W of J.listChildEdges(Q)){let G=W.getChild();if(X.has(G))continue;if(X.add(G),G instanceof F1&&K.has(W.getName()))$.add(G);else if(G instanceof O1)Y(G)}}return Y(Z),Array.from($)}function zM1(Z){let X=c6.fromGraph(Z.getGraph()).getRoot(),$=Z.getGraph().listParentEdges(Z).filter((Y)=>Y.getParent()!==X).map((Y)=>Y.getName());return Array.from(new Set($))}var D3="prune",fN=0.011764705882352941,Qs={propertyTypes:[i.NODE,i.SKIN,i.MESH,i.CAMERA,i.PRIMITIVE,i.PRIMITIVE_TARGET,i.ANIMATION,i.MATERIAL,i.TEXTURE,i.ACCESSOR,i.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function Is(Z=Qs){let J=RZ(Qs,Z),X=new Set(J.propertyTypes),$=J.keepExtras;return m$(D3,async(Y)=>{let Q=Y.getLogger(),K=Y.getRoot(),W=Y.getGraph(),G=new _s,z=(v)=>G.dispose(v.target);if(W.addEventListener("node:dispose",z),X.has(i.MESH))for(let v of K.listMeshes()){if(v.listPrimitives().length>0)continue;v.dispose()}if(X.has(i.NODE)){if(!J.keepLeaves)for(let v of K.listScenes())bs(W,v,$);for(let v of K.listNodes())D4(v,$)}if(X.has(i.SKIN))for(let v of K.listSkins())D4(v,$);if(X.has(i.MESH))for(let v of K.listMeshes())D4(v,$);if(X.has(i.CAMERA))for(let v of K.listCameras())D4(v,$);if(X.has(i.PRIMITIVE))Ks(W,i.PRIMITIVE,$);if(X.has(i.PRIMITIVE_TARGET))Ks(W,i.PRIMITIVE_TARGET,$);if(!J.keepAttributes&&X.has(i.ACCESSOR)){let v=new Map;for(let H of K.listMeshes())for(let V of H.listPrimitives()){let q=V.getMaterial();if(!q)continue;let F=hs(Y,V,q),x=vM1(V,F);Ws(V,x),V.listTargets().forEach((c)=>Ws(c,x)),v.has(q)?v.get(q).add(V):v.set(q,new Set([V]))}for(let[H,V]of v)VM1(H,Array.from(V))}if(X.has(i.ANIMATION))for(let v of K.listAnimations()){for(let H of v.listChannels())if(!H.getTargetNode())H.dispose();if(!v.listChannels().length){let H=v.listSamplers();D4(v,$),H.forEach((V)=>D4(V,$))}else v.listSamplers().forEach((H)=>D4(H,$))}if(X.has(i.MATERIAL))K.listMaterials().forEach((v)=>D4(v,$));if(X.has(i.TEXTURE)){if(K.listTextures().forEach((v)=>D4(v,$)),!J.keepSolidTextures)await HM1(Y)}if(X.has(i.ACCESSOR))K.listAccessors().forEach((v)=>D4(v,$));if(X.has(i.BUFFER))K.listBuffers().forEach((v)=>D4(v,$));if(W.removeEventListener("node:dispose",z),!G.empty()){let v=G.entries().map(([H,V])=>`${H} (${V})`).join(", ");Q.info(`${D3}: Removed types... ${v}`)}else Q.debug(`${D3}: No unused properties found.`);Q.debug(`${D3}: Complete.`)})}class _s{constructor(){this.disposed={}}empty(){for(let Z in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(Z){this.disposed[Z.propertyType]=this.disposed[Z.propertyType]||0,this.disposed[Z.propertyType]++}}function D4(Z,J){let X=Z.listParents().filter((Y)=>!(Y instanceof W3||Y instanceof QZ)),$=J&&!Us(Z.getExtras());if(!X.length&&!$)Z.dispose()}function Ks(Z,J,X){for(let $ of Z.listEdges()){let Y=$.getParent();if(Y.propertyType===J)D4(Y,X)}}function bs(Z,J,X){if(J.listChildren().forEach((K)=>bs(Z,K,X)),J instanceof K3)return;let $=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==i.ROOT&&W!==i.SCENE&&W!==i.NODE}),Y=Z.listChildren(J).length===0,Q=X&&!Us(J.getExtras());if(Y&&!$&&!Q)J.dispose()}function Ws(Z,J){for(let X of J)Z.setAttribute(X,null)}function vM1(Z,J){let X=[];for(let $ of Z.listSemantics())if($==="NORMAL"&&!J.has($))X.push($);else if($==="TANGENT"&&!J.has($))X.push($);else if($.startsWith("TEXCOORD_")&&!J.has($))X.push($);else if($.startsWith("COLOR_")&&$!=="COLOR_0")X.push($);return X}function hs(Z,J,X,$=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let z of Q)if(z.getChild()instanceof I$)K.add(z.getName());for(let z of Q){let v=z.getName(),H=z.getChild();if(H instanceof F1){if(K.has(v.replace(/Info$/,"")))$.add(`TEXCOORD_${H.getTexCoord()}`)}if(H instanceof I$&&v.match(/normalTexture/i))$.add("TANGENT");if(H instanceof O1)hs(Z,J,H,$)}let W=X instanceof Q7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===g1.Mode.POINTS;if(W&&!G)$.add("NORMAL");return $}function VM1(Z,J){let X=GM1(Z),$=new Set(X.map((G)=>G.getTexCoord())),Y=Array.from($).sort(),Q=new Map(Y.map((G,z)=>[G,z])),K=new Map(Y.map((G,z)=>[`TEXCOORD_${G}`,`TEXCOORD_${z}`]));for(let G of X){let z=G.getTexCoord();G.setTexCoord(Q.get(z))}for(let G of J){let z=G.listSemantics().filter((v)=>v.startsWith("TEXCOORD_")).sort();W(G,z),G.listTargets().forEach((v)=>W(v,z))}function W(G,z){for(let v of z){let H=G.getAttribute(v);if(!H)continue;let V=K.get(v);if(V===v)continue;G.setAttribute(V,H),G.setAttribute(v,null)}}}async function HM1(Z){let J=Z.getRoot(),X=Z.getGraph(),$=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await FM1(K);if(!G)return;if(WM1(K)==="srgb")vR.convertSRGBToLinear(G,G);let z=K.getName()||K.getURI(),v=(W=K.getSize())==null?void 0:W.join("x"),H=zM1(K);for(let V of X.listParentEdges(K)){let q=V.getParent();if(q!==J&&qM1(q,G,V.getName(),$))V.dispose()}if(K.listParents().length===1)K.dispose(),$.debug(`${D3}: Removed solid-color texture "${z}" (${v}px ${H.join(", ")})`)});await Promise.all(Q)}function qM1(Z,J,X,$){if(Z instanceof Q7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(QM1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(AD1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=fN;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return Es(ks(fs(),J,[0.5,0.5,1,1]))<=fN}return $.warn(`${D3}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function FM1(Z){let J=await xM1(Z);if(!J)return null;let X=[1/0,1/0,1/0,1/0],$=[-1/0,-1/0,-1/0,-1/0],Y=[0,0,0,0],[Q,K]=J.shape;for(let W=0;W<Q;W++){for(let G=0;G<K;G++)for(let z=0;z<4;z++)X[z]=Math.min(X[z],J.get(W,G,z)),$[z]=Math.max($[z],J.get(W,G,z));if(Es(ks(Y,$,X))/255>fN)return null}return $M1(Y,ZM1(Y,$,X),0.00196078431372549)}async function xM1(Z){try{return await Pn(Z.getImage(),Z.getMimeType())}catch(J){return null}}var MN="flatten",Gs={cleanup:!0};function Ss(Z=Gs){let J=RZ(Gs,Z);return m$(MN,async(X)=>{let $=X.getRoot(),Y=X.getLogger(),Q=new Set;for(let z of $.listSkins())for(let v of z.listJoints())Q.add(v);let K=new Set;for(let z of $.listAnimations())for(let v of z.listChannels()){let H=v.getTargetNode();if(H&&v.getTargetPath()!=="weights")K.add(H)}let W=new Set,G=new Set;for(let z of $.listScenes())z.traverse((v)=>{let H=v.getParentNode();if(!H)return;if(Q.has(H)||W.has(H))W.add(v);if(K.has(H)||G.has(H))G.add(v)});for(let z of $.listScenes())z.traverse((v)=>{if(K.has(v))return;if(W.has(v))return;if(G.has(v))return;MD1(v)});if(K.size)Y.debug(`${MN}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(Is({propertyTypes:[i.NODE],keepLeaves:!1}));Y.debug(`${MN}: Complete.`)})}function As(Z){return RG(Z)}var cM1={skipValidation:!1},zs=4294967295,{LINE_STRIP:wM1,LINE_LOOP:UM1,TRIANGLE_STRIP:BM1,TRIANGLE_FAN:jM1}=g1.Mode;function LM1(Z,J={}){let X=RZ(cM1,J),$=Z[0],Y=c6.fromGraph($.getGraph());if(!X.skipValidation&&new Set(Z.map(Bs)).size>1)throw new Error("Requires >=2 Primitives, sharing the same Material and Mode, with compatible vertex attributes and indices.");for(let q of Z)switch(q.getMode()){case wM1:case UM1:sD1(q);break;case BM1:case jM1:Os(q);break}let Q=[],K=new Uint32Array(Z.length),W=0,G=0;for(let q=0;q<Z.length;q++){let F=Z[q],x=F.getIndices(),c=F.getAttribute("POSITION").getCount(),w=x?x.getArray():null,B=x?x.getCount():c,j=new Uint32Array(c).fill(zs);for(let L=0;L<B;L++){let R=w?w[L]:L;if(j[R]===zs)j[R]=W++,K[q]++}Q.push(j),G+=B}let z=Y.createPrimitive().setMode($.getMode()).setMaterial($.getMaterial());for(let q of $.listSemantics()){let F=$.getAttribute(q),x=hJ[F.getComponentType()],c=MZ(Y,F).setArray(new x(W*F.getElementSize()));z.setAttribute(q,c)}let v=$.getIndices(),H=v?MZ(Y,v).setArray(IN(G,W)):null;z.setIndices(H);let V=0;for(let q=0;q<Q.length;q++){let F=Z[q],x=F.getIndices(),c=x?x.getCount():-1,w=Q[q];if(x&&H)MM1(x,w,H,V),V+=c;for(let B of z.listSemantics()){let j=F.getAttribute(B),L=z.getAttribute(B);DM1(j,x,w,L)}}return z}function DM1(Z,J,X,$){let Y=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),W=Z.getArray(),G=$.getArray(),z=new Uint8Array(Z.getCount());for(let v=0,H=J?J.getCount():K;v<H;v++){let V=Q?Q[v]:v,q=X[V];if(z[q])continue;for(let F=0;F<Y;F++)G[q*Y+F]=W[V*Y+F];z[q]=1}}function MM1(Z,J,X,$){let Y=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let W=0;W<Y;W++){let G=Q[W],z=J[G];K[$+W]=z}}var kN="join",{ROOT:RM1,NODE:NM1,MESH:OM1,PRIMITIVE:PM1,ACCESSOR:TM1}=i,RN=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],vs={keepMeshes:!1,keepNamed:!1,cleanup:!0,filter:()=>!0};function ms(Z=vs){let J=RZ(vs,Z);return m$(kN,async(X)=>{let $=X.getRoot(),Y=X.getLogger();for(let Q of $.listScenes())Vs(X,Q,J),Q.traverse((K)=>Vs(X,K,J));if(J.cleanup)await X.transform(Is({propertyTypes:[NM1,OM1,PM1,TM1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));Y.debug(`${kN}: Complete.`)})}function Vs(Z,J,X){let $=Z.getLogger(),Y={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let z=Q[G];if(!X.filter(z))continue;if(z.listParents().some((V)=>V instanceof QZ))continue;let H=z.getMesh();if(!H)continue;if(z.getExtension("EXT_mesh_gpu_instancing"))continue;if(z.getSkin())continue;for(let V of H.listPrimitives()){if(V.listTargets().length>0)continue;let q=V.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;gG(V),fM1(V);let F=Bs(V),x=H.getName()||z.getName();if(X.keepMeshes||X.keepNamed&&x)F+=`|${G}`;if(!(F in Y))Y[F]={prims:[],primMeshes:[],primNodes:[],dstNode:z,dstMesh:void 0};let c=Y[F];c.prims.push(V),c.primNodes.push(z)}}let K=Object.values(Y).filter(({prims:G})=>G.length>1),W=new Set(K.flatMap((G)=>G.primNodes));for(let G of W){let z=G.getMesh();if(z.listParents().some((H)=>{return H.propertyType!==RM1&&G!==H}))G.setMesh(z.clone())}for(let G of K){let{dstNode:z,primNodes:v}=G;G.dstMesh=z.getMesh(),G.primMeshes=v.map((H)=>H.getMesh())}for(let G of K){let{prims:z,primNodes:v,primMeshes:H,dstNode:V,dstMesh:q}=G,F=V.getMatrix();for(let w=0;w<z.length;w++){let B=v[w],j=H[w],L=z[w];if(j.removePrimitive(L),ON(L))L=z[w]=CM1(z[w]);if(B!==V)Ls(RN,RD1(RN,F),B.getMatrix()),Rs(L,RN)}let x=LM1(z),c=x.listAttributes()[0].getCount();q.addPrimitive(x),$.debug(`${kN}: Joined Primitives (${z.length}) containing ${NN(c)} vertices under Node "${V.getName()}".`)}}function CM1(Z){let J=Z.clone();for(let $ of J.listSemantics())J.setAttribute($,J.getAttribute($).clone());let X=J.getIndices();if(X)J.setIndices(X.clone());return J}function fM1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)CN(X)}}var{TRANSLATION:JO6,ROTATION:XO6,SCALE:$O6,WEIGHTS:YO6}=QZ.TargetPath;var kM1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var QO6=M3({level:"high"},kM1);var EM1="unweld";function IM1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let $=Z.getGraph(),Y=c6.fromGraph($),Q=Y.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,Hs(Y,G,X,J)),G.listParents().length===1)G.dispose();for(let G of Z.listTargets())for(let z of G.listAttributes())if(G.swap(z,Hs(Y,z,X,J)),z.listParents().length===1)z.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${EM1}: ${Sx(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function Hs(Z,J,X,$){if($.has(J)&&$.get(J).has(X))return $.get(J).get(X);let Y=J.getArray(),K=new Y.constructor(X.getCount()*J.getElementSize()),W=X.getArray(),G=J.getElementSize();for(let v=0,H=X.getCount();v<H;v++)for(let V=0;V<G;V++)K[v*G+V]=Y[W[v]*G+V];if(!$.has(J))$.set(J,new Map);let z=MZ(Z,J).setArray(K);return $.get(J).set(X,z),z}var qs;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(qs||(qs={}));var _M1=0.000001;function bM1(Z,J,X,$=0.0001){let Y=J.length/Z.length,Q=new Array(Y).fill(0),K=new Array(Y).fill(0),W=new Array(Y).fill(0),G=new Array(Y).fill(0),z=Z.length-1,v=1;for(let H=1;H<z;++H){let V=Z[v-1],q=Z[H],F=Z[H+1],x=(q-V)/(F-V),c=!1;if(q!==F&&(H!==1||q!==Z[0])){if(iG(J,v-1,G),iG(J,H,K),iG(J,H+1,W),X==="slerp"){let w=AM1(Q,G,W,x),B=xs(G,K)+xs(K,W);c=!Ix(K,w,$)||B+Number.EPSILON>=Math.PI}else if(X==="lerp"){let w=SM1(Q,G,W,x);c=!Ix(K,w,$)}else if(X==="step")c=!Ix(K,G)||!Ix(K,W)}if(c){if(H!==v)Z[v]=Z[H],Fs(J,v,iG(J,H,Q));v++}}if(z>0)Z[v]=Z[z],Fs(J,v,iG(J,z,Q)),v++;return v}function iG(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)X[$]=Z[J*Y+$];return X}function Fs(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)Z[J*Y+$]=X[$]}function Ix(Z,J,X=0){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>X)return!1;return!0}function hM1(Z,J,X){return Z*(1-X)+J*X}function SM1(Z,J,X,$){for(let Y=0;Y<J.length;Y++)Z[Y]=hM1(J[Y],X[Y],$);return Z}function AM1(Z,J,X,$){let Y=J[0],Q=J[1],K=J[2],W=J[3],G=X[0],z=X[1],v=X[2],H=X[3],V,q,F,x,c;if(q=Y*G+Q*z+K*v+W*H,q<0)q=-q,G=-G,z=-z,v=-v,H=-H;if(1-q>_M1)V=Math.acos(q),F=Math.sin(V),x=Math.sin((1-$)*V)/F,c=Math.sin($*V)/F;else x=1-$,c=$;return Z[0]=x*Y+c*G,Z[1]=x*Q+c*z,Z[2]=x*K+c*v,Z[3]=x*W+c*H,Z}function xs(Z,J){let X=mM1(Z,J);return Math.acos(2*X*X-1)}function mM1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var KO6=new Float32Array(0),WO6={ready:Promise.resolve(),resample:bM1,tolerance:0.0001,cleanup:!0};var S$="simplify",{POINTS:us,LINES:uM1,LINE_STRIP:lM1,LINE_LOOP:yM1,TRIANGLES:pM1,TRIANGLE_STRIP:ls,TRIANGLE_FAN:ys}=g1.Mode,ps={ratio:0,error:0.0001,lockBorder:!1};function is(Z){let J=RZ(ps,Z),X=J.simplifier;if(!X)throw new Error(`${S$}: simplifier dependency required — install "meshoptimizer".`);return m$(S$,async($)=>{let Y=$.getLogger();await X.ready,await $.transform(_N({overwrite:!1}));let Q=0;for(let K of $.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G!==pM1&&G!==ls&&G!==ys&&G!==us){Q++;continue}if(iM1(W,J),A$(W,B6.RENDER)===0)ws(W)}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)Y.warn(`${S$}: Skipped ${Q} primitives: Unsupported draw mode.`);Y.debug(`${S$}: Complete.`)})}function iM1(Z,J){let X=M3({},ps,J),$=X.simplifier,Y=Z.getGraph(),Q=c6.fromGraph(Y),K=Q.getLogger();switch(Z.getMode()){case us:return gM1(Q,Z,X);case uM1:case lM1:case yM1:return K.warn(`${S$}: Skipping primitive simplification: Unsupported draw mode.`),Z;case ls:case ys:Os(Z);break}let W=A$(Z,B6.UPLOAD),G=A$(Z,B6.RENDER);if(G<W/2)gG(Z);let z=Z.getAttribute("POSITION"),v=Z.getIndices(),H=z.getArray(),V=v.getArray();if(!(H instanceof Float32Array))H=hx(H,z.getComponentType(),z.getNormalized());if(!(V instanceof Uint32Array))V=new Uint32Array(V);let q=Math.floor(X.ratio*G/3)*3,F=X.lockBorder?["LockBorder"]:[],[x,c]=$.simplify(V,H,3,q,X.error,F);if(Z.setIndices(MZ(Q,v).setArray(x)),v.listParents().length===1)v.dispose();gG(Z);let w=A$(Z,B6.UPLOAD);if(w<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${S$}: ${Sx(W,w)} vertices, error: ${c.toFixed(4)}.`),Z}function gM1(Z,J,X){let $=X.simplifier,Y=Z.getLogger();if(J.getIndices())IM1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),z=K.getArray(),v=W?W.getArray():void 0,H=W?W.getComponentSize():void 0;if(!(z instanceof Float32Array))z=hx(z,K.getComponentType(),K.getNormalized());if(v&&!(v instanceof Float32Array))v=hx(v,K.getComponentType(),K.getNormalized());let V=Math.floor(X.ratio*G),q=$.simplifyPoints(z,3,V,v,H),[F,x]=$.compactMesh(q);Y.debug(`${S$}: ${Sx(K.getCount(),x)} vertices.`);for(let c of Ax(J)){let w=MZ(Z,c);if(PN(c,null,F,w,x),UD1(J,c,w),c.listParents().length===1)c.dispose()}return J}var EN;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(EN||(EN={}));var GO6={resizeFilter:EN.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var rs=t(os(),1);var N3={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DIRECTORIES:[(()=>{try{return h5.dirname(g.resolve("@hytopia.com/assets"))}catch{return null}})(),h5.resolve(process.cwd(),"assets")].filter(Boolean),OPTIMIZER_RUNS:[{suffix:"",options:["--compress","false","--instance","false","--simplify","false"]},{suffix:"-named-nodes",options:["--compress","false","--instance","false","--simplify","false","--join","true","--join-named","false"]}]};class j6{static instance=new j6;optimize=!0;optimizeEveryStart=!1;_modelUriDocuments=new Map;_modelUriBoundingBoxes=new Map;_modelUriNodeNames=new Map;_modelUriTrimeshes=new Map;constructor(){}async preloadModels(){let Z=await this._getAbsoluteModelPaths();console.log(`ModelRegistry.preloadModels(): Preloading ${Z.length} models...`);for(let J of Z){if(this.optimize)await this._resolveOptimizedModelPath(J);await this._loadModelData(J)}console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models!`)}getAnimationNames(Z){let J=this._modelUriDocuments.get(Z);if(!J)p.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J.getRoot().listAnimations().map(($)=>$.getName())}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)p.fatalError(`ModelRegistry.getBoundingBox(): Model ${Z} not found!`);return J}getDepth(Z){let J=this.getBoundingBox(Z);return J.max.z-J.min.z}getHeight(Z){let J=this.getBoundingBox(Z);return J.max.y-J.min.y}getNodeNames(Z){let J=this._modelUriNodeNames.get(Z);if(!J)p.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){p.error(`ModelRegistry.getTrimesh(): Model ${Z} not found!`);return}let $=X.vertices;if(J!==1){$=new Float32Array($.length);for(let Y=0;Y<$.length;Y++)$[Y]=X.vertices[Y]*J}return{vertices:$,indices:X.indices}}getWidth(Z){let J=this.getBoundingBox(Z);return J.max.x-J.min.x}modelHasNode(Z,J){let X=this._modelUriNodeNames.get(Z);if(!X)p.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=h5.normalize(Z);for(let X of N3.DIRECTORIES){let $=h5.normalize(X);if(J.startsWith($))return h5.relative($,J).replace(/\\/g,"/")}return h5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of N3.DIRECTORIES){let X=h5.resolve(process.cwd(),J);if(!gJ.existsSync(X))continue;let $=await AF("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let Y of $)Z.push(h5.join(X,Y))}return Z}async _loadModelData(Z){let J=await new xR().read(Z),X=As(J.getRoot().listScenes()[0]),$=J.getRoot().listNodes().map((Q)=>Q.getName()),Y=this._absoluteModelPathToModelUri(Z);this._modelUriDocuments.set(Y,J),this._modelUriBoundingBoxes.set(Y,{min:{x:X.min[0],y:X.min[1],z:X.min[2]},max:{x:X.max[0],y:X.max[1],z:X.max[2]}}),this._modelUriNodeNames.set(Y,$),this._modelUriTrimeshes.set(Y,await this._buildTrimesh(Y))}async _resolveOptimizedModelPath(Z){let J=this._buildOptimizedModelPath(Z);if(!this.optimizeEveryStart&&this._isOptimizedVersionValid(Z))return J;return await this._optimizeModel(Z,J)}_isOptimizedVersionValid(Z){let J=`${this._buildOptimizedModelPath(Z)}${N3.CHECKSUM_EXT}`;if(!gJ.existsSync(J))return!1;let X=this._calculateChecksum(Z),$=gJ.readFileSync(J,"utf8");return X===$}_calculateChecksum(Z){if(!gJ.existsSync(Z))return"";let J=gJ.readFileSync(Z);return oM1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=h5.basename(Z),X=J.replace(/\.[^/.]+$/,""),$=h5.dirname(Z),Y=h5.join($,N3.OPTIMIZED_DIR,X);return h5.join(Y,J)}async _buildTrimesh(Z,J=1,X=0.001){let $=this._modelUriDocuments.get(Z);if(!$)p.fatalError(`ModelRegistry._buildTrimesh(): Model ${Z} not found!`);let Y=Cs($);Y.setLogger(new z5(DG.WARN)),await Y.transform(js({pivot:"center"}),Ss(),ms(),_N(),is({simplifier:rs.MeshoptSimplifier,ratio:J,error:X}),Ps());for(let q of Y.getRoot().listScenes())for(let F of q.listChildren())Ns(F);let Q=[],K=0,W=0;for(let q of Y.getRoot().listMeshes())for(let F of q.listPrimitives()){let x=F.getAttribute("POSITION"),c=F.getIndices();if(!x||!c)continue;let w=x.getArray(),B=c.getArray(),j=B instanceof Uint32Array?B:new Uint32Array(B);if(w.length===0||j.length===0)continue;Q.push({vertices:w,indices:j}),K+=w.length,W+=j.length}if(Q.length===0){p.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no primitives with POSITION and INDICES!`);return}let G=new Float32Array(K),z=new Uint32Array(W),v=0,H=0,V=0;for(let q of Q){G.set(q.vertices,v);let F=q.vertices.length/3;for(let x=0;x<q.indices.length;x++)z[V+x]=q.indices[x]+H;v+=q.vertices.length,V+=q.indices.length,H+=F}return{vertices:G,indices:z}}async _optimizeModel(Z,J){let X=h5.dirname(J);gJ.rmSync(X,{recursive:!0,force:!0}),gJ.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let $ of N3.OPTIMIZER_RUNS){let Y=J.replace(/(\.[^/.]+)$/,`${$.suffix}$1`),{stderr:Q}=await Hi("npx",["@gltf-transform/cli","optimize",Z,Y,...$.options]);if(Q)return p.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return gJ.writeFileSync(`${J}${N3.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var oG;((Y)=>{Y.DYNAMIC="dynamic";Y.FIXED="fixed";Y.KINEMATIC_POSITION="kinematic_position";Y.KINEMATIC_VELOCITY="kinematic_velocity"})(oG||={});var uN=0.001,ts="dynamic";class u$ extends B0{_additionalMass=0;_colliders=new Set;_explicitSleep=!1;_enabledPositions={x:!0,y:!0,z:!0};_enabledRotations={x:!0,y:!0,z:!0};_rigidBody;_rigidBodyDesc;_rigidBodyType;_simulation;constructor(Z){super();Z.type??=ts,this._rigidBodyDesc=this._createRigidBodyDesc(Z),this._rigidBodyType=Z.type,this._applyRigidBodyOptions(Z),this._autoAddToSimulation(Z)}get additionalMass(){if(!this._requireNotRemoved("additionalMass"))return 0;return this._additionalMass}get additionalSolverIterations(){if(!this._requireNotRemoved("additionalSolverIterations"))return 0;return this._rigidBody?this._rigidBody.additionalSolverIterations():this._rigidBodyDesc.additionalSolverIterations}get angularDamping(){if(!this._requireNotRemoved("angularDamping"))return 0;return this._rigidBody?this._rigidBody.angularDamping():this._rigidBodyDesc.angularDamping}get angularVelocity(){if(!this._requireNotRemoved("angularVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.angvel():this._rigidBodyDesc.angvel}get colliders(){return this._colliders}get dominanceGroup(){if(!this._requireNotRemoved("dominanceGroup"))return 0;return this._rigidBody?this._rigidBody.dominanceGroup():this._rigidBodyDesc.dominanceGroup}get directionFromRotation(){let{x:Z,y:J,z:X,w:$}=this.rotation;return{x:-2*(Z*X+$*J),y:-2*(J*X-$*Z),z:-(1-2*(Z*Z+J*J))}}get effectiveAngularInertia(){if(!this._requireNotRemoved("effectiveAngularInertia"))return;return this._rigidBody?this._rigidBody.effectiveAngularInertia():void 0}get effectiveInverseMass(){if(!this._requireNotRemoved("effectiveInverseMass"))return;return this._rigidBody?this._rigidBody.effectiveInvMass():void 0}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("effectiveWorldInversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.effectiveWorldInvInertiaSqrt():void 0}get enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get inversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("inversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.invPrincipalInertiaSqrt():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(Z){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(Z,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(Z)}setAdditionalMassProperties(Z){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:J,centerOfMass:X,principalAngularInertia:$,principalAngularInertiaLocalFrame:Y}=Z;this._rigidBody?this._rigidBody.setAdditionalMassProperties(J,X,$,Y,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMassProperties(J,X,$,Y)}setAdditionalSolverIterations(Z){if(!this._requireDynamic("setAdditionalSolverIterations"))return;if(!this._requireNotRemoved("setAdditionalSolverIterations"))return;this._rigidBody?this._rigidBody.setAdditionalSolverIterations(Z):this._rigidBodyDesc.setAdditionalSolverIterations(Z)}setAngularDamping(Z){if(!this._requireDynamic("setAngularDamping"))return;if(!this._requireNotRemoved("setAngularDamping"))return;this._rigidBody?this._rigidBody.setAngularDamping(Z):this._rigidBodyDesc.setAngularDamping(Z)}setAngularVelocity(Z){if(!this._requireNotKinematicPositionBased("setAngularVelocity"))return;if(!this._requireNotRemoved("setAngularVelocity"))return;this._rigidBody?this._rigidBody.setAngvel(Z,!this._explicitSleep):this._rigidBodyDesc.setAngvel(Z)}setCcdEnabled(Z){if(!this._requireDynamic("setCcdEnabled"))return;if(!this._requireNotRemoved("setCcdEnabled"))return;this._rigidBody?this._rigidBody.enableCcd(Z):this._rigidBodyDesc.setCcdEnabled(Z)}setDominanceGroup(Z){if(!this._requireDynamic("setDominanceGroup"))return;if(!this._requireNotRemoved("setDominanceGroup"))return;this._rigidBody?this._rigidBody.setDominanceGroup(Z):this._rigidBodyDesc.setDominanceGroup(Z)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._rigidBody?this._rigidBody.setEnabled(Z):this._rigidBodyDesc.setEnabled(Z)}setEnabledPositions(Z){if(!this._requireDynamic("setEnabledPositions"))return;if(!this._requireNotRemoved("setEnabledPositions"))return;this._rigidBody?this._rigidBody.setEnabledTranslations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledTranslations(Z.x,Z.y,Z.z),this._enabledPositions=Z}setEnabledRotations(Z){if(!this._requireDynamic("setEnabledRotations"))return;if(!this._requireNotRemoved("setEnabledRotations"))return;this._rigidBody?this._rigidBody.setEnabledRotations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledRotations(Z.x,Z.y,Z.z),this._enabledRotations=Z}setGravityScale(Z){if(!this._requireDynamic("setGravityScale"))return;if(!this._requireNotRemoved("setGravityScale"))return;this._rigidBody?this._rigidBody.setGravityScale(Z,!this._explicitSleep):this._rigidBodyDesc.setGravityScale(Z)}setLinearDamping(Z){if(!this._requireDynamic("setLinearDamping"))return;if(!this._requireNotRemoved("setLinearDamping"))return;this._rigidBody?this._rigidBody.setLinearDamping(Z):this._rigidBodyDesc.setLinearDamping(Z)}setLinearVelocity(Z){if(!this._requireNotKinematicPositionBased("setLinearVelocity"))return;if(!this._requireNotRemoved("setLinearVelocity"))return;this._rigidBody?this._rigidBody.setLinvel(Z,!this._explicitSleep):this._rigidBodyDesc.setLinvel(Z.x,Z.y,Z.z)}setNextKinematicRotation(Z){if(!this._requireKinematic("setNextKinematicRotation"))return;if(!this._requireNotRemoved("setNextKinematicRotation"))return;this._rigidBody?this._rigidBody.setNextKinematicRotation(Z):this._rigidBodyDesc.setRotation(Z)}setNextKinematicPosition(Z){if(!this._requireKinematic("setNextKinematicPosition"))return;if(!this._requireNotRemoved("setNextKinematicPosition"))return;this._rigidBody?this._rigidBody.setNextKinematicTranslation(Z):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setPosition(Z){if(!this._requireNotRemoved("setPosition"))return;this._rigidBody?this._rigidBody.setTranslation(Z,!this._explicitSleep):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setRotation(Z){if(!this._requireNotRemoved("setRotation"))return;this._rigidBody?this._rigidBody.setRotation(Z,!this._explicitSleep):this._rigidBodyDesc.setRotation(Z)}setSleeping(Z){if(!this._requireDynamic("setSleeping"))return;if(!this._requireNotRemoved("setSleeping"))return;this._rigidBody?Z?this._rigidBody.sleep():this._rigidBody.wakeUp():this._rigidBodyDesc.sleeping=Z,this._explicitSleep=Z}setSoftCcdPrediction(Z){if(!this._requireDynamic("setSoftCcdPrediction"))return;if(!this._requireNotRemoved("setSoftCcdPrediction"))return;this._rigidBody?this._rigidBody.setSoftCcdPrediction(Z):this._rigidBodyDesc.setSoftCcdPrediction(Z)}setCollisionGroupsForSolidColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSolidColliders"))return;this._colliders.forEach((J)=>{if(J.isSensor)return;J.setCollisionGroups(Z)})}setCollisionGroupsForSensorColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSensorColliders"))return;this._colliders.forEach((J)=>{if(!J.isSensor)return;J.setCollisionGroups(Z)})}setType(Z){if(!this._requireNotRemoved("setType"))return;let X={["dynamic"]:X1.RigidBodyType.Dynamic,["fixed"]:X1.RigidBodyType.Fixed,["kinematic_position"]:X1.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:X1.RigidBodyType.KinematicVelocityBased}[Z];if(X===void 0)return p.error(`Invalid RigidBodyType: ${Z}`);this._rigidBody?this._rigidBody.setBodyType(X,!this._explicitSleep):this._rigidBodyDesc.status=X,this._rigidBodyType=Z}addForce(Z){if(!this._requireNotRemoved("addForce"))return;if(!this._requireCreated("addForce"))return;if(!this._requireDynamic("addForce"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addForce(Z,!this._explicitSleep)}addTorque(Z){if(!this._requireNotRemoved("addTorque"))return;if(!this._requireCreated("addTorque"))return;if(!this._requireDynamic("addTorque"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addTorque(Z,!this._explicitSleep)}addChildColliderToSimulation(Z){if(!this._requireNotRemoved("addChildColliderToSimulation"))return;if(!this._requireCreated("addChildColliderToSimulation"))return;Z.addToSimulation(this._simulation,this)}addToSimulation(Z){if(!this._requireNotRemoved("addToSimulation"))return;if(this._rigidBody)return p.error("RigidBody.addToSimulation(): Rigid body already exists in the simulation!");this._simulation=Z,this._rigidBody=this._simulation.createRawRigidBody(this._rigidBodyDesc),this._colliders.forEach((J)=>{if(!J.isSimulated)J.addToSimulation(Z,this)})}applyImpulse(Z){if(!this._requireNotRemoved("applyImpulse"))return;if(!this._requireCreated("applyImpulse"))return;if(!this._requireDynamic("applyImpulse"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulse(Z,!this._explicitSleep)}applyImpulseAtPoint(Z,J){if(!this._requireNotRemoved("applyImpulseAtPoint"))return;if(!this._requireCreated("applyImpulseAtPoint"))return;if(!this._requireDynamic("applyImpulseAtPoint"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulseAtPoint(Z,J,!this._explicitSleep)}applyTorqueImpulse(Z){if(!this._requireNotRemoved("applyTorqueImpulse"))return;if(!this._requireCreated("applyTorqueImpulse"))return;if(!this._requireDynamic("applyTorqueImpulse"))return;this._rigidBody.applyTorqueImpulse(Z,!this._explicitSleep)}createAndAddChildCollider(Z){if(!this._requireNotRemoved("createAndAddChildCollider"))return null;return this._simulation?new S5({...Z,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(Z)}createAndAddChildColliders(Z){let J=[];return Z.forEach((X)=>{let $=this.createAndAddChildCollider(X);if($)J.push($)}),J}getCollidersByTag(Z){let J=[];for(let X of this._colliders)if(X.tag===Z)J.push(X);return J}linkCollider(Z){if(!this._requireNotRemoved("linkCollider"))return;if(Z.parentRigidBody!==this)return p.error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(Z)}lockAllRotations(){if(!this._requireNotRemoved("lockAllRotations"))return;this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){if(!this._requireNotRemoved("lockAllPositions"))return;this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._rigidBody)return p.error("RigidBody.removeFromSimulation(): Rigid body does not exist in the simulation!");this._colliders.forEach((Z)=>{Z.removeFromSimulation()}),this._simulation.removeRawRigidBody(this._rigidBody),this._simulation=void 0,this._rigidBody=void 0}unlinkCollider(Z){if(!this._requireNotRemoved("unlinkCollider"))return;if(!Z.isRemoved)return p.error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(Z)}resetAngularVelocity(){if(!this._requireNotRemoved("resetAngularVelocity"))return;if(!this._requireCreated("resetAngularVelocity"))return;this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){if(!this._requireNotRemoved("resetForces"))return;if(!this._requireCreated("resetForces"))return;this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){if(!this._requireNotRemoved("resetLinearVelocity"))return;if(!this._requireCreated("resetLinearVelocity"))return;this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){if(!this._requireNotRemoved("resetTorques"))return;if(!this._requireCreated("resetTorques"))return;this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){if(!this._requireNotRemoved("sleep"))return;this.setSleeping(!0)}wakeUp(){if(!this._requireNotRemoved("wakeUp"))return;this.setSleeping(!1)}_applyRigidBodyOptions(Z){[["additionalMass",this.setAdditionalMass.bind(this)],["additionalMassProperties",this.setAdditionalMassProperties.bind(this)],["additionalSolverIterations",this.setAdditionalSolverIterations.bind(this)],["angularDamping",this.setAngularDamping.bind(this)],["angularVelocity",this.setAngularVelocity.bind(this)],["dominanceGroup",this.setDominanceGroup.bind(this)],["ccdEnabled",this.setCcdEnabled.bind(this)],["enabled",this.setEnabled.bind(this)],["enabledPositions",this.setEnabledPositions.bind(this)],["enabledRotations",this.setEnabledRotations.bind(this)],["gravityScale",this.setGravityScale.bind(this)],["linearDamping",this.setLinearDamping.bind(this)],["linearVelocity",this.setLinearVelocity.bind(this)],["position",this.setPosition.bind(this)],["rotation",this.setRotation.bind(this)],["sleeping",this.setSleeping.bind(this)],["softCcdPrediction",this.setSoftCcdPrediction.bind(this)]].forEach(([X,$])=>{if(X in Z)$(Z[X])})}_autoAddToSimulation(Z){if(Z.colliders)this._createAndAddPendingChildColliders(Z.colliders);if(Z.simulation)this.addToSimulation(Z.simulation)}_createAndAddPendingChildCollider(Z){if(!this._requireNotRemoved("createAndAddPendingChildCollider"))return null;if(!this._requireNotSimulated("createAndAddPendingChildCollider"))return null;let J=new S5(Z);return this._colliders.add(J),J}_createAndAddPendingChildColliders(Z){let J=[];return Z.forEach((X)=>{let $=this._createAndAddPendingChildCollider(X);if($)J.push($)}),J}_createRigidBodyDesc(Z){let J=Z.type??ts;return{["dynamic"]:()=>X1.RigidBodyDesc.dynamic(),["fixed"]:()=>X1.RigidBodyDesc.fixed(),["kinematic_position"]:()=>X1.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>X1.RigidBodyDesc.kinematicVelocityBased()}[J]()}_requireCreated(Z){if(!this._rigidBody||!this._simulation)p.error(`RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody&&!!this._simulation}_requireDynamic(Z){if(!this.isDynamic)p.error(`RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method: ${Z}()`);return this.isDynamic}_requireKinematic(Z){if(!this.isKinematic)p.error(`RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method: ${Z}()`);return this.isKinematic}_requireNotKinematicPositionBased(Z){if(this.isKinematicPositionBased)p.error(`RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method: ${Z}()`);return!this.isKinematicPositionBased}_requireNotRemoved(Z){if(!this._rigidBody&&!this._rigidBodyDesc)p.error(`RigidBody._requireNotRemoved(): Rigid body has been removed and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody||!!this._rigidBodyDesc}_requireNotSimulated(Z){if(this.isSimulated)p.error(`RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method: ${Z}()`);return!this.isSimulated}_isNegligibleVector(Z){return Math.abs(Z.x)<uN&&Math.abs(Z.y)<uN&&Math.abs(Z.z)<uN}}var lN;((Y)=>{Y[Y.Average=0]="Average";Y[Y.Min=1]="Min";Y[Y.Multiply=2]="Multiply";Y[Y.Max=3]="Max"})(lN||={});var O3;((v)=>{v.NONE="none";v.BALL="ball";v.BLOCK="block";v.CAPSULE="capsule";v.CONE="cone";v.CYLINDER="cylinder";v.ROUND_CYLINDER="round-cylinder";v.TRIMESH="trimesh";v.VOXELS="voxels";v.WEDGE="wedge"})(O3||={});class S5 extends B0{_collider;_colliderDesc;_onCollision;_parentRigidBody;_relativePosition={x:0,y:0,z:0};_relativeRotation={x:0,y:0,z:0,w:1};_shape;_simulation;_tag;constructor(Z){super();this._colliderDesc=this._createColliderDesc(Z),this._shape=Z.shape,this._applyColliderOptions(Z),this._autoAddToSimulation(Z)}static optionsFromBlockHalfExtents(Z){return{shape:"block",halfExtents:Z}}static optionsFromModelUri(Z,J=1,X){let $=j6.instance.getBoundingBox(Z),Y=$.max.x-$.min.x,Q=$.max.y-$.min.y,K=$.max.z-$.min.z,W=Math.max(Y,K),G=Math.min(Y,K),z=W/G,v=W/Q,H=W*J/2,V=(B)=>Math.max(0.01,B),q=()=>({shape:"block",halfExtents:{x:V(Y*J/2),y:V(Q*J/2),z:V(K*J/2)}}),F=()=>({shape:"round-cylinder",radius:V(H),halfHeight:V(Q*J/2),borderRadius:V(H*0.1)}),x=()=>{let B=j6.instance.getTrimesh(Z,J);if(!B)return;return{shape:"trimesh",vertices:B.vertices,indices:B.indices}},c=()=>({shape:"wedge",extents:{x:Y*J,y:Q*J,z:K*J}}),w=()=>({shape:"capsule",radius:V(H),halfHeight:V(Q*J/2-H)});if(X)switch(X){case"block":return q();case"capsule":return w();case"round-cylinder":return F();case"trimesh":{let B=x();if(!B){p.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return B}case"wedge":return c();default:p.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(z>2)return q();if(v>1.5)return F();return w()}get bounciness(){if(!this._requireNotRemoved("bounciness"))return 0;return this._collider?this._collider.restitution():this._colliderDesc.restitution}get bouncinessCombineRule(){if(!this._requireNotRemoved("bouncinessCombineRule"))return 0;return this._collider?this._collider.restitutionCombineRule():this._colliderDesc.restitutionCombineRule}get collisionGroups(){if(!this._requireNotRemoved("collisionGroups"))return{belongsTo:[],collidesWith:[]};return this._collider?v9.decodeRawCollisionGroups(this._collider.collisionGroups()):v9.decodeRawCollisionGroups(this._colliderDesc.collisionGroups)}get friction(){if(!this._requireNotRemoved("friction"))return 0;return this._collider?this._collider.friction():this._colliderDesc.friction}get frictionCombineRule(){if(!this._requireNotRemoved("frictionCombineRule"))return 0;return this._collider?this._collider.frictionCombineRule():this._colliderDesc.frictionCombineRule}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._collider?this._collider.isEnabled():this._colliderDesc.enabled}get isRemoved(){return!this._collider&&!this._colliderDesc}get isSensor(){if(!this._requireNotRemoved("isSensor"))return!1;return this._collider?this._collider.isSensor():this._colliderDesc.isSensor}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return!!this._collider}get parentRigidBody(){if(!this._requireNotRemoved("parentRigidBody"))return;return this._parentRigidBody}get rawCollider(){if(!this._requireNotRemoved("rawCollider"))return;return this._collider}get rawShape(){if(!this._requireNotRemoved("rawShape"))return;return this._collider?this._collider.shape:this._colliderDesc.shape}get relativePosition(){if(!this._requireNotRemoved("relativePosition"))return{x:0,y:0,z:0};return this._relativePosition}get relativeRotation(){if(!this._requireNotRemoved("relativeRotation"))return{x:0,y:0,z:0,w:1};return this._relativeRotation}get shape(){if(!this._requireNotRemoved("shape"))return"none";return this._shape}get tag(){if(!this._requireNotRemoved("tag"))return;return this._tag}setBounciness(Z){if(!this._requireNotRemoved("setBounciness"))return;this._collider?this._collider.setRestitution(Z):this._colliderDesc.setRestitution(Z)}setBouncinessCombineRule(Z){if(!this._requireNotRemoved("setBouncinessCombineRule"))return;this._collider?this._collider.setRestitutionCombineRule(Z):this._colliderDesc.setRestitutionCombineRule(Z)}setCollisionGroups(Z){if(!this._requireNotRemoved("setCollisionGroups"))return;let J=v9.buildRawCollisionGroups(Z);this._collider?this._collider.setCollisionGroups(J):this._colliderDesc.setCollisionGroups(J)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._collider?this._collider.setEnabled(Z):this._colliderDesc.setEnabled(Z)}setFriction(Z){if(!this._requireNotRemoved("setFriction"))return;this._collider?this._collider.setFriction(Z):this._colliderDesc.setFriction(Z)}setFrictionCombineRule(Z){if(!this._requireNotRemoved("setFrictionCombineRule"))return;this._collider?this._collider.setFrictionCombineRule(Z):this._colliderDesc.setFrictionCombineRule(Z)}setMass(Z){if(!this._requireNotRemoved("setMass"))return;this._collider?this._collider.setMass(Z):this._colliderDesc.setMass(Z)}setOnCollision(Z){if(!this._requireNotRemoved("setOnCollision"))return;if(this._onCollision=Z,this.isSimulated)if(this.enableCollisionEvents(!!Z),Z)this._simulation.colliderMap.setColliderCollisionCallback(this,Z);else this._simulation.colliderMap.removeColliderCollisionCallback(this)}setRelativeRotation(Z){if(!this._requireNotRemoved("setRelativeRotation"))return;this._relativeRotation=Z,this._collider?this._collider.parent()?this._collider.setRotationWrtParent(Z):this._collider.setRotation(Z):this._colliderDesc.setRotation(Z)}setRelativePosition(Z){if(!this._requireNotRemoved("setRelativePosition"))return;this._relativePosition=Z,this._collider?this._collider.parent()?this._collider.setTranslationWrtParent(Z):this._collider.setTranslation(Z):this._colliderDesc.setTranslation(Z.x,Z.y,Z.z)}setSensor(Z){if(!this._requireNotRemoved("setSensor"))return;this._collider?this._collider.setSensor(Z):this._colliderDesc.setSensor(Z)}setTag(Z){if(!this._requireNotRemoved("setTag"))return;this._tag=Z}setVoxel(Z,J){if(!this._requireNotRemoved("setVoxel"))return;if(!this._requireSimulated("setVoxel"))return;if(this.shape!=="voxels")return p.error("Collider.setVoxel(): Collider is not a voxels collider!");this._collider.setVoxel(Z.x,Z.y,Z.z,J)}addToSimulation(Z,J){if(!this._requireNotRemoved("addToSimulation"))return;if(!this._requireUnsimulated("addToSimulation"))return;if(J){if(!J.isSimulated)return p.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")p.warning("Collider.addToSimulation(): Trimesh colliders are strongly discouraged to be used with dynamic rigid bodies, they will not contribute any mass!")}if(this._simulation=Z,this._parentRigidBody=J,this._collider=this._simulation.createRawCollider(this._colliderDesc,J?.rawRigidBody),this._colliderDesc=void 0,J)J.linkCollider(this);if(this._onCollision)this.setOnCollision(this._onCollision)}combineVoxelStates(Z){if(!this._requireNotRemoved("combineVoxelStates"))return;if(!this._requireSimulated("combineVoxelStates"))return;if(!Z.isSimulated)return p.error("Collider.combineVoxelStates(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Other collider is not a voxels collider!");this._collider.combineVoxelStates(Z.rawCollider,0,0,0)}enableCollisionEvents(Z){if(!this._requireNotRemoved("enableCollisionEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|X1.ActiveEvents.COLLISION_EVENTS:J&~X1.ActiveEvents.COLLISION_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}enableContactForceEvents(Z){if(!this._requireNotRemoved("enableContactForceEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|X1.ActiveEvents.CONTACT_FORCE_EVENTS:J&~X1.ActiveEvents.CONTACT_FORCE_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}propagateVoxelChange(Z,J){if(!this._requireNotRemoved("propagateVoxelChange"))return;if(!this._requireSimulated("propagateVoxelChange"))return;if(!Z.isSimulated)return p.error("Collider.propagateVoxelChange(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Other collider is not a voxels collider!");this._collider.propagateVoxelChange(Z.rawCollider,J.x,J.y,J.z,0,0,0)}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._requireSimulated("removeFromSimulation"))return;if(this._simulation.removeRawCollider(this._collider),this._simulation=void 0,this._collider=void 0,this._parentRigidBody)this._parentRigidBody.unlinkCollider(this);this._parentRigidBody=void 0}scale(Z){if(!this._requireNotRemoved("scale"))return;switch(this.setRelativePosition({x:this.relativePosition.x*Z,y:this.relativePosition.y*Z,z:this.relativePosition.z*Z}),this._shape){case"ball":{if(this._collider)this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.radius*=Z;return}case"block":{if(this._collider){let J=this._collider.halfExtents();this._collider.setHalfExtents({x:J.x*Z,y:J.y*Z,z:J.z*Z})}else this._colliderDesc.shape.halfExtents.x*=Z,this._colliderDesc.shape.halfExtents.y*=Z,this._colliderDesc.shape.halfExtents.z*=Z;return}case"capsule":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cone":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"round-cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRoundRadius(this._collider.roundRadius()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight=this._colliderDesc.shape.halfHeight*Z,this._colliderDesc.shape.borderRadius=this._colliderDesc.shape.borderRadius*Z,this._colliderDesc.shape.radius=this._colliderDesc.shape.radius*Z;return}case"trimesh":{p.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"voxels":{p.error("Collider.setScale(): Voxels colliders cannot be scaled!");return}case"wedge":{p.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:p.fatalError(`Collider.setScale(): ${this._shape} is not a valid collider shape!`)}}_applyColliderOptions(Z){[["bounciness",this.setBounciness.bind(this)],["bouncinessCombineRule",this.setBouncinessCombineRule.bind(this)],["collisionGroups",this.setCollisionGroups.bind(this)],["enabled",this.setEnabled.bind(this)],["friction",this.setFriction.bind(this)],["frictionCombineRule",this.setFrictionCombineRule.bind(this)],["isSensor",this.setSensor.bind(this)],["mass",this.setMass.bind(this)],["onCollision",this.setOnCollision.bind(this)],["relativePosition",this.setRelativePosition.bind(this)],["relativeRotation",this.setRelativeRotation.bind(this)],["tag",this.setTag.bind(this)]].forEach(([X,$])=>{if(Z[X]!==void 0)$.call(this,Z[X])})}_autoAddToSimulation(Z){if(Z.simulation)this.addToSimulation(Z.simulation,Z.parentRigidBody)}_buildWedgeConvexHullVertices(Z){let{x:J,y:X,z:$}=Z,Y=J/2,Q=$/2,K=X/2;return new Float32Array([-Y,0-K,-Q,Y,0-K,-Q,Y,0-K,Q,-Y,0-K,Q,-Y,X-K,-Q,Y,X-K,-Q])}_createColliderDesc(Z){let{shape:J,flags:X}=Z;switch(J){case"ball":{if(!Z.radius)p.fatalError("Ball collider must have a radius!");return X1.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)p.fatalError("Block collider must have halfExtents!");return X1.ColliderDesc.cuboid(Z.halfExtents.x,Z.halfExtents.y,Z.halfExtents.z)}case"capsule":{if(!Z.halfHeight||!Z.radius)p.fatalError("Capsule collider must have halfHeight and radius!");return X1.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cone collider must have radius and halfHeight!");return X1.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cylinder collider must have radius and halfHeight!");return X1.ColliderDesc.cylinder(Z.halfHeight,Z.radius)}case"round-cylinder":{if(!Z.radius||!Z.halfHeight||!Z.borderRadius)p.fatalError("Round cylinder collider must have radius, halfHeight, and borderRadius!");return X1.ColliderDesc.roundCylinder(Z.halfHeight,Z.radius,Z.borderRadius)}case"trimesh":{if(!Z.indices||!Z.vertices)p.fatalError("Trimesh collider must have vertices and indices!");return X1.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)p.fatalError("Voxels collider must have coordinates and size!");return X1.ColliderDesc.voxels(this._coordinatesToInt32Array(Z.coordinates),Z.size)}case"wedge":{if(!Z.extents)p.fatalError("Wedge collider must have extents!");let $=this._buildWedgeConvexHullVertices(Z.extents),Y=X1.ColliderDesc.convexHull($);if(!Y)throw p.fatalError("Failed to create convex hull for wedge collider!"),new Error("Convex hull creation failed");return Y}default:p.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)p.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)p.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)p.error(`Collider._requireNotRemoved(): Collider is removed, invoked method: ${Z}()`);return!this.isRemoved}_setActiveCollisionTypes(){(this._collider??this._colliderDesc).setActiveCollisionTypes(X1.ActiveCollisionTypes.DYNAMIC_DYNAMIC|X1.ActiveCollisionTypes.DYNAMIC_KINEMATIC|X1.ActiveCollisionTypes.DYNAMIC_FIXED|X1.ActiveCollisionTypes.KINEMATIC_KINEMATIC|X1.ActiveCollisionTypes.KINEMATIC_FIXED)}_coordinatesToInt32Array(Z){let J=new Int32Array(Z.length*3);for(let X=0;X<Z.length;X++){let $=Z[X],Y=X*3;J[Y]=Math.floor($.x),J[Y+1]=Math.floor($.y),J[Y+2]=Math.floor($.z)}return J}}var rM1={shape:"voxels"},yN;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(yN||={});class A5 extends B0{_id;_customColliderOptions;_halfExtents;_isLiquid;_lightLevel;_name;_textureUri;constructor(Z={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(Z.id<0)p.fatalError("BlockType.constructor(): BlockType id not set.");super();this._id=Z.id,this._customColliderOptions=Z.customColliderOptions,this._halfExtents=Z.halfExtents??{x:0.5,y:0.5,z:0.5},this._isLiquid=Z.isLiquid??!1,this._name=Z.name,this._textureUri=Z.textureUri,this._lightLevel=Math.min(Z.lightLevel??0,15)}get id(){return this._id}get colliderOptions(){return{...this._customColliderOptions,...rM1}}get halfExtents(){return this._halfExtents}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}get lightLevel(){return this._lightLevel}get name(){return this._name}get size(){return{x:this._halfExtents.x*2,y:this._halfExtents.y*2,z:this._halfExtents.z*2}}get textureUri(){return this._textureUri}createCollider(Z){let J=new S5({...this.colliderOptions,coordinates:Z,size:this.size});if(this.isLiquid)J.setSensor(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_COLLISION")||this.isLiquid)J.enableCollisionEvents(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))J.enableContactForceEvents(!0);if(v9.isDefaultCollisionGroups(J.collisionGroups))J.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return J}serialize(){return T0.serializeBlockType(this)}}var pN;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(pN||={});class rG extends B0{_blockTypes=new Map;_world;constructor(Z){super();this._world=Z}get world(){return this._world}getAllBlockTypes(){return Array.from(this._blockTypes.values())}getBlockType(Z){let J=this._blockTypes.get(Z);if(!J)p.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends A5{constructor($=Z){super($)}};return this.registerBlockType(X),X}registerBlockType(Z){this._blockTypes.set(Z.id,Z),this.emitWithWorld(this._world,"BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE",{blockTypeRegistry:this,id:Z.id,blockType:Z})}serialize(){return T0.serializeBlockTypeRegistry(this)}}var jP={};_Q(jP,{worldSchema:()=>BP,worldPacketDefinition:()=>d00,vectorSchema:()=>W1,vectorBooleanSchema:()=>sk1,uiSchema:()=>wP,uiPacketDefinition:()=>i00,uiDatasSchema:()=>UP,uiDatasPacketDefinition:()=>g00,uiDataSendPacketDefinition:()=>C00,uiDataSchema:()=>Lz,syncResponseSchema:()=>cP,syncResponsePacketDefinition:()=>p00,syncRequestSchema:()=>iO,syncRequestPacketDefinition:()=>T00,stateRequestSchema:()=>pO,stateRequestPacketDefinition:()=>P00,sceneUIsSchema:()=>xP,sceneUIsPacketDefinition:()=>y00,sceneUISchema:()=>FP,rgbColorSchema:()=>D6,registeredPackets:()=>fc,quaternionSchema:()=>XP,playersSchema:()=>qP,playersPacketDefinition:()=>l00,playerSchema:()=>HP,physicsDebugRenderSchema:()=>VP,physicsDebugRenderPacketDefinition:()=>m00,physicsDebugRaycastsSchema:()=>vP,physicsDebugRaycastsPacketDefinition:()=>u00,physicsDebugRaycastSchema:()=>zP,particleEmittersSchema:()=>GP,particleEmittersPacketDefinition:()=>A00,particleEmitterSchema:()=>WP,outboundPackets:()=>Cc,modelNodeOverrideSchema:()=>JP,lightsSchema:()=>KP,lightsPacketDefinition:()=>S00,lightSchema:()=>QP,isValidPacket:()=>rk1,inputSchema:()=>yO,inputPacketDefinition:()=>O00,inboundPackets:()=>Tc,hexColorSchema:()=>uO,heartbeatSchema:()=>mO,heartbeatPacketDefinition:()=>M00,entitySchema:()=>$P,entitiesSchema:()=>YP,entitiesPacketDefinition:()=>h00,definePacket:()=>f0,debugConfigSchema:()=>lO,debugConfigPacketDefinition:()=>N00,createPacket:()=>mk1,connectionSchema:()=>AO,connectionPacketDefinition:()=>D00,chunksSchema:()=>ZP,chunksPacketDefinition:()=>b00,chunkSchema:()=>eO,chatMessagesSchema:()=>tO,chatMessagesPacketDefinition:()=>_00,chatMessageSendPacketDefinition:()=>R00,chatMessageSchema:()=>jz,cameraSchema:()=>rO,cameraPacketDefinition:()=>I00,blocksSchema:()=>nO,blocksPacketDefinition:()=>k00,blockTypesSchema:()=>oO,blockTypesPacketDefinition:()=>E00,blockTypeSchema:()=>sO,blockSchema:()=>aO,bidirectionalPackets:()=>Pc,audiosSchema:()=>dO,audiosPacketDefinition:()=>f00,audioSchema:()=>gO,PacketId:()=>C1});var Pc={};_Q(Pc,{heartbeatPacketDefinition:()=>M00,connectionPacketDefinition:()=>D00});var hO=t(j00(),1);class SO extends hO.default{static instance=new hO.default}var C1;((O)=>{O[O.SYNC_REQUEST=0]="SYNC_REQUEST";O[O.INPUT=1]="INPUT";O[O.STATE_REQUEST=2]="STATE_REQUEST";O[O.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";O[O.UI_DATA_SEND=4]="UI_DATA_SEND";O[O.SYNC_RESPONSE=32]="SYNC_RESPONSE";O[O.AUDIOS=33]="AUDIOS";O[O.BLOCKS=34]="BLOCKS";O[O.BLOCK_TYPES=35]="BLOCK_TYPES";O[O.CHAT_MESSAGES=36]="CHAT_MESSAGES";O[O.CHUNKS=37]="CHUNKS";O[O.ENTITIES=38]="ENTITIES";O[O.WORLD=39]="WORLD";O[O.CAMERA=40]="CAMERA";O[O.UI=41]="UI";O[O.UI_DATAS=42]="UI_DATAS";O[O.SCENE_UIS=43]="SCENE_UIS";O[O.LIGHTS=44]="LIGHTS";O[O.PLAYERS=45]="PLAYERS";O[O.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";O[O.CONNECTION=116]="CONNECTION";O[O.HEARTBEAT=117]="HEARTBEAT";O[O.DEBUG_CONFIG=128]="DEBUG_CONFIG";O[O.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";O[O.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(C1||={});function mk1(Z,J,X){if(!Z.validate(J))throw new Error(`Invalid payload for packet with id ${Z.id}. Error: ${SO.instance.errorsText(Z.validate.errors)}`);let $=[Z.id,J];if(typeof X==="number")$.push(X);return $}function f0(Z,J){return{id:Z,schema:J,validate:SO.instance.compile(J)}}var uk1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},L00={type:"object",properties:{role:{type:"string",enum:["auto","client","server"],nullable:!0},fingerprints:{type:"array",items:{type:"object",properties:{algorithm:{type:"string",enum:["sha-1","sha-224","sha-256","sha-384","sha-512"]},value:{type:"string"}},required:["algorithm","value"]}}},required:["fingerprints"],additionalProperties:!1},lk1={type:"object",properties:{foundation:{type:"string"},priority:{type:"number"},ip:{type:"string"},address:{type:"string"},protocol:{type:"string",enum:["udp","tcp"]},port:{type:"number"},type:{type:"string",enum:["host"]},tcpType:{type:"string",enum:["passive"],nullable:!0}},required:["foundation","priority","ip","address","protocol","port","type"],additionalProperties:!1},yk1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},pk1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},ik1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},gk1={type:"object",properties:{streamId:{type:"number"},ordered:{type:"boolean",nullable:!0},maxPacketLifeTime:{type:"number",nullable:!0},maxRetransmits:{type:"number",nullable:!0}},required:["streamId"],additionalProperties:!1},dk1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:yk1,ic:{type:"array",items:lk1},d:L00,s:ik1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},ak1={type:"object",properties:{i:{type:"string"},d:L00},required:["i","d"],additionalProperties:!1},nk1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:gk1},required:["l","s"],additionalProperties:!1},AO={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},c:{...ak1,nullable:!0},ca:{...uk1,nullable:!0},d:{type:"array",items:{...nk1},nullable:!0},pa:{...pk1,nullable:!0},t:{type:"array",items:{...dk1},nullable:!0}},additionalProperties:!1};var D00=f0(116,AO);var mO={type:"null",nullable:!0};var M00=f0(117,mO);var Tc={};_Q(Tc,{uiDataSendPacketDefinition:()=>C00,syncRequestPacketDefinition:()=>T00,stateRequestPacketDefinition:()=>P00,inputPacketDefinition:()=>O00,debugConfigPacketDefinition:()=>N00,chatMessageSendPacketDefinition:()=>R00});var uO={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var jz={type:"object",properties:{m:{type:"string"},c:{...uO,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var R00=f0(3,jz);var lO={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var N00=f0(128,lO);var yO={type:"object",properties:{"1":{type:"boolean",nullable:!0},"2":{type:"boolean",nullable:!0},"3":{type:"boolean",nullable:!0},"4":{type:"boolean",nullable:!0},"5":{type:"boolean",nullable:!0},"6":{type:"boolean",nullable:!0},"7":{type:"boolean",nullable:!0},"8":{type:"boolean",nullable:!0},"9":{type:"boolean",nullable:!0},"0":{type:"boolean",nullable:!0},w:{type:"boolean",nullable:!0},a:{type:"boolean",nullable:!0},s:{type:"boolean",nullable:!0},d:{type:"boolean",nullable:!0},q:{type:"boolean",nullable:!0},e:{type:"boolean",nullable:!0},r:{type:"boolean",nullable:!0},f:{type:"boolean",nullable:!0},z:{type:"boolean",nullable:!0},x:{type:"boolean",nullable:!0},c:{type:"boolean",nullable:!0},v:{type:"boolean",nullable:!0},u:{type:"boolean",nullable:!0},i:{type:"boolean",nullable:!0},o:{type:"boolean",nullable:!0},j:{type:"boolean",nullable:!0},k:{type:"boolean",nullable:!0},l:{type:"boolean",nullable:!0},n:{type:"boolean",nullable:!0},m:{type:"boolean",nullable:!0},sp:{type:"boolean",nullable:!0},sh:{type:"boolean",nullable:!0},tb:{type:"boolean",nullable:!0},ml:{type:"boolean",nullable:!0},mr:{type:"boolean",nullable:!0},cp:{type:"number",nullable:!0},cy:{type:"number",nullable:!0},sq:{type:"number",nullable:!0}},additionalProperties:!1};var O00=f0(1,yO);var pO={type:"object",properties:{},additionalProperties:!1};var P00=f0(2,pO);var iO={type:"null",nullable:!0};var T00=f0(0,iO);var Lz={type:"object",properties:{},additionalProperties:!0};var C00=f0(4,Lz);var Cc={};_Q(Cc,{worldPacketDefinition:()=>d00,uiPacketDefinition:()=>i00,uiDatasPacketDefinition:()=>g00,syncResponsePacketDefinition:()=>p00,sceneUIsPacketDefinition:()=>y00,playersPacketDefinition:()=>l00,physicsDebugRenderPacketDefinition:()=>m00,physicsDebugRaycastsPacketDefinition:()=>u00,particleEmittersPacketDefinition:()=>A00,lightsPacketDefinition:()=>S00,entitiesPacketDefinition:()=>h00,chunksPacketDefinition:()=>b00,chatMessagesPacketDefinition:()=>_00,cameraPacketDefinition:()=>I00,blocksPacketDefinition:()=>k00,blockTypesPacketDefinition:()=>E00,audiosPacketDefinition:()=>f00});var W1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var gO={type:"object",properties:{i:{type:"number"},a:{type:"string",nullable:!0},cd:{type:"number",nullable:!0},d:{type:"number",nullable:!0},de:{type:"number",nullable:!0},di:{type:"number",minimum:0,nullable:!0},e:{type:"number",nullable:!0},l:{type:"boolean",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pl:{type:"boolean",nullable:!0},pr:{type:"number",minimum:0,nullable:!0},r:{type:"boolean",nullable:!0},rd:{type:"number",nullable:!0},s:{type:"number",nullable:!0},v:{type:"number",minimum:0,maximum:1,nullable:!0}},required:["i"],additionalProperties:!1};var dO={type:"array",items:{...gO}};var f00=f0(33,dO);var aO={type:"object",properties:{i:{type:"number"},c:W1},required:["i","c"],additionalProperties:!1};var nO={type:"array",items:{...aO}};var k00=f0(34,nO);var sO={type:"object",properties:{i:{type:"number"},l:{type:"boolean",nullable:!0},ll:{type:"number",nullable:!0},n:{type:"string",nullable:!0},t:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var oO={type:"array",items:{...sO}};var E00=f0(35,oO);var rO={type:"object",properties:{m:{type:"number",nullable:!0},e:{type:"number",nullable:!0},et:{type:"number",nullable:!0},fo:{type:"number",nullable:!0},ffo:{type:"number",nullable:!0},fv:{type:"number",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pt:{...W1,nullable:!0},pl:{...W1,nullable:!0},s:{type:"array",items:{type:"string"},nullable:!0},sa:{type:"number",nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var tO={type:"array",items:{...jz}};var eO={type:"object",properties:{c:W1,b:{type:"array",items:{type:"number",minimum:0,maximum:255},minItems:4096,maxItems:4096,nullable:!0},rm:{type:"boolean",nullable:!0}},required:["c"],additionalProperties:!1};var ZP={type:"array",items:{...eO}};var D6={type:"array",items:[{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255}],minItems:3,maxItems:3};var JP={type:"object",properties:{n:{type:"string"},h:{type:"boolean",nullable:!0},o:{type:"number",minimum:0,maximum:1,nullable:!0},r:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},t:{...D6,nullable:!0}},required:["n"],additionalProperties:!1};var XP={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var $P={type:"object",properties:{i:{type:"number"},al:{type:"array",items:{type:"string"},nullable:!0},ao:{type:"array",items:{type:"string"},nullable:!0},ap:{type:"number",nullable:!0},as:{type:"array",items:{type:"string"},nullable:!0},bh:{...W1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...JP},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...XP,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...D6,nullable:!0}},required:["i"],additionalProperties:!1};var YP={type:"array",items:{...$P}};var QP={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...D6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",minimum:0,maximum:1,nullable:!0},rm:{type:"boolean",nullable:!0},t:{type:"number",nullable:!0},te:{type:"number",nullable:!0},tp:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var KP={type:"array",items:{...QP}};var WP={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},b:{type:"number",nullable:!0},ce:{...D6,nullable:!0},cev:{...D6,nullable:!0},cs:{...D6,nullable:!0},csv:{...D6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...W1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...W1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pv:{...W1,nullable:!0},r:{type:"number",nullable:!0},rv:{type:"number",nullable:!0},rm:{type:"boolean",nullable:!0},se:{type:"number",nullable:!0},sev:{type:"number",nullable:!0},ss:{type:"number",nullable:!0},ssv:{type:"number",nullable:!0},t:{type:"boolean",nullable:!0},tu:{type:"string",nullable:!0},v:{...W1,nullable:!0},vv:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var GP={type:"array",items:{...WP}};var zP={type:"object",properties:{o:{...W1},d:{...W1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var vP={type:"array",items:{...zP}};var VP={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var HP={type:"object",properties:{i:{type:"string"},p:{type:"string",nullable:!0},rm:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var qP={type:"array",items:{...HP}};var FP={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"object",nullable:!0},t:{type:"string",nullable:!0},v:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var xP={type:"array",items:{...FP}};var cP={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var wP={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var UP={type:"array",items:{...Lz}};var sk1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var BP={type:"object",properties:{i:{type:"number"},ac:{...D6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...D6,nullable:!0},di:{type:"number",nullable:!0},dp:{...W1,nullable:!0},fc:{...D6,nullable:!0},ff:{type:"number",nullable:!0},fn:{type:"number",nullable:!0},n:{type:"string",nullable:!0},s:{type:"string",nullable:!0},si:{type:"number",nullable:!0},t:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var I00=f0(40,rO);var _00=f0(36,tO);var b00=f0(37,ZP);var h00=f0(38,YP);var S00=f0(44,KP);var A00=f0(46,GP);var m00=f0(192,VP);var u00=f0(193,vP);var l00=f0(45,qP);var y00=f0(43,xP);var p00=f0(32,cP);var i00=f0(41,wP);var g00=f0(42,UP);var d00=f0(39,BP);var fc=new Map,ok1={...Pc,...Tc,...Cc};for(let Z of Object.values(ok1))if("id"in Z&&"schema"in Z){let J=Z;if(fc.has(J.id))throw new Error(`Packet with id ${J.id} is already registered.`);fc.set(J.id,J)}function rk1(Z){if(typeof Z!=="object"||Z===null||typeof Z[0]!=="number"||Z[0]<0||Z[1]===void 0||Z[2]!==void 0&&(typeof Z[2]!=="number"||Z[2]<0))return!1;let J=fc.get(Z[0]);return!!J&&J.validate(Z[1])}var Y0=jP;import t$ from"fs";import D80 from"path";var xI1=t(l10(),1),cI1=t(OP(),1),wI1=t(TP(),1),r$=t(lc(),1),bP=t(n10(),1);var s10=r$.default;function w5(Z){if(Z===null)return"null";if(Array.isArray(Z))return"array";return typeof Z}function XX(Z){return w5(Z)==="object"}function UI1(Z){return Array.isArray(Z)&&Z.length>0&&Z.every((J)=>("message"in J))}function hP(Z,J){return Z.length<124?Z:J}var o10="graphql-transport-ws";var u5=((Z)=>{return Z[Z.InternalServerError=4500]="InternalServerError",Z[Z.InternalClientError=4005]="InternalClientError",Z[Z.BadRequest=4400]="BadRequest",Z[Z.BadResponse=4004]="BadResponse",Z[Z.Unauthorized=4401]="Unauthorized",Z[Z.Forbidden=4403]="Forbidden",Z[Z.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",Z[Z.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",Z[Z.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",Z[Z.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",Z[Z.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",Z})(u5||{}),l5=((Z)=>{return Z.ConnectionInit="connection_init",Z.ConnectionAck="connection_ack",Z.Ping="ping",Z.Pong="pong",Z.Subscribe="subscribe",Z.Next="next",Z.Error="error",Z.Complete="complete",Z})(l5||{});function r10(Z){if(!XX(Z))throw new Error(`Message is expected to be an object, but got ${w5(Z)}`);if(!Z.type)throw new Error("Message is missing the 'type' property");if(typeof Z.type!=="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${w5(Z.type)}`);switch(Z.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(Z.payload!=null&&!XX(Z.payload))throw new Error(`"${Z.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${Z.payload}"`);break}case"subscribe":{if(typeof Z.id!=="string")throw new Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${w5(Z.id)}`);if(!Z.id)throw new Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!XX(Z.payload))throw new Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${w5(Z.payload)}`);if(typeof Z.payload.query!=="string")throw new Error(`"${Z.type}" message payload expects the 'query' property to be a string, but got ${w5(Z.payload.query)}`);if(Z.payload.variables!=null&&!XX(Z.payload.variables))throw new Error(`"${Z.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${w5(Z.payload.variables)}`);if(Z.payload.operationName!=null&&w5(Z.payload.operationName)!=="string")throw new Error(`"${Z.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${w5(Z.payload.operationName)}`);if(Z.payload.extensions!=null&&!XX(Z.payload.extensions))throw new Error(`"${Z.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${w5(Z.payload.extensions)}`);break}case"next":{if(typeof Z.id!=="string")throw new Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${w5(Z.id)}`);if(!Z.id)throw new Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!XX(Z.payload))throw new Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${w5(Z.payload)}`);break}case"error":{if(typeof Z.id!=="string")throw new Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${w5(Z.id)}`);if(!Z.id)throw new Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!UI1(Z.payload))throw new Error(`"${Z.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(Z.payload)}`);break}case"complete":{if(typeof Z.id!=="string")throw new Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${w5(Z.id)}`);if(!Z.id)throw new Error(`"${Z.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${Z.type}"`)}return Z}function t10(Z,J){return r10(typeof Z==="string"?JSON.parse(Z,J):Z)}function i3(Z,J){return r10(Z),JSON.stringify(Z,J)}function AP(Z){let{url:J,connectionParams:X,lazy:$=!0,onNonLazyError:Y=console.error,lazyCloseTimeout:Q=0,keepAlive:K=0,disablePong:W,connectionAckWaitTimeout:G=0,retryAttempts:z=5,retryWait:v=async function C(b){let I=Math.pow(2,b);await new Promise((a)=>setTimeout(a,I*1000+Math.floor(Math.random()*2700+300)))},shouldRetry:H=SP,on:V,webSocketImpl:q,generateID:F=function C(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(b)=>{let I=Math.random()*16|0;return(b=="x"?I:I&3|8).toString(16)})},jsonMessageReplacer:x,jsonMessageReviver:c}=Z,w;if(q){if(!jI1(q))throw new Error("Invalid WebSocket implementation provided");w=q}else if(typeof WebSocket!=="undefined")w=WebSocket;else if(typeof global!=="undefined")w=global.WebSocket||global.MozWebSocket;else if(typeof window!=="undefined")w=window.WebSocket||window.MozWebSocket;if(!w)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let B=w,j=(()=>{let C=(()=>{let I={};return{on(a,s){return I[a]=s,()=>{delete I[a]}},emit(a){if("id"in a)I[a.id]?.(a)}}})(),b={connecting:V?.connecting?[V.connecting]:[],opened:V?.opened?[V.opened]:[],connected:V?.connected?[V.connected]:[],ping:V?.ping?[V.ping]:[],pong:V?.pong?[V.pong]:[],message:V?.message?[C.emit,V.message]:[C.emit],closed:V?.closed?[V.closed]:[],error:V?.error?[V.error]:[]};return{onMessage:C.on,on(I,a){let s=b[I];return s.push(a),()=>{s.splice(s.indexOf(a),1)}},emit(I,...a){for(let s of[...b[I]])s(...a)}}})();function L(C){let b=[j.on("error",(I)=>{b.forEach((a)=>a()),C(I)}),j.on("closed",(I)=>{b.forEach((a)=>a()),C(I)})]}let R,M=0,N,P=!1,O=0,_=!1;async function k(){clearTimeout(N);let[C,b]=await(R??(R=new Promise((s,Z0)=>(async()=>{if(P){if(await v(O),!M)return R=void 0,Z0({code:1000,reason:"All Subscriptions Gone"});O++}j.emit("connecting",P);let o=new B(typeof J==="function"?await J():J,o10),M0,R0;function m0(){if(isFinite(K)&&K>0)clearTimeout(R0),R0=setTimeout(()=>{if(o.readyState===B.OPEN)o.send(i3({type:l5.Ping})),j.emit("ping",!1,void 0)},K)}L((s0)=>{if(R=void 0,clearTimeout(M0),clearTimeout(R0),Z0(s0),s0 instanceof pc)o.close(4499,"Terminated"),o.onerror=null,o.onclose=null}),o.onerror=(s0)=>j.emit("error",s0),o.onclose=(s0)=>j.emit("closed",s0),o.onopen=async()=>{try{j.emit("opened",o);let s0=typeof X==="function"?await X():X;if(o.readyState!==B.OPEN)return;if(o.send(i3(s0?{type:l5.ConnectionInit,payload:s0}:{type:l5.ConnectionInit},x)),isFinite(G)&&G>0)M0=setTimeout(()=>{o.close(u5.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},G);m0()}catch(s0){j.emit("error",s0),o.close(u5.InternalClientError,hP(s0 instanceof Error?s0.message:String(s0),"Internal client error"))}};let N1=!1;o.onmessage=({data:s0})=>{try{let B1=t10(s0,c);if(j.emit("message",B1),B1.type==="ping"||B1.type==="pong"){if(j.emit(B1.type,!0,B1.payload),B1.type==="pong")m0();else if(!W)o.send(i3(B1.payload?{type:l5.Pong,payload:B1.payload}:{type:l5.Pong})),j.emit("pong",!1,B1.payload);return}if(N1)return;if(B1.type!==l5.ConnectionAck)throw new Error(`First message cannot be of type ${B1.type}`);clearTimeout(M0),N1=!0,j.emit("connected",o,B1.payload,P),P=!1,O=0,s([o,new Promise((W4,RJ)=>L(RJ))])}catch(B1){o.onmessage=null,j.emit("error",B1),o.close(u5.BadResponse,hP(B1 instanceof Error?B1.message:String(B1),"Bad response"))}}})())));if(C.readyState===B.CLOSING)await b;let I=()=>{},a=new Promise((s)=>I=s);return[C,I,Promise.race([a.then(()=>{if(!M){let s=()=>C.close(1000,"Normal Closure");if(isFinite(Q)&&Q>0)N=setTimeout(()=>{if(C.readyState===B.OPEN)s()},Q);else s()}}),b])]}function h(C){if(SP(C)&&(BI1(C.code)||[u5.InternalServerError,u5.InternalClientError,u5.BadRequest,u5.BadResponse,u5.Unauthorized,u5.SubprotocolNotAcceptable,u5.SubscriberAlreadyExists,u5.TooManyInitialisationRequests].includes(C.code)))throw C;if(_)return!1;if(SP(C)&&C.code===1000)return M>0;if(!z||O>=z)throw C;if(!H(C))throw C;return P=!0}if(!$)(async()=>{M++;for(;;)try{let[,,C]=await k();await C}catch(C){try{if(!h(C))return}catch(b){return Y?.(b)}}})();function f(C,b){let I=F(C),a=!1,s=!1,Z0=()=>{M--,a=!0};return(async()=>{M++;for(;;)try{let[o,M0,R0]=await k();if(a)return M0();let m0=j.onMessage(I,(N1)=>{switch(N1.type){case l5.Next:{b.next(N1.payload);return}case l5.Error:{s=!0,a=!0,b.error(N1.payload),Z0();return}case l5.Complete:{a=!0,Z0();return}}});o.send(i3({id:I,type:l5.Subscribe,payload:C},x)),Z0=()=>{if(!a&&o.readyState===B.OPEN)o.send(i3({id:I,type:l5.Complete},x));M--,a=!0,M0()},await R0.finally(m0);return}catch(o){if(!h(o))return}})().then(()=>{if(!s)b.complete()}).catch((o)=>{b.error(o)}),()=>{if(!a)Z0()}}return{on:j.on,subscribe:f,iterate(C){let b=[],I={done:!1,error:null,resolve:()=>{}},a=f(C,{next(Z0){b.push(Z0),I.resolve()},error(Z0){I.done=!0,I.error=Z0,I.resolve()},complete(){I.done=!0,I.resolve()}}),s=async function*Z0(){for(;;){if(!b.length)await new Promise((o)=>I.resolve=o);while(b.length)yield b.shift();if(I.error)throw I.error;if(I.done)return}}();return s.throw=async(Z0)=>{if(!I.done)I.done=!0,I.error=Z0,I.resolve();return{done:!0,value:void 0}},s.return=async()=>{return a(),{done:!0,value:void 0}},s},async dispose(){if(_=!0,R){let[C]=await R;C.close(1000,"Normal Closure")}},terminate(){if(R)j.emit("closed",new pc)}}}class pc extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function SP(Z){return XX(Z)&&"code"in Z&&"reason"in Z}function BI1(Z){if([1000,1001,1006,1005,1012,1013,1014].includes(Z))return!1;return Z>=1000&&Z<=1999}function jI1(Z){return typeof Z==="function"&&"constructor"in Z&&"CLOSED"in Z&&"CLOSING"in Z&&"CONNECTING"in Z&&"OPEN"in Z}var M80=t(L80(),1);var kz="./dev/persistence";class O4{static instance=new O4;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;_gqlWs;constructor(){this._gqlWs=AP({url:"wss://prod.gql.hytopia.com/graphql",webSocketImpl:s10});try{this._creativeGateway=new M80.CreativeGateway}catch{console.warn(["━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","\uD83D\uDEA8 HYTOPIA PLATFORM GATEWAY IS NOT INITIALIZED \uD83D\uDEA8","","\uD83D\uDD27 Local development is still possible, but these features will be disabled:"," • \uD83D\uDC64 Player Accounts"," • \uD83C\uDFAD Player Cosmetics"," • \uD83D\uDC1B Crash Analytics & Debug Logs","","\uD83D\uDCA1 These features will be enabled but modified:"," • \uD83D\uDCBE Player & Global Persisted Data - Data will be persisted"," locally in the ./dev/persistence directory of your project."," Player ids for data persistence will begin at 1 for the first "," player to join your local server, and increments for each"," additional player. This means that if you restart your"," server, the first player id will be 1 again. This is to ensure"," that data persistence across server restarts can be easily"," tested and debugged in local development.","","To enable the HYTOPIA Platform Gateway locally:"," 1. Set these environment variables:"," HYTOPIA_API_KEY, HYTOPIA_GAME_ID, HYTOPIA_LOBBY_ID"," 2. You can find these values at: https://create.hytopia.com","","Note: In production, these environment variables will be auto-populated ","& the HYTOPIA Platform Gateway will automatically be initialized \uD83D\uDE80","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",""].join(`
400
400
  `))}}get isGatewayAvailable(){return!!this._creativeGateway}async getData(Z){if(!this._creativeGateway&&process.env.NODE_ENV==="production")return p.warning("PlatformGateway.getData(): You are running in production mode, but the Platform Gateway is not initialized! No data will be returned."),{error:{code:"gatewayError",message:"Platform Gateway is not initialized."}};return this._creativeGateway?await this._creativeGateway.kv.get(Z):this._readDevDataLocally(Z)}async getPlayerCosmetics(Z){let J=this._gqlWs.iterate({query:`{
401
401
  userById(id: "${Z}") {
402
402
  characterSettings { skinTone hairColor eyeColor hairStyle }
@@ -447,7 +447,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
447
447
  xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
448
448
  6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
449
449
  0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
450
- -----END RSA PRIVATE KEY-----`;var Cf=process.env.PORT??8080,ff="0.10.15",kf;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(kf||={});class FK extends B0{static instance=new FK;_webserver=YU.default();_internalHttpServer;constructor(){super();this._webserver.use((Z,J,X)=>{J.header("Access-Control-Allow-Origin","*"),X()}),this._webserver.get("/",(Z,J)=>{J.json({status:"OK",version:ff,runtime:"node"})}),this._webserver.use(YU.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(YU.default.static(ja1.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Ua1.createServer(this._webserver):Ba1.createServer({key:$U.existsSync("assets/certs/localhost.key")?$U.readFileSync("assets/certs/localhost.key"):zY0,cert:$U.existsSync("assets/certs/localhost.crt")?$U.readFileSync("assets/certs/localhost.crt"):GY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else p.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(Cf,this._onStarted),console.info(`WebServer.start(): Server running on port ${Cf}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return p.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=La1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&M7.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await O4.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
450
+ -----END RSA PRIVATE KEY-----`;var Cf=process.env.PORT??8080,ff="0.10.16",kf;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(kf||={});class FK extends B0{static instance=new FK;_webserver=YU.default();_internalHttpServer;constructor(){super();this._webserver.use((Z,J,X)=>{J.header("Access-Control-Allow-Origin","*"),X()}),this._webserver.get("/",(Z,J)=>{J.json({status:"OK",version:ff,runtime:"node"})}),this._webserver.use(YU.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(YU.default.static(ja1.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Ua1.createServer(this._webserver):Ba1.createServer({key:$U.existsSync("assets/certs/localhost.key")?$U.readFileSync("assets/certs/localhost.key"):zY0,cert:$U.existsSync("assets/certs/localhost.crt")?$U.readFileSync("assets/certs/localhost.crt"):GY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else p.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(Cf,this._onStarted),console.info(`WebServer.start(): Server running on port ${Cf}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return p.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=La1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&M7.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await O4.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
451
451
  Content-Type: text/plain\r
452
452
  Content-Length: ${W.length}\r
453
453
  Connection: close\r