hytopia 0.10.35-notifications-prerelease → 0.10.35-notifications-prerelease-3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.mjs +2 -2
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 fq1}from"node:buffer";import{StringDecoder as kq1}from"node:string_decoder";var vF=(Z,J,X)=>{if(X)return;if(Z)return{transform:Eq1.bind(void 0,new TextEncoder)};let $=new kq1(J);return{transform:Iq1.bind(void 0,$),final:_q1.bind(void 0,$)}},Eq1=function*(Z,J){if(fq1.isBuffer(J))yield o7(J);else if(typeof J==="string")yield Z.encode(J);else yield J},Iq1=function*(Z,J){yield _8(J)?Z.write(J):J},_q1=function*(Z){let J=Z.end();if(J!=="")yield J};import{callbackify as iy}from"node:util";var KM=iy(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:$=Sq1}=J[X];for await(let Y of $(Z))yield*VF(Y,J,X+1)},gy=async function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*hq1(X,Number(J),Z)},hq1=async function*(Z,J,X){if(Z===void 0)return;for await(let $ of Z())yield*VF($,X,J+1)},dy=iy(async({currentIterable:Z},J)=>{if(Z!==void 0){await(J?Z.throw(J):Z.return());return}if(J)throw J}),Sq1=function*(Z){yield Z};var WM=(Z,J,X,$)=>{try{for(let Y of Z(...J))X.push(Y);$()}catch(Y){$(Y)}},ay=(Z,J)=>[...J.flatMap((X)=>[...N$(X,Z,0)]),...eW(Z)],N$=function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:$=Aq1}=J[X];for(let Y of $(Z))yield*N$(Y,J,X+1)},eW=function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*bq1(X,Number(J),Z)},bq1=function*(Z,J,X){if(Z===void 0)return;for(let $ of Z())yield*N$($,X,J+1)},Aq1=function*(Z){yield Z};var GM=({value:Z,value:{transform:J,final:X,writableObjectMode:$,readableObjectMode:Y},optionName:Q},{encoding:K})=>{let W={},G=sy(Z,K,Q),z=P$(J),v=P$(X),H=z?KM.bind(void 0,VF,W):WM.bind(void 0,N$),V=z||v?KM.bind(void 0,gy,W):WM.bind(void 0,eW),q=z||v?dy.bind(void 0,W):void 0;return{stream:new mq1({writableObjectMode:$,writableHighWaterMark:ny($),readableObjectMode:Y,readableHighWaterMark:ny(Y),transform(c,w,x){H([c,G,0],this,x)},flush(c){V([G],this,c)},destroy:q})}},HF=(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=sy(K,X,W);Z=ay(G,Z)}return Z},sy=({transform:Z,final:J,binary:X,writableObjectMode:$,readableObjectMode:Y,preserveNewlines:Q},K,W)=>{let G={};return[{transform:ly($,W)},vF(X,K,$),zF(X,Q,$,G),{transform:Z,final:J},{transform:yy(Y,W)},uy({binary:X,preserveNewlines:Q,readableObjectMode:Y,state:G})].filter(Boolean)};var oy=(Z,J)=>{for(let X of uq1(Z))lq1(Z,X,J)},uq1=(Z)=>new Set(Object.entries(Z).filter(([,{direction:J}])=>J==="input").map(([J])=>Number(J))),lq1=(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 TypeError(`Only the \`stdin\` option, not \`${G}\`, can be ${EJ[W]} with synchronous methods.`)}let K=Y.map(({contents:W})=>W).map((W)=>yq1(W,$));X.input=gW(K)},yq1=(Z,J)=>{let X=HF(Z,J,"utf8",!0);return pq1(X),gW(X)},pq1=(Z)=>{let J=Z.find((X)=>typeof X!=="string"&&!_8(X));if(J!==void 0)throw 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 aq1,appendFileSync as nq1}from"node:fs";var qF=({stdioItems:Z,encoding:J,verboseInfo:X,fdNumber:$})=>$!=="all"&&lQ(X,$)&&!E5.has(J)&&iq1($)&&(Z.some(({type:Y,value:Q})=>Y==="native"&&gq1.has(Q))||Z.every(({type:Y})=>v4.has(Y))),iq1=(Z)=>Z===1||Z===2,gq1=new Set(["pipe","overlapped"]),ry=async(Z,J,X,$)=>{for await(let Y of Z)if(!dq1(J))ey(Y,X,$)},ty=(Z,J,X)=>{for(let $ of Z)ey($,J,X)},dq1=(Z)=>Z._readableState.pipes.length>0,ey=(Z,J,X)=>{let $=Rq(Z);t9({type:"output",verboseMessage:$,fdNumber:J,verboseInfo:X})};var Zp=({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)=>sq1({result:G,fileDescriptors:Z,fdNumber:z,state:Q,outputFiles:K,isMaxBuffer:$,verboseInfo:Y},X)),...Q}},sq1=({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=Jy(Z,Q,H),q=o7(V),{stdioItems:F,objectMode:c}=J[X],w=oq1([q],F,G,$),{serializedResult:x,finalResult:j=x}=rq1({chunks:w,objectMode:c,encoding:G,lines:z,stripFinalNewline:v,fdNumber:X});tq1({serializedResult:x,fdNumber:X,state:$,verboseInfo:K,encoding:G,stdioItems:F,objectMode:c});let B=W[X]?j:void 0;try{if($.error===void 0)eq1(x,F,Y);return B}catch(L){return $.error=L,B}},oq1=(Z,J,X,$)=>{try{return HF(Z,J,X,!1)}catch(Y){return $.error=Y,Z}},rq1=({chunks:Z,objectMode:J,encoding:X,lines:$,stripFinalNewline:Y,fdNumber:Q})=>{if(J)return{serializedResult:Z};if(X==="buffer")return{serializedResult:gW(Z)};let K=cm(Z,X);if($[Q])return{serializedResult:K,finalResult:QM(K,!Y[Q],J)};return{serializedResult:K}},tq1=({serializedResult:Z,fdNumber:J,state:X,verboseInfo:$,encoding:Y,stdioItems:Q,objectMode:K})=>{if(!qF({stdioItems:Q,encoding:Y,verboseInfo:$,fdNumber:J}))return;let W=QM(Z,!1,K);try{ty(W,J,$)}catch(G){X.error??=G}},eq1=(Z,J,X)=>{for(let{path:$,append:Y}of J.filter(({type:Q})=>WF.has(Q))){let Q=typeof $==="string"?$:$.toString();if(Y||X.has(Q))nq1($,Z);else X.add(Q),aq1($,Z)}};var Jp=([,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,ZZ(J,X,"all")];if(Array.isArray(J))return[ZZ(Z,X,"all"),...J];if(_8(Z)&&_8(J))return FD([Z,J]);return`${Z}${J}`};import{once as zM}from"node:events";var Xp=async(Z,J)=>{let[X,$]=await ZF1(Z);return J.isForcefullyTerminated??=!1,[X,$]},ZF1=async(Z)=>{let[J,X]=await Promise.allSettled([zM(Z,"spawn"),zM(Z,"exit")]);if(J.status==="rejected")return[];return X.status==="rejected"?$p(Z):X.value},$p=async(Z)=>{try{return await zM(Z,"exit")}catch{return $p(Z)}},Yp=async(Z)=>{let[J,X]=await Z;if(!JF1(J,X)&&vM(J,X))throw new e9;return[J,X]},JF1=(Z,J)=>Z===void 0&&J===void 0,vM=(Z,J)=>Z!==0||J!==null;var Qp=({error:Z,status:J,signal:X,output:$},{maxBuffer:Y})=>{let Q=XF1(Z,J,X),K=Q?.code==="ETIMEDOUT",W=Zy(Q,$,Y);return{resultError:Q,exitCode:J,signal:X,timedOut:K,isMaxBuffer:W}},XF1=(Z,J,X)=>{if(Z!==void 0)return Z;return vM(J,X)?new e9:void 0};var Kp=(Z,J,X)=>{let{file:$,commandArguments:Y,command:Q,escapedCommand:K,startTime:W,verboseInfo:G,options:z,fileDescriptors:v}=YF1(Z,J,X),H=WF1({file:$,commandArguments:Y,options:z,command:Q,escapedCommand:K,verboseInfo:G,fileDescriptors:v,startTime:W});return oQ(H,G,z)},YF1=(Z,J,X)=>{let{command:$,escapedCommand:Y,startTime:Q,verboseInfo:K}=Nq(Z,J,X),W=QF1(X),{file:G,commandArguments:z,options:v}=sq(Z,J,W);KF1(v);let H=Sy(v,K);return{file:G,commandArguments:z,command:$,escapedCommand:Y,startTime:Q,verboseInfo:K,options:v,fileDescriptors:H}},QF1=(Z)=>Z.node&&!Z.ipc?{...Z,ipc:!1}:Z,KF1=({ipc:Z,ipcInput:J,detached:X,cancelSignal:$})=>{if(J)FF("ipcInput");if(Z)FF("ipc: true");if(X)FF("detached: true");if($)FF("cancelSignal")},FF=(Z)=>{throw TypeError(`The "${Z}" option cannot be used with synchronous methods.`)},WF1=({file:Z,commandArguments:J,options:X,command:$,escapedCommand:Y,verboseInfo:Q,fileDescriptors:K,startTime:W})=>{let G=GF1({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}=Qp(G,X),{output:F,error:c=z}=Zp({fileDescriptors:K,syncResult:G,options:X,isMaxBuffer:q,verboseInfo:Q}),w=F.map((j,B)=>ZZ(j,X,B)),x=ZZ(Jp(F,X),X,"all");return vF1({error:c,exitCode:v,signal:H,timedOut:V,isMaxBuffer:q,stdio:w,all:x,options:X,command:$,escapedCommand:Y,startTime:W})},GF1=({file:Z,commandArguments:J,options:X,command:$,escapedCommand:Y,fileDescriptors:Q,startTime:K})=>{try{oy(Q,X);let W=zF1(X);return $F1(Z,J,W)}catch(W){return sQ({error:W,command:$,escapedCommand:Y,fileDescriptors:Q,options:X,startTime:K,isSync:!0})}},zF1=({encoding:Z,maxBuffer:J,...X})=>({...X,encoding:"buffer",maxBuffer:$F(J)}),vF1=({error:Z,exitCode:J,signal:X,timedOut:$,isMaxBuffer:Y,stdio:Q,all:K,options:W,command:G,escapedCommand:z,startTime:v})=>Z===void 0?YF({command:G,escapedCommand:z,stdio:Q,all:K,ipcOutput:[],options:W,startTime:v}):tW({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 rc1}from"node:events";import{spawn as tc1}from"node:child_process";import Vp from"node:process";import{once as VM,on as VF1}from"node:events";var Wp=({anyProcess:Z,channel:J,isSubprocess:X,ipc:$},{reference:Y=!0,filter:Q}={})=>{return iQ({methodName:"getOneMessage",isSubprocess:X,ipc:$,isConnected:pq(Z)}),HF1({anyProcess:Z,channel:J,isSubprocess:X,filter:Q,reference:Y})},HF1=async({anyProcess:Z,channel:J,isSubprocess:X,filter:$,reference:Y})=>{mq(J,Y);let Q=kJ(Z,J,X),K=new AbortController;try{return await Promise.race([qF1(Q,$,K),FF1(Q,X,K),cF1(Q,X,K)])}catch(W){throw gQ(Z),W}finally{K.abort(),uq(J,Y)}},qF1=async(Z,J,{signal:X})=>{if(J===void 0){let[$]=await VM(Z,"message",{signal:X});return $}for await(let[$]of VF1(Z,"message",{signal:X}))if(J($))return $},FF1=async(Z,J,{signal:X})=>{await VM(Z,"disconnect",{signal:X}),du(J)},cF1=async(Z,J,{signal:X})=>{let[$]=await VM(Z,"strict:error",{signal:X});throw Sq($,J)};import{once as zp,on as wF1}from"node:events";var vp=({anyProcess:Z,channel:J,isSubprocess:X,ipc:$},{reference:Y=!0}={})=>HM({anyProcess:Z,channel:J,isSubprocess:X,ipc:$,shouldAwait:!X,reference:Y}),HM=({anyProcess:Z,channel:J,isSubprocess:X,ipc:$,shouldAwait:Y,reference:Q})=>{iQ({methodName:"getEachMessage",isSubprocess:X,ipc:$,isConnected:pq(Z)}),mq(J,Q);let K=kJ(Z,J,X),W=new AbortController,G={};return xF1(Z,K,W),UF1({ipcEmitter:K,isSubprocess:X,controller:W,state:G}),jF1({anyProcess:Z,channel:J,ipcEmitter:K,isSubprocess:X,shouldAwait:Y,controller:W,state:G,reference:Q})},xF1=async(Z,J,X)=>{try{await zp(J,"disconnect",{signal:X.signal}),X.abort()}catch{}},UF1=async({ipcEmitter:Z,isSubprocess:J,controller:X,state:$})=>{try{let[Y]=await zp(Z,"strict:error",{signal:X.signal});$.error=Sq(Y,J),X.abort()}catch{}},jF1=async function*({anyProcess:Z,channel:J,ipcEmitter:X,isSubprocess:$,shouldAwait:Y,controller:Q,state:K,reference:W}){try{for await(let[G]of wF1(X,"message",{signal:Q.signal}))Gp(K),yield G}catch{Gp(K)}finally{if(Q.abort(),uq(J,W),!$)gQ(Z);if(Y)await Z}},Gp=({error:Z})=>{if(Z)throw Z};var Hp=(Z,{ipc:J})=>{Object.assign(Z,Fp(Z,!1,J))},qp=()=>{let Z=Vp,J=!0,X=Vp.channel!==void 0;return{...Fp(Z,!0,X),getCancelSignal:jl.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:!0,ipc:X})}},Fp=(Z,J,X)=>({sendMessage:aq.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getOneMessage:Wp.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getEachMessage:vp.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X})});import{ChildProcess as BF1}from"node:child_process";import{PassThrough as LF1,Readable as DF1,Writable as MF1,Duplex as RF1}from"node:stream";var cp=({error:Z,command:J,escapedCommand:X,fileDescriptors:$,options:Y,startTime:Q,verboseInfo:K})=>{XM($);let W=new BF1;PF1(W,$),Object.assign(W,{readable:NF1,writable:OF1,duplex:TF1});let G=sQ({error:Z,command:J,escapedCommand:X,fileDescriptors:$,options:Y,startTime:Q,isSync:!1}),z=CF1(G,K,Y);return{subprocess:W,promise:z}},PF1=(Z,J)=>{let X=ZG(),$=ZG(),Y=ZG(),Q=Array.from({length:J.length-3},ZG),K=ZG(),W=[X,$,Y,...Q];Object.assign(Z,{stdin:X,stdout:$,stderr:Y,all:K,stdio:W})},ZG=()=>{let Z=new LF1;return Z.end(),Z},NF1=()=>new DF1({read(){}}),OF1=()=>new MF1({write(){}}),TF1=()=>new RF1({read(){},write(){}}),CF1=async(Z,J,X)=>oQ(Z,J,X);import{createReadStream as wp,createWriteStream as xp}from"node:fs";import{Buffer as fF1}from"node:buffer";import{Readable as JG,Writable as kF1,Duplex as EF1}from"node:stream";var jp=(Z,J)=>GF(IF1,Z,J,!1),XG=({type:Z,optionName:J})=>{throw TypeError(`The \`${J}\` option cannot be ${EJ[Z]}.`)},Up={fileNumber:XG,generator:GM,asyncGenerator:GM,nodeStream:({value:Z})=>({stream:Z}),webTransform({value:{transform:Z,writableObjectMode:J,readableObjectMode:X}}){let $=J||X;return{stream:EF1.fromWeb(Z,{objectMode:$})}},duplex:({value:{transform:Z}})=>({stream:Z}),native(){}},IF1={input:{...Up,fileUrl:({value:Z})=>({stream:wp(Z)}),filePath:({value:{file:Z}})=>({stream:wp(Z)}),webStream:({value:Z})=>({stream:JG.fromWeb(Z)}),iterable:({value:Z})=>({stream:JG.from(Z)}),asyncIterable:({value:Z})=>({stream:JG.from(Z)}),string:({value:Z})=>({stream:JG.from(Z)}),uint8Array:({value:Z})=>({stream:JG.from(fF1.from(Z))})},output:{...Up,fileUrl:({value:Z})=>({stream:xp(Z)}),filePath:({value:{file:Z,append:J}})=>({stream:xp(Z,J?{flags:"a"}:{})}),webStream:({value:Z})=>({stream:kF1.fromWeb(Z)}),iterable:XG,asyncIterable:XG,string:XG,uint8Array:XG}};import{on as _F1,once as Bp}from"node:events";import{PassThrough as hF1,getDefaultHighWaterMark as SF1}from"node:stream";import{finished as Mp}from"node:stream/promises";function O$(Z){if(!Array.isArray(Z))throw TypeError(`Expected an array, got \`${typeof Z}\`.`);for(let Y of Z)qM(Y);let J=Z.some(({readableObjectMode:Y})=>Y),X=bF1(Z,J),$=new Rp({objectMode:J,writableHighWaterMark:X,readableHighWaterMark:X});for(let Y of Z)$.add(Y);return $}var bF1=(Z,J)=>{if(Z.length===0)return SF1(J);let X=Z.filter(({readableObjectMode:$})=>$===J).map(({readableHighWaterMark:$})=>$);return Math.max(...X)};class Rp extends hF1{#Z=new Set([]);#J=new Set([]);#$=new Set([]);#X;#Y=Symbol("unpipe");#v=new WeakMap;add(Z){if(qM(Z),this.#Z.has(Z))return;this.#Z.add(Z),this.#X??=AF1(this,this.#Z,this.#Y);let J=lF1({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(qM(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 AF1=async(Z,J,X)=>{cF(Z,Lp);let $=new AbortController;try{await Promise.race([mF1(Z,$),uF1(Z,J,X,$)])}finally{$.abort(),cF(Z,-Lp)}},mF1=async(Z,{signal:J})=>{try{await Mp(Z,{signal:J,cleanup:!0})}catch(X){throw Pp(Z,X),X}},uF1=async(Z,J,X,{signal:$})=>{for await(let[Y]of _F1(Z,"unpipe",{signal:$}))if(J.has(Y))Y.emit(X)},qM=(Z)=>{if(typeof Z?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof Z}\`.`)},lF1=async({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,onFinished:Q,unpipeEvent:K})=>{cF(Z,Dp);let W=new AbortController;try{await Promise.race([yF1(Q,J,W),pF1({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,controller:W}),iF1({stream:J,streams:X,ended:$,aborted:Y,unpipeEvent:K,controller:W})])}finally{W.abort(),cF(Z,-Dp)}if(X.size>0&&X.size===$.size+Y.size)if($.size===0&&Y.size>0)FM(Z);else gF1(Z)},yF1=async(Z,J,{signal:X})=>{try{if(await Z,!X.aborted)FM(J)}catch($){if(!X.aborted)Pp(J,$)}},pF1=async({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,controller:{signal:Q}})=>{try{if(await Mp(J,{signal:Q,cleanup:!0,readable:!0,writable:!1}),X.has(J))$.add(J)}catch(K){if(Q.aborted||!X.has(J))return;if(Np(K))Y.add(J);else Op(Z,K)}},iF1=async({stream:Z,streams:J,ended:X,aborted:$,unpipeEvent:Y,controller:{signal:Q}})=>{if(await Bp(Z,Y,{signal:Q}),!Z.readable)return Bp(Q,"abort",{signal:Q});J.delete(Z),X.delete(Z),$.delete(Z)},gF1=(Z)=>{if(Z.writable)Z.end()},Pp=(Z,J)=>{if(Np(J))FM(Z);else Op(Z,J)},Np=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",FM=(Z)=>{if(Z.readable||Z.writable)Z.destroy()},Op=(Z,J)=>{if(!Z.destroyed)Z.once("error",dF1),Z.destroy(J)},dF1=()=>{},cF=(Z,J)=>{let X=Z.getMaxListeners();if(X!==0&&X!==Number.POSITIVE_INFINITY)Z.setMaxListeners(X+J)},Lp=2,Dp=1;import{finished as Tp}from"node:stream/promises";var tQ=(Z,J)=>{Z.pipe(J),aF1(Z,J),nF1(Z,J)},aF1=async(Z,J)=>{if(H9(Z)||H9(J))return;try{await Tp(Z,{cleanup:!0,readable:!0,writable:!1})}catch{}cM(J)},cM=(Z)=>{if(Z.writable)Z.end()},nF1=async(Z,J)=>{if(H9(Z)||H9(J))return;try{await Tp(J,{cleanup:!0,readable:!1,writable:!0})}catch{}wM(Z)},wM=(Z)=>{if(Z.readable)Z.destroy()};var Cp=(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)))sF1(Z,W,K,Y);for(let{stream:W}of Q.filter(({type:G})=>!v4.has(G)))rF1({subprocess:Z,stream:W,direction:K,fdNumber:Y,pipeGroups:$,controller:X})}for(let[Y,Q]of $.entries()){let K=Q.length===1?Q[0]:O$(Q);tQ(K,Y)}},sF1=(Z,J,X,$)=>{if(X==="output")tQ(Z.stdio[$],J);else tQ(J,Z.stdio[$]);let Y=oF1[$];if(Y!==void 0)Z[Y]=J;Z.stdio[$]=J},oF1=["stdin","stdout","stderr"],rF1=({subprocess:Z,stream:J,direction:X,fdNumber:$,pipeGroups:Y,controller:Q})=>{if(J===void 0)return;tF1(J,Q);let[K,W]=X==="output"?[J,Z.stdio[$]]:[Z.stdio[$],J],G=Y.get(K)??[];Y.set(K,[...G,W])},tF1=(Z,{signal:J})=>{if(H9(Z))M$(Z,eF1,J)},eF1=2;import{addAbortListener as Xc1}from"node:events";var T$=[];T$.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")T$.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")T$.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var wF=(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"),UM=globalThis,Zc1=Object.defineProperty.bind(Object);class fp{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(UM[xM])return UM[xM];Zc1(UM,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 BM{}var Jc1=(Z)=>{return{onExit(J,X){return Z.onExit(J,X)},load(){return Z.load()},unload(){return Z.unload()}}};class kp extends BM{onExit(){return()=>{}}load(){}unload(){}}class Ep extends BM{#Z=jM.platform==="win32"?"SIGINT":"SIGHUP";#J=new fp;#$;#X;#Y;#v={};#H=!1;constructor(Z){super();this.#$=Z,this.#v={};for(let J of T$)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(!wF(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 T$)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,T$.forEach((Z)=>{let J=this.#v[Z];if(!J)throw 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(!wF(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"&&wF(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 jM=globalThis.process,{onExit:Ip,load:yL6,unload:pL6}=Jc1(wF(jM)?new Ep(jM):new kp);var _p=(Z,{cleanup:J,detached:X},{signal:$})=>{if(!J||X)return;let Y=Ip(()=>{Z.kill()});Xc1($,()=>{Y()})};var Sp=({source:Z,sourcePromise:J,boundOptions:X,createNested:$},...Y)=>{let Q=Pq(),{destination:K,destinationStream:W,destinationError:G,from:z,unpipeSignal:v}=$c1(X,$,Y),{sourceStream:H,sourceError:V}=Qc1(Z,z),{options:q,fileDescriptors:F}=J7.get(Z);return{sourcePromise:J,sourceStream:H,sourceOptions:q,sourceError:V,destination:K,destinationStream:W,destinationError:G,unpipeSignal:v,fileDescriptors:F,startTime:Q}},$c1=(Z,J,X)=>{try{let{destination:$,pipeOptions:{from:Y,to:Q,unpipeSignal:K}={}}=Yc1(Z,J,...X),W=Aq($,Q);return{destination:$,destinationStream:W,from:Y,unpipeSignal:K}}catch($){return{destinationError:$}}},Yc1=(Z,J,X,...$)=>{if(Array.isArray(X))return{destination:J(hp,Z)(X,...$),pipeOptions:Z};if(typeof X==="string"||X instanceof URL||HD(X)){if(Object.keys(Z).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[Y,Q,K]=cq(X,...$);return{destination:J(hp)(Y,Q,K),pipeOptions:K}}if(J7.has(X)){if(Object.keys(Z).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:X,pipeOptions:$[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${X}`)},hp=({options:Z})=>({options:{...Z,stdin:"pipe",piped:!0}}),Qc1=(Z,J)=>{try{return{sourceStream:dQ(Z,J)}}catch(X){return{sourceError:X}}};var Ap=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$,fileDescriptors:Y,sourceOptions:Q,startTime:K})=>{let W=Kc1({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$});if(W!==void 0)throw LM({error:W,fileDescriptors:Y,sourceOptions:Q,startTime:K})},Kc1=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$})=>{if(J!==void 0&&$!==void 0)return $;if($!==void 0)return wM(Z),$;if(J!==void 0)return cM(X),J},LM=({error:Z,fileDescriptors:J,sourceOptions:X,startTime:$})=>sQ({error:Z,command:bp,escapedCommand:bp,fileDescriptors:J,options:X,startTime:$,isSync:!1}),bp="source.pipe(destination)";var mp=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 Wc1}from"node:stream/promises";var up=(Z,J,X)=>{let $=xF.has(J)?zc1(Z,J):Gc1(Z,J);return M$(Z,Vc1,X.signal),M$(J,Hc1,X.signal),vc1(J),$},Gc1=(Z,J)=>{let X=O$([Z]);return tQ(X,J),xF.set(J,X),X},zc1=(Z,J)=>{let X=xF.get(J);return X.add(Z),X},vc1=async(Z)=>{try{await Wc1(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}xF.delete(Z)},xF=new WeakMap,Vc1=2,Hc1=1;import{aborted as qc1}from"node:util";var lp=(Z,J)=>Z===void 0?[]:[Fc1(Z,J)],Fc1=async(Z,{sourceStream:J,mergedStream:X,fileDescriptors:$,sourceOptions:Y,startTime:Q})=>{await qc1(Z,J),await X.remove(J);let K=Error("Pipe canceled by `unpipeSignal` option.");throw LM({error:K,fileDescriptors:$,sourceOptions:Y,startTime:Q})};var UF=(Z,...J)=>{if(w8(J[0]))return UF.bind(void 0,{...Z,boundOptions:{...Z.boundOptions,...J[0]}});let{destination:X,...$}=Sp(Z,...J),Y=cc1({...$,destination:X});return Y.pipe=UF.bind(void 0,{...Z,source:X,sourcePromise:Y,boundOptions:{}}),Y},cc1=async({sourcePromise:Z,sourceStream:J,sourceOptions:X,sourceError:$,destination:Y,destinationStream:Q,destinationError:K,unpipeSignal:W,fileDescriptors:G,startTime:z})=>{let v=wc1(Z,Y);Ap({sourceStream:J,sourceError:$,destinationStream:Q,destinationError:K,fileDescriptors:G,sourceOptions:X,startTime:z});let H=new AbortController;try{let V=up(J,Q,H);return await Promise.race([mp(v),...lp(W,{sourceStream:J,mergedStream:V,sourceOptions:X,fileDescriptors:G,startTime:z})])}finally{H.abort()}},wc1=(Z,J)=>Promise.allSettled([Z,J]);import{setImmediate as Mc1}from"node:timers/promises";import{on as xc1}from"node:events";import{getDefaultHighWaterMark as Uc1}from"node:stream";var jF=({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:$,encoding:Y,preserveNewlines:Q})=>{let K=new AbortController;return jc1(J,K),pp({stream:Z,controller:K,binary:X,shouldEncode:!Z.readableObjectMode&&$,encoding:Y,shouldSplit:!Z.readableObjectMode,preserveNewlines:Q})},jc1=async(Z,J)=>{try{await Z}catch{}finally{J.abort()}},DM=({stream:Z,onStreamEnd:J,lines:X,encoding:$,stripFinalNewline:Y,allMixed:Q})=>{let K=new AbortController;Bc1(J,K,Z);let W=Z.readableObjectMode&&!Q;return pp({stream:Z,controller:K,binary:$==="buffer",shouldEncode:!W,encoding:$,shouldSplit:!W&&X,preserveNewlines:!Y})},Bc1=async(Z,J,X)=>{try{await Z}catch{X.destroy()}finally{J.abort()}},pp=({stream:Z,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K})=>{let W=xc1(Z,"data",{signal:J.signal,highWaterMark:yp,highWatermark:yp});return Lc1({onStdoutChunk:W,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K})},MM=Uc1(!0),yp=MM,Lc1=async function*({onStdoutChunk:Z,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K}){let W=Dc1({binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K});try{for await(let[G]of Z)yield*N$(G,W,0)}catch(G){if(!J.signal.aborted)throw G}finally{yield*eW(W)}},Dc1=({binary:Z,shouldEncode:J,encoding:X,shouldSplit:$,preserveNewlines:Y})=>[vF(Z,X,!J),zF(Z,Y,!$,{})].filter(Boolean);var ip=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,buffer:Y,maxBuffer:Q,lines:K,allMixed:W,stripFinalNewline:G,verboseInfo:z,streamInfo:v})=>{let H=Rc1({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,allMixed:W,verboseInfo:z,streamInfo:v});if(!Y){await Promise.all([Pc1(Z),H]);return}let V=$M(G,X),q=DM({stream:Z,onStreamEnd:J,lines:K,encoding:$,stripFinalNewline:V,allMixed:W}),[F]=await Promise.all([Nc1({stream:Z,iterable:q,fdNumber:X,encoding:$,maxBuffer:Q,lines:K}),H]);return F},Rc1=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,allMixed:Y,verboseInfo:Q,streamInfo:{fileDescriptors:K}})=>{if(!qF({stdioItems:K[X]?.stdioItems,encoding:$,verboseInfo:Q,fdNumber:X}))return;let W=DM({stream:Z,onStreamEnd:J,lines:!0,encoding:$,stripFinalNewline:!0,allMixed:Y});await ry(W,Z,X,Q)},Pc1=async(Z)=>{if(await Mc1(),Z.readableFlowing===null)Z.resume()},Nc1=async({stream:Z,stream:{readableObjectMode:J},iterable:X,fdNumber:$,encoding:Y,maxBuffer:Q,lines:K})=>{try{if(J||K)return await eq(X,{maxBuffer:Q});if(Y==="buffer")return new Uint8Array(await ZF(X,{maxBuffer:Q}));return await XF(X,{maxBuffer:Q})}catch(W){return gp(rl({error:W,stream:Z,readableObjectMode:J,lines:K,encoding:Y,fdNumber:$}))}},RM=async(Z)=>{try{return await Z}catch(J){return gp(J)}},gp=({bufferedData:Z})=>qm(Z)?new Uint8Array(Z):Z;import{finished as Oc1}from"node:stream/promises";var $G=async(Z,J,X,{isSameDirection:$,stopOnExit:Y=!1}={})=>{let Q=Tc1(Z,X),K=new AbortController;try{await Promise.race([...Y?[X.exitPromise]:[],Oc1(Z,{cleanup:!0,signal:K.signal})])}catch(W){if(!Q.stdinCleanedUp)kc1(W,J,X,$)}finally{K.abort()}},Tc1=(Z,{originalStreams:[J],subprocess:X})=>{let $={stdinCleanedUp:!1};if(Z===J)Cc1(Z,X,$);return $},Cc1=(Z,J,X)=>{let{_destroy:$}=Z;Z._destroy=(...Y)=>{fc1(J,X),$.call(Z,...Y)}},fc1=({exitCode:Z,signalCode:J},X)=>{if(Z!==null||J!==null)X.stdinCleanedUp=!0},kc1=(Z,J,X,$)=>{if(!Ec1(Z,J,X,$))throw Z},Ec1=(Z,J,X,$=!0)=>{if(X.propagating)return dp(Z)||BF(Z);return X.propagating=!0,PM(X,J)===$?dp(Z):BF(Z)},PM=({fileDescriptors:Z},J)=>J!=="all"&&Z[J].direction==="input",BF=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",dp=(Z)=>Z?.code==="EPIPE";var ap=({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>Z.stdio.map((G,z)=>NM({stream:G,fdNumber:z,encoding:J,buffer:X[z],maxBuffer:$[z],lines:Y[z],allMixed:!1,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})),NM=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=$G(Z,J,z);if(PM(z,J)){await v;return}let[H]=await Promise.all([ip({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 np=({stdout:Z,stderr:J},{all:X})=>X&&(Z||J)?O$([Z,J].filter(Boolean)):void 0,sp=({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>NM({...Ic1(Z,X),fdNumber:"all",encoding:J,maxBuffer:$[1]+$[2],lines:Y[1]||Y[2],allMixed:_c1(Z),stripFinalNewline:Q,verboseInfo:K,streamInfo:W}),Ic1=({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}},_c1=({all:Z,stdout:J,stderr:X})=>Z&&J&&X&&J.readableObjectMode!==X.readableObjectMode;import{once as hc1}from"node:events";var op=(Z)=>lQ(Z,"ipc"),rp=(Z,J)=>{let X=Rq(Z);t9({type:"ipc",verboseMessage:X,fdNumber:"ipc",verboseInfo:J})};var tp=async({subprocess:Z,buffer:J,maxBuffer:X,ipc:$,ipcOutput:Y,verboseInfo:Q})=>{if(!$)return Y;let K=op(Q),W=r7(J,"ipc"),G=r7(X,"ipc");for await(let z of HM({anyProcess:Z,channel:Z.channel,isSubprocess:!1,ipc:$,shouldAwait:!1,reference:!0})){if(W)tl(Z,Y,G),Y.push(z);if(K)rp(z,Q)}return Y},ep=async(Z,J)=>{return await Promise.allSettled([Z]),J};var Zi=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:c,onInternalError:w,controller:x})=>{let j=Xp(Z,V),B={originalStreams:c,fileDescriptors:F,subprocess:Z,exitPromise:j,propagating:!1},L=ap({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:z,verboseInfo:q,streamInfo:B}),R=sp({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:z,verboseInfo:q,streamInfo:B}),M=[],P=tp({subprocess:Z,buffer:X,maxBuffer:$,ipc:v,ipcOutput:M,verboseInfo:q}),N=Sc1(c,Z,B),O=bc1(F,B);try{return await Promise.race([Promise.all([{},Yp(j),Promise.all(L),R,P,Cl(Z,H),...N,...O]),w,Ac1(Z,x),...Rl(Z,Q,V,x),...gu({subprocess:Z,cancelSignal:K,gracefulCancel:W,context:V,controller:x}),...Dl({subprocess:Z,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,context:V,controller:x})])}catch(k){return V.terminationReason??="other",Promise.all([{error:k},j,Promise.all(L.map((E)=>RM(E))),RM(R),ep(P,M),Promise.allSettled(N),Promise.allSettled(O)])}},Sc1=(Z,J,X)=>Z.map(($,Y)=>$===J.stdio[Y]?void 0:$G($,Y,X)),bc1=(Z,J)=>Z.flatMap(({stdioItems:X},$)=>X.filter(({value:Y,stream:Q=Y})=>F9(Q,{checkOpen:!1})&&!H9(Q)).map(({type:Y,value:Q,stream:K=Q})=>$G(K,$,J,{isSameDirection:v4.has(Y),stopOnExit:Y==="native"}))),Ac1=async(Z,{signal:J})=>{let[X]=await hc1(Z,"error",{signal:J});throw X};var Ji=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),YG=(Z,J,X)=>{let $=Z[X];if(!$.has(J))$.set(J,[]);let Y=$.get(J),Q=Z7();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 mc1}from"node:stream";import{callbackify as uc1}from"node:util";import{finished as Xi}from"node:stream/promises";var OM=async(Z)=>{if(Z===void 0)return;try{await TM(Z)}catch{}},$i=async(Z)=>{if(Z===void 0)return;try{await CM(Z)}catch{}},TM=async(Z)=>{await Xi(Z,{cleanup:!0,readable:!1,writable:!0})},CM=async(Z)=>{await Xi(Z,{cleanup:!0,readable:!0,writable:!1})},LF=async(Z,J)=>{if(await Z,J)throw J},DF=(Z,J,X)=>{if(X&&!BF(X))Z.destroy(X);else if(J)Z.destroy()};var Yi=({subprocess:Z,concurrentStreams:J,encoding:X},{from:$,binary:Y=!0,preserveNewlines:Q=!0}={})=>{let K=Y||E5.has(X),{subprocessStdout:W,waitReadableDestroy:G}=fM(Z,$,J),{readableEncoding:z,readableObjectMode:v,readableHighWaterMark:H}=kM(W,K),{read:V,onStdoutDataDone:q}=EM({subprocessStdout:W,subprocess:Z,binary:K,encoding:X,preserveNewlines:Q}),F=new mc1({read:V,destroy:uc1(_M.bind(void 0,{subprocessStdout:W,subprocess:Z,waitReadableDestroy:G})),highWaterMark:H,objectMode:v,encoding:z});return IM({subprocessStdout:W,onStdoutDataDone:q,readable:F,subprocess:Z}),F},fM=(Z,J,X)=>{let $=dQ(Z,J),Y=YG(X,$,"readableDestroy");return{subprocessStdout:$,waitReadableDestroy:Y}},kM=({readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X},$)=>$?{readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X}:{readableEncoding:Z,readableObjectMode:!0,readableHighWaterMark:MM},EM=({subprocessStdout:Z,subprocess:J,binary:X,encoding:$,preserveNewlines:Y})=>{let Q=Z7(),K=jF({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:!X,encoding:$,preserveNewlines:Y});return{read(){lc1(this,K,Q)},onStdoutDataDone:Q}},lc1=async(Z,J,X)=>{try{let{value:$,done:Y}=await J.next();if(Y)X.resolve();else Z.push($)}catch{}},IM=async({subprocessStdout:Z,onStdoutDataDone:J,readable:X,subprocess:$,subprocessStdin:Y})=>{try{if(await CM(Z),await $,await OM(Y),await J,X.readable)X.push(null)}catch(Q){await OM(Y),Qi(X,Q)}},_M=async({subprocessStdout:Z,subprocess:J,waitReadableDestroy:X},$)=>{if(await eQ(X,J))Qi(Z,$),await LF(J,$)},Qi=(Z,J)=>{DF(Z,Z.readable,J)};import{Writable as yc1}from"node:stream";import{callbackify as Ki}from"node:util";var Wi=({subprocess:Z,concurrentStreams:J},{to:X}={})=>{let{subprocessStdin:$,waitWritableFinal:Y,waitWritableDestroy:Q}=hM(Z,X,J),K=new yc1({...SM($,Z,Y),destroy:Ki(AM.bind(void 0,{subprocessStdin:$,subprocess:Z,waitWritableFinal:Y,waitWritableDestroy:Q})),highWaterMark:$.writableHighWaterMark,objectMode:$.writableObjectMode});return bM($,K),K},hM=(Z,J,X)=>{let $=Aq(Z,J),Y=YG(X,$,"writableFinal"),Q=YG(X,$,"writableDestroy");return{subprocessStdin:$,waitWritableFinal:Y,waitWritableDestroy:Q}},SM=(Z,J,X)=>({write:pc1.bind(void 0,Z),final:Ki(ic1.bind(void 0,Z,J,X))}),pc1=(Z,J,X,$)=>{if(Z.write(J,X))$();else Z.once("drain",$)},ic1=async(Z,J,X)=>{if(await eQ(X,J)){if(Z.writable)Z.end();await J}},bM=async(Z,J,X)=>{try{if(await TM(Z),J.writable)J.end()}catch($){await $i(X),Gi(J,$)}},AM=async({subprocessStdin:Z,subprocess:J,waitWritableFinal:X,waitWritableDestroy:$},Y)=>{if(await eQ(X,J),await eQ($,J))Gi(Z,Y),await LF(J,Y)},Gi=(Z,J)=>{DF(Z,Z.writable,J)};import{Duplex as gc1}from"node:stream";import{callbackify as dc1}from"node:util";var zi=({subprocess:Z,concurrentStreams:J,encoding:X},{from:$,to:Y,binary:Q=!0,preserveNewlines:K=!0}={})=>{let W=Q||E5.has(X),{subprocessStdout:G,waitReadableDestroy:z}=fM(Z,$,J),{subprocessStdin:v,waitWritableFinal:H,waitWritableDestroy:V}=hM(Z,Y,J),{readableEncoding:q,readableObjectMode:F,readableHighWaterMark:c}=kM(G,W),{read:w,onStdoutDataDone:x}=EM({subprocessStdout:G,subprocess:Z,binary:W,encoding:X,preserveNewlines:K}),j=new gc1({read:w,...SM(v,Z,H),destroy:dc1(ac1.bind(void 0,{subprocessStdout:G,subprocessStdin:v,subprocess:Z,waitReadableDestroy:z,waitWritableFinal:H,waitWritableDestroy:V})),readableHighWaterMark:c,writableHighWaterMark:v.writableHighWaterMark,readableObjectMode:F,writableObjectMode:v.writableObjectMode,encoding:q});return IM({subprocessStdout:G,onStdoutDataDone:x,readable:j,subprocess:Z,subprocessStdin:v}),bM(v,j,G),j},ac1=async({subprocessStdout:Z,subprocessStdin:J,subprocess:X,waitReadableDestroy:$,waitWritableFinal:Y,waitWritableDestroy:Q},K)=>{await Promise.all([_M({subprocessStdout:Z,subprocess:X,waitReadableDestroy:$},K),AM({subprocessStdin:J,subprocess:X,waitWritableFinal:Y,waitWritableDestroy:Q},K)])};var mM=(Z,J,{from:X,binary:$=!1,preserveNewlines:Y=!1}={})=>{let Q=$||E5.has(J),K=dQ(Z,X),W=jF({subprocessStdout:K,subprocess:Z,binary:Q,shouldEncode:!0,encoding:J,preserveNewlines:Y});return nc1(W,K,Z)},nc1=async function*(Z,J,X){try{yield*Z}finally{if(J.readable)J.destroy();await X}};var vi=(Z,{encoding:J})=>{let X=Ji();Z.readable=Yi.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.writable=Wi.bind(void 0,{subprocess:Z,concurrentStreams:X}),Z.duplex=zi.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.iterable=mM.bind(void 0,Z,J),Z[Symbol.asyncIterator]=mM.bind(void 0,Z,J,{})};var Vi=(Z,J)=>{for(let[X,$]of oc1){let Y=$.value.bind(J);Reflect.defineProperty(Z,X,{...$,value:Y})}},sc1=(async()=>{})().constructor.prototype,oc1=["then","catch","finally"].map((Z)=>[Z,Reflect.getOwnPropertyDescriptor(sc1,Z)]);var Hi=(Z,J,X,$)=>{let{file:Y,commandArguments:Q,command:K,escapedCommand:W,startTime:G,verboseInfo:z,options:v,fileDescriptors:H}=ec1(Z,J,X),{subprocess:V,promise:q}=Jw1({file:Y,commandArguments:Q,options:v,startTime:G,verboseInfo:z,command:K,escapedCommand:W,fileDescriptors:H});return V.pipe=UF.bind(void 0,{source:V,sourcePromise:q,boundOptions:{},createNested:$}),Vi(V,q),J7.set(V,{options:v,fileDescriptors:H}),V},ec1=(Z,J,X)=>{let{command:$,escapedCommand:Y,startTime:Q,verboseInfo:K}=Nq(Z,J,X),{file:W,commandArguments:G,options:z}=sq(Z,J,X),v=Zw1(z),H=jp(v,K);return{file:W,commandArguments:G,command:$,escapedCommand:Y,startTime:Q,verboseInfo:K,options:v,fileDescriptors:H}},Zw1=({timeout:Z,signal:J,...X})=>{if(J!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...X,timeoutDuration:Z}},Jw1=({file:Z,commandArguments:J,options:X,startTime:$,verboseInfo:Y,command:Q,escapedCommand:K,fileDescriptors:W})=>{let G;try{G=tc1(Z,J,X)}catch(F){return cp({error:F,command:Q,escapedCommand:K,fileDescriptors:W,options:X,startTime:$,verboseInfo:Y})}let z=new AbortController;rc1(Number.POSITIVE_INFINITY,z.signal);let v=[...G.stdio];Cp(G,W,z),_p(G,X,z);let H={},V=Z7();G.kill=pu.bind(void 0,{kill:G.kill.bind(G),options:X,onInternalError:V,context:H,controller:z}),G.all=np(G,X),vi(G,X),Hp(G,X);let q=Xw1({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}},Xw1=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,c,w]=await Zi({subprocess:Z,options:J,context:G,verboseInfo:$,fileDescriptors:Y,originalStreams:Q,onInternalError:z,controller:v});v.abort(),z.resolve();let x=F.map((L,R)=>ZZ(L,J,R)),j=ZZ(c,J,"all"),B=$w1({errorInfo:H,exitCode:V,signal:q,stdio:x,all:j,ipcOutput:w,context:G,options:J,command:K,escapedCommand:W,startTime:X});return oQ(B,$,J)},$w1=({errorInfo:Z,exitCode:J,signal:X,stdio:$,all:Y,ipcOutput:Q,context:K,options:W,command:G,escapedCommand:z,startTime:v})=>("error"in Z)?tW({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 t7,isForcefullyTerminated:K.isForcefullyTerminated,exitCode:J,signal:X,stdio:$,all:Y,ipcOutput:Q,options:W,startTime:v,isSync:!1}):YF({command:G,escapedCommand:z,stdio:$,all:Y,ipcOutput:Q,options:W,startTime:v});var MF=(Z,J)=>{let X=Object.fromEntries(Object.entries(J).map(([$,Y])=>[$,Yw1($,Z[$],Y)]));return{...Z,...X}},Yw1=(Z,J,X)=>{if(Qw1.has(Z)&&w8(J)&&w8(X))return{...J,...X};return X},Qw1=new Set(["env",...UD]);var IJ=(Z,J,X,$)=>{let Y=(K,W,G)=>IJ(K,W,X,G),Q=(...K)=>Kw1({mapArguments:Z,deepOptions:X,boundOptions:J,setBoundExeca:$,createNested:Y},...K);if($!==void 0)$(Q,Y,J);return Q},Kw1=({mapArguments:Z,deepOptions:J={},boundOptions:X={},setBoundExeca:$,createNested:Y},Q,...K)=>{if(w8(Q))return Y(Z,MF(X,Q),$);let{file:W,commandArguments:G,options:z,isSync:v}=Ww1({mapArguments:Z,firstArgument:Q,nextArguments:K,deepOptions:J,boundOptions:X});return v?Kp(W,G,z):Hi(W,G,z,Y)},Ww1=({mapArguments:Z,firstArgument:J,nextArguments:X,deepOptions:$,boundOptions:Y})=>{let Q=jm(J)?Bm(J,X):[J,...X],[K,W,G]=cq(...Q),z=MF(MF($,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})=>ci(Z,J),Fi=({file:Z,commandArguments:J})=>({...ci(Z,J),isSync:!0}),ci=(Z,J)=>{if(J.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${Z} ${J}.`);let[X,...$]=Gw1(Z);return{file:X,commandArguments:$}},Gw1=(Z)=>{if(typeof Z!=="string")throw TypeError(`The command must be a string: ${String(Z)}.`);let J=Z.trim();if(J==="")return[];let X=[];for(let $ of J.split(zw1)){let Y=X.at(-1);if(Y&&Y.endsWith("\\"))X[X.length-1]=`${Y.slice(0,-1)} ${$}`;else X.push($)}return X},zw1=/ +/g;var wi=(Z,J,X)=>{Z.sync=J(vw1,X),Z.s=Z.sync},xi=({options:Z})=>Ui(Z),vw1=({options:Z})=>({...Ui(Z),isSync:!0}),Ui=(Z)=>({options:{...Vw1(Z),...Z}}),Vw1=({input:Z,inputFile:J,stdio:X})=>Z===void 0&&J===void 0&&X===void 0?{stdin:"inherit"}:{},ji={preferLocal:!0};var Bi=IJ(()=>({})),kR6=IJ(()=>({isSync:!0})),ER6=IJ(qi),IR6=IJ(Fi),_R6=IJ(Nl),hR6=IJ(xi,{},ji,wi),{sendMessage:SR6,getOneMessage:bR6,getEachMessage:AR6,getCancelSignal:mR6}=qp();var ui=t(Ei(),1);var KG=(Z)=>{if(typeof Z!=="string")throw TypeError("invalid pattern");if(Z.length>65536)throw TypeError("pattern is too long")};var jw1={"[: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]},WG=(Z)=>Z.replace(/[[\]\\-]/g,"\\$&"),Bw1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ii=(Z)=>Z.join(""),_i=(Z,J)=>{let X=J;if(Z.charAt(X)!=="[")throw 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 c=Z.charAt(Q);if((c==="!"||c==="^")&&Q===X+1){z=!0,Q++;continue}if(c==="]"&&K&&!G){v=Q+1;break}if(K=!0,c==="\\"){if(!G){G=!0,Q++;continue}}if(c==="["&&!G){for(let[w,[x,j,B]]of Object.entries(jw1))if(Z.startsWith(w,Q)){if(H)return["$.",!1,Z.length-X,!0];if(Q+=w.length,B)Y.push(x);else $.push(x);W=W||j;continue Z}}if(G=!1,H){if(c>H)$.push(WG(H)+"-"+WG(c));else if(c===H)$.push(WG(c));H="",Q++;continue}if(Z.startsWith("-]",Q+1)){$.push(WG(c+"-")),Q+=2;continue}if(Z.startsWith("-",Q+1)){H=c,Q+=2;continue}$.push(WG(c)),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 c=$[0].length===2?$[0].slice(-1):$[0];return[Bw1(c),!1,v-X,!1]}let V="["+(z?"^":"")+Ii($)+"]",q="["+(z?"":"^")+Ii(Y)+"]";return[$.length&&Y.length?"("+V+"|"+q+")":$.length?V:q,W,v-X,!0]};var c9=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/\[([^\/\\])\]/g,"$1"):Z.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var Lw1=new Set(["!","?","+","*","@"]),hi=(Z)=>Lw1.has(Z),Dw1="(?!(?:^|/)\\.\\.?(?:$|/))",RF="(?!\\.)",Mw1=new Set(["[","."]),Rw1=new Set(["..","."]),Pw1=new Set("().*{}+?[]^$\\!"),Nw1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),pM="[^/]",Si=pM+"*?",bi=pM+"+?";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 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 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 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&&hi(F)&&Z.charAt(V)==="("){J.push(q),q="";let c=new Z6(F,J);V=Z6.#F(Z,c,V,$),J.push(c);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(hi(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,c,w]=typeof V==="string"?Z6.#c(V,this.#J,W):V.toRegExpSource(Z);return this.#J=this.#J||c,this.#$=this.#$||w,q}).join(""),z="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&Rw1.has(this.#X[0]))){let q=Mw1,F=J&&q.has(G.charAt(0))||G.startsWith("\\.")&&q.has(G.charAt(2))||G.startsWith("\\.\\.")&&q.has(G.charAt(4)),c=!J&&!Z&&q.has(G.charAt(0));z=F?Dw1:c?RF:""}}}let v="";if(this.isEnd()&&this.#Z.#W&&this.#Y?.type==="!")v="(?:$|\\/)";return[z+G+v,c9(G),this.#J=!!this.#J,this.#$]}let X=this.type==="*"||this.type==="+",$=this.type==="!"?"(?:(?!(?:":"(?:",Y=this.#w(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,c9(this.toString()),!1,!1]}let Q=!X||Z||J||!RF?"":this.#w(!0);if(Q===Y)Q="";if(Q)Y=`(?:${Y})(?:${Q})*?`;let K="";if(this.type==="!"&&this.#V)K=(this.isStart()&&!J?RF:"")+bi;else{let W=this.type==="!"?"))"+(this.isStart()&&!J&&!Z?RF:"")+Si+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&Q?")":this.type==="*"&&Q?")?":`)${this.type}`;K=$+Y+W}return[K,c9(Y),this.#J=!!this.#J,this.#$]}#w(Z){return this.#X.map((J)=>{if(typeof J==="string")throw 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#c(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+=(Pw1.has(W)?"\\":"")+W;continue}if(W==="\\"){if(K===Z.length-1)Y+="\\\\";else $=!0;continue}if(W==="["){let[G,z,v,H]=_i(Z,K);if(v){Y+=G,Q=Q||z,K+=v-1,J=J||H;continue}}if(W==="*"){if(X&&Z==="*")Y+=bi;else Y+=Si;J=!0;continue}if(W==="?"){Y+=pM,J=!0;continue}Y+=Nw1(W)}return[Y,c9(Z),!!J,Q]}}var Z3=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/[?*()[\]]/g,"[$&]"):Z.replace(/[?*()[\]\\]/g,"\\$&")};var h6=(Z,J,X={})=>{if(KG(J),!X.nocomment&&J.charAt(0)==="#")return!1;return new H4(J,X).match(Z)},Ow1=/^\*+([^+@!?\*\[\(]*)$/,Tw1=(Z)=>(J)=>!J.startsWith(".")&&J.endsWith(Z),Cw1=(Z)=>(J)=>J.endsWith(Z),fw1=(Z)=>{return Z=Z.toLowerCase(),(J)=>!J.startsWith(".")&&J.toLowerCase().endsWith(Z)},kw1=(Z)=>{return Z=Z.toLowerCase(),(J)=>J.toLowerCase().endsWith(Z)},Ew1=/^\*+\.\*+$/,Iw1=(Z)=>!Z.startsWith(".")&&Z.includes("."),_w1=(Z)=>Z!=="."&&Z!==".."&&Z.includes("."),hw1=/^\.\*+$/,Sw1=(Z)=>Z!=="."&&Z!==".."&&Z.startsWith("."),bw1=/^\*+$/,Aw1=(Z)=>Z.length!==0&&!Z.startsWith("."),mw1=(Z)=>Z.length!==0&&Z!=="."&&Z!=="..",uw1=/^\?+([^+@!?\*\[\(]*)?$/,lw1=([Z,J=""])=>{let X=li([Z]);if(!J)return X;return J=J.toLowerCase(),($)=>X($)&&$.toLowerCase().endsWith(J)},yw1=([Z,J=""])=>{let X=yi([Z]);if(!J)return X;return J=J.toLowerCase(),($)=>X($)&&$.toLowerCase().endsWith(J)},pw1=([Z,J=""])=>{let X=yi([Z]);return!J?X:($)=>X($)&&$.endsWith(J)},iw1=([Z,J=""])=>{let X=li([Z]);return!J?X:($)=>X($)&&$.endsWith(J)},li=([Z])=>{let J=Z.length;return(X)=>X.length===J&&!X.startsWith(".")},yi=([Z])=>{let J=Z.length;return(X)=>X.length===J&&X!=="."&&X!==".."},pi=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ai={win32:{sep:"\\"},posix:{sep:"/"}},gw1=pi==="win32"?Ai.win32.sep:Ai.posix.sep;h6.sep=gw1;var J6=Symbol("globstar **");h6.GLOBSTAR=J6;var dw1="[^/]",aw1=dw1+"*?",nw1="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",sw1="(?:(?!(?:\\/|^)\\.).)*?",ow1=(Z,J={})=>(X)=>h6(X,Z,J);h6.filter=ow1;var V4=(Z,J={})=>Object.assign({},Z,J),rw1=(Z)=>{if(!Z||typeof Z!=="object"||!Object.keys(Z).length)return h6;let J=h6;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})};h6.defaults=rw1;var ii=(Z,J={})=>{if(KG(Z),J.nobrace||!/\{(?:(?!\{).)*\}/.test(Z))return[Z];return ui.default(Z)};h6.braceExpand=ii;var tw1=(Z,J={})=>new H4(Z,J).makeRe();h6.makeRe=tw1;var ew1=(Z,J,X={})=>{let $=new H4(J,X);if(Z=Z.filter((Y)=>$.match(Y)),$.options.nonull&&!Z.length)Z.push(J);return Z};h6.match=ew1;var mi=/[?*]|[+@!]\(.*?\)|\[|\]/,Zx1=(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(KG(Z),J=J||{},this.options=J,this.pattern=Z,this.platform=J.platform||pi,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]==="?"||!mi.test(Y[2]))&&!mi.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]),c=!F&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&/^[a-z]:$/i.test(Z[3]),w=typeof J[0]==="string"&&/^[a-z]:$/i.test(J[0]),x=!w&&J[0]===""&&J[1]===""&&J[2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]),j=c?3:F?0:void 0,B=x?3:w?0:void 0;if(typeof j==="number"&&typeof B==="number"){let[L,R]=[Z[j],J[B]];if(L.toLowerCase()===R.toLowerCase()){if(J[B]=L,B>j)J=J.slice(B);else if(j>B)Z=Z.slice(j)}}}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 Error("wtf?")}braceExpand(){return ii(this.pattern,this.options)}parse(Z){KG(Z);let J=this.options;if(Z==="**")return J6;if(Z==="")return"";let X,$=null;if(X=Z.match(bw1))$=J.dot?mw1:Aw1;else if(X=Z.match(Ow1))$=(J.nocase?J.dot?kw1:fw1:J.dot?Cw1:Tw1)(X[1]);else if(X=Z.match(uw1))$=(J.nocase?J.dot?yw1:lw1:J.dot?pw1:iw1)(X);else if(X=Z.match(Ew1))$=J.dot?_w1:Iw1;else if(X=Z.match(hw1))$=Sw1;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?aw1:J.dot?nw1:sw1,$=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"?Zx1(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 h6.defaults(Z).Minimatch}}h6.AST=Z6;h6.Minimatch=H4;h6.escape=Z3;h6.unescape=c9;import{fileURLToPath as Ex1}from"node:url";var J3=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,di=new Set,iM=typeof process==="object"&&!!process?process:{},ai=(Z,J,X,$)=>{typeof iM.emitWarning==="function"?iM.emitWarning(Z,J,X,$):console.error(`[${X}] ${J}: ${Z}`)},PF=globalThis.AbortController,gi=globalThis.AbortSignal;if(typeof PF>"u"){gi=class{onabort;_onabort=[];reason;aborted=!1;addEventListener($,Y){this._onabort.push(Y)}},PF=class{constructor(){J()}signal=new gi;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=iM.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,ai("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 Jx1=(Z)=>!di.has(Z),YP6=Symbol("type"),_J=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),ni=(Z)=>!_J(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?GG:null;class GG extends Array{constructor(Z){super(Z);this.fill(0)}}class X3{heap;length;static#Z=!1;static create(Z){let J=ni(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 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 zG{#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;#w;#c;#U;#O;#j;#T;#D;#L;#B;#P;#x;#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.#w,get head(){return Z.#c},get tail(){return Z.#U},free:Z.#O,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,$,Y)=>Z.#h(J,X,$,Y),moveToTail:(J)=>Z.#A(J),indexes:(J)=>Z.#N(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:c,fetchMethod:w,memoMethod:x,noDeleteOnFetchRejection:j,noDeleteOnStaleGet:B,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:R,ignoreFetchAbort:M}=Z;if(J!==0&&!_J(J))throw TypeError("max option must be a nonnegative integer");let P=J?ni(J):Array;if(!P)throw Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=F||this.#J,this.sizeCalculation=c,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#H=x,w!==void 0&&typeof w!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#v=w,this.#P=!!w,this.#z=new Map,this.#V=Array(J).fill(void 0),this.#Q=Array(J).fill(void 0),this.#F=new P(J),this.#w=new P(J),this.#c=0,this.#U=0,this.#O=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.#j=[];else this.#Y=void 0,this.#j=void 0;if(this.#B=!!this.#$,this.#f=!!this.#X,this.#x=!!this.#Y,this.noDisposeOnSet=!!H,this.noUpdateTTL=!!V,this.noDeleteOnFetchRejection=!!j,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!_J(this.#J))throw TypeError("maxSize must be a positive integer if specified")}if(!_J(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#u()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!B,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=_J($)||$===0?$:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!_J(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(Jx1("LRU_CACHE_UNBOUNDED"))di.add("LRU_CACHE_UNBOUNDED"),ai("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",zG)}}getRemainingTTL(Z){return this.#z.has(Z)?1/0:0}#K(){let Z=new GG(this.#Z),J=new GG(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 GG(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(!_J($))if(Y){if(typeof Y!=="function")throw TypeError("sizeCalculation must be a function");if($=Y(X,J),!_J($))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return $},this.#S=(J,X,$)=>{if(Z[J]=X,this.#J){let Y=this.#J-Z[J];while(this.#G>Y)this.#b(!0)}if(this.#G+=Z[J],$)$.entrySize=X,$.totalCalculatedSize=this.#G}}#_=(Z)=>{};#S=(Z,J,X)=>{};#l=(Z,J,X,$)=>{if(X||$)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({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.#c)break;else J=this.#w[J]}}*#C({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#c;;){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.#N())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.#N()){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.#N())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.#N()){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.#N()){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.#N({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.#O.length!==0?this.#O.pop():this.#W===this.#Z?this.#b(!1):this.#W,this.#V[v]=Z,this.#Q[v]=J,this.#z.set(Z,v),this.#F[this.#U]=v,this.#w[v]=this.#U,this.#U=v,this.#W++,this.#S(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.#P&&this.#q(H)){H.__abortController.abort(Error("replaced"));let{__staleWhileFetching:V}=H;if(V!==void 0&&!Q){if(this.#B)this.#$?.(V,Z,"set");if(this.#x)this.#j?.push([V,Z,"set"])}}else if(!Q){if(this.#B)this.#$?.(H,Z,"set");if(this.#x)this.#j?.push([H,Z,"set"])}if(this.#_(v),this.#S(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.#x&&this.#j){let H=this.#j,V;while(V=H?.shift())this.#Y?.(...V)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#c];if(this.#b(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#x&&this.#j){let Z=this.#j,J;while(J=Z?.shift())this.#Y?.(...J)}}}#b(Z){let J=this.#c,X=this.#V[J],$=this.#Q[J];if(this.#P&&this.#q($))$.__abortController.abort(Error("evicted"));else if(this.#B||this.#x){if(this.#B)this.#$?.($,X,"evict");if(this.#x)this.#j?.push([$,X,"evict"])}if(this.#_(J),Z)this.#V[J]=void 0,this.#Q[J]=void 0,this.#O.push(J);if(this.#W===1)this.#c=this.#U=0,this.#O.length=0;else this.#c=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}#h(Z,J,X,$){let Y=J===void 0?void 0:this.#Q[J];if(this.#q(Y))return Y;let Q=new PF,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:$},G=(F,c=!1)=>{let{aborted:w}=Q.signal,x=X.ignoreFetchAbort&&F!==void 0;if(X.status)if(w&&!c){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,x)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(w&&!x&&!c)return v(Q.signal.reason);let j=V;if(this.#Q[J]===V)if(F===void 0)if(j.__staleWhileFetching)this.#Q[J]=j.__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:c}=Q.signal,w=c&&X.allowStaleOnFetchAbort,x=w||X.allowStaleOnFetchRejection,j=x||X.noDeleteOnFetchRejection,B=V;if(this.#Q[J]===V){if(!j||B.__staleWhileFetching===void 0)this.#E(Z,"fetch");else if(!w)this.#Q[J]=B.__staleWhileFetching}if(x){if(X.status&&B.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return B.__staleWhileFetching}else if(B.__returned===B)throw F},H=(F,c)=>{let w=this.#v?.(Z,Y,W);if(w&&w instanceof Promise)w.then((x)=>F(x===void 0?void 0:x),c);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(F(void 0),X.allowStaleOnFetchAbort)F=(x)=>G(x,!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.#P)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof PF}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:c=!1,status:w,signal:x}=J;if(!this.#P){if(w)w.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,status:w})}let j={allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:z,noDeleteOnFetchRejection:v,allowStaleOnFetchRejection:H,allowStaleOnFetchAbort:q,ignoreFetchAbort:V,status:w,signal:x},B=this.#z.get(Z);if(B===void 0){if(w)w.fetch="miss";let L=this.#h(Z,B,j,F);return L.__returned=L}else{let L=this.#Q[B];if(this.#q(L)){let O=X&&L.__staleWhileFetching!==void 0;if(w){if(w.fetch="inflight",O)w.returnedStale=!0}return O?L.__staleWhileFetching:L.__returned=L}let R=this.#R(B);if(!c&&!R){if(w)w.fetch="hit";if(this.#A(B),$)this.#I(B);if(w)this.#M(w,B);return L}let M=this.#h(Z,B,j,F),N=M.__staleWhileFetching!==void 0&&X;if(w){if(w.fetch=R?"stale":"refresh",N&&R)w.returnedStale=!0}return N?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#H;if(!X)throw 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.#w[J]=Z,this.#F[Z]=J}#A(Z){if(Z!==this.#U){if(Z===this.#c)this.#c=this.#F[Z];else this.#p(this.#w[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(Error("deleted"));else if(this.#B||this.#x){if(this.#B)this.#$?.(Y,Z,J);if(this.#x)this.#j?.push([Y,Z,J])}if(this.#z.delete(Z),this.#V[$]=void 0,this.#Q[$]=void 0,$===this.#U)this.#U=this.#w[$];else if($===this.#c)this.#c=this.#F[$];else{let Q=this.#w[$];this.#F[Q]=this.#F[$];let K=this.#F[$];this.#w[K]=this.#w[$]}this.#W--,this.#O.push($)}}if(this.#x&&this.#j?.length){let $=this.#j,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(Error("deleted"));else{let $=this.#V[J];if(this.#B)this.#$?.(X,$,Z);if(this.#x)this.#j?.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.#c=0,this.#U=0,this.#O.length=0,this.#G=0,this.#W=0,this.#x&&this.#j){let J=this.#j,X;while(X=J?.shift())this.#Y?.(...X)}}}import{posix as Hx1,win32 as ZR}from"node:path";import{fileURLToPath as qx1}from"node:url";import{lstatSync as Fx1,readdir as cx1,readdirSync as wx1,readlinkSync as xx1,realpathSync as Ux1}from"fs";import*as jx1 from"node:fs";import{lstat as Lx1,readdir as Dx1,readlink as Mx1,realpath as Rx1}from"node:fs/promises";import{EventEmitter as oM}from"node:events";import ei from"node:stream";import{StringDecoder as Xx1}from"node:string_decoder";var si=typeof process==="object"&&process?process:{stdout:null,stderr:null},$x1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof f$||Z instanceof ei||Yx1(Z)||Qx1(Z)),Yx1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof oM&&typeof Z.pipe==="function"&&Z.pipe!==ei.Writable.prototype.pipe,Qx1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof oM&&typeof Z.write==="function"&&typeof Z.end==="function",JZ=Symbol("EOF"),XZ=Symbol("maybeEmitEnd"),hJ=Symbol("emittedEnd"),NF=Symbol("emittingEnd"),vG=Symbol("emittedError"),OF=Symbol("closed"),oi=Symbol("read"),TF=Symbol("flush"),ri=Symbol("flushChunk"),w9=Symbol("encoding"),$3=Symbol("decoder"),y8=Symbol("flowing"),VG=Symbol("paused"),Y3=Symbol("resume"),p8=Symbol("buffer"),S6=Symbol("pipes"),i8=Symbol("bufferLength"),gM=Symbol("bufferPush"),CF=Symbol("bufferShift"),c6=Symbol("objectMode"),x8=Symbol("destroyed"),dM=Symbol("error"),aM=Symbol("emitData"),ti=Symbol("emitEnd"),nM=Symbol("emitEnd2"),$7=Symbol("async"),sM=Symbol("abort"),fF=Symbol("aborted"),HG=Symbol("signal"),C$=Symbol("dataListeners"),I5=Symbol("discarded"),qG=(Z)=>Promise.resolve().then(Z),Kx1=(Z)=>Z(),Wx1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",Gx1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,zx1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class rM{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 Zg extends rM{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 vx1=(Z)=>!!Z.objectMode,Vx1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class f$ extends oM{[y8]=!1;[VG]=!1;[S6]=[];[p8]=[];[c6];[w9];[$7];[$3];[JZ]=!1;[hJ]=!1;[NF]=!1;[OF]=!1;[vG]=null;[i8]=0;[x8]=!1;[HG];[fF]=!1;[C$]=0;[I5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(vx1(J))this[c6]=!0,this[w9]=null;else if(Vx1(J))this[w9]=J.encoding,this[c6]=!1;else this[c6]=!1,this[w9]=null;if(this[$7]=!!J.async,this[$3]=this[w9]?new Xx1(this[w9]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[p8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[S6]});let{signal:X}=J;if(X)if(this[HG]=X,X.aborted)this[sM]();else X.addEventListener("abort",()=>this[sM]())}get bufferLength(){return this[i8]}get encoding(){return this[w9]}set encoding(Z){throw Error("Encoding must be set at instantiation time")}setEncoding(Z){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[c6]}set objectMode(Z){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[$7]}set["async"](Z){this[$7]=this[$7]||!!Z}[sM](){this[fF]=!0,this.emit("abort",this[HG]?.reason),this.destroy(this[HG]?.reason)}get aborted(){return this[fF]}set aborted(Z){}write(Z,J,X){if(this[fF])return!1;if(this[JZ])throw Error("write after end");if(this[x8])return this.emit("error",Object.assign(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[$7]?qG:Kx1;if(!this[c6]&&!Buffer.isBuffer(Z)){if(zx1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(Gx1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[c6]){if(this[y8]&&this[i8]!==0)this[TF](!0);if(this[y8])this.emit("data",Z);else this[gM](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[w9]&&!this[$3]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[w9])Z=this[$3].write(Z);if(this[y8]&&this[i8]!==0)this[TF](!0);if(this[y8])this.emit("data",Z);else this[gM](Z);if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}read(Z){if(this[x8])return null;if(this[I5]=!1,this[i8]===0||Z===0||Z&&Z>this[i8])return this[XZ](),null;if(this[c6])Z=null;if(this[p8].length>1&&!this[c6])this[p8]=[this[w9]?this[p8].join(""):Buffer.concat(this[p8],this[i8])];let J=this[oi](Z||null,this[p8][0]);return this[XZ](),J}[oi](Z,J){if(this[c6])this[CF]();else{let X=J;if(Z===X.length||Z===null)this[CF]();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[JZ])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[JZ]=!0,this.writable=!1,this[y8]||!this[VG])this[XZ]();return this}[Y3](){if(this[x8])return;if(!this[C$]&&!this[S6].length)this[I5]=!0;if(this[VG]=!1,this[y8]=!0,this.emit("resume"),this[p8].length)this[TF]();else if(this[JZ])this[XZ]();else this.emit("drain")}resume(){return this[Y3]()}pause(){this[y8]=!1,this[VG]=!0,this[I5]=!1}get destroyed(){return this[x8]}get flowing(){return this[y8]}get paused(){return this[VG]}[gM](Z){if(this[c6])this[i8]+=1;else this[i8]+=Z.length;this[p8].push(Z)}[CF](){if(this[c6])this[i8]-=1;else this[i8]-=this[p8][0].length;return this[p8].shift()}[TF](Z=!1){do;while(this[ri](this[CF]())&&this[p8].length);if(!Z&&!this[p8].length&&!this[JZ])this.emit("drain")}[ri](Z){return this.emit("data",Z),this[y8]}pipe(Z,J){if(this[x8])return Z;this[I5]=!1;let X=this[hJ];if(J=J||{},Z===si.stdout||Z===si.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[S6].push(!J.proxyErrors?new rM(this,Z,J):new Zg(this,Z,J)),this[$7])qG(()=>this[Y3]());else this[Y3]();return Z}unpipe(Z){let J=this[S6].find((X)=>X.dest===Z);if(J){if(this[S6].length===1){if(this[y8]&&this[C$]===0)this[y8]=!1;this[S6]=[]}else this[S6].splice(this[S6].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[I5]=!1,this[C$]++,!this[S6].length&&!this[y8])this[Y3]()}else if(Z==="readable"&&this[i8]!==0)super.emit("readable");else if(Wx1(Z)&&this[hJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[vG]){let $=J;if(this[$7])qG(()=>$.call(this,this[vG]));else $.call(this,this[vG])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[C$]=this.listeners("data").length,this[C$]===0&&!this[I5]&&!this[S6].length)this[y8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[C$]=0,!this[I5]&&!this[S6].length)this[y8]=!1}return J}get emittedEnd(){return this[hJ]}[XZ](){if(!this[NF]&&!this[hJ]&&!this[x8]&&this[p8].length===0&&this[JZ]){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!==x8&&this[x8])return!1;else if(Z==="data")return!this[c6]&&!X?!1:this[$7]?(qG(()=>this[aM](X)),!0):this[aM](X);else if(Z==="end")return this[ti]();else if(Z==="close"){if(this[OF]=!0,!this[hJ]&&!this[x8])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Z==="error"){this[vG]=X,super.emit(dM,X);let Y=!this[HG]||this.listeners("error").length?super.emit("error",X):!1;return this[XZ](),Y}else if(Z==="resume"){let Y=super.emit("resume");return this[XZ](),Y}else if(Z==="finish"||Z==="prefinish"){let Y=super.emit(Z);return this.removeAllListeners(Z),Y}let $=super.emit(Z,...J);return this[XZ](),$}[aM](Z){for(let X of this[S6])if(X.dest.write(Z)===!1)this.pause();let J=this[I5]?!1:super.emit("data",Z);return this[XZ](),J}[ti](){if(this[hJ])return!1;return this[hJ]=!0,this.readable=!1,this[$7]?(qG(()=>this[nM]()),!0):this[nM]()}[nM](){if(this[$3]){let J=this[$3].end();if(J){for(let X of this[S6])X.dest.write(J);if(!this[I5])super.emit("data",J)}}for(let J of this[S6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[c6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[c6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[c6])throw Error("cannot concat in objectMode");let Z=await this.collect();return this[w9]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(x8,()=>J(Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[I5]=!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[JZ])return J();let Y,Q,K=(v)=>{this.off("data",W),this.off("end",G),this.off(x8,z),J(),Q(v)},W=(v)=>{this.off("error",K),this.off("end",G),this.off(x8,z),this.pause(),Y({value:v,done:!!this[JZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(x8,z),J(),Y({done:!0,value:void 0})},z=()=>K(Error("stream destroyed"));return new Promise((v,H)=>{Q=H,Y=v,this.once(x8,z),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[I5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(dM,J),this.off(x8,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(dM,J),this.once(x8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[x8]){if(Z)this.emit("error",Z);else this.emit(x8);return this}this[x8]=!0,this[I5]=!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(x8);return this}static get isStream(){return $x1}}var Bx1=Ux1.native,cG={lstatSync:Fx1,readdir:cx1,readdirSync:wx1,readlinkSync:xx1,realpathSync:Bx1,promises:{lstat:Lx1,readdir:Dx1,readlink:Mx1,realpath:Rx1}},Qg=(Z)=>!Z||Z===cG||Z===jx1?cG:{...cG,...Z,promises:{...cG.promises,...Z.promises||{}}},Kg=/^\\\\\?\\([a-z]:)\\?$/i,Px1=(Z)=>Z.replace(/\//g,"\\").replace(Kg,"$1\\"),Nx1=/[\\\/]/,F4=0,Wg=1,Gg=2,Y7=4,zg=6,vg=8,k$=10,Vg=12,q4=15,FG=~q4,tM=16,Jg=32,wG=64,x9=128,kF=256,IF=512,Xg=wG|x9|IF,Ox1=1023,eM=(Z)=>Z.isFile()?vg:Z.isDirectory()?Y7:Z.isSymbolicLink()?k$:Z.isCharacterDevice()?Gg:Z.isBlockDevice()?zg:Z.isSocket()?Vg:Z.isFIFO()?Wg:F4,$g=new Map,xG=(Z)=>{let J=$g.get(Z);if(J)return J;let X=Z.normalize("NFKD");return $g.set(Z,X),X},Yg=new Map,EF=(Z)=>{let J=Yg.get(Z);if(J)return J;let X=xG(Z.toLowerCase());return Yg.set(Z,X),X};class JR extends zG{constructor(){super({max:256})}}class Hg extends zG{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var qg=Symbol("PathScurry setAsCwd");class b6{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}#w;get ctimeMs(){return this.#w}#c;get birthtimeMs(){return this.#c}#U;get atime(){return this.#U}#O;get mtime(){return this.#O}#j;get ctime(){return this.#j}#T;get birthtime(){return this.#T}#D;#L;#B;#P;#x;#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?EF(Z):xG(Z),this.#K=J&Ox1,this.nocase=Y,this.roots=$,this.root=X||this,this.#I=Q,this.#B=K.fullpath,this.#x=K.relative,this.#f=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=Qg(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&=~tM,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),$=this.nocase?EF(Z):xG(Z);for(let W of X)if(W.#D===$)return W;let Y=this.parent?this.sep:"",Q=this.#B?this.#B+Y+Z:void 0,K=this.newChild(Z,F4,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=x9;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let Z=this.name,J=this.parent;if(!J)return this.#x=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.#B!==void 0)return this.#B;let Z=this.name,J=this.parent;if(!J)return this.#B=this.name;let $=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#B=$}fullpathPosix(){if(this.#P!==void 0)return this.#P;if(this.sep==="/")return this.#P=this.fullpath();if(!this.parent){let $=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test($))return this.#P=`//?/${$}`;else return this.#P=$}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#P=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)===vg}isDirectory(){return(this.#K&q4)===Y7}isCharacterDevice(){return(this.#K&q4)===Gg}isBlockDevice(){return(this.#K&q4)===zg}isFIFO(){return(this.#K&q4)===Wg}isSocket(){return(this.#K&q4)===Vg}isSymbolicLink(){return(this.#K&k$)===k$}lstatCached(){return this.#K&Jg?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!==k$||this.#K&kF||this.#K&x9)}calledReaddir(){return!!(this.#K&tM)}isENOENT(){return!!(this.#K&x9)}isNamed(Z){return!this.nocase?this.#D===xG(Z):this.#D===EF(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.#b(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.#b(J.code);return}}#u(Z){this.#K|=tM;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#_()}}#_(){if(this.#K&x9)return;this.#K=(this.#K|x9)&FG,this.#S()}#S(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#_()}#l(){this.#K|=IF,this.#N()}#N(){if(this.#K&wG)return;let Z=this.#K;if((Z&q4)===Y7)Z&=FG;this.#K=Z|wG,this.#S()}#C(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#N();else if(Z==="ENOENT")this.#_();else this.children().provisional=0}#y(Z=""){if(Z==="ENOTDIR")this.parent.#N();else if(Z==="ENOENT")this.#_()}#b(Z=""){let J=this.#K;if(J|=kF,Z==="ENOENT")J|=x9;if(Z==="EINVAL"||Z==="UNKNOWN")J&=FG;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#N()}#h(Z,J){return this.#p(Z,J)||this.#q(Z,J)}#q(Z,J){let X=eM(Z),$=this.newChild(Z.name,X,{parent:this}),Y=$.#K&q4;if(Y!==Y7&&Y!==k$&&Y!==F4)$.#K|=wG;return J.unshift($),J.provisional++,$}#p(Z,J){for(let X=J.provisional;X<J.length;X++){let $=J[X];if((this.nocase?EF(Z.name):xG(Z.name))!==$.#D)continue;return this.#A(Z,$,X,J)}}#A(Z,J,X,$){let Y=J.name;if(J.#K=J.#K&FG|eM(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&x9)===0)try{return this.#E(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#y(Z.code)}}lstatSync(){if((this.#K&x9)===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:c,rdev:w,size:x,uid:j}=Z;this.#U=J,this.#Q=X,this.#T=$,this.#c=Y,this.#W=Q,this.#V=K,this.#j=W,this.#w=G,this.#J=z,this.#v=v,this.#G=H,this.#$=V,this.#O=q,this.#F=F,this.#X=c,this.#H=w,this.#z=x,this.#Y=j;let B=eM(Z);if(this.#K=this.#K&FG|B|Jg,B!==F4&&B!==Y7&&B!==k$)this.#K|=wG}#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.#h(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.#h($,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.#h(X,Z);this.#u(Z)}catch(X){this.#C(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&Xg)return!1;let Z=q4&this.#K;if(!(Z===F4||Z===Y7||Z===k$))return!1;return!0}shouldWalk(Z,J){return(this.#K&Y7)===Y7&&!(this.#K&Xg)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#k)return this.#k;if((IF|kF|x9)&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((IF|kF|x9)&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($),$.#x=X.join(this.sep),$.#f=X.join("/"),$=$.parent,X.push("..");$=Z;while($&&$.parent&&!J.has($))$.#x=void 0,$.#f=void 0,$=$.parent}}class _F extends b6{sep="\\";splitSep=Nx1;constructor(Z,J=F4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}newChild(Z,J=F4,X={}){return new _F(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return ZR.parse(Z).root}getRoot(Z){if(Z=Px1(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 UG(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(Kg,"$1\\"),Z===J}}class hF extends b6{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 hF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class XR{root;rootPath;roots;cwd;#Z;#J;#$;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:$,childrenCacheSize:Y=16384,fs:Q=cG}={}){if(this.#X=Qg(Q),Z instanceof URL||Z.startsWith("file://"))Z=qx1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new JR,this.#J=new JR,this.#$=new Hg(Y);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if($===void 0)throw 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:Array(F).fill("..").join(v),relativePosix: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 b6))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 b6))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 b6))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 b6))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 b6))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 b6))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 b6))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 c=()=>{if(--F===0)H()};for(let w of q){if(!Y||Y(w))K.push(X?w:w.fullpath());if($&&w.isSymbolicLink())w.realpath().then((x)=>x?.isUnknown()?x.lstat():x).then((x)=>x?.shouldWalk(W,Q)?G(x,c):c());else if(w.shouldWalk(W,Q))G(w,c);else c()}},!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 b6))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 b6))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 b6))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 b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new f$({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=(c,w,x=!1)=>{if(c)return K.emit("error",c);if($&&!x){let j=[];for(let B of w)if(B.isSymbolicLink())j.push(B.realpath().then((L)=>L?.isUnknown()?L.lstat():L));if(j.length){Promise.all(j).then(()=>q(null,w,!0));return}}for(let j of w)if(j&&(!Y||Y(j))){if(!K.write(X?j:j.fullpath()))H=!0}z--;for(let j of w){let B=j.realpathCached()||j;if(B.shouldWalk(W,Q))G.push(B)}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 b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new f$({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 c=F;if(F.isSymbolicLink()){if(!($&&(c=F.realpathSync())))continue;if(c.isUnknown())c.lstatSync()}if(c.shouldWalk(W,Q))G.push(c)}}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 UG extends XR{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,ZR,"\\",{...J,nocase:X});this.nocase=X;for(let $=this.cwd;$;$=$.parent)$.nocase=this.nocase}parseRootPath(Z){return ZR.parse(Z).root.toUpperCase()}newRoot(Z){return new _F(this.rootPath,Y7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class jG extends XR{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,Hx1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new hF(this.rootPath,Y7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class SF extends jG{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var wP6=process.platform==="win32"?_F:hF,Fg=process.platform==="win32"?UG:process.platform==="darwin"?SF:jG;var Tx1=(Z)=>Z.length>=1,Cx1=(Z)=>Z.length>=1;class Q3{#Z;#J;#$;length;#X;#Y;#v;#H;#W;#G;#z=!0;constructor(Z,J,X,$){if(!Tx1(Z))throw TypeError("empty pattern list");if(!Cx1(J))throw TypeError("empty glob list");if(J.length!==Z.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw 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("/"),c=[z,v,H,V,""].join("/");this.#Z=[F,...G],this.#J=[c,...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 fx1=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=fx1}){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 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 $R{store;constructor(Z=new Map){this.store=Z}copy(){return new $R(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 cg{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 wg{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 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 LG{hasWalkedCache;matches=new cg;subwalks=new wg;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new $R}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 LG(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 kx1=(Z,J)=>typeof Z==="string"?new BG([Z],J):Array.isArray(Z)?new BG(Z,J):Z;class YR{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=kx1(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw 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 LG(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 LG(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 bF extends YR{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 AF extends YR{results;constructor(Z,J,X){super(Z,J,X);this.results=new f$({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 Ix1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Q7{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 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=Ex1(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 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 TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||Ix1,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?UG:J.platform==="darwin"?SF:J.platform?jG:Fg;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 Error("invalid pattern object");return new Q3(W,z,0,this.platform)})}async walk(){return[...await new bF(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 bF(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 AF(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 AF(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 QR=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new H4(X,J).hasMagic())return!0;return!1};function uF(Z,J={}){return new Q7(Z,J).streamSync()}function Ug(Z,J={}){return new Q7(Z,J).stream()}function jg(Z,J={}){return new Q7(Z,J).walkSync()}async function xg(Z,J={}){return new Q7(Z,J).walk()}function lF(Z,J={}){return new Q7(Z,J).iterateSync()}function Bg(Z,J={}){return new Q7(Z,J).iterate()}var _x1=uF,hx1=Object.assign(Ug,{sync:uF}),Sx1=lF,bx1=Object.assign(Bg,{sync:lF}),Ax1=Object.assign(jg,{stream:uF,iterate:lF}),mF=Object.assign(xg,{glob:xg,globSync:jg,sync:Ax1,globStream:Ug,stream:hx1,globStreamSync:uF,streamSync:_x1,globIterate:Bg,iterate:bx1,globIterateSync:lF,iterateSync:Sx1,Glob:Q7,hasMagic:QR,escape:Z3,unescape:c9});mF.glob=mF;class KR{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 $Z{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 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 yF extends KR{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 $Z(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 DG(){return DG=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},DG.apply(this,arguments)}class U9{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 c1{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"),SJ=Symbol("immutableKeys");class pF extends KR{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[H1]=void 0,this[SJ]=void 0,this.graph=Z,this[SJ]=new Set,this[H1]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let $=Z[X];if($ instanceof pF){let Y=this.graph._createEdge(X,this,$);this[SJ].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 $Z){let Y=$;if(Y.getChild()===Z)this.setRef(X,J,Y.getAttributes())}else if($ instanceof U9)for(let Y of $.listRefsByChild(Z)){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if($ instanceof c1){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[SJ].has(Z))throw 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 U9)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 U9||J instanceof c1)return J;throw 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,DG({},$,{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 Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(DG({},Z,{target:this})),this.graph.dispatchEvent(DG({},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[SJ].has(J))Z.getChild().dispose()}else if(this[H1][J]instanceof U9)this[H1][J].remove(Z);else if(this[H1][J]instanceof c1)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 Og="v4.2.1",I$="@glb.bin",g;(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"})(g||(g={}));var sF;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(sF||(sF={}));var h5;(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"})(h5||(h5={}));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 YZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(YZ||(YZ={}));var AJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array};class E0{static createBufferFromDataURI(Z){if(typeof Buffer>"u"){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 Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class HR{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 Tg{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),mx1(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 TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class tF{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))===tF.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}}tF.PNG_FRIED_CHUNK_NAME="CgBI";class _5{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}`}}_5.impls={"image/jpeg":new Tg,"image/png":new tF};function mx1(Z,J){if(J>Z.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw TypeError("Invalid JPG, marker table corrupted");return Z}class QZ{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 _5.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 GR=typeof Float32Array<"u"?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 ux1(){var Z=new GR(3);if(GR!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function WR(Z){var J=Z[0],X=Z[1],$=Z[2];return Math.hypot(J,X,$)}function lx1(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=ux1();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 PG(Z){let J=Cg(),X=Z.propertyType===g.NODE?[Z]:Z.listChildren();for(let $ of X)$.traverse((Y)=>{let Q=Y.getMesh();if(!Q)return;let K=yx1(Q,Y.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))zR(K.min,J),zR(K.max,J)});return J}function yx1(Z,J){let X=Cg();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=lx1(W,K,J),zR(W,X)}}return X}function zR(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 Cg(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}var Lg="https://null.example";class c4{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return QZ.basename(new URL(Z,Lg).pathname)}static extension(Z){return QZ.extension(new URL(Z,Lg).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)}}c4.DEFAULT_INIT={};c4.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;function Dg(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function E$(Z){if(Dg(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Dg(X)===!1)return!1;if(Object.hasOwn(X,"isPrototypeOf")===!1)return!1;return!0}var vR,MG;(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"})(MG||(MG={}));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)}}vR=z5;z5.Verbosity=MG;z5.DEFAULT_INSTANCE=new vR(vR.Verbosity.INFO);function px1(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],c=Z[14],w=Z[15],x=J*K-X*Q,j=J*W-$*Q,B=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,P=z*F-v*q,N=z*c-H*q,O=z*w-V*q,k=v*c-H*F,E=v*w-V*F,S=H*w-V*c;return x*S-j*E+B*k+L*O-R*N+M*P}function ix1(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],c=J[12],w=J[13],x=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*$+L*W+R*H+M*c,Z[1]=B*Y+L*G+R*V+M*w,Z[2]=B*Q+L*z+R*q+M*x,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*$+L*W+R*H+M*c,Z[5]=B*Y+L*G+R*V+M*w,Z[6]=B*Q+L*z+R*q+M*x,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*$+L*W+R*H+M*c,Z[9]=B*Y+L*G+R*V+M*w,Z[10]=B*Q+L*z+R*q+M*x,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*$+L*W+R*H+M*c,Z[13]=B*Y+L*G+R*V+M*w,Z[14]=B*Q+L*z+R*q+M*x,Z[15]=B*K+L*v+R*F+M*j,Z}function gx1(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 dx1(Z,J){var X=new GR(3);gx1(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,c=K+v+F,w=0;if(c>0)w=Math.sqrt(c+1)*2,Z[3]=0.25*w,Z[0]=(H-q)/w,Z[1]=(V-G)/w,Z[2]=(W-z)/w;else if(K>v&&K>F)w=Math.sqrt(1+K-v-F)*2,Z[3]=(H-q)/w,Z[0]=0.25*w,Z[1]=(W+z)/w,Z[2]=(V+G)/w;else if(v>F)w=Math.sqrt(1+v-K-F)*2,Z[3]=(V-G)/w,Z[0]=(W+z)/w,Z[1]=0.25*w,Z[2]=(H+q)/w;else w=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/w,Z[0]=(V+G)/w,Z[1]=(H+q)/w,Z[2]=0.25*w;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 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 Error("Invalid component type.")}}static decompose(Z,J,X,$){let Y=WR([Z[0],Z[1],Z[2]]),Q=WR([Z[4],Z[5],Z[6]]),K=WR([Z[8],Z[9],Z[10]]);if(px1(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,dx1(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,c=K*v,w=K*H,x=W*H,j=G*z,B=G*v,L=G*H,R=X[0],M=X[1],P=X[2];return Y[0]=(1-(c+x))*R,Y[1]=(q+L)*R,Y[2]=(F-B)*R,Y[3]=0,Y[4]=(q-L)*M,Y[5]=(1-(V+x))*M,Y[6]=(w+j)*M,Y[7]=0,Y[8]=(F+B)*P,Y[9]=(w-j)*P,Y[10]=(1-(V+c))*P,Y[11]=0,Y[12]=Z[0],Y[13]=Z[1],Y[14]=Z[2],Y[15]=1,Y}}function ax1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),$=J.getChild();return X===$||X.equals($)}function nx1(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 sx1(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 fg(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 kg(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!E$(Z)||!E$(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(oF(W)&&oF(G)){if(!fg(W,G))return!1}else if(E$(W)&&E$(G)){if(!kg(W,G))return!1}else if(W!==G)return!1}return!0}function oF(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Mg="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",ox1=999,rx1=6,Rg=new Set,tx1=function(){let J="";for(let X=0;X<rx1;X++)J+=Mg.charAt(Math.floor(Math.random()*Mg.length));return J},Eg=function(){for(let J=0;J<ox1;J++){let X=tx1();if(!Rg.has(X))return Rg.add(X),X}return""},bJ=(Z)=>Z,ex1=new Set;class eF extends pF{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 $Z){if(!this[SJ].has(X))$.dispose()}else if($ instanceof U9||$ instanceof c1)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 $Z)if(this[SJ].has(X))$.getChild().copy(J(Y.getChild()),J);else this.setRef(X,J(Y.getChild()),Y.getAttributes());else if(Y instanceof c1||Y instanceof U9)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(E$(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=ex1){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 $Z||Y instanceof $Z){if(!ax1($,Y))return!1}else if($ instanceof c1||Y instanceof c1||$ instanceof U9||Y instanceof U9){if(!nx1($,Y))return!1}else if($ instanceof A6||Y instanceof A6){if(!sx1($,Y))return!1}else if(E$($)||E$(Y)){if(!kg($,Y))return!1}else if(oF($)||oF(Y)){if(!fg($,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 x6 extends eF{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 x6{init(){this.propertyType=g.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 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 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?ZU1(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 ZU1(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 Error("Unknown accessor componentType.")}}class qR extends x6{init(){this.propertyType=g.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new c1,samplers:new c1})}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 KZ extends x6{init(){this.propertyType=g.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)}}KZ.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class mJ extends x6{init(){this.propertyType=g.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:mJ.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:h5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:h5.OTHER})}}mJ.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class FR extends x6{init(){this.propertyType=g.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class _$ extends x6{init(){this.propertyType=g.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:_$.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)}}_$.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class O1 extends eF{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}O1.EXTENSION_NAME=void 0;class F1 extends x6{init(){this.propertyType=g.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:iF,G:gF,B:dF,A:JU1}=v5;class K7 extends x6{init(){this.propertyType=g.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:K7.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:iF|gF|dF|JU1,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:iF|gF|dF,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:iF|gF|dF})}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:iF})}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:gF|dF})}}K7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class NG extends x6{init(){this.propertyType=g.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new c1})}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 Zc extends x6{init(){this.propertyType=g.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 c1})}copy(Z,J=bJ){if(J===bJ)throw 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())ix1(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===g.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===g.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 x6{init(){this.propertyType=g.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:g1.Mode.TRIANGLES,material:null,indices:null,attributes:new A6,targets:new c1})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:h5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:h5.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 cR extends eF{init(){this.propertyType=g.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:h5.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 x6{init(){this.propertyType=g.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new c1})}copy(Z,J=bJ){if(J===bJ)throw 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 wR extends x6{init(){this.propertyType=g.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new c1})}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:h5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class h$ extends x6{init(){this.propertyType=g.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||_5.extensionToMimeType(QZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=_5.extensionToMimeType(QZ.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 _5.getSize(Z,this.getMimeType())}}class W3 extends x6{init(){this.propertyType=g.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Og}`,version:"2.0"},defaultScene:null,accessors:new c1,animations:new c1,buffers:new c1,cameras:new c1,materials:new c1,meshes:new c1,nodes:new c1,scenes:new c1,skins:new c1,textures:new c1})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw Error("Root cannot be cloned.")}copy(Z,J=bJ){if(J===bJ)throw 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 Zc)this.addRef("nodes",Z);else if(Z instanceof _$)this.addRef("cameras",Z);else if(Z instanceof wR)this.addRef("skins",Z);else if(Z instanceof NG)this.addRef("meshes",Z);else if(Z instanceof K7)this.addRef("materials",Z);else if(Z instanceof h$)this.addRef("textures",Z);else if(Z instanceof qR)this.addRef("animations",Z);else if(Z instanceof K0)this.addRef("accessors",Z);else if(Z instanceof FR)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 w6{static fromGraph(Z){return w6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new yF,this._root=new W3(this._graph),this._logger=z5.DEFAULT_INSTANCE,w6._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 Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw 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 Zc(this._graph,Z)}createCamera(Z=""){return new _$(this._graph,Z)}createSkin(Z=""){return new wR(this._graph,Z)}createMesh(Z=""){return new NG(this._graph,Z)}createPrimitive(){return new g1(this._graph)}createPrimitiveTarget(Z=""){return new cR(this._graph,Z)}createMaterial(Z=""){return new K7(this._graph,Z)}createTexture(Z=""){return new h$(this._graph,Z)}createAnimation(Z=""){return new qR(this._graph,Z)}createAnimationChannel(Z=""){return new KZ(this._graph,Z)}createAnimationSampler(Z=""){return new mJ(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 FR(this._graph,Z)}}w6._GRAPH_DOCUMENTS=new WeakMap;class T1{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}}T1.EXTENSION_NAME=void 0;class Ig{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 Pg={logger:z5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},XU1=new Set([g.BUFFER,g.TEXTURE,g.MATERIAL,g.MESH,g.PRIMITIVE,g.NODE,g.SCENE]);class _g{static read(Z,J=Pg){let X=m6({},Pg,J),{json:$}=Z,Y=new w6().setLogger(X.logger);this.validate(Z,X);let Q=new Ig(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,P)=>M.EXTENSION_NAME>P.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let P=Y.createExtension(M).setRequired(z.includes(M.EXTENSION_NAME)),N=P.prereadTypes.filter((O)=>!XU1.has(O));if(N.length)X.logger.warn(`Preread hooks for some types (${N.join()}), requested by extension ${P.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of P.readDependencies)P.install(O,X.dependencies[O])}let v=$.buffers||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.BUFFER)).forEach((M)=>M.preread(Q,g.BUFFER)),Q.buffers=v.map((M)=>{let P=Y.createBuffer(M.name);if(M.extras)P.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)P.setURI(M.uri);return P});let H=$.bufferViews||[];Q.bufferViewBuffers=H.map((M,P)=>{if(!Q.bufferViews[P]){let N=Z.json.buffers[M.buffer],O=N.uri?Z.resources[N.uri]:Z.resources[I$],k=M.byteOffset||0;Q.bufferViews[P]=E0.toView(O,k,M.byteLength)}return Q.buffers[M.buffer]});let V=$.accessors||[];Q.accessors=V.map((M)=>{let P=Q.bufferViewBuffers[M.bufferView],N=Y.createAccessor(M.name,P).setType(M.type);if(M.extras)N.setExtras(M.extras);if(M.normalized!==void 0)N.setNormalized(M.normalized);if(M.bufferView===void 0)return N;return N.setArray(nF(M,Q)),N});let q=$.images||[],F=$.textures||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.TEXTURE)).forEach((M)=>M.preread(Q,g.TEXTURE)),Q.textures=q.map((M)=>{let P=Y.createTexture(M.name);if(M.extras)P.setExtras(M.extras);if(M.bufferView!==void 0){let N=$.bufferViews[M.bufferView],O=Z.json.buffers[N.buffer],k=O.uri?Z.resources[O.uri]:Z.resources[I$],E=N.byteOffset||0,S=N.byteLength,f=k.slice(E,E+S);P.setImage(f)}else if(M.uri!==void 0){if(P.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)P.setURI(M.uri)}if(M.mimeType!==void 0)P.setMimeType(M.mimeType);else if(M.uri){let N=QZ.extension(M.uri);P.setMimeType(_5.extensionToMimeType(N))}return P}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.MATERIAL)).forEach((M)=>M.preread(Q,g.MATERIAL));let c=$.materials||[];Q.materials=c.map((M)=>{let P=Y.createMaterial(M.name);if(M.extras)P.setExtras(M.extras);if(M.alphaMode!==void 0)P.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)P.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)P.setDoubleSided(M.doubleSided);let N=M.pbrMetallicRoughness||{};if(N.baseColorFactor!==void 0)P.setBaseColorFactor(N.baseColorFactor);if(M.emissiveFactor!==void 0)P.setEmissiveFactor(M.emissiveFactor);if(N.metallicFactor!==void 0)P.setMetallicFactor(N.metallicFactor);if(N.roughnessFactor!==void 0)P.setRoughnessFactor(N.roughnessFactor);if(N.baseColorTexture!==void 0){let O=N.baseColorTexture,k=Q.textures[F[O.index].source];P.setBaseColorTexture(k),Q.setTextureInfo(P.getBaseColorTextureInfo(),O)}if(M.emissiveTexture!==void 0){let O=M.emissiveTexture,k=Q.textures[F[O.index].source];P.setEmissiveTexture(k),Q.setTextureInfo(P.getEmissiveTextureInfo(),O)}if(M.normalTexture!==void 0){let O=M.normalTexture,k=Q.textures[F[O.index].source];if(P.setNormalTexture(k),Q.setTextureInfo(P.getNormalTextureInfo(),O),M.normalTexture.scale!==void 0)P.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let O=M.occlusionTexture,k=Q.textures[F[O.index].source];if(P.setOcclusionTexture(k),Q.setTextureInfo(P.getOcclusionTextureInfo(),O),M.occlusionTexture.strength!==void 0)P.setOcclusionStrength(M.occlusionTexture.strength)}if(N.metallicRoughnessTexture!==void 0){let O=N.metallicRoughnessTexture,k=Q.textures[F[O.index].source];P.setMetallicRoughnessTexture(k),Q.setTextureInfo(P.getMetallicRoughnessTextureInfo(),O)}return P}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.MESH)).forEach((M)=>M.preread(Q,g.MESH));let w=$.meshes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.PRIMITIVE)).forEach((M)=>M.preread(Q,g.PRIMITIVE)),Q.meshes=w.map((M)=>{let P=Y.createMesh(M.name);if(M.extras)P.setExtras(M.extras);if(M.weights!==void 0)P.setWeights(M.weights);return(M.primitives||[]).forEach((O)=>{let k=Y.createPrimitive();if(O.extras)k.setExtras(O.extras);if(O.material!==void 0)k.setMaterial(Q.materials[O.material]);if(O.mode!==void 0)k.setMode(O.mode);for(let[f,C]of Object.entries(O.attributes||{}))k.setAttribute(f,Q.accessors[C]);if(O.indices!==void 0)k.setIndices(Q.accessors[O.indices]);let E=M.extras&&M.extras.targetNames||[];(O.targets||[]).forEach((f,C)=>{let h=E[C]||C.toString(),_=Y.createPrimitiveTarget(h);for(let[a,s]of Object.entries(f))_.setAttribute(a,Q.accessors[s]);k.addTarget(_)}),P.addPrimitive(k)}),P});let x=$.cameras||[];Q.cameras=x.map((M)=>{let P=Y.createCamera(M.name).setType(M.type);if(M.extras)P.setExtras(M.extras);if(M.type===_$.Type.PERSPECTIVE){let N=M.perspective;if(P.setYFov(N.yfov),P.setZNear(N.znear),N.zfar!==void 0)P.setZFar(N.zfar);if(N.aspectRatio!==void 0)P.setAspectRatio(N.aspectRatio)}else{let N=M.orthographic;P.setZNear(N.znear).setZFar(N.zfar).setXMag(N.xmag).setYMag(N.ymag)}return P});let j=$.nodes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.NODE)).forEach((M)=>M.preread(Q,g.NODE)),Q.nodes=j.map((M)=>{let P=Y.createNode(M.name);if(M.extras)P.setExtras(M.extras);if(M.translation!==void 0)P.setTranslation(M.translation);if(M.rotation!==void 0)P.setRotation(M.rotation);if(M.scale!==void 0)P.setScale(M.scale);if(M.matrix!==void 0){let N=[0,0,0],O=[0,0,0,1],k=[1,1,1];I0.decompose(M.matrix,N,O,k),P.setTranslation(N),P.setRotation(O),P.setScale(k)}if(M.weights!==void 0)P.setWeights(M.weights);return P});let B=$.skins||[];Q.skins=B.map((M)=>{let P=Y.createSkin(M.name);if(M.extras)P.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)P.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)P.setSkeleton(Q.nodes[M.skeleton]);for(let N of M.joints)P.addJoint(Q.nodes[N]);return P}),j.map((M,P)=>{let N=Q.nodes[P];if((M.children||[]).forEach((k)=>N.addChild(Q.nodes[k])),M.mesh!==void 0)N.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)N.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)N.setSkin(Q.skins[M.skin])});let L=$.animations||[];Q.animations=L.map((M)=>{let P=Y.createAnimation(M.name);if(M.extras)P.setExtras(M.extras);let O=(M.samplers||[]).map((E)=>{let S=Y.createAnimationSampler().setInput(Q.accessors[E.input]).setOutput(Q.accessors[E.output]).setInterpolation(E.interpolation||mJ.Interpolation.LINEAR);if(E.extras)S.setExtras(E.extras);return P.addSampler(S),S});return(M.channels||[]).forEach((E)=>{let S=Y.createAnimationChannel().setSampler(O[E.sampler]).setTargetPath(E.target.path);if(E.target.node!==void 0)S.setTargetNode(Q.nodes[E.target.node]);if(E.extras)S.setExtras(E.extras);P.addChannel(S)}),P});let R=$.scenes||[];if(Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.SCENE)).forEach((M)=>M.preread(Q,g.SCENE)),Q.scenes=R.map((M)=>{let P=Y.createScene(M.name);if(M.extras)P.setExtras(M.extras);return(M.nodes||[]).map((O)=>Q.nodes[O]).forEach((O)=>P.addChild(O)),P}),$.scene!==void 0)Y.getRoot().setDefaultScene(Q.scenes[$.scene]);return Y.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),V.forEach((M,P)=>{let N=Q.accessors[P],O=!!M.sparse,k=!M.bufferView&&!N.getArray();if(O||k)N.setSparse(!0).setArray(YU1(M,Q))}),Y}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let $ of X.extensionsRequired)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))throw 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 $U1(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=AJ[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,c;switch(Z.componentType){case K0.ComponentType.FLOAT:c=v.getFloat32(F,!0);break;case K0.ComponentType.UNSIGNED_INT:c=v.getUint32(F,!0);break;case K0.ComponentType.UNSIGNED_SHORT:c=v.getUint16(F,!0);break;case K0.ComponentType.UNSIGNED_BYTE:c=v.getUint8(F);break;case K0.ComponentType.SHORT:c=v.getInt16(F,!0);break;case K0.ComponentType.BYTE:c=v.getInt8(F);break;default:throw Error(`Unexpected componentType "${Z.componentType}".`)}z[V*K+q]=c}return z}function nF(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=AJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if(Y.byteStride!==void 0&&Y.byteStride!==G)return $U1(Z,J);let z=$.byteOffset+(Z.byteOffset||0),v=Z.count*K*W;return new Q($.buffer.slice(z,z+v))}function YU1(Z,J){let X=AJ[Z.componentType],$=K0.getElementSize(Z.type),Y;if(Z.bufferView!==void 0)Y=nF(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=nF(W,J),v=nF(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 RG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(RG||(RG={}));class w4{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 VR(Y>1,()=>X.basename||"buffer"),this.imageURIGenerator=new VR(Q>1,(K)=>QU1(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===YZ.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 $=_5.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 Error(Y)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return h5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:$}=X.getAttributes();if($)return $;if(X.getParent().propertyType!==g.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return h5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}w4.BufferViewTarget=RG;w4.BufferViewUsage=h5;w4.USAGE_TO_TARGET={[h5.ARRAY_BUFFER]:RG.ARRAY_BUFFER,[h5.ELEMENT_ARRAY_BUFFER]:RG.ELEMENT_ARRAY_BUFFER};class VR{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 QU1(Z,J){let X=Z.getGraph().listParentEdges(J).find(($)=>$.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:aF}=w4,{UNSIGNED_INT:KU1,UNSIGNED_SHORT:WU1,UNSIGNED_BYTE:GU1}=K0.ComponentType,zU1=new Set([g.ACCESSOR,g.BUFFER,g.MATERIAL,g.MESH]);class hg{static write(Z,J){let X=Z.getGraph(),$=Z.getRoot(),Y={asset:m6({generator:`glTF-Transform ${Og}`},$.getAsset()),extras:m6({},$.getExtras())},Q={json:Y,resources:{}},K=new w4(Z,Q,J),W=J.logger||z5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((w)=>w.EXTENSION_NAME)),z=Z.getRoot().listExtensionsUsed().filter((w)=>G.has(w.extensionName)).sort((w,x)=>w.extensionName>x.extensionName?1:-1),v=Z.getRoot().listExtensionsRequired().filter((w)=>G.has(w.extensionName)).sort((w,x)=>w.extensionName>x.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 w of z){let x=w.prewriteTypes.filter((j)=>!zU1.has(j));if(x.length)W.warn(`Prewrite hooks for some types (${x.join()}), requested by extension ${w.extensionName}, are unsupported. Please file an issue or a PR.`);for(let j of w.writeDependencies)w.install(j,J.dependencies[j])}function H(w,x,j,B){let L=[],R=0;for(let N of w){let O=K.createAccessorDef(N);O.bufferView=Y.bufferViews.length;let k=N.getArray(),E=E0.pad(E0.toView(k));O.byteOffset=R,R+=E.byteLength,L.push(E),K.accessorIndexMap.set(N,Y.accessors.length),Y.accessors.push(O)}let M=E0.concat(L),P={buffer:x,byteOffset:j,byteLength:M.byteLength};if(B)P.target=B;return Y.bufferViews.push(P),{buffers:L,byteLength:R}}function V(w,x,j){let B=w[0].getCount(),L=0;for(let O of w){let k=K.createAccessorDef(O);k.bufferView=Y.bufferViews.length,k.byteOffset=L;let E=O.getElementSize(),S=O.getComponentSize();L+=E0.padNumber(E*S),K.accessorIndexMap.set(O,Y.accessors.length),Y.accessors.push(k)}let R=B*L,M=new ArrayBuffer(R),P=new DataView(M);for(let O=0;O<B;O++){let k=0;for(let E of w){let S=E.getElementSize(),f=E.getComponentSize(),C=E.getComponentType(),h=E.getArray();for(let _=0;_<S;_++){let a=O*L+k+_*f,s=h[O*S+_];switch(C){case K0.ComponentType.FLOAT:P.setFloat32(a,s,!0);break;case K0.ComponentType.BYTE:P.setInt8(a,s);break;case K0.ComponentType.SHORT:P.setInt16(a,s,!0);break;case K0.ComponentType.UNSIGNED_BYTE:P.setUint8(a,s);break;case K0.ComponentType.UNSIGNED_SHORT:P.setUint16(a,s,!0);break;case K0.ComponentType.UNSIGNED_INT:P.setUint32(a,s,!0);break;default:throw Error("Unexpected component type: "+C)}}k+=E0.padNumber(S*f)}}let N={buffer:x,byteOffset:j,byteLength:R,byteStride:L,target:w4.BufferViewTarget.ARRAY_BUFFER};return Y.bufferViews.push(N),{byteLength:R,buffers:[new Uint8Array(M)]}}function q(w,x,j){let B=[],L=0,R=new Map,M=-1/0,P=!1;for(let C of w){let h=K.createAccessorDef(C);Y.accessors.push(h),K.accessorIndexMap.set(C,Y.accessors.length-1);let _=[],a=[],s=[],Z0=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),_.push(m0);for(let s0=0;s0<s.length;s0++)a.push(s[s0])}let o=_.length,M0={accessorDef:h,count:o};if(R.set(C,M0),o===0)continue;if(o>C.getCount()/2)P=!0;let R0=AJ[C.getComponentType()];M0.indices=_,M0.values=new R0(a)}if(!Number.isFinite(M))return{buffers:B,byteLength:L};if(P)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let N=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,O=M<255?GU1:M<65535?WU1:KU1,k={buffer:x,byteOffset:j+L,byteLength:0};for(let C of w){let h=R.get(C);if(h.count===0)continue;h.indicesByteOffset=k.byteLength;let _=E0.pad(E0.toView(new N(h.indices)));B.push(_),L+=_.byteLength,k.byteLength+=_.byteLength}Y.bufferViews.push(k);let E=Y.bufferViews.length-1,S={buffer:x,byteOffset:j+L,byteLength:0};for(let C of w){let h=R.get(C);if(h.count===0)continue;h.valuesByteOffset=S.byteLength;let _=E0.pad(E0.toView(h.values));B.push(_),L+=_.byteLength,S.byteLength+=_.byteLength}Y.bufferViews.push(S);let f=Y.bufferViews.length-1;for(let C of w){let h=R.get(C);if(h.count===0)continue;h.accessorDef.sparse={count:h.count,indices:{bufferView:E,byteOffset:h.indicesByteOffset,componentType:O},values:{bufferView:f,byteOffset:h.valuesByteOffset}}}return{buffers:B,byteLength:L}}if(Y.accessors=[],Y.bufferViews=[],Y.samplers=[],Y.textures=[],Y.images=$.listTextures().map((w,x)=>{let j=K.createPropertyDef(w);if(w.getMimeType())j.mimeType=w.getMimeType();let B=w.getImage();if(B)K.createImageData(j,B,w);return K.imageIndexMap.set(w,x),j}),z.filter((w)=>w.prewriteTypes.includes(g.ACCESSOR)).forEach((w)=>w.prewrite(K,g.ACCESSOR)),$.listAccessors().forEach((w)=>{let{accessorUsageGroupedByParent:x,accessorParents:j}=K;if(K.accessorIndexMap.has(w))return;let B=K.getAccessorUsage(w);if(K.addAccessorToUsageGroup(w,B),x.has(B)){let L=X.listParents(w).find((R)=>R.propertyType!==g.ROOT);j.set(w,L)}}),z.filter((w)=>w.prewriteTypes.includes(g.BUFFER)).forEach((w)=>w.prewrite(K,g.BUFFER)),($.listAccessors().length>0||K.otherBufferViews.size>0||$.listTextures().length>0&&J.format===YZ.GLB)&&$.listBuffers().length===0)throw Error("Buffer required for Document resources, but none was found.");if(Y.buffers=[],$.listBuffers().forEach((w,x)=>{let j=K.createPropertyDef(w),B=K.accessorUsageGroupedByParent,L=w.listParents().filter((S)=>S instanceof K0),R=new Set(L.map((S)=>K.accessorParents.get(S))),M=new Map(Array.from(R).map((S,f)=>[S,f])),P={};for(let S of L){var N;if(K.accessorIndexMap.has(S))continue;let f=K.getAccessorUsage(S),C=f;if(B.has(f)){let h=K.accessorParents.get(S);C+=`:${M.get(h)}`}P[N=C]||(P[N]={usage:f,accessors:[]}),P[C].accessors.push(S)}let O=[],k=Y.buffers.length,E=0;for(let{usage:S,accessors:f}of Object.values(P))if(S===aF.ARRAY_BUFFER&&J.vertexLayout===sF.INTERLEAVED){let C=V(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===aF.ARRAY_BUFFER)for(let C of f){let h=V([C],k,E);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else if(S===aF.SPARSE){let C=q(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===aF.ELEMENT_ARRAY_BUFFER){let C=w4.BufferViewTarget.ELEMENT_ARRAY_BUFFER,h=H(f,k,E,C);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else{let C=H(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}if(K.imageBufferViews.length&&x===0){for(let S=0;S<K.imageBufferViews.length;S++)if(Y.bufferViews[Y.images[S].bufferView].byteOffset=E,E+=K.imageBufferViews[S].byteLength,O.push(K.imageBufferViews[S]),E%8){let f=8-E%8;E+=f,O.push(new Uint8Array(f))}}if(K.otherBufferViews.has(w))for(let S of K.otherBufferViews.get(w))Y.bufferViews.push({buffer:k,byteOffset:E,byteLength:S.byteLength}),K.otherBufferViewsIndexMap.set(S,Y.bufferViews.length-1),E+=S.byteLength,O.push(S);if(E){let S;if(J.format===YZ.GLB)S=I$;else S=K.bufferURIGenerator.createURI(w,"bin"),j.uri=S;j.byteLength=E,K.assignResourceURI(S,E0.concat(O),!0)}Y.buffers.push(j),K.bufferIndexMap.set(w,x)}),$.listAccessors().find((w)=>!w.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");z.filter((w)=>w.prewriteTypes.includes(g.MATERIAL)).forEach((w)=>w.prewrite(K,g.MATERIAL)),Y.materials=$.listMaterials().map((w,x)=>{let j=K.createPropertyDef(w);if(w.getAlphaMode()!==K7.AlphaMode.OPAQUE)j.alphaMode=w.getAlphaMode();if(w.getAlphaMode()===K7.AlphaMode.MASK)j.alphaCutoff=w.getAlphaCutoff();if(w.getDoubleSided())j.doubleSided=!0;if(j.pbrMetallicRoughness={},!I0.eq(w.getBaseColorFactor(),[1,1,1,1]))j.pbrMetallicRoughness.baseColorFactor=w.getBaseColorFactor();if(!I0.eq(w.getEmissiveFactor(),[0,0,0]))j.emissiveFactor=w.getEmissiveFactor();if(w.getRoughnessFactor()!==1)j.pbrMetallicRoughness.roughnessFactor=w.getRoughnessFactor();if(w.getMetallicFactor()!==1)j.pbrMetallicRoughness.metallicFactor=w.getMetallicFactor();if(w.getBaseColorTexture()){let B=w.getBaseColorTexture(),L=w.getBaseColorTextureInfo();j.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(B,L)}if(w.getEmissiveTexture()){let B=w.getEmissiveTexture(),L=w.getEmissiveTextureInfo();j.emissiveTexture=K.createTextureInfoDef(B,L)}if(w.getNormalTexture()){let B=w.getNormalTexture(),L=w.getNormalTextureInfo(),R=K.createTextureInfoDef(B,L);if(w.getNormalScale()!==1)R.scale=w.getNormalScale();j.normalTexture=R}if(w.getOcclusionTexture()){let B=w.getOcclusionTexture(),L=w.getOcclusionTextureInfo(),R=K.createTextureInfoDef(B,L);if(w.getOcclusionStrength()!==1)R.strength=w.getOcclusionStrength();j.occlusionTexture=R}if(w.getMetallicRoughnessTexture()){let B=w.getMetallicRoughnessTexture(),L=w.getMetallicRoughnessTextureInfo();j.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(B,L)}return K.materialIndexMap.set(w,x),j}),z.filter((w)=>w.prewriteTypes.includes(g.MESH)).forEach((w)=>w.prewrite(K,g.MESH)),Y.meshes=$.listMeshes().map((w,x)=>{let j=K.createPropertyDef(w),B=null;if(j.primitives=w.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 P=L.getIndices();if(P)R.indices=K.accessorIndexMap.get(P);for(let N of L.listSemantics())R.attributes[N]=K.accessorIndexMap.get(L.getAttribute(N));for(let N of L.listTargets()){let O={};for(let k of N.listSemantics())O[k]=K.accessorIndexMap.get(N.getAttribute(k));R.targets=R.targets||[],R.targets.push(O)}if(L.listTargets().length&&!B)B=L.listTargets().map((N)=>N.getName());return R}),w.getWeights().length)j.weights=w.getWeights();if(B)j.extras=j.extras||{},j.extras.targetNames=B;return K.meshIndexMap.set(w,x),j}),Y.cameras=$.listCameras().map((w,x)=>{let j=K.createPropertyDef(w);if(j.type=w.getType(),j.type===_$.Type.PERSPECTIVE){j.perspective={znear:w.getZNear(),zfar:w.getZFar(),yfov:w.getYFov()};let B=w.getAspectRatio();if(B!==null)j.perspective.aspectRatio=B}else j.orthographic={znear:w.getZNear(),zfar:w.getZFar(),xmag:w.getXMag(),ymag:w.getYMag()};return K.cameraIndexMap.set(w,x),j}),Y.nodes=$.listNodes().map((w,x)=>{let j=K.createPropertyDef(w);if(!I0.eq(w.getTranslation(),[0,0,0]))j.translation=w.getTranslation();if(!I0.eq(w.getRotation(),[0,0,0,1]))j.rotation=w.getRotation();if(!I0.eq(w.getScale(),[1,1,1]))j.scale=w.getScale();if(w.getWeights().length)j.weights=w.getWeights();return K.nodeIndexMap.set(w,x),j}),Y.skins=$.listSkins().map((w,x)=>{let j=K.createPropertyDef(w),B=w.getInverseBindMatrices();if(B)j.inverseBindMatrices=K.accessorIndexMap.get(B);let L=w.getSkeleton();if(L)j.skeleton=K.nodeIndexMap.get(L);return j.joints=w.listJoints().map((R)=>K.nodeIndexMap.get(R)),K.skinIndexMap.set(w,x),j}),$.listNodes().forEach((w,x)=>{let j=Y.nodes[x],B=w.getMesh();if(B)j.mesh=K.meshIndexMap.get(B);let L=w.getCamera();if(L)j.camera=K.cameraIndexMap.get(L);let R=w.getSkin();if(R)j.skin=K.skinIndexMap.get(R);if(w.listChildren().length>0)j.children=w.listChildren().map((M)=>K.nodeIndexMap.get(M))}),Y.animations=$.listAnimations().map((w,x)=>{let j=K.createPropertyDef(w),B=new Map;return j.samplers=w.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(),B.set(L,R),M}),j.channels=w.listChannels().map((L)=>{let R=K.createPropertyDef(L);return R.sampler=B.get(L.getSampler()),R.target={node:K.nodeIndexMap.get(L.getTargetNode()),path:L.getTargetPath()},R}),K.animationIndexMap.set(w,x),j}),Y.scenes=$.listScenes().map((w,x)=>{let j=K.createPropertyDef(w);return j.nodes=w.listChildren().map((B)=>K.nodeIndexMap.get(B)),K.sceneIndexMap.set(w,x),j});let c=$.getDefaultScene();if(c)Y.scene=$.listScenes().indexOf(c);return Y.extensionsUsed=z.map((w)=>w.extensionName),Y.extensionsRequired=v.map((w)=>w.extensionName),z.forEach((w)=>w.write(K)),vU1(Y),Q}}function vU1(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 rF;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(rF||(rF={}));class Sg{constructor(){this._logger=z5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=sF.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=Ng(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),_g.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(($)=>VU1(J,$)))throw Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some(($)=>HU1(J,$)))throw 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===YZ.GLB&&Z.getRoot().listBuffers().length>1)throw Error("GLB must have 0–1 buffers.");return hg.write(Z,{format:J.format||YZ.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:YZ.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=`__${Eg()}.${QZ.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 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(!Ng(Z))throw Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==rF.JSON)throw 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]!==rF.BIN)return{json:Q,resources:{}};let G=W[0],z=E0.toView(Z,K+8,G);return{json:Q,resources:{[I$]:z}}}}function VU1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function HU1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Ng(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 Sg{constructor(Z=null,J=c4.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 Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),c4.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw 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(c4.isAbsoluteURL(Z)||c4.isAbsoluteURL(J))return c4.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(c4.isAbsoluteURL(Z))return c4.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:YZ.GLTF,basename:QZ.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 qU1(Object.keys(Y),10))await Promise.all(z.map(async function(v){if(c4.isAbsoluteURL(v)){if(c4.extension(v)==="bin")throw 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 qU1(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 In=t(UR(),1),_n=t(wn(),1),KD1=t(En(),1);async function WD1(Z,J){if(!(Z instanceof Uint8Array))throw Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:$}=await _n.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return In.default(new Uint8Array(X),[$.width,$.height,4],[4,4*$.width|0,1],0)}async function hn(Z,J){return WD1(Z)}var bn=163,An=166;function GD1(){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 rN6=new Uint8Array([0]),p6=[171,75,84,88,32,50,48,187,13,10,26,10];function Sn(Z){return new TextDecoder().decode(Z)}function Dc(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 Error("Missing KTX 2.0 identifier.");let X=GD1(),$=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 O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)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(),c=q._nextUint16(),w=q._nextUint16(),x=q._nextUint16(),j=q._nextUint8(),B=q._nextUint8(),L=q._nextUint8(),R=q._nextUint8(),M=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],P=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],O={vendorId:F,descriptorType:c,versionNumber:w,colorModel:j,colorPrimaries:B,transferFunction:L,flags:R,texelBlockDimension:M,bytesPlane:P,samples:[]},k=6,E=4,S=(x/4-k)/E;for(let O8=0;O8<S;O8++){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[O8]=q6}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(O);let f=new U3(Z,W,G,!0);while(f._offset<G){let O8=f._nextUint32(),q6=f._scan(O8),fH=Sn(q6);if(X.keyValue[fH]=f._nextUint8Array(O8-q6.byteLength-1),fH.match(/^ktx/i)){let LA=Sn(X.keyValue[fH]);X.keyValue[fH]=LA.substring(0,LA.lastIndexOf("\x00"))}let RG1=O8%4?4-O8%4:0;f._skip(RG1)}if(v<=0)return X;let C=new U3(Z,z,v,!0),h=C._nextUint16(),_=C._nextUint16(),a=C._nextUint32(),s=C._nextUint32(),Z0=C._nextUint32(),o=C._nextUint32(),M0=[];for(let O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)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,j1=new Uint8Array(Z.buffer,Z.byteOffset+R0,a),W4=new Uint8Array(Z.buffer,Z.byteOffset+m0,s),NJ=new Uint8Array(Z.buffer,Z.byteOffset+N1,Z0),IQ=new Uint8Array(Z.buffer,Z.byteOffset+s0,o);return X.globalData={endpointCount:h,selectorCount:_,imageDescs:M0,endpointsData:j1,selectorsData:W4,tablesData:NJ,extendedData:IQ},X}var zZ="EXT_mesh_gpu_instancing",X6="EXT_meshopt_compression",bG="EXT_texture_webp",AG="EXT_texture_avif",s1="KHR_draco_mesh_compression",j4="KHR_lights_punctual",vZ="KHR_materials_anisotropy",VZ="KHR_materials_clearcoat",HZ="KHR_materials_diffuse_transmission",qZ="KHR_materials_dispersion",FZ="KHR_materials_emissive_strength",cZ="KHR_materials_ior",wZ="KHR_materials_iridescence",xZ="KHR_materials_pbrSpecularGlossiness",UZ="KHR_materials_sheen",jZ="KHR_materials_specular",BZ="KHR_materials_transmission",gJ="KHR_materials_unlit",LZ="KHR_materials_volume",U6="KHR_materials_variants",tn="KHR_mesh_quantization",mG="KHR_texture_basisu",DZ="KHR_texture_transform",B4="KHR_xmp_json_ld",gR="INSTANCE_ATTRIBUTE";class aR extends O1{init(){this.extensionName=zZ,this.propertyType="InstancedMesh",this.parentTypes=[g.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:gR})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}aR.EXTENSION_NAME=zZ;class Pc extends T1{constructor(...Z){super(...Z);this.extensionName=zZ,this.provideTypes=[g.NODE],this.prewriteTypes=[g.ACCESSOR]}createInstancedMesh(){return new aR(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[zZ])return;let Q=$.extensions[zZ],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[Y].setExtension(zZ,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(gR);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,gR);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let $=X.getExtension(zZ);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[zZ]=K}}),this}}Pc.EXTENSION_NAME=zZ;function MZ(){return MZ=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},MZ.apply(null,arguments)}var uG;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(uG||(uG={}));var j3;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(j3||(j3={}));var $8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})($8||($8={}));function zD1(Z){if(!Z.extensions||!Z.extensions[X6])return!1;return!!Z.extensions[X6].fallback}var{BYTE:vD1,SHORT:mn,FLOAT:VD1}=K0.ComponentType,{encodeNormalizedInt:un,decodeNormalizedInt:dR}=I0;function HD1(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!==j3.ATTRIBUTES)return K;if(Y!==$8.NONE){let W=Z.getNormalized()?qD1(Z):new Float32Array(K.array);switch(Y){case $8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=VD1,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?mn:vD1,K.normalized=!0,W=Z.getElementSize()===3?cD1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case $8.QUATERNION:K.byteStride=8,K.componentType=mn,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>dR(G,Z.getComponentType())),K.max=K.max.map((G)=>dR(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>un(G,K.componentType)),K.max=K.max.map((G)=>un(G,K.componentType))}else if(K.byteStride%4)K.array=FD1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function qD1(Z){let J=Z.getComponentType(),X=Z.getArray(),$=new Float32Array(X.length);for(let Y=0;Y<X.length;Y++)$[Y]=dR(X[Y],J);return $}function FD1(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 cD1(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 wD1(Z,J){if(J===w4.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some(($)=>{return $ instanceof g1&&$.getMode()===g1.Mode.TRIANGLES})?j3.TRIANGLES:j3.INDICES;return j3.ATTRIBUTES}function xD1(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===g.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=en(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 en(Z){for(let J of Z.listParents()){if(!(J instanceof mJ))continue;for(let X of J.listParents()){if(!(X instanceof KZ))continue;return X.getTargetPath()}}return null}var ln={method:uG.QUANTIZE};class yG extends T1{constructor(...Z){super(...Z);this.extensionName=X6,this.prereadTypes=[g.BUFFER,g.PRIMITIVE],this.prewriteTypes=[g.BUFFER,g.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=ln,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=MZ({},ln,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw Error(`[${X6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw Error(`[${X6}]: Missing WASM support.`)}if(J===g.BUFFER)this._prereadBuffers(Z);else if(J===g.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[I$],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(zD1(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===g.ACCESSOR)this._prewriteAccessors(Z);else if(J===g.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===g.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(en(v)==="weights")continue;if(v.getSparse())continue;let H=Z.getAccessorUsage(v),V=Z.accessorUsageGroupedByParent.has(H)?z(v):null,q=wD1(v,H),F=$.method===uG.FILTER?xD1(v,this.document):{filter:$8.NONE},c=HD1(v,X,q,F),{array:w,byteStride:x}=c,j=v.getBuffer();if(!j)throw Error(`${X6}: Missing buffer for accessor.`);let B=this.document.getRoot().listBuffers().indexOf(j),L=[H,V,q,F.filter,x,B].join(":"),R=this._encoderBufferViews[L],M=this._encoderBufferViewData[L],P=this._encoderBufferViewAccessors[L];if(!R||!M)P=this._encoderBufferViewAccessors[L]=[],M=this._encoderBufferViewData[L]=[],R=this._encoderBufferViews[L]={buffer:K,target:w4.USAGE_TO_TARGET[H],byteOffset:0,byteLength:0,byteStride:H===w4.BufferViewUsage.ARRAY_BUFFER?x:void 0,extensions:{[X6]:{buffer:B,byteOffset:0,byteLength:0,mode:q,filter:F.filter!==$8.NONE?F.filter:void 0,byteStride:x,count:0}}};let N=Z.createAccessorDef(v);if(N.componentType=c.componentType,N.normalized=c.normalized,N.byteOffset=R.byteLength,N.min&&c.min)N.min=c.min;if(N.max&&c.max)N.max=c.max;Z.accessorIndexMap.set(v,J.accessors.length),J.accessors.push(N),P.push(N),M.push(new Uint8Array(w.buffer,w.byteOffset,w.byteLength)),R.byteLength+=w.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}}yG.EXTENSION_NAME=X6;yG.EncoderMethod=uG;class Zs{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=yn(J,0);if(!X)return null;let $=X.end;while(X=yn(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 Nc extends T1{constructor(...Z){super(...Z);this.extensionName=AG,this.prereadTypes=[g.TEXTURE]}static register(){_5.registerFormat("image/avif",new Zs)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[AG])X.source=X.extensions[AG].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[AG]={source:Q.source},delete Q.source})}}),this}}Nc.EXTENSION_NAME=AG;function yn(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 Js{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 Oc extends T1{constructor(...Z){super(...Z);this.extensionName=bG,this.prereadTypes=[g.TEXTURE]}static register(){_5.registerFormat("image/webp",new Js)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[bG])X.source=X.extensions[bG].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[bG]={source:Q.source},delete Q.source})}}),this}}Oc.EXTENSION_NAME=bG;var S8,Xs,$s;function UD1(Z,J){let X=new S8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==S8.TRIANGULAR_MESH)throw Error(`[${s1}] Unknown geometry type.`);let Y=new S8.Mesh;if(!Z.DecodeBufferToMesh(X,Y).ok()||Y.ptr===0)throw Error(`[${s1}] Decoding failure.`);return Y}finally{S8.destroy(X)}}function jD1(Z,J){let $=J.num_faces()*3,Y,Q;if(J.num_points()<=65534){let K=$*Uint16Array.BYTES_PER_ELEMENT;Y=S8._malloc(K),Z.GetTrianglesUInt16Array(J,K,Y),Q=new Uint16Array(S8.HEAPU16.buffer,Y,$).slice()}else{let K=$*Uint32Array.BYTES_PER_ELEMENT;Y=S8._malloc(K),Z.GetTrianglesUInt32Array(J,K,Y),Q=new Uint32Array(S8.HEAPU32.buffer,Y,$).slice()}return S8._free(Y),Q}function BD1(Z,J,X,$){let Y=$s[$.componentType],Q=Xs[$.componentType],K=X.num_components(),G=J.num_points()*K,z=G*Q.BYTES_PER_ELEMENT,v=S8._malloc(z);Z.GetAttributeDataArrayForAllPoints(J,X,Y,z,v);let H=new Q(S8.HEAPF32.buffer,v,G).slice();return S8._free(v),H}function LD1(Z){S8=Z,Xs={[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},$s={[K0.ComponentType.FLOAT]:S8.DT_FLOAT32,[K0.ComponentType.UNSIGNED_INT]:S8.DT_UINT32,[K0.ComponentType.UNSIGNED_SHORT]:S8.DT_UINT16,[K0.ComponentType.UNSIGNED_BYTE]:S8.DT_UINT8,[K0.ComponentType.SHORT]:S8.DT_INT16,[K0.ComponentType.BYTE]:S8.DT_INT8}}var U4,lG;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(lG||(lG={}));var L4;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(L4||(L4={}));var Ys={[L4.POSITION]:14,[L4.NORMAL]:10,[L4.COLOR]:8,[L4.TEX_COORD]:12,[L4.GENERIC]:12},pn={decodeSpeed:5,encodeSpeed:5,method:lG.EDGEBREAKER,quantizationBits:Ys,quantizationVolume:"mesh"};function DD1(Z){U4=Z}function MD1(Z,J=pn){let X=MZ({},pn,J);X.quantizationBits=MZ({},Ys,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 c of Z.listSemantics()){let w=Z.getAttribute(c);if(w.getSparse()){z=!0;continue}let x=RD1(c),j=PD1($,w.getComponentType(),Y,U4[x],w.getCount(),w.getElementSize(),w.getArray());if(j===-1)throw Error(`Error compressing "${c}" attribute.`);if(K[c]=j,X.quantizationVolume==="mesh"||c!=="POSITION")Q.SetAttributeQuantization(j,X.quantizationBits[x]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:B}=X,L=Math.max(B.max[0]-B.min[0],B.max[1]-B.min[1],B.max[2]-B.min[2]);Q.SetAttributeExplicitQuantization(j,X.quantizationBits[x],w.getElementSize(),B.min,L)}else throw Error("Invalid quantization volume state.")}let v=Z.getIndices();if(!v)throw new Mc("Primitive must have indices.");if($.AddFacesToMesh(Y,v.getCount()/3,v.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===lG.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 Mc("Error applying Draco compression.");let V=new Uint8Array(H);for(let c=0;c<H;++c)V[c]=W.GetValue(c);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 RD1(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 PD1(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 Error(`Unexpected component type, "${J}".`)}}class Mc extends Error{}class pG extends T1{constructor(...Z){super(...Z);this.extensionName=s1,this.prereadTypes=[g.PRIMITIVE],this.prewriteTypes=[g.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,LD1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,DD1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw 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[I$],q=v.byteOffset||0,F=v.byteLength,c=E0.toView(V,q,F);G=new this._decoderModule.Decoder,z=UD1(G,c),$.set(W.bufferView,[G,z]),J.debug(`[${s1}] Decompressed ${c.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=BD1(G,z,V,H);Z.accessors[K.attributes[v]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(jD1(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 Error(`[${s1}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${s1}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let $=ND1(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=PG(this.document.getRoot().listScenes().pop());for(let K of Array.from($.keys())){let W=$.get(K);if(!W)throw 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=MD1(K,MZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof Mc){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 c=Z.createAccessorDef(F);c.count=v.numVertices,Z.accessorIndexMap.set(F,z.length),z.push(c)}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}}pG.EXTENSION_NAME=s1;pG.EncoderMethod=lG;function ND1(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=gn(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=gn(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(g.PRIMITIVE)||!V.has(g.ROOT))throw 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 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 Error(`[${s1}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return v}function gn(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 B3 extends O1{init(){this.extensionName=j4,this.propertyType="Light",this.parentTypes=[g.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:B3.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)}}B3.EXTENSION_NAME=j4;B3.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};class nR extends T1{constructor(...Z){super(...Z);this.extensionName=j4}createLight(Z=""){return new B3(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[j4])return this;let Y=(J.json.extensions[j4].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[j4])return;let W=Q.extensions[j4];Z.nodes[K].setExtension(j4,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()===B3.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(j4);if(Q){let K=Z.nodeIndexMap.get(Y),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[j4]={light:$.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[j4]={lights:X},this}}nR.EXTENSION_NAME=j4;var{R:OD1,G:TD1,B:CD1}=v5;class sR extends O1{init(){this.extensionName=vZ,this.propertyType="Anisotropy",this.parentTypes=[g.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:OD1|TD1|CD1})}}sR.EXTENSION_NAME=vZ;class oR extends T1{constructor(...Z){super(...Z);this.extensionName=vZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createAnisotropy(){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.createAnisotropy();Z.materials[Q].setExtension(vZ,K);let W=Y.extensions[vZ];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(vZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[vZ]={};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}}oR.EXTENSION_NAME=vZ;var{R:dn,G:an,B:fD1}=v5;class rR extends O1{init(){this.extensionName=VZ,this.propertyType="Clearcoat",this.parentTypes=[g.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:dn})}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:dn|an|fD1})}}rR.EXTENSION_NAME=VZ;class tR extends T1{constructor(...Z){super(...Z);this.extensionName=VZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createClearcoat(){return new rR(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}}tR.EXTENSION_NAME=VZ;var{R:kD1,G:ED1,B:ID1,A:_D1}=v5;class eR extends O1{init(){this.extensionName=HZ,this.propertyType="DiffuseTransmission",this.parentTypes=[g.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:_D1})}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:kD1|ED1|ID1})}}eR.EXTENSION_NAME=HZ;class ZP extends T1{constructor(...Z){super(...Z);this.extensionName=HZ}createDiffuseTransmission(){return new eR(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[HZ]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(HZ,K);let W=Y.extensions[HZ];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(HZ);if(!$)continue;let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[HZ]={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}}ZP.EXTENSION_NAME=HZ;class JP extends O1{init(){this.extensionName=qZ,this.propertyType="Dispersion",this.parentTypes=[g.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}JP.EXTENSION_NAME=qZ;class XP extends T1{constructor(...Z){super(...Z);this.extensionName=qZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createDispersion(){return new JP(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.createDispersion();Z.materials[Y].setExtension(qZ,Q);let K=$.extensions[qZ];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(qZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[qZ]={dispersion:$.getDispersion()}}}),this}}XP.EXTENSION_NAME=qZ;class $P extends O1{init(){this.extensionName=FZ,this.propertyType="EmissiveStrength",this.parentTypes=[g.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}$P.EXTENSION_NAME=FZ;class YP extends T1{constructor(...Z){super(...Z);this.extensionName=FZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createEmissiveStrength(){return new $P(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.createEmissiveStrength();Z.materials[Y].setExtension(FZ,Q);let K=$.extensions[FZ];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(FZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[FZ]={emissiveStrength:$.getEmissiveStrength()}}}),this}}YP.EXTENSION_NAME=FZ;class QP extends O1{init(){this.extensionName=cZ,this.propertyType="IOR",this.parentTypes=[g.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}QP.EXTENSION_NAME=cZ;class Tc extends T1{constructor(...Z){super(...Z);this.extensionName=cZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createIOR(){return new QP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[cZ]){let Q=this.createIOR();Z.materials[Y].setExtension(cZ,Q);let K=$.extensions[cZ];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(cZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[cZ]={ior:$.getIOR()}}}),this}}Tc.EXTENSION_NAME=cZ;var{R:hD1,G:SD1}=v5;class KP extends O1{init(){this.extensionName=wZ,this.propertyType="Iridescence",this.parentTypes=[g.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:hD1})}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:SD1})}}KP.EXTENSION_NAME=wZ;class WP extends T1{constructor(...Z){super(...Z);this.extensionName=wZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createIridescence(){return new KP(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.createIridescence();Z.materials[Q].setExtension(wZ,K);let W=Y.extensions[wZ];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(wZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[wZ]={};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}}WP.EXTENSION_NAME=wZ;var{R:nn,G:sn,B:on,A:rn}=v5;class GP extends O1{init(){this.extensionName=xZ,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[g.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:nn|sn|on|rn,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:nn|sn|on|rn})}}GP.EXTENSION_NAME=xZ;class Cc extends T1{constructor(...Z){super(...Z);this.extensionName=xZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createPBRSpecularGlossiness(){return new GP(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.createPBRSpecularGlossiness();Z.materials[Q].setExtension(xZ,K);let W=Y.extensions[xZ];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(xZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[xZ]={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}}Cc.EXTENSION_NAME=xZ;var{R:bD1,G:AD1,B:mD1,A:uD1}=v5;class zP extends O1{init(){this.extensionName=UZ,this.propertyType="Sheen",this.parentTypes=[g.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:bD1|AD1|mD1,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:uD1})}}zP.EXTENSION_NAME=UZ;class vP extends T1{constructor(...Z){super(...Z);this.extensionName=UZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createSheen(){return new zP(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.createSheen();Z.materials[Q].setExtension(UZ,K);let W=Y.extensions[UZ];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(UZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[UZ]={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}}vP.EXTENSION_NAME=UZ;var{R:lD1,G:yD1,B:pD1,A:iD1}=v5;class VP extends O1{init(){this.extensionName=jZ,this.propertyType="Specular",this.parentTypes=[g.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:iD1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:lD1|yD1|pD1,isColor:!0})}}VP.EXTENSION_NAME=jZ;class fc extends T1{constructor(...Z){super(...Z);this.extensionName=jZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createSpecular(){return new VP(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.createSpecular();Z.materials[Q].setExtension(jZ,K);let W=Y.extensions[jZ];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(jZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[jZ]={};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}}fc.EXTENSION_NAME=jZ;var{R:gD1}=v5;class HP extends O1{init(){this.extensionName=BZ,this.propertyType="Transmission",this.parentTypes=[g.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:gD1})}}HP.EXTENSION_NAME=BZ;class qP extends T1{constructor(...Z){super(...Z);this.extensionName=BZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createTransmission(){return new HP(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}}qP.EXTENSION_NAME=BZ;class FP extends O1{init(){this.extensionName=gJ,this.propertyType="Unlit",this.parentTypes=[g.MATERIAL]}}FP.EXTENSION_NAME=gJ;class kc extends T1{constructor(...Z){super(...Z);this.extensionName=gJ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createUnlit(){return new FP(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[gJ])Z.materials[$].setExtension(gJ,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(gJ)){let $=Z.materialIndexMap.get(X),Y=J.json.materials[$];Y.extensions=Y.extensions||{},Y.extensions[gJ]={}}}),this}}kc.EXTENSION_NAME=gJ;class cP extends O1{init(){this.extensionName=U6,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new c1})}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")}}cP.EXTENSION_NAME=U6;class wP extends O1{init(){this.extensionName=U6,this.propertyType="MappingList",this.parentTypes=[g.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new c1})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}wP.EXTENSION_NAME=U6;class Rc extends O1{init(){this.extensionName=U6,this.propertyType="Variant",this.parentTypes=["MappingList"]}}Rc.EXTENSION_NAME=U6;class xP extends T1{constructor(...Z){super(...Z);this.extensionName=U6}createMappingList(){return new wP(this.document.getGraph())}createVariant(Z=""){return new Rc(this.document.getGraph(),Z)}createMapping(){return new cP(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof Rc)}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 c=this.createMapping();if(F.material!==void 0)c.setMaterial(Z.materials[F.material]);for(let w of F.variants||[])c.addVariant(Y[w]);V.addMapping(c)}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((c)=>Y.get(c)),q});v.extensions=v.extensions||{},v.extensions[U6]={mappings:H}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[U6]={variants:$},this}}xP.EXTENSION_NAME=U6;var{G:dD1}=v5;class UP extends O1{init(){this.extensionName=LZ,this.propertyType="Volume",this.parentTypes=[g.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:dD1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}UP.EXTENSION_NAME=LZ;class jP extends T1{constructor(...Z){super(...Z);this.extensionName=LZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createVolume(){return new UP(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[LZ]){let K=this.createVolume();Z.materials[Q].setExtension(LZ,K);let W=Y.extensions[LZ];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(LZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[LZ]={};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}}jP.EXTENSION_NAME=LZ;class iG extends T1{constructor(...Z){super(...Z);this.extensionName=tn}read(Z){return this}write(Z){return this}}iG.EXTENSION_NAME=tn;class Qs{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=Dc(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=Dc(Z).dataFormatDescriptor[0];if(X.colorModel===bn)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===An)return(X.samples[0].channelType&15)===3?4:3;throw Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=Dc(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 BP extends T1{constructor(...Z){super(...Z);this.extensionName=mG,this.prereadTypes=[g.TEXTURE]}static register(){_5.registerFormat("image/ktx2",new Qs)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[mG]){let X=J.extensions[mG];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[mG]={source:Y.source},delete Y.source})}}),this}}BP.EXTENSION_NAME=mG;class LP extends O1{init(){this.extensionName=DZ,this.propertyType="Transform",this.parentTypes=[g.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)}}LP.EXTENSION_NAME=DZ;class DP extends T1{constructor(...Z){super(...Z);this.extensionName=DZ}createTransform(){return new LP(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[DZ])continue;let $=this.createTransform(),Y=X.extensions[DZ];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(DZ,$)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,$]of J){let Y=X.getExtension(DZ);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[DZ]=Q}return this}}DP.EXTENSION_NAME=DZ;var aD1=[g.ROOT,g.SCENE,g.NODE,g.MESH,g.MATERIAL,g.TEXTURE,g.ANIMATION];class MP extends O1{init(){this.extensionName=B4,this.propertyType="Packet",this.parentTypes=aD1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",MZ({},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=MZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=iR(this.get("context")),J=iR(this.get("properties"));return MZ({"@context":Z},J)}fromJSONLD(Z){Z=iR(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 Error(`${B4}: Missing context for term, "${Z}".`)}}MP.EXTENSION_NAME=B4;function iR(Z){return JSON.parse(JSON.stringify(Z))}class RP extends T1{constructor(...Z){super(...Z);this.extensionName=B4}createPacket(){return new MP(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[B4];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[B4]){let V=H.extensions[B4];W[G][v].setExtension(B4,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 g.ROOT:Q=J.asset;break;case g.SCENE:Q=J.scenes[Z.sceneIndexMap.get(Y)];break;case g.NODE:Q=J.nodes[Z.nodeIndexMap.get(Y)];break;case g.MESH:Q=J.meshes[Z.meshIndexMap.get(Y)];break;case g.MATERIAL:Q=J.materials[Z.materialIndexMap.get(Y)];break;case g.TEXTURE:Q=J.images[Z.imageIndexMap.get(Y)];break;case g.ANIMATION:Q=J.animations[Z.animationIndexMap.get(Y)];break;default:Q=null,this.document.getLogger().warn(`[${B4}]: Unsupported parent property, "${Y.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[B4]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[B4]={packets:X};return this}}RP.EXTENSION_NAME=B4;var nD1=[pG,nR,oR,tR,ZP,XP,YP,Tc,WP,Cc,fc,vP,qP,kc,xP,jP,iG,BP,DP,RP],JO6=[Pc,yG,Nc,Oc,...nD1];var sD1=t(UR(),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:Ks,LINES:Ec,LINE_STRIP:oD1,LINE_LOOP:rD1,TRIANGLES:Ic,TRIANGLE_STRIP:tD1,TRIANGLE_FAN:eD1}=g1.Mode;function l$(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function PZ(Z,J){let X=M3({},Z);for(let $ in J)if(J[$]!==void 0)X[$]=J[$];return X}function Rs(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 Error("Unexpected mode: "+Z.getMode())}}var ZM1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function OP(Z){return ZM1.format(Z)}function JM1(Z,J,X=2){let $=Z>J?"–":"+",Y="%";return $+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function Ac(Z,J){return`${OP(Z)} → ${OP(J)} (${JM1(Z,J)})`}function mc(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 XM1(Z,J,X){Z.swap(J,X);for(let $ of Z.listTargets())$.swap(J,X)}function Ps(Z){let J=Z.getIndices(),X=mc(Z);if(Z.dispose(),J&&!TP(J))J.dispose();for(let $ of X)if(!TP($))$.dispose()}function RZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function $M1(Z,J=Z){let X=hP(Z,J);for(let $=0;$<X.length;$++)X[$]=$;return X}function hP(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function TP(Z){return Z.listParents().some((J)=>J.propertyType!==g.ROOT)}function Ns(Z){for(let J in Z)return!1;return!0}function Os(Z){let J=w6.fromGraph(Z.getGraph()),X=Z.getMaterial(),$=J.getRoot().listMaterials().indexOf(X),Y=QM1[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 YM1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var QM1={[Ks]:Ks,[Ec]:Ec,[oD1]:Ec,[rD1]:Ec,[Ic]:Ic,[tD1]:Ic,[eD1]:Ic},L3="center",Ws={pivot:"center"};function Ts(Z=Ws){let J=PZ(Ws,Z);return l$(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=PG(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 KM1(Z){let J=new Set,X=Z,$;while($=X.getParentNode()){if(J.has($))throw Error("Circular dependency in scene graph.");J.add($),X=$}return X.listParents().filter((Y)=>Y instanceof K3)}function WM1(Z){let J=KM1(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<"u"?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 GM1(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],c=J[13],w=J[14],x=J[15],j=X*W-$*K,B=X*G-Y*K,L=X*z-Q*K,R=$*G-Y*W,M=$*z-Q*W,P=Y*z-Q*G,N=v*c-H*F,O=v*w-V*F,k=v*x-q*F,E=H*w-V*c,S=H*x-q*c,f=V*x-q*w,C=j*f-B*S+L*E+R*k-M*O+P*N;if(!C)return null;return C=1/C,Z[0]=(W*f-G*S+z*E)*C,Z[1]=(Y*S-$*f-Q*E)*C,Z[2]=(c*P-w*M+x*R)*C,Z[3]=(V*M-H*P-q*R)*C,Z[4]=(G*k-K*f-z*O)*C,Z[5]=(X*f-Y*k+Q*O)*C,Z[6]=(w*L-F*P-x*B)*C,Z[7]=(v*P-V*L+q*B)*C,Z[8]=(K*S-W*k+z*N)*C,Z[9]=($*k-X*S-Q*N)*C,Z[10]=(F*M-c*L+x*j)*C,Z[11]=(H*L-v*M-q*j)*C,Z[12]=(W*O-K*E-G*N)*C,Z[13]=(X*E-$*O+Y*N)*C,Z[14]=(c*B-F*R-w*j)*C,Z[15]=(v*R-H*B+V*j)*C,Z}function zM1(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],c=Z[14],w=Z[15],x=J*K-X*Q,j=J*W-$*Q,B=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,P=z*F-v*q,N=z*c-H*q,O=z*w-V*q,k=v*c-H*F,E=v*w-V*F,S=H*w-V*c;return x*S-j*E+B*k+L*O-R*N+M*P}function Cs(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],c=J[12],w=J[13],x=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*$+L*W+R*H+M*c,Z[1]=B*Y+L*G+R*V+M*w,Z[2]=B*Q+L*z+R*q+M*x,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*$+L*W+R*H+M*c,Z[5]=B*Y+L*G+R*V+M*w,Z[6]=B*Q+L*z+R*q+M*x,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*$+L*W+R*H+M*c,Z[9]=B*Y+L*G+R*V+M*w,Z[10]=B*Q+L*z+R*q+M*x,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*$+L*W+R*H+M*c,Z[13]=B*Y+L*G+R*V+M*w,Z[14]=B*Q+L*z+R*q+M*x,Z[15]=B*K+L*v+R*F+M*j,Z}var j6;(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"})(j6||(j6={}));function u$(Z,J){let X=Z.getAttribute("POSITION"),$=Z.getIndices();switch(J){case j6.RENDER:return $?$.getCount():X.getCount();case j6.RENDER_CACHED:return $?new Set($.getArray()).size:X.getCount();case j6.UPLOAD_NAIVE:case j6.UPLOAD:return X.getCount();case j6.DISTINCT:case j6.DISTINCT_POSITION:return vM1(J);case j6.UNUSED:return $?X.getCount()-new Set($.getArray()).size:0;default:return VM1(J)}}function vM1(Z){throw Error(`Not implemented: ${Z}`)}function VM1(Z){throw Error(`Unexpected value: ${Z}`)}var dJ=4294967295;class fs{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of mc(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 HM1(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 HM1(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 qM1(Z,J,X,$,Y=dJ){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 Error("Hash table full.")}function dG(Z,J,X){let $=w6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=FM1(Z);let Y=Z.getIndices(),Q=Y?Y.getArray():null,K=u$(Z,j6.RENDER),W=$.createAccessor(),G=K,z=hP(G,X);for(let H=0;H<G;H++)z[H]=J[Q?Q[H]:H];Z.setIndices(W.setArray(z));let v=mc(Z);for(let H of Z.listAttributes()){let V=RZ($,H);CP(H,Y,J,V,X),Z.swap(H,V)}for(let H of Z.listTargets())for(let V of H.listAttributes()){let q=RZ($,V);CP(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 CP(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 FM1(Z){let J=u$(Z,j6.UPLOAD),X=Z.getIndices(),$=X?X.getArray():null;if(!X||!$)return[$M1(J,1e6),J];let Y=new Uint32Array(J).fill(dJ),Q=0;for(let K=0;K<$.length;K++){let W=$[K];if(Y[W]===dJ)Y[W]=Q++}return[Y,Q]}function cM1(){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 wM1(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 xM1(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 UM1(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 uc(){var Z=new R3(3);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return 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}function ks(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 BM1(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 LM1(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 DM1=jM1;(function(){var Z=uc();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 fP="weld",hc={overwrite:!0};function SP(Z=hc){let J=PZ(hc,Z);return l$(fP,async(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes()){for(let Q of Y.listPrimitives())if(lc(Q,J),u$(Q,j6.RENDER)===0)Ps(Q);if(Y.listPrimitives().length===0)Y.dispose()}$.debug(`${fP}: Complete.`)})}function lc(Z,J=hc){let X=Z.getGraph(),Y=w6.fromGraph(X).getLogger(),Q=M3({},hc,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 fs(Z),H=YM1(K+K/4),V=new Uint32Array(H).fill(dJ),q=new Uint32Array(K).fill(dJ),F=0;for(let c=0;c<z;c++){let w=G?G[c]:c;if(q[w]!==dJ)continue;let x=qM1(V,H,v,w,dJ),j=V[x];if(j===dJ)V[x]=w,q[w]=F++;else q[w]=q[j]}Y.debug(`${fP}: ${Ac(K,F)} vertices.`),dG(Z,q,F)}var{FLOAT:MM1}=K0.ComponentType;function Es(Z,J){let X=Z.getAttribute("POSITION");if(X)Gs(J,X);let $=Z.getAttribute("NORMAL");if($)zs(J,$);let Y=Z.getAttribute("TANGENT");if(Y)vs(J,Y);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)Gs(J,K);let W=Q.getAttribute("NORMAL");if(W)zs(J,W);let G=Q.getAttribute("TANGENT");if(G)vs(J,G)}if(zM1(J)<0)RM1(Z)}function Gs(Z,J){let X=J.getComponentType(),$=J.getNormalized(),Y=J.getArray(),Q=X===MM1?Y:new Float32Array(Y.length),K=uc();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];BM1(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 zs(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=cM1();wM1(Q,Z),UM1(Q,Q),xM1(Q,Q);let K=uc();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(LM1(K,K,Q),ks(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 vs(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=uc();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],ks(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 RM1(Z){if(Z.getMode()!==g1.Mode.TRIANGLES)return;if(!Z.getIndices())lc(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 PM1(Z,J){for(let X of Z.listPrimitives()){let $=NM1(X,Z);if(X!==$)Z.removePrimitive(X).addPrimitive($)}for(let X of Z.listPrimitives())dG(X),Es(X,J)}function NM1(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 Vs=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function Is(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!I0.eq(X,Vs))PM1(J,X);for(let $ of Z.listChildren()){let Y=$.getMatrix();Cs(Y,Y,X),$.setMatrix(Y)}return Z.setMatrix(Vs)}var{LINES:OM1,LINE_STRIP:TM1,LINE_LOOP:CM1,TRIANGLES:fM1,TRIANGLE_STRIP:kM1,TRIANGLE_FAN:EM1}=g1.Mode;function IM1(Z){let J=Z.getGraph(),X=w6.fromGraph(J);if(!Z.getIndices())lc(Z);let $=Z.getIndices(),Y=$.getArray(),Q=Rs(Z),W=new AJ[$.getComponentType()](Q*2),G=Z.getMode();if(G===TM1)for(let v=0;v<Q;v++)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else if(G===CM1)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 Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(OM1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(RZ(X,$).setArray(W));else $.setArray(W)}function _s(Z){let J=Z.getGraph(),X=w6.fromGraph(J);if(!Z.getIndices())lc(Z);let $=Z.getIndices(),Y=$.getArray(),Q=Rs(Z),W=new AJ[$.getComponentType()](Q*3),G=Z.getMode();if(G===kM1)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===EM1)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 Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(fM1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(RZ(X,$).setArray(W));else $.setArray(W)}var WO6={keepUniqueNames:!1,propertyTypes:[g.ACCESSOR,g.MESH,g.TEXTURE,g.MATERIAL,g.SKIN]};var Hs="dequantize",Sc={pattern:/^((?!JOINTS_).)*$/};function hs(Z=Sc){let J=PZ(Sc,Z);return l$(Hs,(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes())for(let Q of Y.listPrimitives())_M1(Q,J);X.createExtension(iG).dispose(),$.debug(`${Hs}: Complete.`)})}function _M1(Z,J=Sc){let X=PZ(Sc,J);for(let $ of Z.listSemantics())if(X.pattern.test($))kP(Z.getAttribute($));for(let $ of Z.listTargets())for(let Y of $.listSemantics())if(X.pattern.test(Y))kP($.getAttribute(Y))}function kP(Z){let J=Z.getArray();if(!J)return;let X=bc(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function bc(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:Ss,ROOT:GO6}=g;function bs(Z){let J=new w6().setLogger(Z.getLogger()),X=bP(J,Z);return hM1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function hM1(Z,J,X){X||(X=bP(Z,J));for(let $ of J.getRoot().listExtensionsUsed()){let Y=Z.createExtension($.constructor);if($.isRequired())Y.setRequired(!0)}return SM1(Z,J,bM1(J),X)}function SM1(Z,J,X,$){$||($=bP(Z,J));let Y=new Map;for(let Q of X)if(!Y.has(Q)&&Q.propertyType!==Ss)Y.set(Q,$(Q));for(let[Q,K]of Y.entries())K.copy(Q,$);return Y}function bP(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return($)=>{if($.propertyType===Ss)return $;let Y=X.get($);if(!Y)Y=new $.constructor(Z.getGraph()),X.set($,Y);return Y}}function bM1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}function As(){var Z=new R3(4);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function AM1(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 mM1(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 uM1(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 lM1(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 ms=mM1,pM1=uM1,us=yM1;(function(){var Z=As();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 iM1=/color|emissive|diffuse/i;function gM1(Z){return Z.getGraph().listParentEdges(Z).some((Y)=>{return Y.getAttributes().isColor||iM1.test(Y.getName())})?"srgb":null}function dM1(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 h$)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 aM1(Z){let X=w6.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",EP=0.011764705882352941,qs={propertyTypes:[g.NODE,g.SKIN,g.MESH,g.CAMERA,g.PRIMITIVE,g.PRIMITIVE_TARGET,g.ANIMATION,g.MATERIAL,g.TEXTURE,g.ACCESSOR,g.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function ls(Z=qs){let J=PZ(qs,Z),X=new Set(J.propertyTypes),$=J.keepExtras;return l$(D3,async(Y)=>{let Q=Y.getLogger(),K=Y.getRoot(),W=Y.getGraph(),G=new ys,z=(v)=>G.dispose(v.target);if(W.addEventListener("node:dispose",z),X.has(g.MESH))for(let v of K.listMeshes()){if(v.listPrimitives().length>0)continue;v.dispose()}if(X.has(g.NODE)){if(!J.keepLeaves)for(let v of K.listScenes())ps(W,v,$);for(let v of K.listNodes())D4(v,$)}if(X.has(g.SKIN))for(let v of K.listSkins())D4(v,$);if(X.has(g.MESH))for(let v of K.listMeshes())D4(v,$);if(X.has(g.CAMERA))for(let v of K.listCameras())D4(v,$);if(X.has(g.PRIMITIVE))Fs(W,g.PRIMITIVE,$);if(X.has(g.PRIMITIVE_TARGET))Fs(W,g.PRIMITIVE_TARGET,$);if(!J.keepAttributes&&X.has(g.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=is(Y,V,q),c=nM1(V,F);cs(V,c),V.listTargets().forEach((w)=>cs(w,c)),v.has(q)?v.get(q).add(V):v.set(q,new Set([V]))}for(let[H,V]of v)sM1(H,Array.from(V))}if(X.has(g.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(g.MATERIAL))K.listMaterials().forEach((v)=>D4(v,$));if(X.has(g.TEXTURE)){if(K.listTextures().forEach((v)=>D4(v,$)),!J.keepSolidTextures)await oM1(Y)}if(X.has(g.ACCESSOR))K.listAccessors().forEach((v)=>D4(v,$));if(X.has(g.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 ys{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 KZ)),$=J&&!Ns(Z.getExtras());if(!X.length&&!$)Z.dispose()}function Fs(Z,J,X){for(let $ of Z.listEdges()){let Y=$.getParent();if(Y.propertyType===J)D4(Y,X)}}function ps(Z,J,X){if(J.listChildren().forEach((K)=>ps(Z,K,X)),J instanceof K3)return;let $=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==g.ROOT&&W!==g.SCENE&&W!==g.NODE}),Y=Z.listChildren(J).length===0,Q=X&&!Ns(J.getExtras());if(Y&&!$&&!Q)J.dispose()}function cs(Z,J){for(let X of J)Z.setAttribute(X,null)}function nM1(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 is(Z,J,X,$=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let z of Q)if(z.getChild()instanceof h$)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 h$&&v.match(/normalTexture/i))$.add("TANGENT");if(H instanceof O1)is(Z,J,H,$)}let W=X instanceof K7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===g1.Mode.POINTS;if(W&&!G)$.add("NORMAL");return $}function sM1(Z,J){let X=dM1(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 oM1(Z){let J=Z.getRoot(),X=Z.getGraph(),$=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await tM1(K);if(!G)return;if(gM1(K)==="srgb")HR.convertSRGBToLinear(G,G);let z=K.getName()||K.getURI(),v=(W=K.getSize())==null?void 0:W.join("x"),H=aM1(K);for(let V of X.listParentEdges(K)){let q=V.getParent();if(q!==J&&rM1(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 rM1(Z,J,X,$){if(Z instanceof K7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(pM1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(DM1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=EP;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return us(ms(As(),J,[0.5,0.5,1,1]))<=EP}return $.warn(`${D3}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function tM1(Z){let J=await eM1(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(us(ms(Y,$,X))/255>EP)return null}return lM1(Y,AM1(Y,$,X),0.00196078431372549)}async function eM1(Z){try{return await hn(Z.getImage(),Z.getMimeType())}catch(J){return null}}var PP="flatten",ws={cleanup:!0};function gs(Z=ws){let J=PZ(ws,Z);return l$(PP,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;WM1(v)});if(K.size)Y.debug(`${PP}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(ls({propertyTypes:[g.NODE],keepLeaves:!1}));Y.debug(`${PP}: Complete.`)})}function ds(Z){return PG(Z)}var ZR1={skipValidation:!1},xs=4294967295,{LINE_STRIP:JR1,LINE_LOOP:XR1,TRIANGLE_STRIP:$R1,TRIANGLE_FAN:YR1}=g1.Mode;function QR1(Z,J={}){let X=PZ(ZR1,J),$=Z[0],Y=w6.fromGraph($.getGraph());if(!X.skipValidation&&new Set(Z.map(Os)).size>1)throw 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 JR1:case XR1:IM1(q);break;case $R1:case YR1:_s(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],c=F.getIndices(),w=F.getAttribute("POSITION").getCount(),x=c?c.getArray():null,j=c?c.getCount():w,B=new Uint32Array(w).fill(xs);for(let L=0;L<j;L++){let R=x?x[L]:L;if(B[R]===xs)B[R]=W++,K[q]++}Q.push(B),G+=j}let z=Y.createPrimitive().setMode($.getMode()).setMaterial($.getMaterial());for(let q of $.listSemantics()){let F=$.getAttribute(q),c=AJ[F.getComponentType()],w=RZ(Y,F).setArray(new c(W*F.getElementSize()));z.setAttribute(q,w)}let v=$.getIndices(),H=v?RZ(Y,v).setArray(hP(G,W)):null;z.setIndices(H);let V=0;for(let q=0;q<Q.length;q++){let F=Z[q],c=F.getIndices(),w=c?c.getCount():-1,x=Q[q];if(c&&H)WR1(c,x,H,V),V+=w;for(let j of z.listSemantics()){let B=F.getAttribute(j),L=z.getAttribute(j);KR1(B,c,x,L)}}return z}function KR1(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 WR1(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 IP="join",{ROOT:GR1,NODE:zR1,MESH:vR1,PRIMITIVE:VR1,ACCESSOR:HR1}=g,NP=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Us={keepMeshes:!1,keepNamed:!1,cleanup:!0,filter:()=>!0};function as(Z=Us){let J=PZ(Us,Z);return l$(IP,async(X)=>{let $=X.getRoot(),Y=X.getLogger();for(let Q of $.listScenes())js(X,Q,J),Q.traverse((K)=>js(X,K,J));if(J.cleanup)await X.transform(ls({propertyTypes:[zR1,vR1,VR1,HR1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));Y.debug(`${IP}: Complete.`)})}function js(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 KZ))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;dG(V),FR1(V);let F=Os(V),c=H.getName()||z.getName();if(X.keepMeshes||X.keepNamed&&c)F+=`|${G}`;if(!(F in Y))Y[F]={prims:[],primMeshes:[],primNodes:[],dstNode:z,dstMesh:void 0};let w=Y[F];w.prims.push(V),w.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!==GR1&&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 x=0;x<z.length;x++){let j=v[x],B=H[x],L=z[x];if(B.removePrimitive(L),TP(L))L=z[x]=qR1(z[x]);if(j!==V)Cs(NP,GM1(NP,F),j.getMatrix()),Es(L,NP)}let c=QR1(z),w=c.listAttributes()[0].getCount();q.addPrimitive(c),$.debug(`${IP}: Joined Primitives (${z.length}) containing ${OP(w)} vertices under Node "${V.getName()}".`)}}function qR1(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 FR1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)kP(X)}}var{TRANSLATION:zO6,ROTATION:vO6,SCALE:VO6,WEIGHTS:HO6}=KZ.TargetPath;var cR1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var qO6=M3({level:"high"},cR1);var wR1="unweld";function xR1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let $=Z.getGraph(),Y=w6.fromGraph($),Q=Y.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,Bs(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,Bs(Y,z,X,J)),z.listParents().length===1)z.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${wR1}: ${Ac(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function Bs(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=RZ(Z,J).setArray(K);return $.get(J).set(X,z),z}var Ls;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Ls||(Ls={}));var UR1=0.000001;function jR1(Z,J,X,$=0.0001){let Y=J.length/Z.length,Q=Array(Y).fill(0),K=Array(Y).fill(0),W=Array(Y).fill(0),G=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],c=(q-V)/(F-V),w=!1;if(q!==F&&(H!==1||q!==Z[0])){if(gG(J,v-1,G),gG(J,H,K),gG(J,H+1,W),X==="slerp"){let x=DR1(Q,G,W,c),j=Ms(G,K)+Ms(K,W);w=!_c(K,x,$)||j+Number.EPSILON>=Math.PI}else if(X==="lerp"){let x=LR1(Q,G,W,c);w=!_c(K,x,$)}else if(X==="step")w=!_c(K,G)||!_c(K,W)}if(w){if(H!==v)Z[v]=Z[H],Ds(J,v,gG(J,H,Q));v++}}if(z>0)Z[v]=Z[z],Ds(J,v,gG(J,z,Q)),v++;return v}function gG(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)X[$]=Z[J*Y+$];return X}function Ds(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)Z[J*Y+$]=X[$]}function _c(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 BR1(Z,J,X){return Z*(1-X)+J*X}function LR1(Z,J,X,$){for(let Y=0;Y<J.length;Y++)Z[Y]=BR1(J[Y],X[Y],$);return Z}function DR1(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,c,w;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>UR1)V=Math.acos(q),F=Math.sin(V),c=Math.sin((1-$)*V)/F,w=Math.sin($*V)/F;else c=1-$,w=$;return Z[0]=c*Y+w*G,Z[1]=c*Q+w*z,Z[2]=c*K+w*v,Z[3]=c*W+w*H,Z}function Ms(Z,J){let X=MR1(Z,J);return Math.acos(2*X*X-1)}function MR1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var FO6=new Float32Array(0),cO6={ready:Promise.resolve(),resample:jR1,tolerance:0.0001,cleanup:!0};var m$="simplify",{POINTS:ns,LINES:RR1,LINE_STRIP:PR1,LINE_LOOP:NR1,TRIANGLES:OR1,TRIANGLE_STRIP:ss,TRIANGLE_FAN:os}=g1.Mode,rs={ratio:0,error:0.0001,lockBorder:!1};function ts(Z){let J=PZ(rs,Z),X=J.simplifier;if(!X)throw Error(`${m$}: simplifier dependency required — install "meshoptimizer".`);return l$(m$,async($)=>{let Y=$.getLogger();await X.ready,await $.transform(SP({overwrite:!1}));let Q=0;for(let K of $.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G!==OR1&&G!==ss&&G!==os&&G!==ns){Q++;continue}if(TR1(W,J),u$(W,j6.RENDER)===0)Ps(W)}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)Y.warn(`${m$}: Skipped ${Q} primitives: Unsupported draw mode.`);Y.debug(`${m$}: Complete.`)})}function TR1(Z,J){let X=M3({},rs,J),$=X.simplifier,Y=Z.getGraph(),Q=w6.fromGraph(Y),K=Q.getLogger();switch(Z.getMode()){case ns:return CR1(Q,Z,X);case RR1:case PR1:case NR1:return K.warn(`${m$}: Skipping primitive simplification: Unsupported draw mode.`),Z;case ss:case os:_s(Z);break}let W=u$(Z,j6.UPLOAD),G=u$(Z,j6.RENDER);if(G<W/2)dG(Z);let z=Z.getAttribute("POSITION"),v=Z.getIndices(),H=z.getArray(),V=v.getArray();if(!(H instanceof Float32Array))H=bc(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"]:[],[c,w]=$.simplify(V,H,3,q,X.error,F);if(Z.setIndices(RZ(Q,v).setArray(c)),v.listParents().length===1)v.dispose();dG(Z);let x=u$(Z,j6.UPLOAD);if(x<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${m$}: ${Ac(W,x)} vertices, error: ${w.toFixed(4)}.`),Z}function CR1(Z,J,X){let $=X.simplifier,Y=Z.getLogger();if(J.getIndices())xR1(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=bc(z,K.getComponentType(),K.getNormalized());if(v&&!(v instanceof Float32Array))v=bc(v,K.getComponentType(),K.getNormalized());let V=Math.floor(X.ratio*G),q=$.simplifyPoints(z,3,V,v,H),[F,c]=$.compactMesh(q);Y.debug(`${m$}: ${Ac(K.getCount(),c)} vertices.`);for(let w of mc(J)){let x=RZ(Z,w);if(CP(w,null,F,x,c),XM1(J,w,x),w.listParents().length===1)w.dispose()}return J}var _P;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(_P||(_P={}));var wO6={resizeFilter:_P.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var Qo=t(Yo(),1);var NZ={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DATA_SCHEMA_VERSION:1,DATA_EXT:".data.json",DIRECTORIES:[(()=>{try{return q5.dirname(i.resolve("@hytopia.com/assets"))}catch{return null}})(),q5.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 B6{static instance=new B6;optimize=!0;optimizeEveryStart=!1;_modelUriAnimationNames=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...`);let J=performance.now();for(let $ of Z){if(this.optimize)await this._resolveOptimizedModelPath($);await this._loadModelData($)}let X=performance.now();console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models in ${X-J}ms!`)}getAnimationNames(Z){let J=this._modelUriAnimationNames.get(Z);if(!J)y.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)y.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)y.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){y.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)y.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=q5.normalize(Z);for(let X of NZ.DIRECTORIES){let $=q5.normalize(X);if(J.startsWith($))return q5.relative($,J).replace(/\\/g,"/")}return q5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of NZ.DIRECTORIES){let X=q5.resolve(process.cwd(),J);if(!M4.existsSync(X))continue;let $=await mF("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let Y of $)Z.push(q5.join(X,Y))}return Z}async _loadModelData(Z){let X=`${this._buildOptimizedModelPath(Z)}${NZ.DATA_EXT}`,$=this._absoluteModelPathToModelUri(Z),Y=this._calculateChecksum(Z),Q;if(M4.existsSync(X))try{let K=M4.readFileSync(X,"utf8"),W=JSON.parse(K);if(W?.schemaVersion!==NZ.DATA_SCHEMA_VERSION)throw Error("ModelRegistry._loadModelData(): Schema version mismatch! Data will be regenerated..");if(W?.source?.sha256!==Y)throw Error("ModelRegistry._loadModelData(): Checksum mismatch! Data will be regenerated..");Q=W}catch{}if(!Q){let K=await new xR().read(Z),W=ds(K.getRoot().listScenes()[0]),G=K.getRoot().listNodes().map((H)=>H.getName()),z=K.getRoot().listAnimations().map((H)=>H.getName()),v=await this._buildTrimesh(K);Q={schemaVersion:NZ.DATA_SCHEMA_VERSION,source:{uri:$,sha256:Y},animationNames:z,boundingBox:{min:{x:W.min[0],y:W.min[1],z:W.min[2]},max:{x:W.max[0],y:W.max[1],z:W.max[2]}},nodeNames:G,trimesh:v?{vertices:Array.from(v.vertices),indices:Array.from(v.indices)}:void 0};try{let H=q5.dirname(X);M4.mkdirSync(H,{recursive:!0}),M4.writeFileSync(X,JSON.stringify(Q))}catch(H){y.warning(`ModelRegistry._loadModelData(): Failed to write data file for ${$}. Error: ${String(H)}`)}}this._modelUriAnimationNames.set($,Q.animationNames),this._modelUriBoundingBoxes.set($,Q.boundingBox),this._modelUriNodeNames.set($,Q.nodeNames),this._modelUriTrimeshes.set($,Q.trimesh?{vertices:new Float32Array(Q.trimesh.vertices),indices:new Uint32Array(Q.trimesh.indices)}:void 0)}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)}${NZ.CHECKSUM_EXT}`;if(!M4.existsSync(J))return!1;let X=this._calculateChecksum(Z),$=M4.readFileSync(J,"utf8");return X===$}_calculateChecksum(Z){if(!M4.existsSync(Z))return"";let J=M4.readFileSync(Z);return _R1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=q5.basename(Z),X=J.replace(/\.[^/.]+$/,""),$=q5.dirname(Z),Y=q5.join($,NZ.OPTIMIZED_DIR,X);return q5.join(Y,J)}async _buildTrimesh(Z,J=1,X=0.001){let $=bs(Z);$.setLogger(new z5(MG.WARN)),await $.transform(Ts({pivot:"center"}),gs(),as(),SP(),ts({simplifier:Qo.MeshoptSimplifier,ratio:J,error:X}),hs());for(let V of $.getRoot().listScenes())for(let q of V.listChildren())Is(q);let Y=[],Q=0,K=0;for(let V of $.getRoot().listMeshes())for(let q of V.listPrimitives()){let F=q.getAttribute("POSITION"),c=q.getIndices();if(!F||!c)continue;let w=F.getArray(),x=c.getArray(),j=x instanceof Uint32Array?x:new Uint32Array(x);if(w.length===0||j.length===0)continue;Y.push({vertices:w,indices:j}),Q+=w.length,K+=j.length}if(Y.length===0){y.error("ModelRegistry._buildTrimesh(): Model has no primitives with POSITION and INDICES!");return}let W=new Float32Array(Q),G=new Uint32Array(K),z=0,v=0,H=0;for(let V of Y){W.set(V.vertices,z);let q=V.vertices.length/3;for(let F=0;F<V.indices.length;F++)G[H+F]=V.indices[F]+v;z+=V.vertices.length,H+=V.indices.length,v+=q}return{vertices:W,indices:G}}async _optimizeModel(Z,J){let X=q5.dirname(J);M4.rmSync(X,{recursive:!0,force:!0}),M4.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let $ of NZ.OPTIMIZER_RUNS){let Y=J.replace(/(\.[^/.]+)$/,`${$.suffix}$1`),{stderr:Q}=await Bi("npx",["@gltf-transform/cli","optimize",Z,Y,...$.options]);if(Q)return y.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return M4.writeFileSync(`${J}${NZ.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var rG;((Y)=>{Y.DYNAMIC="dynamic";Y.FIXED="fixed";Y.KINEMATIC_POSITION="kinematic_position";Y.KINEMATIC_VELOCITY="kinematic_velocity"})(rG||={});var yP=0.001,Ko="dynamic";class aJ extends j0{_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??=Ko,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 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 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 y.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 y.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 A5({...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 y.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 y.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 y.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 A5(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??Ko;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)y.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)y.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)y.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)y.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)y.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)y.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)<yP&&Math.abs(Z.y)<yP&&Math.abs(Z.z)<yP}}var pP;((Y)=>{Y[Y.Average=0]="Average";Y[Y.Min=1]="Min";Y[Y.Multiply=2]="Multiply";Y[Y.Max=3]="Max"})(pP||={});var P3;((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"})(P3||={});class A5 extends j0{_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 $=B6.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=(j)=>Math.max(0.01,j),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)}),c=()=>{let j=B6.instance.getTrimesh(Z,J);if(!j)return;return{shape:"trimesh",vertices:j.vertices,indices:j.indices}},w=()=>({shape:"wedge",extents:{x:Y*J,y:Q*J,z:K*J}}),x=()=>({shape:"capsule",radius:V(H),halfHeight:V(Q*J/2-H)});if(X)switch(X){case"block":return q();case"capsule":return x();case"round-cylinder":return F();case"trimesh":{let j=c();if(!j){y.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return j}case"wedge":return w();default:y.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 x()}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 y.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 y.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")y.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 y.error("Collider.combineVoxelStates(): Other collider is not simulated!");if(this.shape!=="voxels")return y.error("Collider.combineVoxelStates(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return y.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 y.error("Collider.propagateVoxelChange(): Other collider is not simulated!");if(this.shape!=="voxels")return y.error("Collider.propagateVoxelChange(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return y.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":{y.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"voxels":{y.error("Collider.setScale(): Voxels colliders cannot be scaled!");return}case"wedge":{y.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:y.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)y.fatalError("Ball collider must have a radius!");return X1.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)y.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)y.fatalError("Capsule collider must have halfHeight and radius!");return X1.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)y.fatalError("Cone collider must have radius and halfHeight!");return X1.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)y.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)y.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)y.fatalError("Trimesh collider must have vertices and indices!");return X1.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)y.fatalError("Voxels collider must have coordinates and size!");return X1.ColliderDesc.voxels(this._coordinatesToInt32Array(Z.coordinates),Z.size)}case"wedge":{if(!Z.extents)y.fatalError("Wedge collider must have extents!");let $=this._buildWedgeConvexHullVertices(Z.extents),Y=X1.ColliderDesc.convexHull($);if(!Y)throw y.fatalError("Failed to create convex hull for wedge collider!"),Error("Convex hull creation failed");return Y}default:y.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)y.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)y.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)y.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 hR1={shape:"voxels"},iP;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(iP||={});class m5 extends j0{_id;_customColliderOptions;_halfExtents;_isLiquid;_lightLevel;_name;_textureUri;constructor(Z={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(Z.id<0)y.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,...hR1}}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 A5({...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 gP;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(gP||={});class tG extends j0{_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)y.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends m5{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 MO={};_Q(MO,{worldSchema:()=>DO,worldPacketDefinition:()=>J10,vectorSchema:()=>W1,vectorBooleanSchema:()=>IE1,uiSchema:()=>BO,uiPacketDefinition:()=>e00,uiDatasSchema:()=>LO,uiDatasPacketDefinition:()=>Z10,uiDataSendPacketDefinition:()=>b00,uiDataSchema:()=>Dz,syncResponseSchema:()=>jO,syncResponsePacketDefinition:()=>t00,syncRequestSchema:()=>dN,syncRequestPacketDefinition:()=>S00,stateRequestSchema:()=>gN,stateRequestPacketDefinition:()=>h00,sceneUIsSchema:()=>UO,sceneUIsPacketDefinition:()=>r00,sceneUISchema:()=>xO,rgbColorSchema:()=>D6,registeredPackets:()=>kw,quaternionSchema:()=>YO,playersSchema:()=>wO,playersPacketDefinition:()=>o00,playerSchema:()=>cO,physicsDebugRenderSchema:()=>FO,physicsDebugRenderPacketDefinition:()=>n00,physicsDebugRaycastsSchema:()=>qO,physicsDebugRaycastsPacketDefinition:()=>s00,physicsDebugRaycastSchema:()=>HO,particleEmittersSchema:()=>VO,particleEmittersPacketDefinition:()=>a00,particleEmitterSchema:()=>vO,outboundPackets:()=>fw,notificationPermissionRequestSchema:()=>zO,notificationPermissionRequestPacketDefinition:()=>d00,modelNodeOverrideSchema:()=>$O,lightsSchema:()=>GO,lightsPacketDefinition:()=>g00,lightSchema:()=>WO,isValidPacket:()=>hE1,inputSchema:()=>iN,inputPacketDefinition:()=>_00,inboundPackets:()=>Cw,hexColorSchema:()=>yN,heartbeatSchema:()=>lN,heartbeatPacketDefinition:()=>k00,entitySchema:()=>QO,entitiesSchema:()=>KO,entitiesPacketDefinition:()=>i00,definePacket:()=>C0,debugConfigSchema:()=>pN,debugConfigPacketDefinition:()=>I00,createPacket:()=>ME1,connectionSchema:()=>uN,connectionPacketDefinition:()=>f00,chunksSchema:()=>XO,chunksPacketDefinition:()=>p00,chunkSchema:()=>JO,chatMessagesSchema:()=>ZO,chatMessagesPacketDefinition:()=>y00,chatMessageSendPacketDefinition:()=>E00,chatMessageSchema:()=>Lz,cameraSchema:()=>eN,cameraPacketDefinition:()=>l00,blocksSchema:()=>oN,blocksPacketDefinition:()=>m00,blockTypesSchema:()=>tN,blockTypesPacketDefinition:()=>u00,blockTypeSchema:()=>rN,blockSchema:()=>sN,bidirectionalPackets:()=>Tw,audiosSchema:()=>nN,audiosPacketDefinition:()=>A00,audioSchema:()=>aN,PacketId:()=>M1});var Tw={};_Q(Tw,{heartbeatPacketDefinition:()=>k00,connectionPacketDefinition:()=>f00});var AN=t(T00(),1);class mN extends AN.default{static instance=new AN.default}var M1;((k)=>{k[k.SYNC_REQUEST=0]="SYNC_REQUEST";k[k.INPUT=1]="INPUT";k[k.STATE_REQUEST=2]="STATE_REQUEST";k[k.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";k[k.UI_DATA_SEND=4]="UI_DATA_SEND";k[k.SYNC_RESPONSE=32]="SYNC_RESPONSE";k[k.AUDIOS=33]="AUDIOS";k[k.BLOCKS=34]="BLOCKS";k[k.BLOCK_TYPES=35]="BLOCK_TYPES";k[k.CHAT_MESSAGES=36]="CHAT_MESSAGES";k[k.CHUNKS=37]="CHUNKS";k[k.ENTITIES=38]="ENTITIES";k[k.WORLD=39]="WORLD";k[k.CAMERA=40]="CAMERA";k[k.UI=41]="UI";k[k.UI_DATAS=42]="UI_DATAS";k[k.SCENE_UIS=43]="SCENE_UIS";k[k.LIGHTS=44]="LIGHTS";k[k.PLAYERS=45]="PLAYERS";k[k.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";k[k.NOTIFICATION_PERMISSION_REQUEST=47]="NOTIFICATION_PERMISSION_REQUEST";k[k.CONNECTION=116]="CONNECTION";k[k.HEARTBEAT=117]="HEARTBEAT";k[k.DEBUG_CONFIG=128]="DEBUG_CONFIG";k[k.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";k[k.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(M1||={});function ME1(Z,J,X){if(!Z.validate(J))throw Error(`Invalid payload for packet with id ${Z.id}. Error: ${mN.instance.errorsText(Z.validate.errors)}`);let $=[Z.id,J];if(typeof X==="number")$.push(X);return $}function C0(Z,J){return{id:Z,schema:J,validate:mN.instance.compile(J)}}var RE1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},C00={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},PE1={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},NE1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},OE1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},TE1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},CE1={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},fE1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:NE1,ic:{type:"array",items:PE1},d:C00,s:TE1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},kE1={type:"object",properties:{i:{type:"string"},d:C00},required:["i","d"],additionalProperties:!1},EE1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:CE1},required:["l","s"],additionalProperties:!1},uN={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},c:{...kE1,nullable:!0},ca:{...RE1,nullable:!0},d:{type:"array",items:{...EE1},nullable:!0},pa:{...OE1,nullable:!0},t:{type:"array",items:{...fE1},nullable:!0}},additionalProperties:!1};var f00=C0(116,uN);var lN={type:"null",nullable:!0};var k00=C0(117,lN);var Cw={};_Q(Cw,{uiDataSendPacketDefinition:()=>b00,syncRequestPacketDefinition:()=>S00,stateRequestPacketDefinition:()=>h00,inputPacketDefinition:()=>_00,debugConfigPacketDefinition:()=>I00,chatMessageSendPacketDefinition:()=>E00});var yN={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var Lz={type:"object",properties:{m:{type:"string"},c:{...yN,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var E00=C0(3,Lz);var pN={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var I00=C0(128,pN);var iN={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 _00=C0(1,iN);var gN={type:"object",properties:{},additionalProperties:!1};var h00=C0(2,gN);var dN={type:"null",nullable:!0};var S00=C0(0,dN);var Dz={type:"object",properties:{},additionalProperties:!0};var b00=C0(4,Dz);var fw={};_Q(fw,{worldPacketDefinition:()=>J10,uiPacketDefinition:()=>e00,uiDatasPacketDefinition:()=>Z10,syncResponsePacketDefinition:()=>t00,sceneUIsPacketDefinition:()=>r00,playersPacketDefinition:()=>o00,physicsDebugRenderPacketDefinition:()=>n00,physicsDebugRaycastsPacketDefinition:()=>s00,particleEmittersPacketDefinition:()=>a00,notificationPermissionRequestPacketDefinition:()=>d00,lightsPacketDefinition:()=>g00,entitiesPacketDefinition:()=>i00,chunksPacketDefinition:()=>p00,chatMessagesPacketDefinition:()=>y00,cameraPacketDefinition:()=>l00,blocksPacketDefinition:()=>m00,blockTypesPacketDefinition:()=>u00,audiosPacketDefinition:()=>A00});var W1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var aN={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 nN={type:"array",items:{...aN}};var A00=C0(33,nN);var sN={type:"object",properties:{i:{type:"number"},c:W1},required:["i","c"],additionalProperties:!1};var oN={type:"array",items:{...sN}};var m00=C0(34,oN);var rN={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 tN={type:"array",items:{...rN}};var u00=C0(35,tN);var eN={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 ZO={type:"array",items:{...Lz}};var JO={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 XO={type:"array",items:{...JO}};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 $O={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 YO={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var QO={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:{...$O},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:{...YO,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 KO={type:"array",items:{...QO}};var WO={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 GO={type:"array",items:{...WO}};var zO={type:"null",nullable:!0};var vO={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 VO={type:"array",items:{...vO}};var HO={type:"object",properties:{o:{...W1},d:{...W1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var qO={type:"array",items:{...HO}};var FO={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var cO={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 wO={type:"array",items:{...cO}};var xO={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 UO={type:"array",items:{...xO}};var jO={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var BO={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var LO={type:"array",items:{...Dz}};var IE1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var DO={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 l00=C0(40,eN);var y00=C0(36,ZO);var p00=C0(37,XO);var i00=C0(38,KO);var g00=C0(44,GO);var d00=C0(47,zO);var a00=C0(46,VO);var n00=C0(192,FO);var s00=C0(193,qO);var o00=C0(45,wO);var r00=C0(43,UO);var t00=C0(32,jO);var e00=C0(41,BO);var Z10=C0(42,LO);var J10=C0(39,DO);var kw=new Map,_E1={...Tw,...Cw,...fw};for(let Z of Object.values(_E1))if("id"in Z&&"schema"in Z){let J=Z;if(kw.has(J.id))throw Error(`Packet with id ${J.id} is already registered.`);kw.set(J.id,J)}function hE1(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=kw.get(Z[0]);return!!J&&J.validate(Z[1])}var $0=MO;var W60=t(C10(),1);import e$ from"fs";import Q60 from"path";var M_1=t(R80(),1),R_1=t(_O(),1),P_1=t(SO(),1),t$=t(yw(),1),pO=t(k80(),1);var E80=t$.default;function U5(Z){if(Z===null)return"null";if(Array.isArray(Z))return"array";return typeof Z}function YX(Z){return U5(Z)==="object"}function N_1(Z){return Array.isArray(Z)&&Z.length>0&&Z.every((J)=>("message"in J))}function iO(Z,J){return Z.length<124?Z:J}var I80="graphql-transport-ws";var l5=((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})(l5||{}),y5=((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})(y5||{});function _80(Z){if(!YX(Z))throw Error(`Message is expected to be an object, but got ${U5(Z)}`);if(!Z.type)throw Error("Message is missing the 'type' property");if(typeof Z.type!=="string")throw Error(`Message is expects the 'type' property to be a string, but got ${U5(Z.type)}`);switch(Z.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(Z.payload!=null&&!YX(Z.payload))throw 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 Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!YX(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${U5(Z.payload)}`);if(typeof Z.payload.query!=="string")throw Error(`"${Z.type}" message payload expects the 'query' property to be a string, but got ${U5(Z.payload.query)}`);if(Z.payload.variables!=null&&!YX(Z.payload.variables))throw Error(`"${Z.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${U5(Z.payload.variables)}`);if(Z.payload.operationName!=null&&U5(Z.payload.operationName)!=="string")throw Error(`"${Z.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${U5(Z.payload.operationName)}`);if(Z.payload.extensions!=null&&!YX(Z.payload.extensions))throw Error(`"${Z.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${U5(Z.payload.extensions)}`);break}case"next":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!YX(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${U5(Z.payload)}`);break}case"error":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!N_1(Z.payload))throw 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 Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);break}default:throw Error(`Invalid message 'type' property "${Z.type}"`)}return Z}function h80(Z,J){return _80(typeof Z==="string"?JSON.parse(Z,J):Z)}function i3(Z,J){return _80(Z),JSON.stringify(Z,J)}function dO(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(h){let _=Math.pow(2,h);await new Promise((a)=>setTimeout(a,_*1000+Math.floor(Math.random()*2700+300)))},shouldRetry:H=gO,on:V,webSocketImpl:q,generateID:F=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(h)=>{let _=Math.random()*16|0;return(h=="x"?_:_&3|8).toString(16)})},jsonMessageReplacer:c,jsonMessageReviver:w}=Z,x;if(q){if(!T_1(q))throw Error("Invalid WebSocket implementation provided");x=q}else if(typeof WebSocket<"u")x=WebSocket;else if(typeof global<"u")x=global.WebSocket||global.MozWebSocket;else if(typeof window<"u")x=window.WebSocket||window.MozWebSocket;if(!x)throw Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let j=x,B=(()=>{let C=(()=>{let _={};return{on(a,s){return _[a]=s,()=>{delete _[a]}},emit(a){if("id"in a)_[a.id]?.(a)}}})(),h={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(_,a){let s=h[_];return s.push(a),()=>{s.splice(s.indexOf(a),1)}},emit(_,...a){for(let s of[...h[_]])s(...a)}}})();function L(C){let h=[B.on("error",(_)=>{h.forEach((a)=>a()),C(_)}),B.on("closed",(_)=>{h.forEach((a)=>a()),C(_)})]}let R,M=0,P,N=!1,O=0,k=!1;async function E(){clearTimeout(P);let[C,h]=await(R??(R=new Promise((s,Z0)=>(async()=>{if(N){if(await v(O),!M)return R=void 0,Z0({code:1000,reason:"All Subscriptions Gone"});O++}B.emit("connecting",N);let o=new j(typeof J==="function"?await J():J,I80),M0,R0;function m0(){if(isFinite(K)&&K>0)clearTimeout(R0),R0=setTimeout(()=>{if(o.readyState===j.OPEN)o.send(i3({type:y5.Ping})),B.emit("ping",!1,void 0)},K)}L((s0)=>{if(R=void 0,clearTimeout(M0),clearTimeout(R0),Z0(s0),s0 instanceof iw)o.close(4499,"Terminated"),o.onerror=null,o.onclose=null}),o.onerror=(s0)=>B.emit("error",s0),o.onclose=(s0)=>B.emit("closed",s0),o.onopen=async()=>{try{B.emit("opened",o);let s0=typeof X==="function"?await X():X;if(o.readyState!==j.OPEN)return;if(o.send(i3(s0?{type:y5.ConnectionInit,payload:s0}:{type:y5.ConnectionInit},c)),isFinite(G)&&G>0)M0=setTimeout(()=>{o.close(l5.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},G);m0()}catch(s0){B.emit("error",s0),o.close(l5.InternalClientError,iO(s0 instanceof Error?s0.message:String(s0),"Internal client error"))}};let N1=!1;o.onmessage=({data:s0})=>{try{let j1=h80(s0,w);if(B.emit("message",j1),j1.type==="ping"||j1.type==="pong"){if(B.emit(j1.type,!0,j1.payload),j1.type==="pong")m0();else if(!W)o.send(i3(j1.payload?{type:y5.Pong,payload:j1.payload}:{type:y5.Pong})),B.emit("pong",!1,j1.payload);return}if(N1)return;if(j1.type!==y5.ConnectionAck)throw Error(`First message cannot be of type ${j1.type}`);clearTimeout(M0),N1=!0,B.emit("connected",o,j1.payload,N),N=!1,O=0,s([o,new Promise((W4,NJ)=>L(NJ))])}catch(j1){o.onmessage=null,B.emit("error",j1),o.close(l5.BadResponse,iO(j1 instanceof Error?j1.message:String(j1),"Bad response"))}}})())));if(C.readyState===j.CLOSING)await h;let _=()=>{},a=new Promise((s)=>_=s);return[C,_,Promise.race([a.then(()=>{if(!M){let s=()=>C.close(1000,"Normal Closure");if(isFinite(Q)&&Q>0)P=setTimeout(()=>{if(C.readyState===j.OPEN)s()},Q);else s()}}),h])]}function S(C){if(gO(C)&&(O_1(C.code)||[l5.InternalServerError,l5.InternalClientError,l5.BadRequest,l5.BadResponse,l5.Unauthorized,l5.SubprotocolNotAcceptable,l5.SubscriberAlreadyExists,l5.TooManyInitialisationRequests].includes(C.code)))throw C;if(k)return!1;if(gO(C)&&C.code===1000)return M>0;if(!z||O>=z)throw C;if(!H(C))throw C;return N=!0}if(!$)(async()=>{M++;for(;;)try{let[,,C]=await E();await C}catch(C){try{if(!S(C))return}catch(h){return Y?.(h)}}})();function f(C,h){let _=F(C),a=!1,s=!1,Z0=()=>{M--,a=!0};return(async()=>{M++;for(;;)try{let[o,M0,R0]=await E();if(a)return M0();let m0=B.onMessage(_,(N1)=>{switch(N1.type){case y5.Next:{h.next(N1.payload);return}case y5.Error:{s=!0,a=!0,h.error(N1.payload),Z0();return}case y5.Complete:{a=!0,Z0();return}}});o.send(i3({id:_,type:y5.Subscribe,payload:C},c)),Z0=()=>{if(!a&&o.readyState===j.OPEN)o.send(i3({id:_,type:y5.Complete},c));M--,a=!0,M0()},await R0.finally(m0);return}catch(o){if(!S(o))return}})().then(()=>{if(!s)h.complete()}).catch((o)=>{h.error(o)}),()=>{if(!a)Z0()}}return{on:B.on,subscribe:f,iterate(C){let h=[],_={done:!1,error:null,resolve:()=>{}},a=f(C,{next(Z0){h.push(Z0),_.resolve()},error(Z0){_.done=!0,_.error=Z0,_.resolve()},complete(){_.done=!0,_.resolve()}}),s=async function*(){for(;;){if(!h.length)await new Promise((o)=>_.resolve=o);while(h.length)yield h.shift();if(_.error)throw _.error;if(_.done)return}}();return s.throw=async(Z0)=>{if(!_.done)_.done=!0,_.error=Z0,_.resolve();return{done:!0,value:void 0}},s.return=async()=>{return a(),{done:!0,value:void 0}},s},async dispose(){if(k=!0,R){let[C]=await R;C.close(1000,"Normal Closure")}},terminate(){if(R)B.emit("closed",new iw)}}}class iw extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function gO(Z){return YX(Z)&&"code"in Z&&"reason"in Z}function O_1(Z){if([1000,1001,1006,1005,1012,1013,1014].includes(Z))return!1;return Z>=1000&&Z<=1999}function T_1(Z){return typeof Z==="function"&&"constructor"in Z&&"CLOSED"in Z&&"CLOSING"in Z&&"CONNECTING"in Z&&"OPEN"in Z}var K60=t(Y60(),1);var Ez="./dev/persistence",dw=process.env.HYTOPIA_NOTIFICATION_SERVICE_URL;class O4{static instance=new O4;creatorApiKey=process.env.HYTOPIA_API_KEY;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;_gqlWs;constructor(){this._gqlWs=dO({url:"wss://prod.gql.hytopia.com/graphql",webSocketImpl:E80});try{this._creativeGateway=new K60.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 Error("wtf?")}braceExpand(){return ii(this.pattern,this.options)}parse(Z){KG(Z);let J=this.options;if(Z==="**")return J6;if(Z==="")return"";let X,$=null;if(X=Z.match(bw1))$=J.dot?mw1:Aw1;else if(X=Z.match(Ow1))$=(J.nocase?J.dot?kw1:fw1:J.dot?Cw1:Tw1)(X[1]);else if(X=Z.match(uw1))$=(J.nocase?J.dot?yw1:lw1:J.dot?pw1:iw1)(X);else if(X=Z.match(Ew1))$=J.dot?_w1:Iw1;else if(X=Z.match(hw1))$=Sw1;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?aw1:J.dot?nw1:sw1,$=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"?Zx1(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 h6.defaults(Z).Minimatch}}h6.AST=Z6;h6.Minimatch=H4;h6.escape=Z3;h6.unescape=c9;import{fileURLToPath as Ex1}from"node:url";var J3=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,di=new Set,iM=typeof process==="object"&&!!process?process:{},ai=(Z,J,X,$)=>{typeof iM.emitWarning==="function"?iM.emitWarning(Z,J,X,$):console.error(`[${X}] ${J}: ${Z}`)},PF=globalThis.AbortController,gi=globalThis.AbortSignal;if(typeof PF>"u"){gi=class{onabort;_onabort=[];reason;aborted=!1;addEventListener($,Y){this._onabort.push(Y)}},PF=class{constructor(){J()}signal=new gi;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=iM.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,ai("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 Jx1=(Z)=>!di.has(Z),YP6=Symbol("type"),_J=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),ni=(Z)=>!_J(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?GG:null;class GG extends Array{constructor(Z){super(Z);this.fill(0)}}class X3{heap;length;static#Z=!1;static create(Z){let J=ni(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 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 zG{#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;#w;#c;#U;#O;#j;#T;#D;#L;#B;#P;#x;#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.#w,get head(){return Z.#c},get tail(){return Z.#U},free:Z.#O,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,$,Y)=>Z.#h(J,X,$,Y),moveToTail:(J)=>Z.#A(J),indexes:(J)=>Z.#N(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:c,fetchMethod:w,memoMethod:x,noDeleteOnFetchRejection:j,noDeleteOnStaleGet:B,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:R,ignoreFetchAbort:M}=Z;if(J!==0&&!_J(J))throw TypeError("max option must be a nonnegative integer");let P=J?ni(J):Array;if(!P)throw Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=F||this.#J,this.sizeCalculation=c,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#H=x,w!==void 0&&typeof w!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#v=w,this.#P=!!w,this.#z=new Map,this.#V=Array(J).fill(void 0),this.#Q=Array(J).fill(void 0),this.#F=new P(J),this.#w=new P(J),this.#c=0,this.#U=0,this.#O=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.#j=[];else this.#Y=void 0,this.#j=void 0;if(this.#B=!!this.#$,this.#f=!!this.#X,this.#x=!!this.#Y,this.noDisposeOnSet=!!H,this.noUpdateTTL=!!V,this.noDeleteOnFetchRejection=!!j,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!_J(this.#J))throw TypeError("maxSize must be a positive integer if specified")}if(!_J(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#u()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!B,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=_J($)||$===0?$:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!_J(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(Jx1("LRU_CACHE_UNBOUNDED"))di.add("LRU_CACHE_UNBOUNDED"),ai("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",zG)}}getRemainingTTL(Z){return this.#z.has(Z)?1/0:0}#K(){let Z=new GG(this.#Z),J=new GG(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 GG(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(!_J($))if(Y){if(typeof Y!=="function")throw TypeError("sizeCalculation must be a function");if($=Y(X,J),!_J($))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return $},this.#S=(J,X,$)=>{if(Z[J]=X,this.#J){let Y=this.#J-Z[J];while(this.#G>Y)this.#b(!0)}if(this.#G+=Z[J],$)$.entrySize=X,$.totalCalculatedSize=this.#G}}#_=(Z)=>{};#S=(Z,J,X)=>{};#l=(Z,J,X,$)=>{if(X||$)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({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.#c)break;else J=this.#w[J]}}*#C({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#c;;){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.#N())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.#N()){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.#N())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.#N()){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.#N()){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.#N({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.#O.length!==0?this.#O.pop():this.#W===this.#Z?this.#b(!1):this.#W,this.#V[v]=Z,this.#Q[v]=J,this.#z.set(Z,v),this.#F[this.#U]=v,this.#w[v]=this.#U,this.#U=v,this.#W++,this.#S(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.#P&&this.#q(H)){H.__abortController.abort(Error("replaced"));let{__staleWhileFetching:V}=H;if(V!==void 0&&!Q){if(this.#B)this.#$?.(V,Z,"set");if(this.#x)this.#j?.push([V,Z,"set"])}}else if(!Q){if(this.#B)this.#$?.(H,Z,"set");if(this.#x)this.#j?.push([H,Z,"set"])}if(this.#_(v),this.#S(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.#x&&this.#j){let H=this.#j,V;while(V=H?.shift())this.#Y?.(...V)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#c];if(this.#b(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#x&&this.#j){let Z=this.#j,J;while(J=Z?.shift())this.#Y?.(...J)}}}#b(Z){let J=this.#c,X=this.#V[J],$=this.#Q[J];if(this.#P&&this.#q($))$.__abortController.abort(Error("evicted"));else if(this.#B||this.#x){if(this.#B)this.#$?.($,X,"evict");if(this.#x)this.#j?.push([$,X,"evict"])}if(this.#_(J),Z)this.#V[J]=void 0,this.#Q[J]=void 0,this.#O.push(J);if(this.#W===1)this.#c=this.#U=0,this.#O.length=0;else this.#c=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}#h(Z,J,X,$){let Y=J===void 0?void 0:this.#Q[J];if(this.#q(Y))return Y;let Q=new PF,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:$},G=(F,c=!1)=>{let{aborted:w}=Q.signal,x=X.ignoreFetchAbort&&F!==void 0;if(X.status)if(w&&!c){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,x)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(w&&!x&&!c)return v(Q.signal.reason);let j=V;if(this.#Q[J]===V)if(F===void 0)if(j.__staleWhileFetching)this.#Q[J]=j.__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:c}=Q.signal,w=c&&X.allowStaleOnFetchAbort,x=w||X.allowStaleOnFetchRejection,j=x||X.noDeleteOnFetchRejection,B=V;if(this.#Q[J]===V){if(!j||B.__staleWhileFetching===void 0)this.#E(Z,"fetch");else if(!w)this.#Q[J]=B.__staleWhileFetching}if(x){if(X.status&&B.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return B.__staleWhileFetching}else if(B.__returned===B)throw F},H=(F,c)=>{let w=this.#v?.(Z,Y,W);if(w&&w instanceof Promise)w.then((x)=>F(x===void 0?void 0:x),c);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(F(void 0),X.allowStaleOnFetchAbort)F=(x)=>G(x,!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.#P)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof PF}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:c=!1,status:w,signal:x}=J;if(!this.#P){if(w)w.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,status:w})}let j={allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:z,noDeleteOnFetchRejection:v,allowStaleOnFetchRejection:H,allowStaleOnFetchAbort:q,ignoreFetchAbort:V,status:w,signal:x},B=this.#z.get(Z);if(B===void 0){if(w)w.fetch="miss";let L=this.#h(Z,B,j,F);return L.__returned=L}else{let L=this.#Q[B];if(this.#q(L)){let O=X&&L.__staleWhileFetching!==void 0;if(w){if(w.fetch="inflight",O)w.returnedStale=!0}return O?L.__staleWhileFetching:L.__returned=L}let R=this.#R(B);if(!c&&!R){if(w)w.fetch="hit";if(this.#A(B),$)this.#I(B);if(w)this.#M(w,B);return L}let M=this.#h(Z,B,j,F),N=M.__staleWhileFetching!==void 0&&X;if(w){if(w.fetch=R?"stale":"refresh",N&&R)w.returnedStale=!0}return N?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#H;if(!X)throw 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.#w[J]=Z,this.#F[Z]=J}#A(Z){if(Z!==this.#U){if(Z===this.#c)this.#c=this.#F[Z];else this.#p(this.#w[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(Error("deleted"));else if(this.#B||this.#x){if(this.#B)this.#$?.(Y,Z,J);if(this.#x)this.#j?.push([Y,Z,J])}if(this.#z.delete(Z),this.#V[$]=void 0,this.#Q[$]=void 0,$===this.#U)this.#U=this.#w[$];else if($===this.#c)this.#c=this.#F[$];else{let Q=this.#w[$];this.#F[Q]=this.#F[$];let K=this.#F[$];this.#w[K]=this.#w[$]}this.#W--,this.#O.push($)}}if(this.#x&&this.#j?.length){let $=this.#j,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(Error("deleted"));else{let $=this.#V[J];if(this.#B)this.#$?.(X,$,Z);if(this.#x)this.#j?.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.#c=0,this.#U=0,this.#O.length=0,this.#G=0,this.#W=0,this.#x&&this.#j){let J=this.#j,X;while(X=J?.shift())this.#Y?.(...X)}}}import{posix as Hx1,win32 as ZR}from"node:path";import{fileURLToPath as qx1}from"node:url";import{lstatSync as Fx1,readdir as cx1,readdirSync as wx1,readlinkSync as xx1,realpathSync as Ux1}from"fs";import*as jx1 from"node:fs";import{lstat as Lx1,readdir as Dx1,readlink as Mx1,realpath as Rx1}from"node:fs/promises";import{EventEmitter as oM}from"node:events";import ei from"node:stream";import{StringDecoder as Xx1}from"node:string_decoder";var si=typeof process==="object"&&process?process:{stdout:null,stderr:null},$x1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof f$||Z instanceof ei||Yx1(Z)||Qx1(Z)),Yx1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof oM&&typeof Z.pipe==="function"&&Z.pipe!==ei.Writable.prototype.pipe,Qx1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof oM&&typeof Z.write==="function"&&typeof Z.end==="function",JZ=Symbol("EOF"),XZ=Symbol("maybeEmitEnd"),hJ=Symbol("emittedEnd"),NF=Symbol("emittingEnd"),vG=Symbol("emittedError"),OF=Symbol("closed"),oi=Symbol("read"),TF=Symbol("flush"),ri=Symbol("flushChunk"),w9=Symbol("encoding"),$3=Symbol("decoder"),y8=Symbol("flowing"),VG=Symbol("paused"),Y3=Symbol("resume"),p8=Symbol("buffer"),S6=Symbol("pipes"),i8=Symbol("bufferLength"),gM=Symbol("bufferPush"),CF=Symbol("bufferShift"),c6=Symbol("objectMode"),x8=Symbol("destroyed"),dM=Symbol("error"),aM=Symbol("emitData"),ti=Symbol("emitEnd"),nM=Symbol("emitEnd2"),$7=Symbol("async"),sM=Symbol("abort"),fF=Symbol("aborted"),HG=Symbol("signal"),C$=Symbol("dataListeners"),I5=Symbol("discarded"),qG=(Z)=>Promise.resolve().then(Z),Kx1=(Z)=>Z(),Wx1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",Gx1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,zx1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class rM{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 Zg extends rM{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 vx1=(Z)=>!!Z.objectMode,Vx1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class f$ extends oM{[y8]=!1;[VG]=!1;[S6]=[];[p8]=[];[c6];[w9];[$7];[$3];[JZ]=!1;[hJ]=!1;[NF]=!1;[OF]=!1;[vG]=null;[i8]=0;[x8]=!1;[HG];[fF]=!1;[C$]=0;[I5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(vx1(J))this[c6]=!0,this[w9]=null;else if(Vx1(J))this[w9]=J.encoding,this[c6]=!1;else this[c6]=!1,this[w9]=null;if(this[$7]=!!J.async,this[$3]=this[w9]?new Xx1(this[w9]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[p8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[S6]});let{signal:X}=J;if(X)if(this[HG]=X,X.aborted)this[sM]();else X.addEventListener("abort",()=>this[sM]())}get bufferLength(){return this[i8]}get encoding(){return this[w9]}set encoding(Z){throw Error("Encoding must be set at instantiation time")}setEncoding(Z){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[c6]}set objectMode(Z){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[$7]}set["async"](Z){this[$7]=this[$7]||!!Z}[sM](){this[fF]=!0,this.emit("abort",this[HG]?.reason),this.destroy(this[HG]?.reason)}get aborted(){return this[fF]}set aborted(Z){}write(Z,J,X){if(this[fF])return!1;if(this[JZ])throw Error("write after end");if(this[x8])return this.emit("error",Object.assign(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[$7]?qG:Kx1;if(!this[c6]&&!Buffer.isBuffer(Z)){if(zx1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(Gx1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[c6]){if(this[y8]&&this[i8]!==0)this[TF](!0);if(this[y8])this.emit("data",Z);else this[gM](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[w9]&&!this[$3]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[w9])Z=this[$3].write(Z);if(this[y8]&&this[i8]!==0)this[TF](!0);if(this[y8])this.emit("data",Z);else this[gM](Z);if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}read(Z){if(this[x8])return null;if(this[I5]=!1,this[i8]===0||Z===0||Z&&Z>this[i8])return this[XZ](),null;if(this[c6])Z=null;if(this[p8].length>1&&!this[c6])this[p8]=[this[w9]?this[p8].join(""):Buffer.concat(this[p8],this[i8])];let J=this[oi](Z||null,this[p8][0]);return this[XZ](),J}[oi](Z,J){if(this[c6])this[CF]();else{let X=J;if(Z===X.length||Z===null)this[CF]();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[JZ])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[JZ]=!0,this.writable=!1,this[y8]||!this[VG])this[XZ]();return this}[Y3](){if(this[x8])return;if(!this[C$]&&!this[S6].length)this[I5]=!0;if(this[VG]=!1,this[y8]=!0,this.emit("resume"),this[p8].length)this[TF]();else if(this[JZ])this[XZ]();else this.emit("drain")}resume(){return this[Y3]()}pause(){this[y8]=!1,this[VG]=!0,this[I5]=!1}get destroyed(){return this[x8]}get flowing(){return this[y8]}get paused(){return this[VG]}[gM](Z){if(this[c6])this[i8]+=1;else this[i8]+=Z.length;this[p8].push(Z)}[CF](){if(this[c6])this[i8]-=1;else this[i8]-=this[p8][0].length;return this[p8].shift()}[TF](Z=!1){do;while(this[ri](this[CF]())&&this[p8].length);if(!Z&&!this[p8].length&&!this[JZ])this.emit("drain")}[ri](Z){return this.emit("data",Z),this[y8]}pipe(Z,J){if(this[x8])return Z;this[I5]=!1;let X=this[hJ];if(J=J||{},Z===si.stdout||Z===si.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[S6].push(!J.proxyErrors?new rM(this,Z,J):new Zg(this,Z,J)),this[$7])qG(()=>this[Y3]());else this[Y3]();return Z}unpipe(Z){let J=this[S6].find((X)=>X.dest===Z);if(J){if(this[S6].length===1){if(this[y8]&&this[C$]===0)this[y8]=!1;this[S6]=[]}else this[S6].splice(this[S6].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[I5]=!1,this[C$]++,!this[S6].length&&!this[y8])this[Y3]()}else if(Z==="readable"&&this[i8]!==0)super.emit("readable");else if(Wx1(Z)&&this[hJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[vG]){let $=J;if(this[$7])qG(()=>$.call(this,this[vG]));else $.call(this,this[vG])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[C$]=this.listeners("data").length,this[C$]===0&&!this[I5]&&!this[S6].length)this[y8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[C$]=0,!this[I5]&&!this[S6].length)this[y8]=!1}return J}get emittedEnd(){return this[hJ]}[XZ](){if(!this[NF]&&!this[hJ]&&!this[x8]&&this[p8].length===0&&this[JZ]){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!==x8&&this[x8])return!1;else if(Z==="data")return!this[c6]&&!X?!1:this[$7]?(qG(()=>this[aM](X)),!0):this[aM](X);else if(Z==="end")return this[ti]();else if(Z==="close"){if(this[OF]=!0,!this[hJ]&&!this[x8])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Z==="error"){this[vG]=X,super.emit(dM,X);let Y=!this[HG]||this.listeners("error").length?super.emit("error",X):!1;return this[XZ](),Y}else if(Z==="resume"){let Y=super.emit("resume");return this[XZ](),Y}else if(Z==="finish"||Z==="prefinish"){let Y=super.emit(Z);return this.removeAllListeners(Z),Y}let $=super.emit(Z,...J);return this[XZ](),$}[aM](Z){for(let X of this[S6])if(X.dest.write(Z)===!1)this.pause();let J=this[I5]?!1:super.emit("data",Z);return this[XZ](),J}[ti](){if(this[hJ])return!1;return this[hJ]=!0,this.readable=!1,this[$7]?(qG(()=>this[nM]()),!0):this[nM]()}[nM](){if(this[$3]){let J=this[$3].end();if(J){for(let X of this[S6])X.dest.write(J);if(!this[I5])super.emit("data",J)}}for(let J of this[S6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[c6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[c6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[c6])throw Error("cannot concat in objectMode");let Z=await this.collect();return this[w9]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(x8,()=>J(Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[I5]=!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[JZ])return J();let Y,Q,K=(v)=>{this.off("data",W),this.off("end",G),this.off(x8,z),J(),Q(v)},W=(v)=>{this.off("error",K),this.off("end",G),this.off(x8,z),this.pause(),Y({value:v,done:!!this[JZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(x8,z),J(),Y({done:!0,value:void 0})},z=()=>K(Error("stream destroyed"));return new Promise((v,H)=>{Q=H,Y=v,this.once(x8,z),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[I5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(dM,J),this.off(x8,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(dM,J),this.once(x8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[x8]){if(Z)this.emit("error",Z);else this.emit(x8);return this}this[x8]=!0,this[I5]=!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(x8);return this}static get isStream(){return $x1}}var Bx1=Ux1.native,cG={lstatSync:Fx1,readdir:cx1,readdirSync:wx1,readlinkSync:xx1,realpathSync:Bx1,promises:{lstat:Lx1,readdir:Dx1,readlink:Mx1,realpath:Rx1}},Qg=(Z)=>!Z||Z===cG||Z===jx1?cG:{...cG,...Z,promises:{...cG.promises,...Z.promises||{}}},Kg=/^\\\\\?\\([a-z]:)\\?$/i,Px1=(Z)=>Z.replace(/\//g,"\\").replace(Kg,"$1\\"),Nx1=/[\\\/]/,F4=0,Wg=1,Gg=2,Y7=4,zg=6,vg=8,k$=10,Vg=12,q4=15,FG=~q4,tM=16,Jg=32,wG=64,x9=128,kF=256,IF=512,Xg=wG|x9|IF,Ox1=1023,eM=(Z)=>Z.isFile()?vg:Z.isDirectory()?Y7:Z.isSymbolicLink()?k$:Z.isCharacterDevice()?Gg:Z.isBlockDevice()?zg:Z.isSocket()?Vg:Z.isFIFO()?Wg:F4,$g=new Map,xG=(Z)=>{let J=$g.get(Z);if(J)return J;let X=Z.normalize("NFKD");return $g.set(Z,X),X},Yg=new Map,EF=(Z)=>{let J=Yg.get(Z);if(J)return J;let X=xG(Z.toLowerCase());return Yg.set(Z,X),X};class JR extends zG{constructor(){super({max:256})}}class Hg extends zG{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var qg=Symbol("PathScurry setAsCwd");class b6{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}#w;get ctimeMs(){return this.#w}#c;get birthtimeMs(){return this.#c}#U;get atime(){return this.#U}#O;get mtime(){return this.#O}#j;get ctime(){return this.#j}#T;get birthtime(){return this.#T}#D;#L;#B;#P;#x;#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?EF(Z):xG(Z),this.#K=J&Ox1,this.nocase=Y,this.roots=$,this.root=X||this,this.#I=Q,this.#B=K.fullpath,this.#x=K.relative,this.#f=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=Qg(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&=~tM,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),$=this.nocase?EF(Z):xG(Z);for(let W of X)if(W.#D===$)return W;let Y=this.parent?this.sep:"",Q=this.#B?this.#B+Y+Z:void 0,K=this.newChild(Z,F4,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=x9;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let Z=this.name,J=this.parent;if(!J)return this.#x=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.#B!==void 0)return this.#B;let Z=this.name,J=this.parent;if(!J)return this.#B=this.name;let $=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#B=$}fullpathPosix(){if(this.#P!==void 0)return this.#P;if(this.sep==="/")return this.#P=this.fullpath();if(!this.parent){let $=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test($))return this.#P=`//?/${$}`;else return this.#P=$}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#P=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)===vg}isDirectory(){return(this.#K&q4)===Y7}isCharacterDevice(){return(this.#K&q4)===Gg}isBlockDevice(){return(this.#K&q4)===zg}isFIFO(){return(this.#K&q4)===Wg}isSocket(){return(this.#K&q4)===Vg}isSymbolicLink(){return(this.#K&k$)===k$}lstatCached(){return this.#K&Jg?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!==k$||this.#K&kF||this.#K&x9)}calledReaddir(){return!!(this.#K&tM)}isENOENT(){return!!(this.#K&x9)}isNamed(Z){return!this.nocase?this.#D===xG(Z):this.#D===EF(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.#b(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.#b(J.code);return}}#u(Z){this.#K|=tM;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#_()}}#_(){if(this.#K&x9)return;this.#K=(this.#K|x9)&FG,this.#S()}#S(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#_()}#l(){this.#K|=IF,this.#N()}#N(){if(this.#K&wG)return;let Z=this.#K;if((Z&q4)===Y7)Z&=FG;this.#K=Z|wG,this.#S()}#C(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#N();else if(Z==="ENOENT")this.#_();else this.children().provisional=0}#y(Z=""){if(Z==="ENOTDIR")this.parent.#N();else if(Z==="ENOENT")this.#_()}#b(Z=""){let J=this.#K;if(J|=kF,Z==="ENOENT")J|=x9;if(Z==="EINVAL"||Z==="UNKNOWN")J&=FG;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#N()}#h(Z,J){return this.#p(Z,J)||this.#q(Z,J)}#q(Z,J){let X=eM(Z),$=this.newChild(Z.name,X,{parent:this}),Y=$.#K&q4;if(Y!==Y7&&Y!==k$&&Y!==F4)$.#K|=wG;return J.unshift($),J.provisional++,$}#p(Z,J){for(let X=J.provisional;X<J.length;X++){let $=J[X];if((this.nocase?EF(Z.name):xG(Z.name))!==$.#D)continue;return this.#A(Z,$,X,J)}}#A(Z,J,X,$){let Y=J.name;if(J.#K=J.#K&FG|eM(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&x9)===0)try{return this.#E(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#y(Z.code)}}lstatSync(){if((this.#K&x9)===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:c,rdev:w,size:x,uid:j}=Z;this.#U=J,this.#Q=X,this.#T=$,this.#c=Y,this.#W=Q,this.#V=K,this.#j=W,this.#w=G,this.#J=z,this.#v=v,this.#G=H,this.#$=V,this.#O=q,this.#F=F,this.#X=c,this.#H=w,this.#z=x,this.#Y=j;let B=eM(Z);if(this.#K=this.#K&FG|B|Jg,B!==F4&&B!==Y7&&B!==k$)this.#K|=wG}#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.#h(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.#h($,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.#h(X,Z);this.#u(Z)}catch(X){this.#C(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&Xg)return!1;let Z=q4&this.#K;if(!(Z===F4||Z===Y7||Z===k$))return!1;return!0}shouldWalk(Z,J){return(this.#K&Y7)===Y7&&!(this.#K&Xg)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#k)return this.#k;if((IF|kF|x9)&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((IF|kF|x9)&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($),$.#x=X.join(this.sep),$.#f=X.join("/"),$=$.parent,X.push("..");$=Z;while($&&$.parent&&!J.has($))$.#x=void 0,$.#f=void 0,$=$.parent}}class _F extends b6{sep="\\";splitSep=Nx1;constructor(Z,J=F4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}newChild(Z,J=F4,X={}){return new _F(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return ZR.parse(Z).root}getRoot(Z){if(Z=Px1(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 UG(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(Kg,"$1\\"),Z===J}}class hF extends b6{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 hF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class XR{root;rootPath;roots;cwd;#Z;#J;#$;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:$,childrenCacheSize:Y=16384,fs:Q=cG}={}){if(this.#X=Qg(Q),Z instanceof URL||Z.startsWith("file://"))Z=qx1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new JR,this.#J=new JR,this.#$=new Hg(Y);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if($===void 0)throw 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:Array(F).fill("..").join(v),relativePosix: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 b6))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 b6))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 b6))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 b6))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 b6))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 b6))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 b6))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 c=()=>{if(--F===0)H()};for(let w of q){if(!Y||Y(w))K.push(X?w:w.fullpath());if($&&w.isSymbolicLink())w.realpath().then((x)=>x?.isUnknown()?x.lstat():x).then((x)=>x?.shouldWalk(W,Q)?G(x,c):c());else if(w.shouldWalk(W,Q))G(w,c);else c()}},!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 b6))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 b6))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 b6))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 b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new f$({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=(c,w,x=!1)=>{if(c)return K.emit("error",c);if($&&!x){let j=[];for(let B of w)if(B.isSymbolicLink())j.push(B.realpath().then((L)=>L?.isUnknown()?L.lstat():L));if(j.length){Promise.all(j).then(()=>q(null,w,!0));return}}for(let j of w)if(j&&(!Y||Y(j))){if(!K.write(X?j:j.fullpath()))H=!0}z--;for(let j of w){let B=j.realpathCached()||j;if(B.shouldWalk(W,Q))G.push(B)}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 b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new f$({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 c=F;if(F.isSymbolicLink()){if(!($&&(c=F.realpathSync())))continue;if(c.isUnknown())c.lstatSync()}if(c.shouldWalk(W,Q))G.push(c)}}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 UG extends XR{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,ZR,"\\",{...J,nocase:X});this.nocase=X;for(let $=this.cwd;$;$=$.parent)$.nocase=this.nocase}parseRootPath(Z){return ZR.parse(Z).root.toUpperCase()}newRoot(Z){return new _F(this.rootPath,Y7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class jG extends XR{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,Hx1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new hF(this.rootPath,Y7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class SF extends jG{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var wP6=process.platform==="win32"?_F:hF,Fg=process.platform==="win32"?UG:process.platform==="darwin"?SF:jG;var Tx1=(Z)=>Z.length>=1,Cx1=(Z)=>Z.length>=1;class Q3{#Z;#J;#$;length;#X;#Y;#v;#H;#W;#G;#z=!0;constructor(Z,J,X,$){if(!Tx1(Z))throw TypeError("empty pattern list");if(!Cx1(J))throw TypeError("empty glob list");if(J.length!==Z.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw 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("/"),c=[z,v,H,V,""].join("/");this.#Z=[F,...G],this.#J=[c,...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 fx1=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=fx1}){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 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 $R{store;constructor(Z=new Map){this.store=Z}copy(){return new $R(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 cg{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 wg{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 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 LG{hasWalkedCache;matches=new cg;subwalks=new wg;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new $R}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 LG(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 kx1=(Z,J)=>typeof Z==="string"?new BG([Z],J):Array.isArray(Z)?new BG(Z,J):Z;class YR{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=kx1(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw 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 LG(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 LG(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 bF extends YR{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 AF extends YR{results;constructor(Z,J,X){super(Z,J,X);this.results=new f$({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 Ix1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Q7{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 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=Ex1(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 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 TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||Ix1,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?UG:J.platform==="darwin"?SF:J.platform?jG:Fg;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 Error("invalid pattern object");return new Q3(W,z,0,this.platform)})}async walk(){return[...await new bF(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 bF(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 AF(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 AF(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 QR=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new H4(X,J).hasMagic())return!0;return!1};function uF(Z,J={}){return new Q7(Z,J).streamSync()}function Ug(Z,J={}){return new Q7(Z,J).stream()}function jg(Z,J={}){return new Q7(Z,J).walkSync()}async function xg(Z,J={}){return new Q7(Z,J).walk()}function lF(Z,J={}){return new Q7(Z,J).iterateSync()}function Bg(Z,J={}){return new Q7(Z,J).iterate()}var _x1=uF,hx1=Object.assign(Ug,{sync:uF}),Sx1=lF,bx1=Object.assign(Bg,{sync:lF}),Ax1=Object.assign(jg,{stream:uF,iterate:lF}),mF=Object.assign(xg,{glob:xg,globSync:jg,sync:Ax1,globStream:Ug,stream:hx1,globStreamSync:uF,streamSync:_x1,globIterate:Bg,iterate:bx1,globIterateSync:lF,iterateSync:Sx1,Glob:Q7,hasMagic:QR,escape:Z3,unescape:c9});mF.glob=mF;class KR{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 $Z{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 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 yF extends KR{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 $Z(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 DG(){return DG=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},DG.apply(this,arguments)}class U9{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 c1{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"),SJ=Symbol("immutableKeys");class pF extends KR{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[H1]=void 0,this[SJ]=void 0,this.graph=Z,this[SJ]=new Set,this[H1]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let $=Z[X];if($ instanceof pF){let Y=this.graph._createEdge(X,this,$);this[SJ].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 $Z){let Y=$;if(Y.getChild()===Z)this.setRef(X,J,Y.getAttributes())}else if($ instanceof U9)for(let Y of $.listRefsByChild(Z)){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if($ instanceof c1){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[SJ].has(Z))throw 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 U9)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 U9||J instanceof c1)return J;throw 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,DG({},$,{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 Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(DG({},Z,{target:this})),this.graph.dispatchEvent(DG({},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[SJ].has(J))Z.getChild().dispose()}else if(this[H1][J]instanceof U9)this[H1][J].remove(Z);else if(this[H1][J]instanceof c1)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 Og="v4.2.1",I$="@glb.bin",g;(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"})(g||(g={}));var sF;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(sF||(sF={}));var h5;(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"})(h5||(h5={}));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 YZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(YZ||(YZ={}));var AJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array};class E0{static createBufferFromDataURI(Z){if(typeof Buffer>"u"){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 Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class HR{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 Tg{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),mx1(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 TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class tF{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))===tF.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}}tF.PNG_FRIED_CHUNK_NAME="CgBI";class _5{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}`}}_5.impls={"image/jpeg":new Tg,"image/png":new tF};function mx1(Z,J){if(J>Z.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw TypeError("Invalid JPG, marker table corrupted");return Z}class QZ{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 _5.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 GR=typeof Float32Array<"u"?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 ux1(){var Z=new GR(3);if(GR!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function WR(Z){var J=Z[0],X=Z[1],$=Z[2];return Math.hypot(J,X,$)}function lx1(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=ux1();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 PG(Z){let J=Cg(),X=Z.propertyType===g.NODE?[Z]:Z.listChildren();for(let $ of X)$.traverse((Y)=>{let Q=Y.getMesh();if(!Q)return;let K=yx1(Q,Y.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))zR(K.min,J),zR(K.max,J)});return J}function yx1(Z,J){let X=Cg();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=lx1(W,K,J),zR(W,X)}}return X}function zR(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 Cg(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}var Lg="https://null.example";class c4{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return QZ.basename(new URL(Z,Lg).pathname)}static extension(Z){return QZ.extension(new URL(Z,Lg).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)}}c4.DEFAULT_INIT={};c4.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;function Dg(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function E$(Z){if(Dg(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Dg(X)===!1)return!1;if(Object.hasOwn(X,"isPrototypeOf")===!1)return!1;return!0}var vR,MG;(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"})(MG||(MG={}));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)}}vR=z5;z5.Verbosity=MG;z5.DEFAULT_INSTANCE=new vR(vR.Verbosity.INFO);function px1(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],c=Z[14],w=Z[15],x=J*K-X*Q,j=J*W-$*Q,B=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,P=z*F-v*q,N=z*c-H*q,O=z*w-V*q,k=v*c-H*F,E=v*w-V*F,S=H*w-V*c;return x*S-j*E+B*k+L*O-R*N+M*P}function ix1(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],c=J[12],w=J[13],x=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*$+L*W+R*H+M*c,Z[1]=B*Y+L*G+R*V+M*w,Z[2]=B*Q+L*z+R*q+M*x,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*$+L*W+R*H+M*c,Z[5]=B*Y+L*G+R*V+M*w,Z[6]=B*Q+L*z+R*q+M*x,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*$+L*W+R*H+M*c,Z[9]=B*Y+L*G+R*V+M*w,Z[10]=B*Q+L*z+R*q+M*x,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*$+L*W+R*H+M*c,Z[13]=B*Y+L*G+R*V+M*w,Z[14]=B*Q+L*z+R*q+M*x,Z[15]=B*K+L*v+R*F+M*j,Z}function gx1(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 dx1(Z,J){var X=new GR(3);gx1(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,c=K+v+F,w=0;if(c>0)w=Math.sqrt(c+1)*2,Z[3]=0.25*w,Z[0]=(H-q)/w,Z[1]=(V-G)/w,Z[2]=(W-z)/w;else if(K>v&&K>F)w=Math.sqrt(1+K-v-F)*2,Z[3]=(H-q)/w,Z[0]=0.25*w,Z[1]=(W+z)/w,Z[2]=(V+G)/w;else if(v>F)w=Math.sqrt(1+v-K-F)*2,Z[3]=(V-G)/w,Z[0]=(W+z)/w,Z[1]=0.25*w,Z[2]=(H+q)/w;else w=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/w,Z[0]=(V+G)/w,Z[1]=(H+q)/w,Z[2]=0.25*w;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 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 Error("Invalid component type.")}}static decompose(Z,J,X,$){let Y=WR([Z[0],Z[1],Z[2]]),Q=WR([Z[4],Z[5],Z[6]]),K=WR([Z[8],Z[9],Z[10]]);if(px1(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,dx1(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,c=K*v,w=K*H,x=W*H,j=G*z,B=G*v,L=G*H,R=X[0],M=X[1],P=X[2];return Y[0]=(1-(c+x))*R,Y[1]=(q+L)*R,Y[2]=(F-B)*R,Y[3]=0,Y[4]=(q-L)*M,Y[5]=(1-(V+x))*M,Y[6]=(w+j)*M,Y[7]=0,Y[8]=(F+B)*P,Y[9]=(w-j)*P,Y[10]=(1-(V+c))*P,Y[11]=0,Y[12]=Z[0],Y[13]=Z[1],Y[14]=Z[2],Y[15]=1,Y}}function ax1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),$=J.getChild();return X===$||X.equals($)}function nx1(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 sx1(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 fg(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 kg(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!E$(Z)||!E$(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(oF(W)&&oF(G)){if(!fg(W,G))return!1}else if(E$(W)&&E$(G)){if(!kg(W,G))return!1}else if(W!==G)return!1}return!0}function oF(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Mg="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",ox1=999,rx1=6,Rg=new Set,tx1=function(){let J="";for(let X=0;X<rx1;X++)J+=Mg.charAt(Math.floor(Math.random()*Mg.length));return J},Eg=function(){for(let J=0;J<ox1;J++){let X=tx1();if(!Rg.has(X))return Rg.add(X),X}return""},bJ=(Z)=>Z,ex1=new Set;class eF extends pF{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 $Z){if(!this[SJ].has(X))$.dispose()}else if($ instanceof U9||$ instanceof c1)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 $Z)if(this[SJ].has(X))$.getChild().copy(J(Y.getChild()),J);else this.setRef(X,J(Y.getChild()),Y.getAttributes());else if(Y instanceof c1||Y instanceof U9)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(E$(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=ex1){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 $Z||Y instanceof $Z){if(!ax1($,Y))return!1}else if($ instanceof c1||Y instanceof c1||$ instanceof U9||Y instanceof U9){if(!nx1($,Y))return!1}else if($ instanceof A6||Y instanceof A6){if(!sx1($,Y))return!1}else if(E$($)||E$(Y)){if(!kg($,Y))return!1}else if(oF($)||oF(Y)){if(!fg($,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 x6 extends eF{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 x6{init(){this.propertyType=g.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 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 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?ZU1(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 ZU1(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 Error("Unknown accessor componentType.")}}class qR extends x6{init(){this.propertyType=g.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new c1,samplers:new c1})}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 KZ extends x6{init(){this.propertyType=g.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)}}KZ.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class mJ extends x6{init(){this.propertyType=g.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:mJ.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:h5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:h5.OTHER})}}mJ.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class FR extends x6{init(){this.propertyType=g.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class _$ extends x6{init(){this.propertyType=g.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:_$.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)}}_$.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class O1 extends eF{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}O1.EXTENSION_NAME=void 0;class F1 extends x6{init(){this.propertyType=g.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:iF,G:gF,B:dF,A:JU1}=v5;class K7 extends x6{init(){this.propertyType=g.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:K7.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:iF|gF|dF|JU1,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:iF|gF|dF,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:iF|gF|dF})}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:iF})}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:gF|dF})}}K7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class NG extends x6{init(){this.propertyType=g.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new c1})}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 Zc extends x6{init(){this.propertyType=g.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 c1})}copy(Z,J=bJ){if(J===bJ)throw 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())ix1(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===g.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===g.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 x6{init(){this.propertyType=g.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:g1.Mode.TRIANGLES,material:null,indices:null,attributes:new A6,targets:new c1})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:h5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:h5.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 cR extends eF{init(){this.propertyType=g.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:h5.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 x6{init(){this.propertyType=g.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new c1})}copy(Z,J=bJ){if(J===bJ)throw 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 wR extends x6{init(){this.propertyType=g.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new c1})}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:h5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class h$ extends x6{init(){this.propertyType=g.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||_5.extensionToMimeType(QZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=_5.extensionToMimeType(QZ.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 _5.getSize(Z,this.getMimeType())}}class W3 extends x6{init(){this.propertyType=g.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Og}`,version:"2.0"},defaultScene:null,accessors:new c1,animations:new c1,buffers:new c1,cameras:new c1,materials:new c1,meshes:new c1,nodes:new c1,scenes:new c1,skins:new c1,textures:new c1})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw Error("Root cannot be cloned.")}copy(Z,J=bJ){if(J===bJ)throw 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 Zc)this.addRef("nodes",Z);else if(Z instanceof _$)this.addRef("cameras",Z);else if(Z instanceof wR)this.addRef("skins",Z);else if(Z instanceof NG)this.addRef("meshes",Z);else if(Z instanceof K7)this.addRef("materials",Z);else if(Z instanceof h$)this.addRef("textures",Z);else if(Z instanceof qR)this.addRef("animations",Z);else if(Z instanceof K0)this.addRef("accessors",Z);else if(Z instanceof FR)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 w6{static fromGraph(Z){return w6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new yF,this._root=new W3(this._graph),this._logger=z5.DEFAULT_INSTANCE,w6._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 Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw 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 Zc(this._graph,Z)}createCamera(Z=""){return new _$(this._graph,Z)}createSkin(Z=""){return new wR(this._graph,Z)}createMesh(Z=""){return new NG(this._graph,Z)}createPrimitive(){return new g1(this._graph)}createPrimitiveTarget(Z=""){return new cR(this._graph,Z)}createMaterial(Z=""){return new K7(this._graph,Z)}createTexture(Z=""){return new h$(this._graph,Z)}createAnimation(Z=""){return new qR(this._graph,Z)}createAnimationChannel(Z=""){return new KZ(this._graph,Z)}createAnimationSampler(Z=""){return new mJ(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 FR(this._graph,Z)}}w6._GRAPH_DOCUMENTS=new WeakMap;class T1{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}}T1.EXTENSION_NAME=void 0;class Ig{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 Pg={logger:z5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},XU1=new Set([g.BUFFER,g.TEXTURE,g.MATERIAL,g.MESH,g.PRIMITIVE,g.NODE,g.SCENE]);class _g{static read(Z,J=Pg){let X=m6({},Pg,J),{json:$}=Z,Y=new w6().setLogger(X.logger);this.validate(Z,X);let Q=new Ig(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,P)=>M.EXTENSION_NAME>P.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let P=Y.createExtension(M).setRequired(z.includes(M.EXTENSION_NAME)),N=P.prereadTypes.filter((O)=>!XU1.has(O));if(N.length)X.logger.warn(`Preread hooks for some types (${N.join()}), requested by extension ${P.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of P.readDependencies)P.install(O,X.dependencies[O])}let v=$.buffers||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.BUFFER)).forEach((M)=>M.preread(Q,g.BUFFER)),Q.buffers=v.map((M)=>{let P=Y.createBuffer(M.name);if(M.extras)P.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)P.setURI(M.uri);return P});let H=$.bufferViews||[];Q.bufferViewBuffers=H.map((M,P)=>{if(!Q.bufferViews[P]){let N=Z.json.buffers[M.buffer],O=N.uri?Z.resources[N.uri]:Z.resources[I$],k=M.byteOffset||0;Q.bufferViews[P]=E0.toView(O,k,M.byteLength)}return Q.buffers[M.buffer]});let V=$.accessors||[];Q.accessors=V.map((M)=>{let P=Q.bufferViewBuffers[M.bufferView],N=Y.createAccessor(M.name,P).setType(M.type);if(M.extras)N.setExtras(M.extras);if(M.normalized!==void 0)N.setNormalized(M.normalized);if(M.bufferView===void 0)return N;return N.setArray(nF(M,Q)),N});let q=$.images||[],F=$.textures||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.TEXTURE)).forEach((M)=>M.preread(Q,g.TEXTURE)),Q.textures=q.map((M)=>{let P=Y.createTexture(M.name);if(M.extras)P.setExtras(M.extras);if(M.bufferView!==void 0){let N=$.bufferViews[M.bufferView],O=Z.json.buffers[N.buffer],k=O.uri?Z.resources[O.uri]:Z.resources[I$],E=N.byteOffset||0,S=N.byteLength,f=k.slice(E,E+S);P.setImage(f)}else if(M.uri!==void 0){if(P.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)P.setURI(M.uri)}if(M.mimeType!==void 0)P.setMimeType(M.mimeType);else if(M.uri){let N=QZ.extension(M.uri);P.setMimeType(_5.extensionToMimeType(N))}return P}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.MATERIAL)).forEach((M)=>M.preread(Q,g.MATERIAL));let c=$.materials||[];Q.materials=c.map((M)=>{let P=Y.createMaterial(M.name);if(M.extras)P.setExtras(M.extras);if(M.alphaMode!==void 0)P.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)P.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)P.setDoubleSided(M.doubleSided);let N=M.pbrMetallicRoughness||{};if(N.baseColorFactor!==void 0)P.setBaseColorFactor(N.baseColorFactor);if(M.emissiveFactor!==void 0)P.setEmissiveFactor(M.emissiveFactor);if(N.metallicFactor!==void 0)P.setMetallicFactor(N.metallicFactor);if(N.roughnessFactor!==void 0)P.setRoughnessFactor(N.roughnessFactor);if(N.baseColorTexture!==void 0){let O=N.baseColorTexture,k=Q.textures[F[O.index].source];P.setBaseColorTexture(k),Q.setTextureInfo(P.getBaseColorTextureInfo(),O)}if(M.emissiveTexture!==void 0){let O=M.emissiveTexture,k=Q.textures[F[O.index].source];P.setEmissiveTexture(k),Q.setTextureInfo(P.getEmissiveTextureInfo(),O)}if(M.normalTexture!==void 0){let O=M.normalTexture,k=Q.textures[F[O.index].source];if(P.setNormalTexture(k),Q.setTextureInfo(P.getNormalTextureInfo(),O),M.normalTexture.scale!==void 0)P.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let O=M.occlusionTexture,k=Q.textures[F[O.index].source];if(P.setOcclusionTexture(k),Q.setTextureInfo(P.getOcclusionTextureInfo(),O),M.occlusionTexture.strength!==void 0)P.setOcclusionStrength(M.occlusionTexture.strength)}if(N.metallicRoughnessTexture!==void 0){let O=N.metallicRoughnessTexture,k=Q.textures[F[O.index].source];P.setMetallicRoughnessTexture(k),Q.setTextureInfo(P.getMetallicRoughnessTextureInfo(),O)}return P}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.MESH)).forEach((M)=>M.preread(Q,g.MESH));let w=$.meshes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.PRIMITIVE)).forEach((M)=>M.preread(Q,g.PRIMITIVE)),Q.meshes=w.map((M)=>{let P=Y.createMesh(M.name);if(M.extras)P.setExtras(M.extras);if(M.weights!==void 0)P.setWeights(M.weights);return(M.primitives||[]).forEach((O)=>{let k=Y.createPrimitive();if(O.extras)k.setExtras(O.extras);if(O.material!==void 0)k.setMaterial(Q.materials[O.material]);if(O.mode!==void 0)k.setMode(O.mode);for(let[f,C]of Object.entries(O.attributes||{}))k.setAttribute(f,Q.accessors[C]);if(O.indices!==void 0)k.setIndices(Q.accessors[O.indices]);let E=M.extras&&M.extras.targetNames||[];(O.targets||[]).forEach((f,C)=>{let h=E[C]||C.toString(),_=Y.createPrimitiveTarget(h);for(let[a,s]of Object.entries(f))_.setAttribute(a,Q.accessors[s]);k.addTarget(_)}),P.addPrimitive(k)}),P});let x=$.cameras||[];Q.cameras=x.map((M)=>{let P=Y.createCamera(M.name).setType(M.type);if(M.extras)P.setExtras(M.extras);if(M.type===_$.Type.PERSPECTIVE){let N=M.perspective;if(P.setYFov(N.yfov),P.setZNear(N.znear),N.zfar!==void 0)P.setZFar(N.zfar);if(N.aspectRatio!==void 0)P.setAspectRatio(N.aspectRatio)}else{let N=M.orthographic;P.setZNear(N.znear).setZFar(N.zfar).setXMag(N.xmag).setYMag(N.ymag)}return P});let j=$.nodes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.NODE)).forEach((M)=>M.preread(Q,g.NODE)),Q.nodes=j.map((M)=>{let P=Y.createNode(M.name);if(M.extras)P.setExtras(M.extras);if(M.translation!==void 0)P.setTranslation(M.translation);if(M.rotation!==void 0)P.setRotation(M.rotation);if(M.scale!==void 0)P.setScale(M.scale);if(M.matrix!==void 0){let N=[0,0,0],O=[0,0,0,1],k=[1,1,1];I0.decompose(M.matrix,N,O,k),P.setTranslation(N),P.setRotation(O),P.setScale(k)}if(M.weights!==void 0)P.setWeights(M.weights);return P});let B=$.skins||[];Q.skins=B.map((M)=>{let P=Y.createSkin(M.name);if(M.extras)P.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)P.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)P.setSkeleton(Q.nodes[M.skeleton]);for(let N of M.joints)P.addJoint(Q.nodes[N]);return P}),j.map((M,P)=>{let N=Q.nodes[P];if((M.children||[]).forEach((k)=>N.addChild(Q.nodes[k])),M.mesh!==void 0)N.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)N.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)N.setSkin(Q.skins[M.skin])});let L=$.animations||[];Q.animations=L.map((M)=>{let P=Y.createAnimation(M.name);if(M.extras)P.setExtras(M.extras);let O=(M.samplers||[]).map((E)=>{let S=Y.createAnimationSampler().setInput(Q.accessors[E.input]).setOutput(Q.accessors[E.output]).setInterpolation(E.interpolation||mJ.Interpolation.LINEAR);if(E.extras)S.setExtras(E.extras);return P.addSampler(S),S});return(M.channels||[]).forEach((E)=>{let S=Y.createAnimationChannel().setSampler(O[E.sampler]).setTargetPath(E.target.path);if(E.target.node!==void 0)S.setTargetNode(Q.nodes[E.target.node]);if(E.extras)S.setExtras(E.extras);P.addChannel(S)}),P});let R=$.scenes||[];if(Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(g.SCENE)).forEach((M)=>M.preread(Q,g.SCENE)),Q.scenes=R.map((M)=>{let P=Y.createScene(M.name);if(M.extras)P.setExtras(M.extras);return(M.nodes||[]).map((O)=>Q.nodes[O]).forEach((O)=>P.addChild(O)),P}),$.scene!==void 0)Y.getRoot().setDefaultScene(Q.scenes[$.scene]);return Y.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),V.forEach((M,P)=>{let N=Q.accessors[P],O=!!M.sparse,k=!M.bufferView&&!N.getArray();if(O||k)N.setSparse(!0).setArray(YU1(M,Q))}),Y}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let $ of X.extensionsRequired)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))throw 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 $U1(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=AJ[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,c;switch(Z.componentType){case K0.ComponentType.FLOAT:c=v.getFloat32(F,!0);break;case K0.ComponentType.UNSIGNED_INT:c=v.getUint32(F,!0);break;case K0.ComponentType.UNSIGNED_SHORT:c=v.getUint16(F,!0);break;case K0.ComponentType.UNSIGNED_BYTE:c=v.getUint8(F);break;case K0.ComponentType.SHORT:c=v.getInt16(F,!0);break;case K0.ComponentType.BYTE:c=v.getInt8(F);break;default:throw Error(`Unexpected componentType "${Z.componentType}".`)}z[V*K+q]=c}return z}function nF(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=AJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if(Y.byteStride!==void 0&&Y.byteStride!==G)return $U1(Z,J);let z=$.byteOffset+(Z.byteOffset||0),v=Z.count*K*W;return new Q($.buffer.slice(z,z+v))}function YU1(Z,J){let X=AJ[Z.componentType],$=K0.getElementSize(Z.type),Y;if(Z.bufferView!==void 0)Y=nF(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=nF(W,J),v=nF(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 RG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(RG||(RG={}));class w4{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 VR(Y>1,()=>X.basename||"buffer"),this.imageURIGenerator=new VR(Q>1,(K)=>QU1(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===YZ.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 $=_5.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 Error(Y)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return h5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:$}=X.getAttributes();if($)return $;if(X.getParent().propertyType!==g.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return h5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}w4.BufferViewTarget=RG;w4.BufferViewUsage=h5;w4.USAGE_TO_TARGET={[h5.ARRAY_BUFFER]:RG.ARRAY_BUFFER,[h5.ELEMENT_ARRAY_BUFFER]:RG.ELEMENT_ARRAY_BUFFER};class VR{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 QU1(Z,J){let X=Z.getGraph().listParentEdges(J).find(($)=>$.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:aF}=w4,{UNSIGNED_INT:KU1,UNSIGNED_SHORT:WU1,UNSIGNED_BYTE:GU1}=K0.ComponentType,zU1=new Set([g.ACCESSOR,g.BUFFER,g.MATERIAL,g.MESH]);class hg{static write(Z,J){let X=Z.getGraph(),$=Z.getRoot(),Y={asset:m6({generator:`glTF-Transform ${Og}`},$.getAsset()),extras:m6({},$.getExtras())},Q={json:Y,resources:{}},K=new w4(Z,Q,J),W=J.logger||z5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((w)=>w.EXTENSION_NAME)),z=Z.getRoot().listExtensionsUsed().filter((w)=>G.has(w.extensionName)).sort((w,x)=>w.extensionName>x.extensionName?1:-1),v=Z.getRoot().listExtensionsRequired().filter((w)=>G.has(w.extensionName)).sort((w,x)=>w.extensionName>x.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 w of z){let x=w.prewriteTypes.filter((j)=>!zU1.has(j));if(x.length)W.warn(`Prewrite hooks for some types (${x.join()}), requested by extension ${w.extensionName}, are unsupported. Please file an issue or a PR.`);for(let j of w.writeDependencies)w.install(j,J.dependencies[j])}function H(w,x,j,B){let L=[],R=0;for(let N of w){let O=K.createAccessorDef(N);O.bufferView=Y.bufferViews.length;let k=N.getArray(),E=E0.pad(E0.toView(k));O.byteOffset=R,R+=E.byteLength,L.push(E),K.accessorIndexMap.set(N,Y.accessors.length),Y.accessors.push(O)}let M=E0.concat(L),P={buffer:x,byteOffset:j,byteLength:M.byteLength};if(B)P.target=B;return Y.bufferViews.push(P),{buffers:L,byteLength:R}}function V(w,x,j){let B=w[0].getCount(),L=0;for(let O of w){let k=K.createAccessorDef(O);k.bufferView=Y.bufferViews.length,k.byteOffset=L;let E=O.getElementSize(),S=O.getComponentSize();L+=E0.padNumber(E*S),K.accessorIndexMap.set(O,Y.accessors.length),Y.accessors.push(k)}let R=B*L,M=new ArrayBuffer(R),P=new DataView(M);for(let O=0;O<B;O++){let k=0;for(let E of w){let S=E.getElementSize(),f=E.getComponentSize(),C=E.getComponentType(),h=E.getArray();for(let _=0;_<S;_++){let a=O*L+k+_*f,s=h[O*S+_];switch(C){case K0.ComponentType.FLOAT:P.setFloat32(a,s,!0);break;case K0.ComponentType.BYTE:P.setInt8(a,s);break;case K0.ComponentType.SHORT:P.setInt16(a,s,!0);break;case K0.ComponentType.UNSIGNED_BYTE:P.setUint8(a,s);break;case K0.ComponentType.UNSIGNED_SHORT:P.setUint16(a,s,!0);break;case K0.ComponentType.UNSIGNED_INT:P.setUint32(a,s,!0);break;default:throw Error("Unexpected component type: "+C)}}k+=E0.padNumber(S*f)}}let N={buffer:x,byteOffset:j,byteLength:R,byteStride:L,target:w4.BufferViewTarget.ARRAY_BUFFER};return Y.bufferViews.push(N),{byteLength:R,buffers:[new Uint8Array(M)]}}function q(w,x,j){let B=[],L=0,R=new Map,M=-1/0,P=!1;for(let C of w){let h=K.createAccessorDef(C);Y.accessors.push(h),K.accessorIndexMap.set(C,Y.accessors.length-1);let _=[],a=[],s=[],Z0=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),_.push(m0);for(let s0=0;s0<s.length;s0++)a.push(s[s0])}let o=_.length,M0={accessorDef:h,count:o};if(R.set(C,M0),o===0)continue;if(o>C.getCount()/2)P=!0;let R0=AJ[C.getComponentType()];M0.indices=_,M0.values=new R0(a)}if(!Number.isFinite(M))return{buffers:B,byteLength:L};if(P)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let N=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,O=M<255?GU1:M<65535?WU1:KU1,k={buffer:x,byteOffset:j+L,byteLength:0};for(let C of w){let h=R.get(C);if(h.count===0)continue;h.indicesByteOffset=k.byteLength;let _=E0.pad(E0.toView(new N(h.indices)));B.push(_),L+=_.byteLength,k.byteLength+=_.byteLength}Y.bufferViews.push(k);let E=Y.bufferViews.length-1,S={buffer:x,byteOffset:j+L,byteLength:0};for(let C of w){let h=R.get(C);if(h.count===0)continue;h.valuesByteOffset=S.byteLength;let _=E0.pad(E0.toView(h.values));B.push(_),L+=_.byteLength,S.byteLength+=_.byteLength}Y.bufferViews.push(S);let f=Y.bufferViews.length-1;for(let C of w){let h=R.get(C);if(h.count===0)continue;h.accessorDef.sparse={count:h.count,indices:{bufferView:E,byteOffset:h.indicesByteOffset,componentType:O},values:{bufferView:f,byteOffset:h.valuesByteOffset}}}return{buffers:B,byteLength:L}}if(Y.accessors=[],Y.bufferViews=[],Y.samplers=[],Y.textures=[],Y.images=$.listTextures().map((w,x)=>{let j=K.createPropertyDef(w);if(w.getMimeType())j.mimeType=w.getMimeType();let B=w.getImage();if(B)K.createImageData(j,B,w);return K.imageIndexMap.set(w,x),j}),z.filter((w)=>w.prewriteTypes.includes(g.ACCESSOR)).forEach((w)=>w.prewrite(K,g.ACCESSOR)),$.listAccessors().forEach((w)=>{let{accessorUsageGroupedByParent:x,accessorParents:j}=K;if(K.accessorIndexMap.has(w))return;let B=K.getAccessorUsage(w);if(K.addAccessorToUsageGroup(w,B),x.has(B)){let L=X.listParents(w).find((R)=>R.propertyType!==g.ROOT);j.set(w,L)}}),z.filter((w)=>w.prewriteTypes.includes(g.BUFFER)).forEach((w)=>w.prewrite(K,g.BUFFER)),($.listAccessors().length>0||K.otherBufferViews.size>0||$.listTextures().length>0&&J.format===YZ.GLB)&&$.listBuffers().length===0)throw Error("Buffer required for Document resources, but none was found.");if(Y.buffers=[],$.listBuffers().forEach((w,x)=>{let j=K.createPropertyDef(w),B=K.accessorUsageGroupedByParent,L=w.listParents().filter((S)=>S instanceof K0),R=new Set(L.map((S)=>K.accessorParents.get(S))),M=new Map(Array.from(R).map((S,f)=>[S,f])),P={};for(let S of L){var N;if(K.accessorIndexMap.has(S))continue;let f=K.getAccessorUsage(S),C=f;if(B.has(f)){let h=K.accessorParents.get(S);C+=`:${M.get(h)}`}P[N=C]||(P[N]={usage:f,accessors:[]}),P[C].accessors.push(S)}let O=[],k=Y.buffers.length,E=0;for(let{usage:S,accessors:f}of Object.values(P))if(S===aF.ARRAY_BUFFER&&J.vertexLayout===sF.INTERLEAVED){let C=V(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===aF.ARRAY_BUFFER)for(let C of f){let h=V([C],k,E);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else if(S===aF.SPARSE){let C=q(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===aF.ELEMENT_ARRAY_BUFFER){let C=w4.BufferViewTarget.ELEMENT_ARRAY_BUFFER,h=H(f,k,E,C);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else{let C=H(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}if(K.imageBufferViews.length&&x===0){for(let S=0;S<K.imageBufferViews.length;S++)if(Y.bufferViews[Y.images[S].bufferView].byteOffset=E,E+=K.imageBufferViews[S].byteLength,O.push(K.imageBufferViews[S]),E%8){let f=8-E%8;E+=f,O.push(new Uint8Array(f))}}if(K.otherBufferViews.has(w))for(let S of K.otherBufferViews.get(w))Y.bufferViews.push({buffer:k,byteOffset:E,byteLength:S.byteLength}),K.otherBufferViewsIndexMap.set(S,Y.bufferViews.length-1),E+=S.byteLength,O.push(S);if(E){let S;if(J.format===YZ.GLB)S=I$;else S=K.bufferURIGenerator.createURI(w,"bin"),j.uri=S;j.byteLength=E,K.assignResourceURI(S,E0.concat(O),!0)}Y.buffers.push(j),K.bufferIndexMap.set(w,x)}),$.listAccessors().find((w)=>!w.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");z.filter((w)=>w.prewriteTypes.includes(g.MATERIAL)).forEach((w)=>w.prewrite(K,g.MATERIAL)),Y.materials=$.listMaterials().map((w,x)=>{let j=K.createPropertyDef(w);if(w.getAlphaMode()!==K7.AlphaMode.OPAQUE)j.alphaMode=w.getAlphaMode();if(w.getAlphaMode()===K7.AlphaMode.MASK)j.alphaCutoff=w.getAlphaCutoff();if(w.getDoubleSided())j.doubleSided=!0;if(j.pbrMetallicRoughness={},!I0.eq(w.getBaseColorFactor(),[1,1,1,1]))j.pbrMetallicRoughness.baseColorFactor=w.getBaseColorFactor();if(!I0.eq(w.getEmissiveFactor(),[0,0,0]))j.emissiveFactor=w.getEmissiveFactor();if(w.getRoughnessFactor()!==1)j.pbrMetallicRoughness.roughnessFactor=w.getRoughnessFactor();if(w.getMetallicFactor()!==1)j.pbrMetallicRoughness.metallicFactor=w.getMetallicFactor();if(w.getBaseColorTexture()){let B=w.getBaseColorTexture(),L=w.getBaseColorTextureInfo();j.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(B,L)}if(w.getEmissiveTexture()){let B=w.getEmissiveTexture(),L=w.getEmissiveTextureInfo();j.emissiveTexture=K.createTextureInfoDef(B,L)}if(w.getNormalTexture()){let B=w.getNormalTexture(),L=w.getNormalTextureInfo(),R=K.createTextureInfoDef(B,L);if(w.getNormalScale()!==1)R.scale=w.getNormalScale();j.normalTexture=R}if(w.getOcclusionTexture()){let B=w.getOcclusionTexture(),L=w.getOcclusionTextureInfo(),R=K.createTextureInfoDef(B,L);if(w.getOcclusionStrength()!==1)R.strength=w.getOcclusionStrength();j.occlusionTexture=R}if(w.getMetallicRoughnessTexture()){let B=w.getMetallicRoughnessTexture(),L=w.getMetallicRoughnessTextureInfo();j.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(B,L)}return K.materialIndexMap.set(w,x),j}),z.filter((w)=>w.prewriteTypes.includes(g.MESH)).forEach((w)=>w.prewrite(K,g.MESH)),Y.meshes=$.listMeshes().map((w,x)=>{let j=K.createPropertyDef(w),B=null;if(j.primitives=w.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 P=L.getIndices();if(P)R.indices=K.accessorIndexMap.get(P);for(let N of L.listSemantics())R.attributes[N]=K.accessorIndexMap.get(L.getAttribute(N));for(let N of L.listTargets()){let O={};for(let k of N.listSemantics())O[k]=K.accessorIndexMap.get(N.getAttribute(k));R.targets=R.targets||[],R.targets.push(O)}if(L.listTargets().length&&!B)B=L.listTargets().map((N)=>N.getName());return R}),w.getWeights().length)j.weights=w.getWeights();if(B)j.extras=j.extras||{},j.extras.targetNames=B;return K.meshIndexMap.set(w,x),j}),Y.cameras=$.listCameras().map((w,x)=>{let j=K.createPropertyDef(w);if(j.type=w.getType(),j.type===_$.Type.PERSPECTIVE){j.perspective={znear:w.getZNear(),zfar:w.getZFar(),yfov:w.getYFov()};let B=w.getAspectRatio();if(B!==null)j.perspective.aspectRatio=B}else j.orthographic={znear:w.getZNear(),zfar:w.getZFar(),xmag:w.getXMag(),ymag:w.getYMag()};return K.cameraIndexMap.set(w,x),j}),Y.nodes=$.listNodes().map((w,x)=>{let j=K.createPropertyDef(w);if(!I0.eq(w.getTranslation(),[0,0,0]))j.translation=w.getTranslation();if(!I0.eq(w.getRotation(),[0,0,0,1]))j.rotation=w.getRotation();if(!I0.eq(w.getScale(),[1,1,1]))j.scale=w.getScale();if(w.getWeights().length)j.weights=w.getWeights();return K.nodeIndexMap.set(w,x),j}),Y.skins=$.listSkins().map((w,x)=>{let j=K.createPropertyDef(w),B=w.getInverseBindMatrices();if(B)j.inverseBindMatrices=K.accessorIndexMap.get(B);let L=w.getSkeleton();if(L)j.skeleton=K.nodeIndexMap.get(L);return j.joints=w.listJoints().map((R)=>K.nodeIndexMap.get(R)),K.skinIndexMap.set(w,x),j}),$.listNodes().forEach((w,x)=>{let j=Y.nodes[x],B=w.getMesh();if(B)j.mesh=K.meshIndexMap.get(B);let L=w.getCamera();if(L)j.camera=K.cameraIndexMap.get(L);let R=w.getSkin();if(R)j.skin=K.skinIndexMap.get(R);if(w.listChildren().length>0)j.children=w.listChildren().map((M)=>K.nodeIndexMap.get(M))}),Y.animations=$.listAnimations().map((w,x)=>{let j=K.createPropertyDef(w),B=new Map;return j.samplers=w.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(),B.set(L,R),M}),j.channels=w.listChannels().map((L)=>{let R=K.createPropertyDef(L);return R.sampler=B.get(L.getSampler()),R.target={node:K.nodeIndexMap.get(L.getTargetNode()),path:L.getTargetPath()},R}),K.animationIndexMap.set(w,x),j}),Y.scenes=$.listScenes().map((w,x)=>{let j=K.createPropertyDef(w);return j.nodes=w.listChildren().map((B)=>K.nodeIndexMap.get(B)),K.sceneIndexMap.set(w,x),j});let c=$.getDefaultScene();if(c)Y.scene=$.listScenes().indexOf(c);return Y.extensionsUsed=z.map((w)=>w.extensionName),Y.extensionsRequired=v.map((w)=>w.extensionName),z.forEach((w)=>w.write(K)),vU1(Y),Q}}function vU1(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 rF;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(rF||(rF={}));class Sg{constructor(){this._logger=z5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=sF.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=Ng(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),_g.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(($)=>VU1(J,$)))throw Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some(($)=>HU1(J,$)))throw 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===YZ.GLB&&Z.getRoot().listBuffers().length>1)throw Error("GLB must have 0–1 buffers.");return hg.write(Z,{format:J.format||YZ.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:YZ.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=`__${Eg()}.${QZ.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 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(!Ng(Z))throw Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==rF.JSON)throw 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]!==rF.BIN)return{json:Q,resources:{}};let G=W[0],z=E0.toView(Z,K+8,G);return{json:Q,resources:{[I$]:z}}}}function VU1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function HU1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Ng(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 Sg{constructor(Z=null,J=c4.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 Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),c4.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw 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(c4.isAbsoluteURL(Z)||c4.isAbsoluteURL(J))return c4.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(c4.isAbsoluteURL(Z))return c4.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:YZ.GLTF,basename:QZ.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 qU1(Object.keys(Y),10))await Promise.all(z.map(async function(v){if(c4.isAbsoluteURL(v)){if(c4.extension(v)==="bin")throw 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 qU1(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 In=t(UR(),1),_n=t(wn(),1),KD1=t(En(),1);async function WD1(Z,J){if(!(Z instanceof Uint8Array))throw Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:$}=await _n.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return In.default(new Uint8Array(X),[$.width,$.height,4],[4,4*$.width|0,1],0)}async function hn(Z,J){return WD1(Z)}var bn=163,An=166;function GD1(){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 rN6=new Uint8Array([0]),p6=[171,75,84,88,32,50,48,187,13,10,26,10];function Sn(Z){return new TextDecoder().decode(Z)}function Dc(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 Error("Missing KTX 2.0 identifier.");let X=GD1(),$=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 O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)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(),c=q._nextUint16(),w=q._nextUint16(),x=q._nextUint16(),j=q._nextUint8(),B=q._nextUint8(),L=q._nextUint8(),R=q._nextUint8(),M=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],P=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],O={vendorId:F,descriptorType:c,versionNumber:w,colorModel:j,colorPrimaries:B,transferFunction:L,flags:R,texelBlockDimension:M,bytesPlane:P,samples:[]},k=6,E=4,S=(x/4-k)/E;for(let O8=0;O8<S;O8++){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[O8]=q6}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(O);let f=new U3(Z,W,G,!0);while(f._offset<G){let O8=f._nextUint32(),q6=f._scan(O8),fH=Sn(q6);if(X.keyValue[fH]=f._nextUint8Array(O8-q6.byteLength-1),fH.match(/^ktx/i)){let LA=Sn(X.keyValue[fH]);X.keyValue[fH]=LA.substring(0,LA.lastIndexOf("\x00"))}let RG1=O8%4?4-O8%4:0;f._skip(RG1)}if(v<=0)return X;let C=new U3(Z,z,v,!0),h=C._nextUint16(),_=C._nextUint16(),a=C._nextUint32(),s=C._nextUint32(),Z0=C._nextUint32(),o=C._nextUint32(),M0=[];for(let O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)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,j1=new Uint8Array(Z.buffer,Z.byteOffset+R0,a),W4=new Uint8Array(Z.buffer,Z.byteOffset+m0,s),NJ=new Uint8Array(Z.buffer,Z.byteOffset+N1,Z0),IQ=new Uint8Array(Z.buffer,Z.byteOffset+s0,o);return X.globalData={endpointCount:h,selectorCount:_,imageDescs:M0,endpointsData:j1,selectorsData:W4,tablesData:NJ,extendedData:IQ},X}var zZ="EXT_mesh_gpu_instancing",X6="EXT_meshopt_compression",bG="EXT_texture_webp",AG="EXT_texture_avif",s1="KHR_draco_mesh_compression",j4="KHR_lights_punctual",vZ="KHR_materials_anisotropy",VZ="KHR_materials_clearcoat",HZ="KHR_materials_diffuse_transmission",qZ="KHR_materials_dispersion",FZ="KHR_materials_emissive_strength",cZ="KHR_materials_ior",wZ="KHR_materials_iridescence",xZ="KHR_materials_pbrSpecularGlossiness",UZ="KHR_materials_sheen",jZ="KHR_materials_specular",BZ="KHR_materials_transmission",gJ="KHR_materials_unlit",LZ="KHR_materials_volume",U6="KHR_materials_variants",tn="KHR_mesh_quantization",mG="KHR_texture_basisu",DZ="KHR_texture_transform",B4="KHR_xmp_json_ld",gR="INSTANCE_ATTRIBUTE";class aR extends O1{init(){this.extensionName=zZ,this.propertyType="InstancedMesh",this.parentTypes=[g.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:gR})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}aR.EXTENSION_NAME=zZ;class Pc extends T1{constructor(...Z){super(...Z);this.extensionName=zZ,this.provideTypes=[g.NODE],this.prewriteTypes=[g.ACCESSOR]}createInstancedMesh(){return new aR(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[zZ])return;let Q=$.extensions[zZ],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[Y].setExtension(zZ,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(gR);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,gR);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let $=X.getExtension(zZ);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[zZ]=K}}),this}}Pc.EXTENSION_NAME=zZ;function MZ(){return MZ=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},MZ.apply(null,arguments)}var uG;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(uG||(uG={}));var j3;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(j3||(j3={}));var $8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})($8||($8={}));function zD1(Z){if(!Z.extensions||!Z.extensions[X6])return!1;return!!Z.extensions[X6].fallback}var{BYTE:vD1,SHORT:mn,FLOAT:VD1}=K0.ComponentType,{encodeNormalizedInt:un,decodeNormalizedInt:dR}=I0;function HD1(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!==j3.ATTRIBUTES)return K;if(Y!==$8.NONE){let W=Z.getNormalized()?qD1(Z):new Float32Array(K.array);switch(Y){case $8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=VD1,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?mn:vD1,K.normalized=!0,W=Z.getElementSize()===3?cD1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case $8.QUATERNION:K.byteStride=8,K.componentType=mn,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>dR(G,Z.getComponentType())),K.max=K.max.map((G)=>dR(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>un(G,K.componentType)),K.max=K.max.map((G)=>un(G,K.componentType))}else if(K.byteStride%4)K.array=FD1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function qD1(Z){let J=Z.getComponentType(),X=Z.getArray(),$=new Float32Array(X.length);for(let Y=0;Y<X.length;Y++)$[Y]=dR(X[Y],J);return $}function FD1(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 cD1(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 wD1(Z,J){if(J===w4.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some(($)=>{return $ instanceof g1&&$.getMode()===g1.Mode.TRIANGLES})?j3.TRIANGLES:j3.INDICES;return j3.ATTRIBUTES}function xD1(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===g.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=en(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 en(Z){for(let J of Z.listParents()){if(!(J instanceof mJ))continue;for(let X of J.listParents()){if(!(X instanceof KZ))continue;return X.getTargetPath()}}return null}var ln={method:uG.QUANTIZE};class yG extends T1{constructor(...Z){super(...Z);this.extensionName=X6,this.prereadTypes=[g.BUFFER,g.PRIMITIVE],this.prewriteTypes=[g.BUFFER,g.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=ln,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=MZ({},ln,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw Error(`[${X6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw Error(`[${X6}]: Missing WASM support.`)}if(J===g.BUFFER)this._prereadBuffers(Z);else if(J===g.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[I$],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(zD1(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===g.ACCESSOR)this._prewriteAccessors(Z);else if(J===g.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===g.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(en(v)==="weights")continue;if(v.getSparse())continue;let H=Z.getAccessorUsage(v),V=Z.accessorUsageGroupedByParent.has(H)?z(v):null,q=wD1(v,H),F=$.method===uG.FILTER?xD1(v,this.document):{filter:$8.NONE},c=HD1(v,X,q,F),{array:w,byteStride:x}=c,j=v.getBuffer();if(!j)throw Error(`${X6}: Missing buffer for accessor.`);let B=this.document.getRoot().listBuffers().indexOf(j),L=[H,V,q,F.filter,x,B].join(":"),R=this._encoderBufferViews[L],M=this._encoderBufferViewData[L],P=this._encoderBufferViewAccessors[L];if(!R||!M)P=this._encoderBufferViewAccessors[L]=[],M=this._encoderBufferViewData[L]=[],R=this._encoderBufferViews[L]={buffer:K,target:w4.USAGE_TO_TARGET[H],byteOffset:0,byteLength:0,byteStride:H===w4.BufferViewUsage.ARRAY_BUFFER?x:void 0,extensions:{[X6]:{buffer:B,byteOffset:0,byteLength:0,mode:q,filter:F.filter!==$8.NONE?F.filter:void 0,byteStride:x,count:0}}};let N=Z.createAccessorDef(v);if(N.componentType=c.componentType,N.normalized=c.normalized,N.byteOffset=R.byteLength,N.min&&c.min)N.min=c.min;if(N.max&&c.max)N.max=c.max;Z.accessorIndexMap.set(v,J.accessors.length),J.accessors.push(N),P.push(N),M.push(new Uint8Array(w.buffer,w.byteOffset,w.byteLength)),R.byteLength+=w.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}}yG.EXTENSION_NAME=X6;yG.EncoderMethod=uG;class Zs{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=yn(J,0);if(!X)return null;let $=X.end;while(X=yn(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 Nc extends T1{constructor(...Z){super(...Z);this.extensionName=AG,this.prereadTypes=[g.TEXTURE]}static register(){_5.registerFormat("image/avif",new Zs)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[AG])X.source=X.extensions[AG].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[AG]={source:Q.source},delete Q.source})}}),this}}Nc.EXTENSION_NAME=AG;function yn(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 Js{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 Oc extends T1{constructor(...Z){super(...Z);this.extensionName=bG,this.prereadTypes=[g.TEXTURE]}static register(){_5.registerFormat("image/webp",new Js)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[bG])X.source=X.extensions[bG].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[bG]={source:Q.source},delete Q.source})}}),this}}Oc.EXTENSION_NAME=bG;var S8,Xs,$s;function UD1(Z,J){let X=new S8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==S8.TRIANGULAR_MESH)throw Error(`[${s1}] Unknown geometry type.`);let Y=new S8.Mesh;if(!Z.DecodeBufferToMesh(X,Y).ok()||Y.ptr===0)throw Error(`[${s1}] Decoding failure.`);return Y}finally{S8.destroy(X)}}function jD1(Z,J){let $=J.num_faces()*3,Y,Q;if(J.num_points()<=65534){let K=$*Uint16Array.BYTES_PER_ELEMENT;Y=S8._malloc(K),Z.GetTrianglesUInt16Array(J,K,Y),Q=new Uint16Array(S8.HEAPU16.buffer,Y,$).slice()}else{let K=$*Uint32Array.BYTES_PER_ELEMENT;Y=S8._malloc(K),Z.GetTrianglesUInt32Array(J,K,Y),Q=new Uint32Array(S8.HEAPU32.buffer,Y,$).slice()}return S8._free(Y),Q}function BD1(Z,J,X,$){let Y=$s[$.componentType],Q=Xs[$.componentType],K=X.num_components(),G=J.num_points()*K,z=G*Q.BYTES_PER_ELEMENT,v=S8._malloc(z);Z.GetAttributeDataArrayForAllPoints(J,X,Y,z,v);let H=new Q(S8.HEAPF32.buffer,v,G).slice();return S8._free(v),H}function LD1(Z){S8=Z,Xs={[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},$s={[K0.ComponentType.FLOAT]:S8.DT_FLOAT32,[K0.ComponentType.UNSIGNED_INT]:S8.DT_UINT32,[K0.ComponentType.UNSIGNED_SHORT]:S8.DT_UINT16,[K0.ComponentType.UNSIGNED_BYTE]:S8.DT_UINT8,[K0.ComponentType.SHORT]:S8.DT_INT16,[K0.ComponentType.BYTE]:S8.DT_INT8}}var U4,lG;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(lG||(lG={}));var L4;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(L4||(L4={}));var Ys={[L4.POSITION]:14,[L4.NORMAL]:10,[L4.COLOR]:8,[L4.TEX_COORD]:12,[L4.GENERIC]:12},pn={decodeSpeed:5,encodeSpeed:5,method:lG.EDGEBREAKER,quantizationBits:Ys,quantizationVolume:"mesh"};function DD1(Z){U4=Z}function MD1(Z,J=pn){let X=MZ({},pn,J);X.quantizationBits=MZ({},Ys,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 c of Z.listSemantics()){let w=Z.getAttribute(c);if(w.getSparse()){z=!0;continue}let x=RD1(c),j=PD1($,w.getComponentType(),Y,U4[x],w.getCount(),w.getElementSize(),w.getArray());if(j===-1)throw Error(`Error compressing "${c}" attribute.`);if(K[c]=j,X.quantizationVolume==="mesh"||c!=="POSITION")Q.SetAttributeQuantization(j,X.quantizationBits[x]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:B}=X,L=Math.max(B.max[0]-B.min[0],B.max[1]-B.min[1],B.max[2]-B.min[2]);Q.SetAttributeExplicitQuantization(j,X.quantizationBits[x],w.getElementSize(),B.min,L)}else throw Error("Invalid quantization volume state.")}let v=Z.getIndices();if(!v)throw new Mc("Primitive must have indices.");if($.AddFacesToMesh(Y,v.getCount()/3,v.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===lG.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 Mc("Error applying Draco compression.");let V=new Uint8Array(H);for(let c=0;c<H;++c)V[c]=W.GetValue(c);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 RD1(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 PD1(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 Error(`Unexpected component type, "${J}".`)}}class Mc extends Error{}class pG extends T1{constructor(...Z){super(...Z);this.extensionName=s1,this.prereadTypes=[g.PRIMITIVE],this.prewriteTypes=[g.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,LD1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,DD1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw 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[I$],q=v.byteOffset||0,F=v.byteLength,c=E0.toView(V,q,F);G=new this._decoderModule.Decoder,z=UD1(G,c),$.set(W.bufferView,[G,z]),J.debug(`[${s1}] Decompressed ${c.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=BD1(G,z,V,H);Z.accessors[K.attributes[v]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(jD1(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 Error(`[${s1}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${s1}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let $=ND1(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=PG(this.document.getRoot().listScenes().pop());for(let K of Array.from($.keys())){let W=$.get(K);if(!W)throw 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=MD1(K,MZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof Mc){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 c=Z.createAccessorDef(F);c.count=v.numVertices,Z.accessorIndexMap.set(F,z.length),z.push(c)}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}}pG.EXTENSION_NAME=s1;pG.EncoderMethod=lG;function ND1(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=gn(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=gn(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(g.PRIMITIVE)||!V.has(g.ROOT))throw 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 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 Error(`[${s1}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return v}function gn(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 B3 extends O1{init(){this.extensionName=j4,this.propertyType="Light",this.parentTypes=[g.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:B3.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)}}B3.EXTENSION_NAME=j4;B3.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};class nR extends T1{constructor(...Z){super(...Z);this.extensionName=j4}createLight(Z=""){return new B3(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[j4])return this;let Y=(J.json.extensions[j4].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[j4])return;let W=Q.extensions[j4];Z.nodes[K].setExtension(j4,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()===B3.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(j4);if(Q){let K=Z.nodeIndexMap.get(Y),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[j4]={light:$.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[j4]={lights:X},this}}nR.EXTENSION_NAME=j4;var{R:OD1,G:TD1,B:CD1}=v5;class sR extends O1{init(){this.extensionName=vZ,this.propertyType="Anisotropy",this.parentTypes=[g.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:OD1|TD1|CD1})}}sR.EXTENSION_NAME=vZ;class oR extends T1{constructor(...Z){super(...Z);this.extensionName=vZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createAnisotropy(){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.createAnisotropy();Z.materials[Q].setExtension(vZ,K);let W=Y.extensions[vZ];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(vZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[vZ]={};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}}oR.EXTENSION_NAME=vZ;var{R:dn,G:an,B:fD1}=v5;class rR extends O1{init(){this.extensionName=VZ,this.propertyType="Clearcoat",this.parentTypes=[g.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:dn})}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:dn|an|fD1})}}rR.EXTENSION_NAME=VZ;class tR extends T1{constructor(...Z){super(...Z);this.extensionName=VZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createClearcoat(){return new rR(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}}tR.EXTENSION_NAME=VZ;var{R:kD1,G:ED1,B:ID1,A:_D1}=v5;class eR extends O1{init(){this.extensionName=HZ,this.propertyType="DiffuseTransmission",this.parentTypes=[g.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:_D1})}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:kD1|ED1|ID1})}}eR.EXTENSION_NAME=HZ;class ZP extends T1{constructor(...Z){super(...Z);this.extensionName=HZ}createDiffuseTransmission(){return new eR(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[HZ]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(HZ,K);let W=Y.extensions[HZ];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(HZ);if(!$)continue;let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[HZ]={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}}ZP.EXTENSION_NAME=HZ;class JP extends O1{init(){this.extensionName=qZ,this.propertyType="Dispersion",this.parentTypes=[g.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}JP.EXTENSION_NAME=qZ;class XP extends T1{constructor(...Z){super(...Z);this.extensionName=qZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createDispersion(){return new JP(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.createDispersion();Z.materials[Y].setExtension(qZ,Q);let K=$.extensions[qZ];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(qZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[qZ]={dispersion:$.getDispersion()}}}),this}}XP.EXTENSION_NAME=qZ;class $P extends O1{init(){this.extensionName=FZ,this.propertyType="EmissiveStrength",this.parentTypes=[g.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}$P.EXTENSION_NAME=FZ;class YP extends T1{constructor(...Z){super(...Z);this.extensionName=FZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createEmissiveStrength(){return new $P(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.createEmissiveStrength();Z.materials[Y].setExtension(FZ,Q);let K=$.extensions[FZ];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(FZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[FZ]={emissiveStrength:$.getEmissiveStrength()}}}),this}}YP.EXTENSION_NAME=FZ;class QP extends O1{init(){this.extensionName=cZ,this.propertyType="IOR",this.parentTypes=[g.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}QP.EXTENSION_NAME=cZ;class Tc extends T1{constructor(...Z){super(...Z);this.extensionName=cZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createIOR(){return new QP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[cZ]){let Q=this.createIOR();Z.materials[Y].setExtension(cZ,Q);let K=$.extensions[cZ];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(cZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[cZ]={ior:$.getIOR()}}}),this}}Tc.EXTENSION_NAME=cZ;var{R:hD1,G:SD1}=v5;class KP extends O1{init(){this.extensionName=wZ,this.propertyType="Iridescence",this.parentTypes=[g.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:hD1})}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:SD1})}}KP.EXTENSION_NAME=wZ;class WP extends T1{constructor(...Z){super(...Z);this.extensionName=wZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createIridescence(){return new KP(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.createIridescence();Z.materials[Q].setExtension(wZ,K);let W=Y.extensions[wZ];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(wZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[wZ]={};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}}WP.EXTENSION_NAME=wZ;var{R:nn,G:sn,B:on,A:rn}=v5;class GP extends O1{init(){this.extensionName=xZ,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[g.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:nn|sn|on|rn,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:nn|sn|on|rn})}}GP.EXTENSION_NAME=xZ;class Cc extends T1{constructor(...Z){super(...Z);this.extensionName=xZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createPBRSpecularGlossiness(){return new GP(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.createPBRSpecularGlossiness();Z.materials[Q].setExtension(xZ,K);let W=Y.extensions[xZ];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(xZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[xZ]={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}}Cc.EXTENSION_NAME=xZ;var{R:bD1,G:AD1,B:mD1,A:uD1}=v5;class zP extends O1{init(){this.extensionName=UZ,this.propertyType="Sheen",this.parentTypes=[g.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:bD1|AD1|mD1,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:uD1})}}zP.EXTENSION_NAME=UZ;class vP extends T1{constructor(...Z){super(...Z);this.extensionName=UZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createSheen(){return new zP(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.createSheen();Z.materials[Q].setExtension(UZ,K);let W=Y.extensions[UZ];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(UZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[UZ]={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}}vP.EXTENSION_NAME=UZ;var{R:lD1,G:yD1,B:pD1,A:iD1}=v5;class VP extends O1{init(){this.extensionName=jZ,this.propertyType="Specular",this.parentTypes=[g.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:iD1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:lD1|yD1|pD1,isColor:!0})}}VP.EXTENSION_NAME=jZ;class fc extends T1{constructor(...Z){super(...Z);this.extensionName=jZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createSpecular(){return new VP(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.createSpecular();Z.materials[Q].setExtension(jZ,K);let W=Y.extensions[jZ];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(jZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[jZ]={};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}}fc.EXTENSION_NAME=jZ;var{R:gD1}=v5;class HP extends O1{init(){this.extensionName=BZ,this.propertyType="Transmission",this.parentTypes=[g.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:gD1})}}HP.EXTENSION_NAME=BZ;class qP extends T1{constructor(...Z){super(...Z);this.extensionName=BZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createTransmission(){return new HP(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}}qP.EXTENSION_NAME=BZ;class FP extends O1{init(){this.extensionName=gJ,this.propertyType="Unlit",this.parentTypes=[g.MATERIAL]}}FP.EXTENSION_NAME=gJ;class kc extends T1{constructor(...Z){super(...Z);this.extensionName=gJ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createUnlit(){return new FP(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[gJ])Z.materials[$].setExtension(gJ,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(gJ)){let $=Z.materialIndexMap.get(X),Y=J.json.materials[$];Y.extensions=Y.extensions||{},Y.extensions[gJ]={}}}),this}}kc.EXTENSION_NAME=gJ;class cP extends O1{init(){this.extensionName=U6,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new c1})}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")}}cP.EXTENSION_NAME=U6;class wP extends O1{init(){this.extensionName=U6,this.propertyType="MappingList",this.parentTypes=[g.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new c1})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}wP.EXTENSION_NAME=U6;class Rc extends O1{init(){this.extensionName=U6,this.propertyType="Variant",this.parentTypes=["MappingList"]}}Rc.EXTENSION_NAME=U6;class xP extends T1{constructor(...Z){super(...Z);this.extensionName=U6}createMappingList(){return new wP(this.document.getGraph())}createVariant(Z=""){return new Rc(this.document.getGraph(),Z)}createMapping(){return new cP(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof Rc)}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 c=this.createMapping();if(F.material!==void 0)c.setMaterial(Z.materials[F.material]);for(let w of F.variants||[])c.addVariant(Y[w]);V.addMapping(c)}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((c)=>Y.get(c)),q});v.extensions=v.extensions||{},v.extensions[U6]={mappings:H}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[U6]={variants:$},this}}xP.EXTENSION_NAME=U6;var{G:dD1}=v5;class UP extends O1{init(){this.extensionName=LZ,this.propertyType="Volume",this.parentTypes=[g.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:dD1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}UP.EXTENSION_NAME=LZ;class jP extends T1{constructor(...Z){super(...Z);this.extensionName=LZ,this.prereadTypes=[g.MESH],this.prewriteTypes=[g.MESH]}createVolume(){return new UP(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[LZ]){let K=this.createVolume();Z.materials[Q].setExtension(LZ,K);let W=Y.extensions[LZ];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(LZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[LZ]={};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}}jP.EXTENSION_NAME=LZ;class iG extends T1{constructor(...Z){super(...Z);this.extensionName=tn}read(Z){return this}write(Z){return this}}iG.EXTENSION_NAME=tn;class Qs{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=Dc(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=Dc(Z).dataFormatDescriptor[0];if(X.colorModel===bn)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===An)return(X.samples[0].channelType&15)===3?4:3;throw Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=Dc(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 BP extends T1{constructor(...Z){super(...Z);this.extensionName=mG,this.prereadTypes=[g.TEXTURE]}static register(){_5.registerFormat("image/ktx2",new Qs)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[mG]){let X=J.extensions[mG];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[mG]={source:Y.source},delete Y.source})}}),this}}BP.EXTENSION_NAME=mG;class LP extends O1{init(){this.extensionName=DZ,this.propertyType="Transform",this.parentTypes=[g.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)}}LP.EXTENSION_NAME=DZ;class DP extends T1{constructor(...Z){super(...Z);this.extensionName=DZ}createTransform(){return new LP(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[DZ])continue;let $=this.createTransform(),Y=X.extensions[DZ];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(DZ,$)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,$]of J){let Y=X.getExtension(DZ);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[DZ]=Q}return this}}DP.EXTENSION_NAME=DZ;var aD1=[g.ROOT,g.SCENE,g.NODE,g.MESH,g.MATERIAL,g.TEXTURE,g.ANIMATION];class MP extends O1{init(){this.extensionName=B4,this.propertyType="Packet",this.parentTypes=aD1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",MZ({},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=MZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=iR(this.get("context")),J=iR(this.get("properties"));return MZ({"@context":Z},J)}fromJSONLD(Z){Z=iR(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 Error(`${B4}: Missing context for term, "${Z}".`)}}MP.EXTENSION_NAME=B4;function iR(Z){return JSON.parse(JSON.stringify(Z))}class RP extends T1{constructor(...Z){super(...Z);this.extensionName=B4}createPacket(){return new MP(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[B4];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[B4]){let V=H.extensions[B4];W[G][v].setExtension(B4,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 g.ROOT:Q=J.asset;break;case g.SCENE:Q=J.scenes[Z.sceneIndexMap.get(Y)];break;case g.NODE:Q=J.nodes[Z.nodeIndexMap.get(Y)];break;case g.MESH:Q=J.meshes[Z.meshIndexMap.get(Y)];break;case g.MATERIAL:Q=J.materials[Z.materialIndexMap.get(Y)];break;case g.TEXTURE:Q=J.images[Z.imageIndexMap.get(Y)];break;case g.ANIMATION:Q=J.animations[Z.animationIndexMap.get(Y)];break;default:Q=null,this.document.getLogger().warn(`[${B4}]: Unsupported parent property, "${Y.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[B4]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[B4]={packets:X};return this}}RP.EXTENSION_NAME=B4;var nD1=[pG,nR,oR,tR,ZP,XP,YP,Tc,WP,Cc,fc,vP,qP,kc,xP,jP,iG,BP,DP,RP],JO6=[Pc,yG,Nc,Oc,...nD1];var sD1=t(UR(),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:Ks,LINES:Ec,LINE_STRIP:oD1,LINE_LOOP:rD1,TRIANGLES:Ic,TRIANGLE_STRIP:tD1,TRIANGLE_FAN:eD1}=g1.Mode;function l$(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function PZ(Z,J){let X=M3({},Z);for(let $ in J)if(J[$]!==void 0)X[$]=J[$];return X}function Rs(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 Error("Unexpected mode: "+Z.getMode())}}var ZM1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function OP(Z){return ZM1.format(Z)}function JM1(Z,J,X=2){let $=Z>J?"–":"+",Y="%";return $+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function Ac(Z,J){return`${OP(Z)} → ${OP(J)} (${JM1(Z,J)})`}function mc(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 XM1(Z,J,X){Z.swap(J,X);for(let $ of Z.listTargets())$.swap(J,X)}function Ps(Z){let J=Z.getIndices(),X=mc(Z);if(Z.dispose(),J&&!TP(J))J.dispose();for(let $ of X)if(!TP($))$.dispose()}function RZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function $M1(Z,J=Z){let X=hP(Z,J);for(let $=0;$<X.length;$++)X[$]=$;return X}function hP(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function TP(Z){return Z.listParents().some((J)=>J.propertyType!==g.ROOT)}function Ns(Z){for(let J in Z)return!1;return!0}function Os(Z){let J=w6.fromGraph(Z.getGraph()),X=Z.getMaterial(),$=J.getRoot().listMaterials().indexOf(X),Y=QM1[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 YM1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var QM1={[Ks]:Ks,[Ec]:Ec,[oD1]:Ec,[rD1]:Ec,[Ic]:Ic,[tD1]:Ic,[eD1]:Ic},L3="center",Ws={pivot:"center"};function Ts(Z=Ws){let J=PZ(Ws,Z);return l$(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=PG(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 KM1(Z){let J=new Set,X=Z,$;while($=X.getParentNode()){if(J.has($))throw Error("Circular dependency in scene graph.");J.add($),X=$}return X.listParents().filter((Y)=>Y instanceof K3)}function WM1(Z){let J=KM1(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<"u"?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 GM1(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],c=J[13],w=J[14],x=J[15],j=X*W-$*K,B=X*G-Y*K,L=X*z-Q*K,R=$*G-Y*W,M=$*z-Q*W,P=Y*z-Q*G,N=v*c-H*F,O=v*w-V*F,k=v*x-q*F,E=H*w-V*c,S=H*x-q*c,f=V*x-q*w,C=j*f-B*S+L*E+R*k-M*O+P*N;if(!C)return null;return C=1/C,Z[0]=(W*f-G*S+z*E)*C,Z[1]=(Y*S-$*f-Q*E)*C,Z[2]=(c*P-w*M+x*R)*C,Z[3]=(V*M-H*P-q*R)*C,Z[4]=(G*k-K*f-z*O)*C,Z[5]=(X*f-Y*k+Q*O)*C,Z[6]=(w*L-F*P-x*B)*C,Z[7]=(v*P-V*L+q*B)*C,Z[8]=(K*S-W*k+z*N)*C,Z[9]=($*k-X*S-Q*N)*C,Z[10]=(F*M-c*L+x*j)*C,Z[11]=(H*L-v*M-q*j)*C,Z[12]=(W*O-K*E-G*N)*C,Z[13]=(X*E-$*O+Y*N)*C,Z[14]=(c*B-F*R-w*j)*C,Z[15]=(v*R-H*B+V*j)*C,Z}function zM1(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],c=Z[14],w=Z[15],x=J*K-X*Q,j=J*W-$*Q,B=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,P=z*F-v*q,N=z*c-H*q,O=z*w-V*q,k=v*c-H*F,E=v*w-V*F,S=H*w-V*c;return x*S-j*E+B*k+L*O-R*N+M*P}function Cs(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],c=J[12],w=J[13],x=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*$+L*W+R*H+M*c,Z[1]=B*Y+L*G+R*V+M*w,Z[2]=B*Q+L*z+R*q+M*x,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*$+L*W+R*H+M*c,Z[5]=B*Y+L*G+R*V+M*w,Z[6]=B*Q+L*z+R*q+M*x,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*$+L*W+R*H+M*c,Z[9]=B*Y+L*G+R*V+M*w,Z[10]=B*Q+L*z+R*q+M*x,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*$+L*W+R*H+M*c,Z[13]=B*Y+L*G+R*V+M*w,Z[14]=B*Q+L*z+R*q+M*x,Z[15]=B*K+L*v+R*F+M*j,Z}var j6;(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"})(j6||(j6={}));function u$(Z,J){let X=Z.getAttribute("POSITION"),$=Z.getIndices();switch(J){case j6.RENDER:return $?$.getCount():X.getCount();case j6.RENDER_CACHED:return $?new Set($.getArray()).size:X.getCount();case j6.UPLOAD_NAIVE:case j6.UPLOAD:return X.getCount();case j6.DISTINCT:case j6.DISTINCT_POSITION:return vM1(J);case j6.UNUSED:return $?X.getCount()-new Set($.getArray()).size:0;default:return VM1(J)}}function vM1(Z){throw Error(`Not implemented: ${Z}`)}function VM1(Z){throw Error(`Unexpected value: ${Z}`)}var dJ=4294967295;class fs{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of mc(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 HM1(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 HM1(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 qM1(Z,J,X,$,Y=dJ){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 Error("Hash table full.")}function dG(Z,J,X){let $=w6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=FM1(Z);let Y=Z.getIndices(),Q=Y?Y.getArray():null,K=u$(Z,j6.RENDER),W=$.createAccessor(),G=K,z=hP(G,X);for(let H=0;H<G;H++)z[H]=J[Q?Q[H]:H];Z.setIndices(W.setArray(z));let v=mc(Z);for(let H of Z.listAttributes()){let V=RZ($,H);CP(H,Y,J,V,X),Z.swap(H,V)}for(let H of Z.listTargets())for(let V of H.listAttributes()){let q=RZ($,V);CP(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 CP(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 FM1(Z){let J=u$(Z,j6.UPLOAD),X=Z.getIndices(),$=X?X.getArray():null;if(!X||!$)return[$M1(J,1e6),J];let Y=new Uint32Array(J).fill(dJ),Q=0;for(let K=0;K<$.length;K++){let W=$[K];if(Y[W]===dJ)Y[W]=Q++}return[Y,Q]}function cM1(){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 wM1(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 xM1(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 UM1(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 uc(){var Z=new R3(3);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return 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}function ks(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 BM1(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 LM1(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 DM1=jM1;(function(){var Z=uc();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 fP="weld",hc={overwrite:!0};function SP(Z=hc){let J=PZ(hc,Z);return l$(fP,async(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes()){for(let Q of Y.listPrimitives())if(lc(Q,J),u$(Q,j6.RENDER)===0)Ps(Q);if(Y.listPrimitives().length===0)Y.dispose()}$.debug(`${fP}: Complete.`)})}function lc(Z,J=hc){let X=Z.getGraph(),Y=w6.fromGraph(X).getLogger(),Q=M3({},hc,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 fs(Z),H=YM1(K+K/4),V=new Uint32Array(H).fill(dJ),q=new Uint32Array(K).fill(dJ),F=0;for(let c=0;c<z;c++){let w=G?G[c]:c;if(q[w]!==dJ)continue;let x=qM1(V,H,v,w,dJ),j=V[x];if(j===dJ)V[x]=w,q[w]=F++;else q[w]=q[j]}Y.debug(`${fP}: ${Ac(K,F)} vertices.`),dG(Z,q,F)}var{FLOAT:MM1}=K0.ComponentType;function Es(Z,J){let X=Z.getAttribute("POSITION");if(X)Gs(J,X);let $=Z.getAttribute("NORMAL");if($)zs(J,$);let Y=Z.getAttribute("TANGENT");if(Y)vs(J,Y);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)Gs(J,K);let W=Q.getAttribute("NORMAL");if(W)zs(J,W);let G=Q.getAttribute("TANGENT");if(G)vs(J,G)}if(zM1(J)<0)RM1(Z)}function Gs(Z,J){let X=J.getComponentType(),$=J.getNormalized(),Y=J.getArray(),Q=X===MM1?Y:new Float32Array(Y.length),K=uc();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];BM1(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 zs(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=cM1();wM1(Q,Z),UM1(Q,Q),xM1(Q,Q);let K=uc();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(LM1(K,K,Q),ks(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 vs(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=uc();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],ks(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 RM1(Z){if(Z.getMode()!==g1.Mode.TRIANGLES)return;if(!Z.getIndices())lc(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 PM1(Z,J){for(let X of Z.listPrimitives()){let $=NM1(X,Z);if(X!==$)Z.removePrimitive(X).addPrimitive($)}for(let X of Z.listPrimitives())dG(X),Es(X,J)}function NM1(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 Vs=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function Is(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!I0.eq(X,Vs))PM1(J,X);for(let $ of Z.listChildren()){let Y=$.getMatrix();Cs(Y,Y,X),$.setMatrix(Y)}return Z.setMatrix(Vs)}var{LINES:OM1,LINE_STRIP:TM1,LINE_LOOP:CM1,TRIANGLES:fM1,TRIANGLE_STRIP:kM1,TRIANGLE_FAN:EM1}=g1.Mode;function IM1(Z){let J=Z.getGraph(),X=w6.fromGraph(J);if(!Z.getIndices())lc(Z);let $=Z.getIndices(),Y=$.getArray(),Q=Rs(Z),W=new AJ[$.getComponentType()](Q*2),G=Z.getMode();if(G===TM1)for(let v=0;v<Q;v++)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else if(G===CM1)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 Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(OM1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(RZ(X,$).setArray(W));else $.setArray(W)}function _s(Z){let J=Z.getGraph(),X=w6.fromGraph(J);if(!Z.getIndices())lc(Z);let $=Z.getIndices(),Y=$.getArray(),Q=Rs(Z),W=new AJ[$.getComponentType()](Q*3),G=Z.getMode();if(G===kM1)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===EM1)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 Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(fM1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(RZ(X,$).setArray(W));else $.setArray(W)}var WO6={keepUniqueNames:!1,propertyTypes:[g.ACCESSOR,g.MESH,g.TEXTURE,g.MATERIAL,g.SKIN]};var Hs="dequantize",Sc={pattern:/^((?!JOINTS_).)*$/};function hs(Z=Sc){let J=PZ(Sc,Z);return l$(Hs,(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes())for(let Q of Y.listPrimitives())_M1(Q,J);X.createExtension(iG).dispose(),$.debug(`${Hs}: Complete.`)})}function _M1(Z,J=Sc){let X=PZ(Sc,J);for(let $ of Z.listSemantics())if(X.pattern.test($))kP(Z.getAttribute($));for(let $ of Z.listTargets())for(let Y of $.listSemantics())if(X.pattern.test(Y))kP($.getAttribute(Y))}function kP(Z){let J=Z.getArray();if(!J)return;let X=bc(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function bc(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:Ss,ROOT:GO6}=g;function bs(Z){let J=new w6().setLogger(Z.getLogger()),X=bP(J,Z);return hM1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function hM1(Z,J,X){X||(X=bP(Z,J));for(let $ of J.getRoot().listExtensionsUsed()){let Y=Z.createExtension($.constructor);if($.isRequired())Y.setRequired(!0)}return SM1(Z,J,bM1(J),X)}function SM1(Z,J,X,$){$||($=bP(Z,J));let Y=new Map;for(let Q of X)if(!Y.has(Q)&&Q.propertyType!==Ss)Y.set(Q,$(Q));for(let[Q,K]of Y.entries())K.copy(Q,$);return Y}function bP(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return($)=>{if($.propertyType===Ss)return $;let Y=X.get($);if(!Y)Y=new $.constructor(Z.getGraph()),X.set($,Y);return Y}}function bM1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}function As(){var Z=new R3(4);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function AM1(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 mM1(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 uM1(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 lM1(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 ms=mM1,pM1=uM1,us=yM1;(function(){var Z=As();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 iM1=/color|emissive|diffuse/i;function gM1(Z){return Z.getGraph().listParentEdges(Z).some((Y)=>{return Y.getAttributes().isColor||iM1.test(Y.getName())})?"srgb":null}function dM1(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 h$)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 aM1(Z){let X=w6.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",EP=0.011764705882352941,qs={propertyTypes:[g.NODE,g.SKIN,g.MESH,g.CAMERA,g.PRIMITIVE,g.PRIMITIVE_TARGET,g.ANIMATION,g.MATERIAL,g.TEXTURE,g.ACCESSOR,g.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function ls(Z=qs){let J=PZ(qs,Z),X=new Set(J.propertyTypes),$=J.keepExtras;return l$(D3,async(Y)=>{let Q=Y.getLogger(),K=Y.getRoot(),W=Y.getGraph(),G=new ys,z=(v)=>G.dispose(v.target);if(W.addEventListener("node:dispose",z),X.has(g.MESH))for(let v of K.listMeshes()){if(v.listPrimitives().length>0)continue;v.dispose()}if(X.has(g.NODE)){if(!J.keepLeaves)for(let v of K.listScenes())ps(W,v,$);for(let v of K.listNodes())D4(v,$)}if(X.has(g.SKIN))for(let v of K.listSkins())D4(v,$);if(X.has(g.MESH))for(let v of K.listMeshes())D4(v,$);if(X.has(g.CAMERA))for(let v of K.listCameras())D4(v,$);if(X.has(g.PRIMITIVE))Fs(W,g.PRIMITIVE,$);if(X.has(g.PRIMITIVE_TARGET))Fs(W,g.PRIMITIVE_TARGET,$);if(!J.keepAttributes&&X.has(g.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=is(Y,V,q),c=nM1(V,F);cs(V,c),V.listTargets().forEach((w)=>cs(w,c)),v.has(q)?v.get(q).add(V):v.set(q,new Set([V]))}for(let[H,V]of v)sM1(H,Array.from(V))}if(X.has(g.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(g.MATERIAL))K.listMaterials().forEach((v)=>D4(v,$));if(X.has(g.TEXTURE)){if(K.listTextures().forEach((v)=>D4(v,$)),!J.keepSolidTextures)await oM1(Y)}if(X.has(g.ACCESSOR))K.listAccessors().forEach((v)=>D4(v,$));if(X.has(g.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 ys{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 KZ)),$=J&&!Ns(Z.getExtras());if(!X.length&&!$)Z.dispose()}function Fs(Z,J,X){for(let $ of Z.listEdges()){let Y=$.getParent();if(Y.propertyType===J)D4(Y,X)}}function ps(Z,J,X){if(J.listChildren().forEach((K)=>ps(Z,K,X)),J instanceof K3)return;let $=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==g.ROOT&&W!==g.SCENE&&W!==g.NODE}),Y=Z.listChildren(J).length===0,Q=X&&!Ns(J.getExtras());if(Y&&!$&&!Q)J.dispose()}function cs(Z,J){for(let X of J)Z.setAttribute(X,null)}function nM1(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 is(Z,J,X,$=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let z of Q)if(z.getChild()instanceof h$)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 h$&&v.match(/normalTexture/i))$.add("TANGENT");if(H instanceof O1)is(Z,J,H,$)}let W=X instanceof K7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===g1.Mode.POINTS;if(W&&!G)$.add("NORMAL");return $}function sM1(Z,J){let X=dM1(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 oM1(Z){let J=Z.getRoot(),X=Z.getGraph(),$=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await tM1(K);if(!G)return;if(gM1(K)==="srgb")HR.convertSRGBToLinear(G,G);let z=K.getName()||K.getURI(),v=(W=K.getSize())==null?void 0:W.join("x"),H=aM1(K);for(let V of X.listParentEdges(K)){let q=V.getParent();if(q!==J&&rM1(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 rM1(Z,J,X,$){if(Z instanceof K7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(pM1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(DM1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=EP;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return us(ms(As(),J,[0.5,0.5,1,1]))<=EP}return $.warn(`${D3}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function tM1(Z){let J=await eM1(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(us(ms(Y,$,X))/255>EP)return null}return lM1(Y,AM1(Y,$,X),0.00196078431372549)}async function eM1(Z){try{return await hn(Z.getImage(),Z.getMimeType())}catch(J){return null}}var PP="flatten",ws={cleanup:!0};function gs(Z=ws){let J=PZ(ws,Z);return l$(PP,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;WM1(v)});if(K.size)Y.debug(`${PP}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(ls({propertyTypes:[g.NODE],keepLeaves:!1}));Y.debug(`${PP}: Complete.`)})}function ds(Z){return PG(Z)}var ZR1={skipValidation:!1},xs=4294967295,{LINE_STRIP:JR1,LINE_LOOP:XR1,TRIANGLE_STRIP:$R1,TRIANGLE_FAN:YR1}=g1.Mode;function QR1(Z,J={}){let X=PZ(ZR1,J),$=Z[0],Y=w6.fromGraph($.getGraph());if(!X.skipValidation&&new Set(Z.map(Os)).size>1)throw 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 JR1:case XR1:IM1(q);break;case $R1:case YR1:_s(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],c=F.getIndices(),w=F.getAttribute("POSITION").getCount(),x=c?c.getArray():null,j=c?c.getCount():w,B=new Uint32Array(w).fill(xs);for(let L=0;L<j;L++){let R=x?x[L]:L;if(B[R]===xs)B[R]=W++,K[q]++}Q.push(B),G+=j}let z=Y.createPrimitive().setMode($.getMode()).setMaterial($.getMaterial());for(let q of $.listSemantics()){let F=$.getAttribute(q),c=AJ[F.getComponentType()],w=RZ(Y,F).setArray(new c(W*F.getElementSize()));z.setAttribute(q,w)}let v=$.getIndices(),H=v?RZ(Y,v).setArray(hP(G,W)):null;z.setIndices(H);let V=0;for(let q=0;q<Q.length;q++){let F=Z[q],c=F.getIndices(),w=c?c.getCount():-1,x=Q[q];if(c&&H)WR1(c,x,H,V),V+=w;for(let j of z.listSemantics()){let B=F.getAttribute(j),L=z.getAttribute(j);KR1(B,c,x,L)}}return z}function KR1(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 WR1(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 IP="join",{ROOT:GR1,NODE:zR1,MESH:vR1,PRIMITIVE:VR1,ACCESSOR:HR1}=g,NP=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Us={keepMeshes:!1,keepNamed:!1,cleanup:!0,filter:()=>!0};function as(Z=Us){let J=PZ(Us,Z);return l$(IP,async(X)=>{let $=X.getRoot(),Y=X.getLogger();for(let Q of $.listScenes())js(X,Q,J),Q.traverse((K)=>js(X,K,J));if(J.cleanup)await X.transform(ls({propertyTypes:[zR1,vR1,VR1,HR1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));Y.debug(`${IP}: Complete.`)})}function js(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 KZ))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;dG(V),FR1(V);let F=Os(V),c=H.getName()||z.getName();if(X.keepMeshes||X.keepNamed&&c)F+=`|${G}`;if(!(F in Y))Y[F]={prims:[],primMeshes:[],primNodes:[],dstNode:z,dstMesh:void 0};let w=Y[F];w.prims.push(V),w.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!==GR1&&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 x=0;x<z.length;x++){let j=v[x],B=H[x],L=z[x];if(B.removePrimitive(L),TP(L))L=z[x]=qR1(z[x]);if(j!==V)Cs(NP,GM1(NP,F),j.getMatrix()),Es(L,NP)}let c=QR1(z),w=c.listAttributes()[0].getCount();q.addPrimitive(c),$.debug(`${IP}: Joined Primitives (${z.length}) containing ${OP(w)} vertices under Node "${V.getName()}".`)}}function qR1(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 FR1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)kP(X)}}var{TRANSLATION:zO6,ROTATION:vO6,SCALE:VO6,WEIGHTS:HO6}=KZ.TargetPath;var cR1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var qO6=M3({level:"high"},cR1);var wR1="unweld";function xR1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let $=Z.getGraph(),Y=w6.fromGraph($),Q=Y.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,Bs(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,Bs(Y,z,X,J)),z.listParents().length===1)z.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${wR1}: ${Ac(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function Bs(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=RZ(Z,J).setArray(K);return $.get(J).set(X,z),z}var Ls;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Ls||(Ls={}));var UR1=0.000001;function jR1(Z,J,X,$=0.0001){let Y=J.length/Z.length,Q=Array(Y).fill(0),K=Array(Y).fill(0),W=Array(Y).fill(0),G=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],c=(q-V)/(F-V),w=!1;if(q!==F&&(H!==1||q!==Z[0])){if(gG(J,v-1,G),gG(J,H,K),gG(J,H+1,W),X==="slerp"){let x=DR1(Q,G,W,c),j=Ms(G,K)+Ms(K,W);w=!_c(K,x,$)||j+Number.EPSILON>=Math.PI}else if(X==="lerp"){let x=LR1(Q,G,W,c);w=!_c(K,x,$)}else if(X==="step")w=!_c(K,G)||!_c(K,W)}if(w){if(H!==v)Z[v]=Z[H],Ds(J,v,gG(J,H,Q));v++}}if(z>0)Z[v]=Z[z],Ds(J,v,gG(J,z,Q)),v++;return v}function gG(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)X[$]=Z[J*Y+$];return X}function Ds(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)Z[J*Y+$]=X[$]}function _c(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 BR1(Z,J,X){return Z*(1-X)+J*X}function LR1(Z,J,X,$){for(let Y=0;Y<J.length;Y++)Z[Y]=BR1(J[Y],X[Y],$);return Z}function DR1(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,c,w;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>UR1)V=Math.acos(q),F=Math.sin(V),c=Math.sin((1-$)*V)/F,w=Math.sin($*V)/F;else c=1-$,w=$;return Z[0]=c*Y+w*G,Z[1]=c*Q+w*z,Z[2]=c*K+w*v,Z[3]=c*W+w*H,Z}function Ms(Z,J){let X=MR1(Z,J);return Math.acos(2*X*X-1)}function MR1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var FO6=new Float32Array(0),cO6={ready:Promise.resolve(),resample:jR1,tolerance:0.0001,cleanup:!0};var m$="simplify",{POINTS:ns,LINES:RR1,LINE_STRIP:PR1,LINE_LOOP:NR1,TRIANGLES:OR1,TRIANGLE_STRIP:ss,TRIANGLE_FAN:os}=g1.Mode,rs={ratio:0,error:0.0001,lockBorder:!1};function ts(Z){let J=PZ(rs,Z),X=J.simplifier;if(!X)throw Error(`${m$}: simplifier dependency required — install "meshoptimizer".`);return l$(m$,async($)=>{let Y=$.getLogger();await X.ready,await $.transform(SP({overwrite:!1}));let Q=0;for(let K of $.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G!==OR1&&G!==ss&&G!==os&&G!==ns){Q++;continue}if(TR1(W,J),u$(W,j6.RENDER)===0)Ps(W)}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)Y.warn(`${m$}: Skipped ${Q} primitives: Unsupported draw mode.`);Y.debug(`${m$}: Complete.`)})}function TR1(Z,J){let X=M3({},rs,J),$=X.simplifier,Y=Z.getGraph(),Q=w6.fromGraph(Y),K=Q.getLogger();switch(Z.getMode()){case ns:return CR1(Q,Z,X);case RR1:case PR1:case NR1:return K.warn(`${m$}: Skipping primitive simplification: Unsupported draw mode.`),Z;case ss:case os:_s(Z);break}let W=u$(Z,j6.UPLOAD),G=u$(Z,j6.RENDER);if(G<W/2)dG(Z);let z=Z.getAttribute("POSITION"),v=Z.getIndices(),H=z.getArray(),V=v.getArray();if(!(H instanceof Float32Array))H=bc(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"]:[],[c,w]=$.simplify(V,H,3,q,X.error,F);if(Z.setIndices(RZ(Q,v).setArray(c)),v.listParents().length===1)v.dispose();dG(Z);let x=u$(Z,j6.UPLOAD);if(x<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${m$}: ${Ac(W,x)} vertices, error: ${w.toFixed(4)}.`),Z}function CR1(Z,J,X){let $=X.simplifier,Y=Z.getLogger();if(J.getIndices())xR1(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=bc(z,K.getComponentType(),K.getNormalized());if(v&&!(v instanceof Float32Array))v=bc(v,K.getComponentType(),K.getNormalized());let V=Math.floor(X.ratio*G),q=$.simplifyPoints(z,3,V,v,H),[F,c]=$.compactMesh(q);Y.debug(`${m$}: ${Ac(K.getCount(),c)} vertices.`);for(let w of mc(J)){let x=RZ(Z,w);if(CP(w,null,F,x,c),XM1(J,w,x),w.listParents().length===1)w.dispose()}return J}var _P;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(_P||(_P={}));var wO6={resizeFilter:_P.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var Qo=t(Yo(),1);var NZ={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DATA_SCHEMA_VERSION:1,DATA_EXT:".data.json",DIRECTORIES:[(()=>{try{return q5.dirname(i.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))}catch{return null}})(),q5.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 B6{static instance=new B6;optimize=!0;optimizeEveryStart=!1;_modelUriAnimationNames=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...`);let J=performance.now();for(let $ of Z){if(this.optimize)await this._resolveOptimizedModelPath($);await this._loadModelData($)}let X=performance.now();console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models in ${X-J}ms!`)}getAnimationNames(Z){let J=this._modelUriAnimationNames.get(Z);if(!J)y.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)y.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)y.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){y.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)y.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=q5.normalize(Z);for(let X of NZ.DIRECTORIES){let $=q5.normalize(X);if(J.startsWith($))return q5.relative($,J).replace(/\\/g,"/")}return q5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of NZ.DIRECTORIES){let X=q5.resolve(process.cwd(),J);if(!M4.existsSync(X))continue;let $=await mF("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let Y of $)Z.push(q5.join(X,Y))}return Z}async _loadModelData(Z){let X=`${this._buildOptimizedModelPath(Z)}${NZ.DATA_EXT}`,$=this._absoluteModelPathToModelUri(Z),Y=this._calculateChecksum(Z),Q;if(M4.existsSync(X))try{let K=M4.readFileSync(X,"utf8"),W=JSON.parse(K);if(W?.schemaVersion!==NZ.DATA_SCHEMA_VERSION)throw Error("ModelRegistry._loadModelData(): Schema version mismatch! Data will be regenerated..");if(W?.source?.sha256!==Y)throw Error("ModelRegistry._loadModelData(): Checksum mismatch! Data will be regenerated..");Q=W}catch{}if(!Q){let K=await new xR().read(Z),W=ds(K.getRoot().listScenes()[0]),G=K.getRoot().listNodes().map((H)=>H.getName()),z=K.getRoot().listAnimations().map((H)=>H.getName()),v=await this._buildTrimesh(K);Q={schemaVersion:NZ.DATA_SCHEMA_VERSION,source:{uri:$,sha256:Y},animationNames:z,boundingBox:{min:{x:W.min[0],y:W.min[1],z:W.min[2]},max:{x:W.max[0],y:W.max[1],z:W.max[2]}},nodeNames:G,trimesh:v?{vertices:Array.from(v.vertices),indices:Array.from(v.indices)}:void 0};try{let H=q5.dirname(X);M4.mkdirSync(H,{recursive:!0}),M4.writeFileSync(X,JSON.stringify(Q))}catch(H){y.warning(`ModelRegistry._loadModelData(): Failed to write data file for ${$}. Error: ${String(H)}`)}}this._modelUriAnimationNames.set($,Q.animationNames),this._modelUriBoundingBoxes.set($,Q.boundingBox),this._modelUriNodeNames.set($,Q.nodeNames),this._modelUriTrimeshes.set($,Q.trimesh?{vertices:new Float32Array(Q.trimesh.vertices),indices:new Uint32Array(Q.trimesh.indices)}:void 0)}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)}${NZ.CHECKSUM_EXT}`;if(!M4.existsSync(J))return!1;let X=this._calculateChecksum(Z),$=M4.readFileSync(J,"utf8");return X===$}_calculateChecksum(Z){if(!M4.existsSync(Z))return"";let J=M4.readFileSync(Z);return _R1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=q5.basename(Z),X=J.replace(/\.[^/.]+$/,""),$=q5.dirname(Z),Y=q5.join($,NZ.OPTIMIZED_DIR,X);return q5.join(Y,J)}async _buildTrimesh(Z,J=1,X=0.001){let $=bs(Z);$.setLogger(new z5(MG.WARN)),await $.transform(Ts({pivot:"center"}),gs(),as(),SP(),ts({simplifier:Qo.MeshoptSimplifier,ratio:J,error:X}),hs());for(let V of $.getRoot().listScenes())for(let q of V.listChildren())Is(q);let Y=[],Q=0,K=0;for(let V of $.getRoot().listMeshes())for(let q of V.listPrimitives()){let F=q.getAttribute("POSITION"),c=q.getIndices();if(!F||!c)continue;let w=F.getArray(),x=c.getArray(),j=x instanceof Uint32Array?x:new Uint32Array(x);if(w.length===0||j.length===0)continue;Y.push({vertices:w,indices:j}),Q+=w.length,K+=j.length}if(Y.length===0){y.error("ModelRegistry._buildTrimesh(): Model has no primitives with POSITION and INDICES!");return}let W=new Float32Array(Q),G=new Uint32Array(K),z=0,v=0,H=0;for(let V of Y){W.set(V.vertices,z);let q=V.vertices.length/3;for(let F=0;F<V.indices.length;F++)G[H+F]=V.indices[F]+v;z+=V.vertices.length,H+=V.indices.length,v+=q}return{vertices:W,indices:G}}async _optimizeModel(Z,J){let X=q5.dirname(J);M4.rmSync(X,{recursive:!0,force:!0}),M4.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let $ of NZ.OPTIMIZER_RUNS){let Y=J.replace(/(\.[^/.]+)$/,`${$.suffix}$1`),{stderr:Q}=await Bi("npx",["@gltf-transform/cli","optimize",Z,Y,...$.options]);if(Q)return y.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return M4.writeFileSync(`${J}${NZ.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var rG;((Y)=>{Y.DYNAMIC="dynamic";Y.FIXED="fixed";Y.KINEMATIC_POSITION="kinematic_position";Y.KINEMATIC_VELOCITY="kinematic_velocity"})(rG||={});var yP=0.001,Ko="dynamic";class aJ extends j0{_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??=Ko,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 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 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 y.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 y.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 A5({...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 y.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 y.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 y.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 A5(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??Ko;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)y.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)y.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)y.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)y.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)y.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)y.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)<yP&&Math.abs(Z.y)<yP&&Math.abs(Z.z)<yP}}var pP;((Y)=>{Y[Y.Average=0]="Average";Y[Y.Min=1]="Min";Y[Y.Multiply=2]="Multiply";Y[Y.Max=3]="Max"})(pP||={});var P3;((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"})(P3||={});class A5 extends j0{_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 $=B6.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=(j)=>Math.max(0.01,j),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)}),c=()=>{let j=B6.instance.getTrimesh(Z,J);if(!j)return;return{shape:"trimesh",vertices:j.vertices,indices:j.indices}},w=()=>({shape:"wedge",extents:{x:Y*J,y:Q*J,z:K*J}}),x=()=>({shape:"capsule",radius:V(H),halfHeight:V(Q*J/2-H)});if(X)switch(X){case"block":return q();case"capsule":return x();case"round-cylinder":return F();case"trimesh":{let j=c();if(!j){y.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return j}case"wedge":return w();default:y.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 x()}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 y.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 y.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")y.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 y.error("Collider.combineVoxelStates(): Other collider is not simulated!");if(this.shape!=="voxels")return y.error("Collider.combineVoxelStates(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return y.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 y.error("Collider.propagateVoxelChange(): Other collider is not simulated!");if(this.shape!=="voxels")return y.error("Collider.propagateVoxelChange(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return y.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":{y.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"voxels":{y.error("Collider.setScale(): Voxels colliders cannot be scaled!");return}case"wedge":{y.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:y.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)y.fatalError("Ball collider must have a radius!");return X1.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)y.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)y.fatalError("Capsule collider must have halfHeight and radius!");return X1.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)y.fatalError("Cone collider must have radius and halfHeight!");return X1.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)y.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)y.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)y.fatalError("Trimesh collider must have vertices and indices!");return X1.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)y.fatalError("Voxels collider must have coordinates and size!");return X1.ColliderDesc.voxels(this._coordinatesToInt32Array(Z.coordinates),Z.size)}case"wedge":{if(!Z.extents)y.fatalError("Wedge collider must have extents!");let $=this._buildWedgeConvexHullVertices(Z.extents),Y=X1.ColliderDesc.convexHull($);if(!Y)throw y.fatalError("Failed to create convex hull for wedge collider!"),Error("Convex hull creation failed");return Y}default:y.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)y.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)y.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)y.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 hR1={shape:"voxels"},iP;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(iP||={});class m5 extends j0{_id;_customColliderOptions;_halfExtents;_isLiquid;_lightLevel;_name;_textureUri;constructor(Z={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(Z.id<0)y.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,...hR1}}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 A5({...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 gP;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(gP||={});class tG extends j0{_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)y.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends m5{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 MO={};_Q(MO,{worldSchema:()=>DO,worldPacketDefinition:()=>J10,vectorSchema:()=>W1,vectorBooleanSchema:()=>IE1,uiSchema:()=>BO,uiPacketDefinition:()=>e00,uiDatasSchema:()=>LO,uiDatasPacketDefinition:()=>Z10,uiDataSendPacketDefinition:()=>b00,uiDataSchema:()=>Dz,syncResponseSchema:()=>jO,syncResponsePacketDefinition:()=>t00,syncRequestSchema:()=>dN,syncRequestPacketDefinition:()=>S00,stateRequestSchema:()=>gN,stateRequestPacketDefinition:()=>h00,sceneUIsSchema:()=>UO,sceneUIsPacketDefinition:()=>r00,sceneUISchema:()=>xO,rgbColorSchema:()=>D6,registeredPackets:()=>kw,quaternionSchema:()=>YO,playersSchema:()=>wO,playersPacketDefinition:()=>o00,playerSchema:()=>cO,physicsDebugRenderSchema:()=>FO,physicsDebugRenderPacketDefinition:()=>n00,physicsDebugRaycastsSchema:()=>qO,physicsDebugRaycastsPacketDefinition:()=>s00,physicsDebugRaycastSchema:()=>HO,particleEmittersSchema:()=>VO,particleEmittersPacketDefinition:()=>a00,particleEmitterSchema:()=>vO,outboundPackets:()=>fw,notificationPermissionRequestSchema:()=>zO,notificationPermissionRequestPacketDefinition:()=>d00,modelNodeOverrideSchema:()=>$O,lightsSchema:()=>GO,lightsPacketDefinition:()=>g00,lightSchema:()=>WO,isValidPacket:()=>hE1,inputSchema:()=>iN,inputPacketDefinition:()=>_00,inboundPackets:()=>Cw,hexColorSchema:()=>yN,heartbeatSchema:()=>lN,heartbeatPacketDefinition:()=>k00,entitySchema:()=>QO,entitiesSchema:()=>KO,entitiesPacketDefinition:()=>i00,definePacket:()=>C0,debugConfigSchema:()=>pN,debugConfigPacketDefinition:()=>I00,createPacket:()=>ME1,connectionSchema:()=>uN,connectionPacketDefinition:()=>f00,chunksSchema:()=>XO,chunksPacketDefinition:()=>p00,chunkSchema:()=>JO,chatMessagesSchema:()=>ZO,chatMessagesPacketDefinition:()=>y00,chatMessageSendPacketDefinition:()=>E00,chatMessageSchema:()=>Lz,cameraSchema:()=>eN,cameraPacketDefinition:()=>l00,blocksSchema:()=>oN,blocksPacketDefinition:()=>m00,blockTypesSchema:()=>tN,blockTypesPacketDefinition:()=>u00,blockTypeSchema:()=>rN,blockSchema:()=>sN,bidirectionalPackets:()=>Tw,audiosSchema:()=>nN,audiosPacketDefinition:()=>A00,audioSchema:()=>aN,PacketId:()=>M1});var Tw={};_Q(Tw,{heartbeatPacketDefinition:()=>k00,connectionPacketDefinition:()=>f00});var AN=t(T00(),1);class mN extends AN.default{static instance=new AN.default}var M1;((k)=>{k[k.SYNC_REQUEST=0]="SYNC_REQUEST";k[k.INPUT=1]="INPUT";k[k.STATE_REQUEST=2]="STATE_REQUEST";k[k.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";k[k.UI_DATA_SEND=4]="UI_DATA_SEND";k[k.SYNC_RESPONSE=32]="SYNC_RESPONSE";k[k.AUDIOS=33]="AUDIOS";k[k.BLOCKS=34]="BLOCKS";k[k.BLOCK_TYPES=35]="BLOCK_TYPES";k[k.CHAT_MESSAGES=36]="CHAT_MESSAGES";k[k.CHUNKS=37]="CHUNKS";k[k.ENTITIES=38]="ENTITIES";k[k.WORLD=39]="WORLD";k[k.CAMERA=40]="CAMERA";k[k.UI=41]="UI";k[k.UI_DATAS=42]="UI_DATAS";k[k.SCENE_UIS=43]="SCENE_UIS";k[k.LIGHTS=44]="LIGHTS";k[k.PLAYERS=45]="PLAYERS";k[k.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";k[k.NOTIFICATION_PERMISSION_REQUEST=47]="NOTIFICATION_PERMISSION_REQUEST";k[k.CONNECTION=116]="CONNECTION";k[k.HEARTBEAT=117]="HEARTBEAT";k[k.DEBUG_CONFIG=128]="DEBUG_CONFIG";k[k.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";k[k.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(M1||={});function ME1(Z,J,X){if(!Z.validate(J))throw Error(`Invalid payload for packet with id ${Z.id}. Error: ${mN.instance.errorsText(Z.validate.errors)}`);let $=[Z.id,J];if(typeof X==="number")$.push(X);return $}function C0(Z,J){return{id:Z,schema:J,validate:mN.instance.compile(J)}}var RE1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},C00={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},PE1={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},NE1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},OE1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},TE1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},CE1={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},fE1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:NE1,ic:{type:"array",items:PE1},d:C00,s:TE1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},kE1={type:"object",properties:{i:{type:"string"},d:C00},required:["i","d"],additionalProperties:!1},EE1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:CE1},required:["l","s"],additionalProperties:!1},uN={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},c:{...kE1,nullable:!0},ca:{...RE1,nullable:!0},d:{type:"array",items:{...EE1},nullable:!0},pa:{...OE1,nullable:!0},t:{type:"array",items:{...fE1},nullable:!0}},additionalProperties:!1};var f00=C0(116,uN);var lN={type:"null",nullable:!0};var k00=C0(117,lN);var Cw={};_Q(Cw,{uiDataSendPacketDefinition:()=>b00,syncRequestPacketDefinition:()=>S00,stateRequestPacketDefinition:()=>h00,inputPacketDefinition:()=>_00,debugConfigPacketDefinition:()=>I00,chatMessageSendPacketDefinition:()=>E00});var yN={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var Lz={type:"object",properties:{m:{type:"string"},c:{...yN,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var E00=C0(3,Lz);var pN={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var I00=C0(128,pN);var iN={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 _00=C0(1,iN);var gN={type:"object",properties:{},additionalProperties:!1};var h00=C0(2,gN);var dN={type:"null",nullable:!0};var S00=C0(0,dN);var Dz={type:"object",properties:{},additionalProperties:!0};var b00=C0(4,Dz);var fw={};_Q(fw,{worldPacketDefinition:()=>J10,uiPacketDefinition:()=>e00,uiDatasPacketDefinition:()=>Z10,syncResponsePacketDefinition:()=>t00,sceneUIsPacketDefinition:()=>r00,playersPacketDefinition:()=>o00,physicsDebugRenderPacketDefinition:()=>n00,physicsDebugRaycastsPacketDefinition:()=>s00,particleEmittersPacketDefinition:()=>a00,notificationPermissionRequestPacketDefinition:()=>d00,lightsPacketDefinition:()=>g00,entitiesPacketDefinition:()=>i00,chunksPacketDefinition:()=>p00,chatMessagesPacketDefinition:()=>y00,cameraPacketDefinition:()=>l00,blocksPacketDefinition:()=>m00,blockTypesPacketDefinition:()=>u00,audiosPacketDefinition:()=>A00});var W1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var aN={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 nN={type:"array",items:{...aN}};var A00=C0(33,nN);var sN={type:"object",properties:{i:{type:"number"},c:W1},required:["i","c"],additionalProperties:!1};var oN={type:"array",items:{...sN}};var m00=C0(34,oN);var rN={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 tN={type:"array",items:{...rN}};var u00=C0(35,tN);var eN={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 ZO={type:"array",items:{...Lz}};var JO={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 XO={type:"array",items:{...JO}};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 $O={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 YO={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var QO={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:{...$O},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:{...YO,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 KO={type:"array",items:{...QO}};var WO={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 GO={type:"array",items:{...WO}};var zO={type:"null",nullable:!0};var vO={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 VO={type:"array",items:{...vO}};var HO={type:"object",properties:{o:{...W1},d:{...W1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var qO={type:"array",items:{...HO}};var FO={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var cO={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 wO={type:"array",items:{...cO}};var xO={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 UO={type:"array",items:{...xO}};var jO={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var BO={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var LO={type:"array",items:{...Dz}};var IE1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var DO={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 l00=C0(40,eN);var y00=C0(36,ZO);var p00=C0(37,XO);var i00=C0(38,KO);var g00=C0(44,GO);var d00=C0(47,zO);var a00=C0(46,VO);var n00=C0(192,FO);var s00=C0(193,qO);var o00=C0(45,wO);var r00=C0(43,UO);var t00=C0(32,jO);var e00=C0(41,BO);var Z10=C0(42,LO);var J10=C0(39,DO);var kw=new Map,_E1={...Tw,...Cw,...fw};for(let Z of Object.values(_E1))if("id"in Z&&"schema"in Z){let J=Z;if(kw.has(J.id))throw Error(`Packet with id ${J.id} is already registered.`);kw.set(J.id,J)}function hE1(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=kw.get(Z[0]);return!!J&&J.validate(Z[1])}var $0=MO;var W60=t(C10(),1);import e$ from"fs";import Q60 from"path";var M_1=t(R80(),1),R_1=t(_O(),1),P_1=t(SO(),1),t$=t(yw(),1),pO=t(k80(),1);var E80=t$.default;function U5(Z){if(Z===null)return"null";if(Array.isArray(Z))return"array";return typeof Z}function YX(Z){return U5(Z)==="object"}function N_1(Z){return Array.isArray(Z)&&Z.length>0&&Z.every((J)=>("message"in J))}function iO(Z,J){return Z.length<124?Z:J}var I80="graphql-transport-ws";var l5=((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})(l5||{}),y5=((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})(y5||{});function _80(Z){if(!YX(Z))throw Error(`Message is expected to be an object, but got ${U5(Z)}`);if(!Z.type)throw Error("Message is missing the 'type' property");if(typeof Z.type!=="string")throw Error(`Message is expects the 'type' property to be a string, but got ${U5(Z.type)}`);switch(Z.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(Z.payload!=null&&!YX(Z.payload))throw 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 Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!YX(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${U5(Z.payload)}`);if(typeof Z.payload.query!=="string")throw Error(`"${Z.type}" message payload expects the 'query' property to be a string, but got ${U5(Z.payload.query)}`);if(Z.payload.variables!=null&&!YX(Z.payload.variables))throw Error(`"${Z.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${U5(Z.payload.variables)}`);if(Z.payload.operationName!=null&&U5(Z.payload.operationName)!=="string")throw Error(`"${Z.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${U5(Z.payload.operationName)}`);if(Z.payload.extensions!=null&&!YX(Z.payload.extensions))throw Error(`"${Z.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${U5(Z.payload.extensions)}`);break}case"next":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!YX(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${U5(Z.payload)}`);break}case"error":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!N_1(Z.payload))throw 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 Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);break}default:throw Error(`Invalid message 'type' property "${Z.type}"`)}return Z}function h80(Z,J){return _80(typeof Z==="string"?JSON.parse(Z,J):Z)}function i3(Z,J){return _80(Z),JSON.stringify(Z,J)}function dO(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(h){let _=Math.pow(2,h);await new Promise((a)=>setTimeout(a,_*1000+Math.floor(Math.random()*2700+300)))},shouldRetry:H=gO,on:V,webSocketImpl:q,generateID:F=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(h)=>{let _=Math.random()*16|0;return(h=="x"?_:_&3|8).toString(16)})},jsonMessageReplacer:c,jsonMessageReviver:w}=Z,x;if(q){if(!T_1(q))throw Error("Invalid WebSocket implementation provided");x=q}else if(typeof WebSocket<"u")x=WebSocket;else if(typeof global<"u")x=global.WebSocket||global.MozWebSocket;else if(typeof window<"u")x=window.WebSocket||window.MozWebSocket;if(!x)throw Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let j=x,B=(()=>{let C=(()=>{let _={};return{on(a,s){return _[a]=s,()=>{delete _[a]}},emit(a){if("id"in a)_[a.id]?.(a)}}})(),h={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(_,a){let s=h[_];return s.push(a),()=>{s.splice(s.indexOf(a),1)}},emit(_,...a){for(let s of[...h[_]])s(...a)}}})();function L(C){let h=[B.on("error",(_)=>{h.forEach((a)=>a()),C(_)}),B.on("closed",(_)=>{h.forEach((a)=>a()),C(_)})]}let R,M=0,P,N=!1,O=0,k=!1;async function E(){clearTimeout(P);let[C,h]=await(R??(R=new Promise((s,Z0)=>(async()=>{if(N){if(await v(O),!M)return R=void 0,Z0({code:1000,reason:"All Subscriptions Gone"});O++}B.emit("connecting",N);let o=new j(typeof J==="function"?await J():J,I80),M0,R0;function m0(){if(isFinite(K)&&K>0)clearTimeout(R0),R0=setTimeout(()=>{if(o.readyState===j.OPEN)o.send(i3({type:y5.Ping})),B.emit("ping",!1,void 0)},K)}L((s0)=>{if(R=void 0,clearTimeout(M0),clearTimeout(R0),Z0(s0),s0 instanceof iw)o.close(4499,"Terminated"),o.onerror=null,o.onclose=null}),o.onerror=(s0)=>B.emit("error",s0),o.onclose=(s0)=>B.emit("closed",s0),o.onopen=async()=>{try{B.emit("opened",o);let s0=typeof X==="function"?await X():X;if(o.readyState!==j.OPEN)return;if(o.send(i3(s0?{type:y5.ConnectionInit,payload:s0}:{type:y5.ConnectionInit},c)),isFinite(G)&&G>0)M0=setTimeout(()=>{o.close(l5.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},G);m0()}catch(s0){B.emit("error",s0),o.close(l5.InternalClientError,iO(s0 instanceof Error?s0.message:String(s0),"Internal client error"))}};let N1=!1;o.onmessage=({data:s0})=>{try{let j1=h80(s0,w);if(B.emit("message",j1),j1.type==="ping"||j1.type==="pong"){if(B.emit(j1.type,!0,j1.payload),j1.type==="pong")m0();else if(!W)o.send(i3(j1.payload?{type:y5.Pong,payload:j1.payload}:{type:y5.Pong})),B.emit("pong",!1,j1.payload);return}if(N1)return;if(j1.type!==y5.ConnectionAck)throw Error(`First message cannot be of type ${j1.type}`);clearTimeout(M0),N1=!0,B.emit("connected",o,j1.payload,N),N=!1,O=0,s([o,new Promise((W4,NJ)=>L(NJ))])}catch(j1){o.onmessage=null,B.emit("error",j1),o.close(l5.BadResponse,iO(j1 instanceof Error?j1.message:String(j1),"Bad response"))}}})())));if(C.readyState===j.CLOSING)await h;let _=()=>{},a=new Promise((s)=>_=s);return[C,_,Promise.race([a.then(()=>{if(!M){let s=()=>C.close(1000,"Normal Closure");if(isFinite(Q)&&Q>0)P=setTimeout(()=>{if(C.readyState===j.OPEN)s()},Q);else s()}}),h])]}function S(C){if(gO(C)&&(O_1(C.code)||[l5.InternalServerError,l5.InternalClientError,l5.BadRequest,l5.BadResponse,l5.Unauthorized,l5.SubprotocolNotAcceptable,l5.SubscriberAlreadyExists,l5.TooManyInitialisationRequests].includes(C.code)))throw C;if(k)return!1;if(gO(C)&&C.code===1000)return M>0;if(!z||O>=z)throw C;if(!H(C))throw C;return N=!0}if(!$)(async()=>{M++;for(;;)try{let[,,C]=await E();await C}catch(C){try{if(!S(C))return}catch(h){return Y?.(h)}}})();function f(C,h){let _=F(C),a=!1,s=!1,Z0=()=>{M--,a=!0};return(async()=>{M++;for(;;)try{let[o,M0,R0]=await E();if(a)return M0();let m0=B.onMessage(_,(N1)=>{switch(N1.type){case y5.Next:{h.next(N1.payload);return}case y5.Error:{s=!0,a=!0,h.error(N1.payload),Z0();return}case y5.Complete:{a=!0,Z0();return}}});o.send(i3({id:_,type:y5.Subscribe,payload:C},c)),Z0=()=>{if(!a&&o.readyState===j.OPEN)o.send(i3({id:_,type:y5.Complete},c));M--,a=!0,M0()},await R0.finally(m0);return}catch(o){if(!S(o))return}})().then(()=>{if(!s)h.complete()}).catch((o)=>{h.error(o)}),()=>{if(!a)Z0()}}return{on:B.on,subscribe:f,iterate(C){let h=[],_={done:!1,error:null,resolve:()=>{}},a=f(C,{next(Z0){h.push(Z0),_.resolve()},error(Z0){_.done=!0,_.error=Z0,_.resolve()},complete(){_.done=!0,_.resolve()}}),s=async function*(){for(;;){if(!h.length)await new Promise((o)=>_.resolve=o);while(h.length)yield h.shift();if(_.error)throw _.error;if(_.done)return}}();return s.throw=async(Z0)=>{if(!_.done)_.done=!0,_.error=Z0,_.resolve();return{done:!0,value:void 0}},s.return=async()=>{return a(),{done:!0,value:void 0}},s},async dispose(){if(k=!0,R){let[C]=await R;C.close(1000,"Normal Closure")}},terminate(){if(R)B.emit("closed",new iw)}}}class iw extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function gO(Z){return YX(Z)&&"code"in Z&&"reason"in Z}function O_1(Z){if([1000,1001,1006,1005,1012,1013,1014].includes(Z))return!1;return Z>=1000&&Z<=1999}function T_1(Z){return typeof Z==="function"&&"constructor"in Z&&"CLOSED"in Z&&"CLOSING"in Z&&"CONNECTING"in Z&&"OPEN"in Z}var K60=t(Y60(),1);var Ez="./dev/persistence",dw=process.env.HYTOPIA_NOTIFICATION_SERVICE_URL||"https://dev.notifications.hytopia.com";class O4{static instance=new O4;creatorApiKey=process.env.HYTOPIA_API_KEY;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;_gqlWs;constructor(){this._gqlWs=dO({url:"wss://prod.gql.hytopia.com/graphql",webSocketImpl:E80});try{this._creativeGateway=new K60.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 getGlobalData(Z){if(!this._creativeGateway&&process.env.NODE_ENV==="production")return y.warning("PlatformGateway.getGlobalData(): 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._readDevGlobalDataLocally(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 bf=process.env.PORT??8080,Af="0.10.35-notifications-prerelease",mf;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(mf||={});class cK extends j0{static instance=new cK;_webserver=KU.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:Af,runtime:"node"})}),this._webserver.use(KU.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(KU.default.static(Tn1.dirname(i.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Nn1.createServer(this._webserver):On1.createServer({key:QU.existsSync("assets/certs/localhost.key")?QU.readFileSync("assets/certs/localhost.key"):aY0,cert:QU.existsSync("assets/certs/localhost.crt")?QU.readFileSync("assets/certs/localhost.crt"):dY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else y.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(bf,this._onStarted),console.info(`WebServer.start(): Server running on port ${bf}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return y.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=Cn1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&R7.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 bf=process.env.PORT??8080,Af="0.10.35-notifications-prerelease-3",mf;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(mf||={});class cK extends j0{static instance=new cK;_webserver=KU.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:Af,runtime:"node"})}),this._webserver.use(KU.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(KU.default.static(Tn1.dirname(i.resolve("@hytopia.com/assets")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Nn1.createServer(this._webserver):On1.createServer({key:QU.existsSync("assets/certs/localhost.key")?QU.readFileSync("assets/certs/localhost.key"):aY0,cert:QU.existsSync("assets/certs/localhost.crt")?QU.readFileSync("assets/certs/localhost.crt"):dY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else y.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(bf,this._onStarted),console.info(`WebServer.start(): Server running on port ${bf}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return y.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=Cn1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&R7.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