hytopia 0.10.0-prerelease-10 → 0.10.0-prerelease-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/scripts.js +6 -21
- package/package.json +1 -1
- 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 YF1}from"node:buffer";import{StringDecoder as QF1}from"node:string_decoder";var NF=(Z,J,X)=>{if(X)return;if(Z)return{transform:KF1.bind(void 0,new TextEncoder)};let $=new QF1(J);return{transform:WF1.bind(void 0,$),final:GF1.bind(void 0,$)}},KF1=function*(Z,J){if(YF1.isBuffer(J))yield JZ(J);else if(typeof J==="string")yield Z.encode(J);else yield J},WF1=function*(Z,J){yield S8(J)?Z.write(J):J},GF1=function*(Z){let J=Z.end();if(J!=="")yield J};import{callbackify as mp}from"node:util";var kM=mp(async(Z,J,X,$)=>{J.currentIterable=Z(...X);try{for await(let Y of J.currentIterable)$.push(Y)}finally{delete J.currentIterable}}),DF=async function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:$=vF1}=J[X];for await(let Y of $(Z))yield*DF(Y,J,X+1)},up=async function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*zF1(X,Number(J),Z)},zF1=async function*(Z,J,X){if(Z===void 0)return;for await(let $ of Z())yield*DF($,X,J+1)},lp=mp(async({currentIterable:Z},J)=>{if(Z!==void 0){await(J?Z.throw(J):Z.return());return}if(J)throw J}),vF1=function*(Z){yield Z};var EM=(Z,J,X,$)=>{try{for(let Y of Z(...J))X.push(Y);$()}catch(Y){$(Y)}},yp=(Z,J)=>[...J.flatMap((X)=>[...B$(X,Z,0)]),...vG(Z)],B$=function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:$=VF1}=J[X];for(let Y of $(Z))yield*B$(Y,J,X+1)},vG=function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*HF1(X,Number(J),Z)},HF1=function*(Z,J,X){if(Z===void 0)return;for(let $ of Z())yield*B$($,X,J+1)},VF1=function*(Z){yield Z};var IM=({value:Z,value:{transform:J,final:X,writableObjectMode:$,readableObjectMode:Y},optionName:Q},{encoding:K})=>{let W={},G=ip(Z,K,Q),z=x$(J),v=x$(X),V=z?kM.bind(void 0,DF,W):EM.bind(void 0,B$),H=z||v?kM.bind(void 0,up,W):EM.bind(void 0,vG),q=z||v?lp.bind(void 0,W):void 0;return{stream:new qF1({writableObjectMode:$,writableHighWaterMark:pp($),readableObjectMode:Y,readableHighWaterMark:pp(Y),transform(w,U,x){V([w,G,0],this,x)},flush(w){H([G],this,w)},destroy:q})}},PF=(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=ip(K,X,W);Z=yp(G,Z)}return Z},ip=({transform:Z,final:J,binary:X,writableObjectMode:$,readableObjectMode:Y,preserveNewlines:Q},K,W)=>{let G={};return[{transform:hp($,W)},NF(X,K,$),RF(X,Q,$,G),{transform:Z,final:J},{transform:bp(Y,W)},Sp({binary:X,preserveNewlines:Q,readableObjectMode:Y,state:G})].filter(Boolean)};var gp=(Z,J)=>{for(let X of FF1(Z))wF1(Z,X,J)},FF1=(Z)=>new Set(Object.entries(Z).filter(([,{direction:J}])=>J==="input").map(([J])=>Number(J))),wF1=(Z,J,X)=>{let{stdioItems:$}=Z[J],Y=$.filter(({contents:W})=>W!==void 0);if(Y.length===0)return;if(J!==0){let[{type:W,optionName:G}]=Y;throw new TypeError(`Only the \`stdin\` option, not \`${G}\`, can be ${jJ[W]} with synchronous methods.`)}let K=Y.map(({contents:W})=>W).map((W)=>UF1(W,$));X.input=XG(K)},UF1=(Z,J)=>{let X=PF(Z,J,"utf8",!0);return xF1(X),XG(X)},xF1=(Z)=>{let J=Z.find((X)=>typeof X!=="string"&&!S8(X));if(J!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${J}.`)};import{writeFileSync as cF1,appendFileSync as OF1}from"node:fs";var CF=({stdioItems:Z,encoding:J,verboseInfo:X,fdNumber:$})=>$!=="all"&&oQ(X,$)&&!f5.has(J)&&BF1($)&&(Z.some(({type:Y,value:Q})=>Y==="native"&&LF1.has(Q))||Z.every(({type:Y})=>H4.has(Y))),BF1=(Z)=>Z===1||Z===2,LF1=new Set(["pipe","overlapped"]),dp=async(Z,J,X,$)=>{for await(let Y of Z)if(!jF1(J))np(Y,X,$)},ap=(Z,J,X)=>{for(let $ of Z)np($,J,X)},jF1=(Z)=>Z._readableState.pipes.length>0,np=(Z,J,X)=>{let $=mq(Z);r9({type:"output",verboseMessage:$,fdNumber:J,verboseInfo:X})};var sp=({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)=>MF1({result:G,fileDescriptors:Z,fdNumber:z,state:Q,outputFiles:K,isMaxBuffer:$,verboseInfo:Y},X)),...Q}},MF1=({result:Z,fileDescriptors:J,fdNumber:X,state:$,outputFiles:Y,isMaxBuffer:Q,verboseInfo:K},{buffer:W,encoding:G,lines:z,stripFinalNewline:v,maxBuffer:V})=>{if(Z===null)return;let H=oy(Z,Q,V),q=JZ(H),{stdioItems:F,objectMode:w}=J[X],U=RF1([q],F,G,$),{serializedResult:x,finalResult:L=x}=NF1({chunks:U,objectMode:w,encoding:G,lines:z,stripFinalNewline:v,fdNumber:X});DF1({serializedResult:x,fdNumber:X,state:$,verboseInfo:K,encoding:G,stdioItems:F,objectMode:w});let j=W[X]?L:void 0;try{if($.error===void 0)PF1(x,F,Y);return j}catch(c){return $.error=c,j}},RF1=(Z,J,X,$)=>{try{return PF(Z,J,X,!1)}catch(Y){return $.error=Y,Z}},NF1=({chunks:Z,objectMode:J,encoding:X,lines:$,stripFinalNewline:Y,fdNumber:Q})=>{if(J)return{serializedResult:Z};if(X==="buffer")return{serializedResult:XG(Z)};let K=vu(Z,X);if($[Q])return{serializedResult:K,finalResult:TM(K,!Y[Q],J)};return{serializedResult:K}},DF1=({serializedResult:Z,fdNumber:J,state:X,verboseInfo:$,encoding:Y,stdioItems:Q,objectMode:K})=>{if(!CF({stdioItems:Q,encoding:Y,verboseInfo:$,fdNumber:J}))return;let W=TM(Z,!1,K);try{ap(W,J,$)}catch(G){X.error??=G}},PF1=(Z,J,X)=>{for(let{path:$,append:Y}of J.filter(({type:Q})=>OF.has(Q))){let Q=typeof $==="string"?$:$.toString();if(Y||X.has(Q))OF1($,Z);else X.add(Q),cF1($,Z)}};var op=([,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,QZ(J,X,"all")];if(Array.isArray(J))return[QZ(Z,X,"all"),...J];if(S8(Z)&&S8(J))return AO([Z,J]);return`${Z}${J}`};import{once as fM}from"node:events";var rp=async(Z,J)=>{let[X,$]=await CF1(Z);return J.isForcefullyTerminated??=!1,[X,$]},CF1=async(Z)=>{let[J,X]=await Promise.allSettled([fM(Z,"spawn"),fM(Z,"exit")]);if(J.status==="rejected")return[];return X.status==="rejected"?tp(Z):X.value},tp=async(Z)=>{try{return await fM(Z,"exit")}catch{return tp(Z)}},ep=async(Z)=>{let[J,X]=await Z;if(!TF1(J,X)&&_M(J,X))throw new t9;return[J,X]},TF1=(Z,J)=>Z===void 0&&J===void 0,_M=(Z,J)=>Z!==0||J!==null;var Zi=({error:Z,status:J,signal:X,output:$},{maxBuffer:Y})=>{let Q=kF1(Z,J,X),K=Q?.code==="ETIMEDOUT",W=sy(Q,$,Y);return{resultError:Q,exitCode:J,signal:X,timedOut:K,isMaxBuffer:W}},kF1=(Z,J,X)=>{if(Z!==void 0)return Z;return _M(J,X)?new t9:void 0};var Ji=(Z,J,X)=>{let{file:$,commandArguments:Y,command:Q,escapedCommand:K,startTime:W,verboseInfo:G,options:z,fileDescriptors:v}=IF1(Z,J,X),V=SF1({file:$,commandArguments:Y,options:z,command:Q,escapedCommand:K,verboseInfo:G,fileDescriptors:v,startTime:W});return QK(V,G,z)},IF1=(Z,J,X)=>{let{command:$,escapedCommand:Y,startTime:Q,verboseInfo:K}=lq(Z,J,X),W=fF1(X),{file:G,commandArguments:z,options:v}=vF(Z,J,W);_F1(v);let V=Ep(v,K);return{file:G,commandArguments:z,command:$,escapedCommand:Y,startTime:Q,verboseInfo:K,options:v,fileDescriptors:V}},fF1=(Z)=>Z.node&&!Z.ipc?{...Z,ipc:!1}:Z,_F1=({ipc:Z,ipcInput:J,detached:X,cancelSignal:$})=>{if(J)TF("ipcInput");if(Z)TF("ipc: true");if(X)TF("detached: true");if($)TF("cancelSignal")},TF=(Z)=>{throw new TypeError(`The "${Z}" option cannot be used with synchronous methods.`)},SF1=({file:Z,commandArguments:J,options:X,command:$,escapedCommand:Y,verboseInfo:Q,fileDescriptors:K,startTime:W})=>{let G=hF1({file:Z,commandArguments:J,options:X,command:$,escapedCommand:Y,fileDescriptors:K,startTime:W});if(G.failed)return G;let{resultError:z,exitCode:v,signal:V,timedOut:H,isMaxBuffer:q}=Zi(G,X),{output:F,error:w=z}=sp({fileDescriptors:K,syncResult:G,options:X,isMaxBuffer:q,verboseInfo:Q}),U=F.map((L,j)=>QZ(L,X,j)),x=QZ(op(F,X),X,"all");return AF1({error:w,exitCode:v,signal:V,timedOut:H,isMaxBuffer:q,stdio:U,all:x,options:X,command:$,escapedCommand:Y,startTime:W})},hF1=({file:Z,commandArguments:J,options:X,command:$,escapedCommand:Y,fileDescriptors:Q,startTime:K})=>{try{gp(Q,X);let W=bF1(X);return EF1(Z,J,W)}catch(W){return YK({error:W,command:$,escapedCommand:Y,fileDescriptors:Q,options:X,startTime:K,isSync:!0})}},bF1=({encoding:Z,maxBuffer:J,...X})=>({...X,encoding:"buffer",maxBuffer:BF(J)}),AF1=({error:Z,exitCode:J,signal:X,timedOut:$,isMaxBuffer:Y,stdio:Q,all:K,options:W,command:G,escapedCommand:z,startTime:v})=>Z===void 0?LF({command:G,escapedCommand:z,stdio:Q,all:K,ipcOutput:[],options:W,startTime:v}):zG({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 NU1}from"node:events";import{spawn as DU1}from"node:child_process";import Ki from"node:process";import{once as SM,on as mF1}from"node:events";var Xi=({anyProcess:Z,channel:J,isSubprocess:X,ipc:$},{reference:Y=!0,filter:Q}={})=>{return eQ({methodName:"getOneMessage",isSubprocess:X,ipc:$,isConnected:YF(Z)}),uF1({anyProcess:Z,channel:J,isSubprocess:X,filter:Q,reference:Y})},uF1=async({anyProcess:Z,channel:J,isSubprocess:X,filter:$,reference:Y})=>{ZF(J,Y);let Q=LJ(Z,J,X),K=new AbortController;try{return await Promise.race([lF1(Q,$,K),yF1(Q,X,K),pF1(Q,X,K)])}catch(W){throw ZK(Z),W}finally{K.abort(),JF(J,Y)}},lF1=async(Z,J,{signal:X})=>{if(J===void 0){let[$]=await SM(Z,"message",{signal:X});return $}for await(let[$]of mF1(Z,"message",{signal:X}))if(J($))return $},yF1=async(Z,J,{signal:X})=>{await SM(Z,"disconnect",{signal:X}),ll(J)},pF1=async(Z,J,{signal:X})=>{let[$]=await SM(Z,"strict:error",{signal:X});throw rq($,J)};import{once as Yi,on as iF1}from"node:events";var Qi=({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})=>{eQ({methodName:"getEachMessage",isSubprocess:X,ipc:$,isConnected:YF(Z)}),ZF(J,Q);let K=LJ(Z,J,X),W=new AbortController,G={};return gF1(Z,K,W),dF1({ipcEmitter:K,isSubprocess:X,controller:W,state:G}),aF1({anyProcess:Z,channel:J,ipcEmitter:K,isSubprocess:X,shouldAwait:Y,controller:W,state:G,reference:Q})},gF1=async(Z,J,X)=>{try{await Yi(J,"disconnect",{signal:X.signal}),X.abort()}catch{}},dF1=async({ipcEmitter:Z,isSubprocess:J,controller:X,state:$})=>{try{let[Y]=await Yi(Z,"strict:error",{signal:X.signal});$.error=rq(Y,J),X.abort()}catch{}},aF1=async function*({anyProcess:Z,channel:J,ipcEmitter:X,isSubprocess:$,shouldAwait:Y,controller:Q,state:K,reference:W}){try{for await(let[G]of iF1(X,"message",{signal:Q.signal}))$i(K),yield G}catch{$i(K)}finally{if(Q.abort(),JF(J,W),!$)ZK(Z);if(Y)await Z}},$i=({error:Z})=>{if(Z)throw Z};var Wi=(Z,{ipc:J})=>{Object.assign(Z,zi(Z,!1,J))},Gi=()=>{let Z=Ki,J=!0,X=Ki.channel!==void 0;return{...zi(Z,!0,X),getCancelSignal:Fy.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:!0,ipc:X})}},zi=(Z,J,X)=>({sendMessage:GF.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getOneMessage:Xi.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getEachMessage:Qi.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X})});import{ChildProcess as nF1}from"node:child_process";import{PassThrough as sF1,Readable as oF1,Writable as rF1,Duplex as tF1}from"node:stream";var vi=({error:Z,command:J,escapedCommand:X,fileDescriptors:$,options:Y,startTime:Q,verboseInfo:K})=>{DM($);let W=new nF1;eF1(W,$),Object.assign(W,{readable:Zw1,writable:Jw1,duplex:Xw1});let G=YK({error:Z,command:J,escapedCommand:X,fileDescriptors:$,options:Y,startTime:Q,isSync:!1}),z=$w1(G,K,Y);return{subprocess:W,promise:z}},eF1=(Z,J)=>{let X=HG(),$=HG(),Y=HG(),Q=Array.from({length:J.length-3},HG),K=HG(),W=[X,$,Y,...Q];Object.assign(Z,{stdin:X,stdout:$,stderr:Y,all:K,stdio:W})},HG=()=>{let Z=new sF1;return Z.end(),Z},Zw1=()=>new oF1({read(){}}),Jw1=()=>new rF1({write(){}}),Xw1=()=>new tF1({read(){},write(){}}),$w1=async(Z,J,X)=>QK(Z,J,X);import{createReadStream as Hi,createWriteStream as Vi}from"node:fs";import{Buffer as Yw1}from"node:buffer";import{Readable as VG,Writable as Qw1,Duplex as Kw1}from"node:stream";var Fi=(Z,J)=>MF(Ww1,Z,J,!1),qG=({type:Z,optionName:J})=>{throw new TypeError(`The \`${J}\` option cannot be ${jJ[Z]}.`)},qi={fileNumber:qG,generator:IM,asyncGenerator:IM,nodeStream:({value:Z})=>({stream:Z}),webTransform({value:{transform:Z,writableObjectMode:J,readableObjectMode:X}}){let $=J||X;return{stream:Kw1.fromWeb(Z,{objectMode:$})}},duplex:({value:{transform:Z}})=>({stream:Z}),native(){}},Ww1={input:{...qi,fileUrl:({value:Z})=>({stream:Hi(Z)}),filePath:({value:{file:Z}})=>({stream:Hi(Z)}),webStream:({value:Z})=>({stream:VG.fromWeb(Z)}),iterable:({value:Z})=>({stream:VG.from(Z)}),asyncIterable:({value:Z})=>({stream:VG.from(Z)}),string:({value:Z})=>({stream:VG.from(Z)}),uint8Array:({value:Z})=>({stream:VG.from(Yw1.from(Z))})},output:{...qi,fileUrl:({value:Z})=>({stream:Vi(Z)}),filePath:({value:{file:Z,append:J}})=>({stream:Vi(Z,J?{flags:"a"}:{})}),webStream:({value:Z})=>({stream:Qw1.fromWeb(Z)}),iterable:qG,asyncIterable:qG,string:qG,uint8Array:qG}};import{on as Gw1,once as wi}from"node:events";import{PassThrough as zw1,getDefaultHighWaterMark as vw1}from"node:stream";import{finished as Bi}from"node:stream/promises";function L$(Z){if(!Array.isArray(Z))throw new TypeError(`Expected an array, got \`${typeof Z}\`.`);for(let Y of Z)bM(Y);let J=Z.some(({readableObjectMode:Y})=>Y),X=Hw1(Z,J),$=new Li({objectMode:J,writableHighWaterMark:X,readableHighWaterMark:X});for(let Y of Z)$.add(Y);return $}var Hw1=(Z,J)=>{if(Z.length===0)return vw1(J);let X=Z.filter(({readableObjectMode:$})=>$===J).map(({readableHighWaterMark:$})=>$);return Math.max(...X)};class Li extends zw1{#Z=new Set([]);#J=new Set([]);#$=new Set([]);#X;#Y=Symbol("unpipe");#v=new WeakMap;add(Z){if(bM(Z),this.#Z.has(Z))return;this.#Z.add(Z),this.#X??=Vw1(this,this.#Z,this.#Y);let J=ww1({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(bM(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 Vw1=async(Z,J,X)=>{kF(Z,Ui);let $=new AbortController;try{await Promise.race([qw1(Z,$),Fw1(Z,J,X,$)])}finally{$.abort(),kF(Z,-Ui)}},qw1=async(Z,{signal:J})=>{try{await Bi(Z,{signal:J,cleanup:!0})}catch(X){throw ji(Z,X),X}},Fw1=async(Z,J,X,{signal:$})=>{for await(let[Y]of Gw1(Z,"unpipe",{signal:$}))if(J.has(Y))Y.emit(X)},bM=(Z)=>{if(typeof Z?.pipe!=="function")throw new TypeError(`Expected a readable stream, got: \`${typeof Z}\`.`)},ww1=async({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,onFinished:Q,unpipeEvent:K})=>{kF(Z,xi);let W=new AbortController;try{await Promise.race([Uw1(Q,J,W),xw1({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,controller:W}),Bw1({stream:J,streams:X,ended:$,aborted:Y,unpipeEvent:K,controller:W})])}finally{W.abort(),kF(Z,-xi)}if(X.size>0&&X.size===$.size+Y.size)if($.size===0&&Y.size>0)AM(Z);else Lw1(Z)},Uw1=async(Z,J,{signal:X})=>{try{if(await Z,!X.aborted)AM(J)}catch($){if(!X.aborted)ji(J,$)}},xw1=async({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,controller:{signal:Q}})=>{try{if(await Bi(J,{signal:Q,cleanup:!0,readable:!0,writable:!1}),X.has(J))$.add(J)}catch(K){if(Q.aborted||!X.has(J))return;if(ci(K))Y.add(J);else Oi(Z,K)}},Bw1=async({stream:Z,streams:J,ended:X,aborted:$,unpipeEvent:Y,controller:{signal:Q}})=>{if(await wi(Z,Y,{signal:Q}),!Z.readable)return wi(Q,"abort",{signal:Q});J.delete(Z),X.delete(Z),$.delete(Z)},Lw1=(Z)=>{if(Z.writable)Z.end()},ji=(Z,J)=>{if(ci(J))AM(Z);else Oi(Z,J)},ci=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",AM=(Z)=>{if(Z.readable||Z.writable)Z.destroy()},Oi=(Z,J)=>{if(!Z.destroyed)Z.once("error",jw1),Z.destroy(J)},jw1=()=>{},kF=(Z,J)=>{let X=Z.getMaxListeners();if(X!==0&&X!==Number.POSITIVE_INFINITY)Z.setMaxListeners(X+J)},Ui=2,xi=1;import{finished as Mi}from"node:stream/promises";var WK=(Z,J)=>{Z.pipe(J),cw1(Z,J),Ow1(Z,J)},cw1=async(Z,J)=>{if(z9(Z)||z9(J))return;try{await Mi(Z,{cleanup:!0,readable:!0,writable:!1})}catch{}mM(J)},mM=(Z)=>{if(Z.writable)Z.end()},Ow1=async(Z,J)=>{if(z9(Z)||z9(J))return;try{await Mi(J,{cleanup:!0,readable:!1,writable:!0})}catch{}uM(Z)},uM=(Z)=>{if(Z.readable)Z.destroy()};var Ri=(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})=>H4.has(G)))Mw1(Z,W,K,Y);for(let{stream:W}of Q.filter(({type:G})=>!H4.has(G)))Nw1({subprocess:Z,stream:W,direction:K,fdNumber:Y,pipeGroups:$,controller:X})}for(let[Y,Q]of $.entries()){let K=Q.length===1?Q[0]:L$(Q);WK(K,Y)}},Mw1=(Z,J,X,$)=>{if(X==="output")WK(Z.stdio[$],J);else WK(J,Z.stdio[$]);let Y=Rw1[$];if(Y!==void 0)Z[Y]=J;Z.stdio[$]=J},Rw1=["stdin","stdout","stderr"],Nw1=({subprocess:Z,stream:J,direction:X,fdNumber:$,pipeGroups:Y,controller:Q})=>{if(J===void 0)return;Dw1(J,Q);let[K,W]=X==="output"?[J,Z.stdio[$]]:[Z.stdio[$],J],G=Y.get(K)??[];Y.set(K,[...G,W])},Dw1=(Z,{signal:J})=>{if(z9(Z))w$(Z,Pw1,J)},Pw1=2;import{addAbortListener as kw1}from"node:events";var j$=[];j$.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")j$.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")j$.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var EF=(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",lM=Symbol.for("signal-exit emitter"),yM=globalThis,Cw1=Object.defineProperty.bind(Object);class Ni{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(yM[lM])return yM[lM];Cw1(yM,lM,{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 iM{}var Tw1=(Z)=>{return{onExit(J,X){return Z.onExit(J,X)},load(){return Z.load()},unload(){return Z.unload()}}};class Di extends iM{onExit(){return()=>{}}load(){}unload(){}}class Pi extends iM{#Z=pM.platform==="win32"?"SIGINT":"SIGHUP";#J=new Ni;#$;#X;#Y;#v={};#V=!1;constructor(Z){super();this.#$=Z,this.#v={};for(let J of j$)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(!EF(this.#$))return()=>{};if(this.#V===!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.#V)return;this.#V=!0,this.#J.count+=1;for(let Z of j$)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.#V)return;this.#V=!1,j$.forEach((Z)=>{let J=this.#v[Z];if(!J)throw new Error("Listener not defined for signal: "+Z);try{this.#$.removeListener(Z,J)}catch(X){}}),this.#$.emit=this.#X,this.#$.reallyExit=this.#Y,this.#J.count-=1}#W(Z){if(!EF(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"&&EF(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 pM=globalThis.process,{onExit:Ci,load:VO6,unload:qO6}=Tw1(EF(pM)?new Pi(pM):new Di);var Ti=(Z,{cleanup:J,detached:X},{signal:$})=>{if(!J||X)return;let Y=Ci(()=>{Z.kill()});kw1($,()=>{Y()})};var Ei=({source:Z,sourcePromise:J,boundOptions:X,createNested:$},...Y)=>{let Q=uq(),{destination:K,destinationStream:W,destinationError:G,from:z,unpipeSignal:v}=Ew1(X,$,Y),{sourceStream:V,sourceError:H}=fw1(Z,z),{options:q,fileDescriptors:F}=Z7.get(Z);return{sourcePromise:J,sourceStream:V,sourceOptions:q,sourceError:H,destination:K,destinationStream:W,destinationError:G,unpipeSignal:v,fileDescriptors:F,startTime:Q}},Ew1=(Z,J,X)=>{try{let{destination:$,pipeOptions:{from:Y,to:Q,unpipeSignal:K}={}}=Iw1(Z,J,...X),W=eq($,Q);return{destination:$,destinationStream:W,from:Y,unpipeSignal:K}}catch($){return{destinationError:$}}},Iw1=(Z,J,X,...$)=>{if(Array.isArray(X))return{destination:J(ki,Z)(X,...$),pipeOptions:Z};if(typeof X==="string"||X instanceof URL||hO(X)){if(Object.keys(Z).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[Y,Q,K]=kq(X,...$);return{destination:J(ki)(Y,Q,K),pipeOptions:K}}if(Z7.has(X)){if(Object.keys(Z).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:X,pipeOptions:$[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${X}`)},ki=({options:Z})=>({options:{...Z,stdin:"pipe",piped:!0}}),fw1=(Z,J)=>{try{return{sourceStream:JK(Z,J)}}catch(X){return{sourceError:X}}};var fi=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$,fileDescriptors:Y,sourceOptions:Q,startTime:K})=>{let W=_w1({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$});if(W!==void 0)throw gM({error:W,fileDescriptors:Y,sourceOptions:Q,startTime:K})},_w1=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$})=>{if(J!==void 0&&$!==void 0)return $;if($!==void 0)return uM(Z),$;if(J!==void 0)return mM(X),J},gM=({error:Z,fileDescriptors:J,sourceOptions:X,startTime:$})=>YK({error:Z,command:Ii,escapedCommand:Ii,fileDescriptors:J,options:X,startTime:$,isSync:!1}),Ii="source.pipe(destination)";var _i=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 Sw1}from"node:stream/promises";var Si=(Z,J,X)=>{let $=IF.has(J)?bw1(Z,J):hw1(Z,J);return w$(Z,mw1,X.signal),w$(J,uw1,X.signal),Aw1(J),$},hw1=(Z,J)=>{let X=L$([Z]);return WK(X,J),IF.set(J,X),X},bw1=(Z,J)=>{let X=IF.get(J);return X.add(Z),X},Aw1=async(Z)=>{try{await Sw1(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}IF.delete(Z)},IF=new WeakMap,mw1=2,uw1=1;import{aborted as lw1}from"node:util";var hi=(Z,J)=>Z===void 0?[]:[yw1(Z,J)],yw1=async(Z,{sourceStream:J,mergedStream:X,fileDescriptors:$,sourceOptions:Y,startTime:Q})=>{await lw1(Z,J),await X.remove(J);let K=new Error("Pipe canceled by `unpipeSignal` option.");throw gM({error:K,fileDescriptors:$,sourceOptions:Y,startTime:Q})};var fF=(Z,...J)=>{if(U8(J[0]))return fF.bind(void 0,{...Z,boundOptions:{...Z.boundOptions,...J[0]}});let{destination:X,...$}=Ei(Z,...J),Y=pw1({...$,destination:X});return Y.pipe=fF.bind(void 0,{...Z,source:X,sourcePromise:Y,boundOptions:{}}),Y},pw1=async({sourcePromise:Z,sourceStream:J,sourceOptions:X,sourceError:$,destination:Y,destinationStream:Q,destinationError:K,unpipeSignal:W,fileDescriptors:G,startTime:z})=>{let v=iw1(Z,Y);fi({sourceStream:J,sourceError:$,destinationStream:Q,destinationError:K,fileDescriptors:G,sourceOptions:X,startTime:z});let V=new AbortController;try{let H=Si(J,Q,V);return await Promise.race([_i(v),...hi(W,{sourceStream:J,mergedStream:H,sourceOptions:X,fileDescriptors:G,startTime:z})])}finally{V.abort()}},iw1=(Z,J)=>Promise.allSettled([Z,J]);import{setImmediate as rw1}from"node:timers/promises";import{on as gw1}from"node:events";import{getDefaultHighWaterMark as dw1}from"node:stream";var _F=({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:$,encoding:Y,preserveNewlines:Q})=>{let K=new AbortController;return aw1(J,K),Ai({stream:Z,controller:K,binary:X,shouldEncode:!Z.readableObjectMode&&$,encoding:Y,shouldSplit:!Z.readableObjectMode,preserveNewlines:Q})},aw1=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;nw1(J,K,Z);let W=Z.readableObjectMode&&!Q;return Ai({stream:Z,controller:K,binary:$==="buffer",shouldEncode:!W,encoding:$,shouldSplit:!W&&X,preserveNewlines:!Y})},nw1=async(Z,J,X)=>{try{await Z}catch{X.destroy()}finally{J.abort()}},Ai=({stream:Z,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K})=>{let W=gw1(Z,"data",{signal:J.signal,highWaterMark:bi,highWatermark:bi});return sw1({onStdoutChunk:W,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K})},aM=dw1(!0),bi=aM,sw1=async function*({onStdoutChunk:Z,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K}){let W=ow1({binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K});try{for await(let[G]of Z)yield*B$(G,W,0)}catch(G){if(!J.signal.aborted)throw G}finally{yield*vG(W)}},ow1=({binary:Z,shouldEncode:J,encoding:X,shouldSplit:$,preserveNewlines:Y})=>[NF(Z,X,!J),RF(Z,Y,!$,{})].filter(Boolean);var mi=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,buffer:Y,maxBuffer:Q,lines:K,allMixed:W,stripFinalNewline:G,verboseInfo:z,streamInfo:v})=>{let V=tw1({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,allMixed:W,verboseInfo:z,streamInfo:v});if(!Y){await Promise.all([ew1(Z),V]);return}let H=PM(G,X),q=dM({stream:Z,onStreamEnd:J,lines:K,encoding:$,stripFinalNewline:H,allMixed:W}),[F]=await Promise.all([ZU1({stream:Z,iterable:q,fdNumber:X,encoding:$,maxBuffer:Q,lines:K}),V]);return F},tw1=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,allMixed:Y,verboseInfo:Q,streamInfo:{fileDescriptors:K}})=>{if(!CF({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 dp(W,Z,X,Q)},ew1=async(Z)=>{if(await rw1(),Z.readableFlowing===null)Z.resume()},ZU1=async({stream:Z,stream:{readableObjectMode:J},iterable:X,fdNumber:$,encoding:Y,maxBuffer:Q,lines:K})=>{try{if(J||K)return await FF(X,{maxBuffer:Q});if(Y==="buffer")return new Uint8Array(await wF(X,{maxBuffer:Q}));return await xF(X,{maxBuffer:Q})}catch(W){return ui(dy({error:W,stream:Z,readableObjectMode:J,lines:K,encoding:Y,fdNumber:$}))}},nM=async(Z)=>{try{return await Z}catch(J){return ui(J)}},ui=({bufferedData:Z})=>Gu(Z)?new Uint8Array(Z):Z;import{finished as JU1}from"node:stream/promises";var FG=async(Z,J,X,{isSameDirection:$,stopOnExit:Y=!1}={})=>{let Q=XU1(Z,X),K=new AbortController;try{await Promise.race([...Y?[X.exitPromise]:[],JU1(Z,{cleanup:!0,signal:K.signal})])}catch(W){if(!Q.stdinCleanedUp)QU1(W,J,X,$)}finally{K.abort()}},XU1=(Z,{originalStreams:[J],subprocess:X})=>{let $={stdinCleanedUp:!1};if(Z===J)$U1(Z,X,$);return $},$U1=(Z,J,X)=>{let{_destroy:$}=Z;Z._destroy=(...Y)=>{YU1(J,X),$.call(Z,...Y)}},YU1=({exitCode:Z,signalCode:J},X)=>{if(Z!==null||J!==null)X.stdinCleanedUp=!0},QU1=(Z,J,X,$)=>{if(!KU1(Z,J,X,$))throw Z},KU1=(Z,J,X,$=!0)=>{if(X.propagating)return li(Z)||SF(Z);return X.propagating=!0,sM(X,J)===$?li(Z):SF(Z)},sM=({fileDescriptors:Z},J)=>J!=="all"&&Z[J].direction==="input",SF=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",li=(Z)=>Z?.code==="EPIPE";var yi=({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>Z.stdio.map((G,z)=>oM({stream:G,fdNumber:z,encoding:J,buffer:X[z],maxBuffer:$[z],lines:Y[z],allMixed:!1,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})),oM=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=FG(Z,J,z);if(sM(z,J)){await v;return}let[V]=await Promise.all([mi({stream:Z,onStreamEnd:v,fdNumber:J,encoding:X,buffer:$,maxBuffer:Y,lines:Q,allMixed:K,stripFinalNewline:W,verboseInfo:G,streamInfo:z}),v]);return V};var pi=({stdout:Z,stderr:J},{all:X})=>X&&(Z||J)?L$([Z,J].filter(Boolean)):void 0,ii=({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>oM({...WU1(Z,X),fdNumber:"all",encoding:J,maxBuffer:$[1]+$[2],lines:Y[1]||Y[2],allMixed:GU1(Z),stripFinalNewline:Q,verboseInfo:K,streamInfo:W}),WU1=({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}},GU1=({all:Z,stdout:J,stderr:X})=>Z&&J&&X&&J.readableObjectMode!==X.readableObjectMode;import{once as zU1}from"node:events";var gi=(Z)=>oQ(Z,"ipc"),di=(Z,J)=>{let X=mq(Z);r9({type:"ipc",verboseMessage:X,fdNumber:"ipc",verboseInfo:J})};var ai=async({subprocess:Z,buffer:J,maxBuffer:X,ipc:$,ipcOutput:Y,verboseInfo:Q})=>{if(!$)return Y;let K=gi(Q),W=XZ(J,"ipc"),G=XZ(X,"ipc");for await(let z of hM({anyProcess:Z,channel:Z.channel,isSubprocess:!1,ipc:$,shouldAwait:!1,reference:!0})){if(W)ay(Z,Y,G),Y.push(z);if(K)di(z,Q)}return Y},ni=async(Z,J)=>{return await Promise.allSettled([Z]),J};var si=async({subprocess:Z,options:{encoding:J,buffer:X,maxBuffer:$,lines:Y,timeoutDuration:Q,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,stripFinalNewline:z,ipc:v,ipcInput:V},context:H,verboseInfo:q,fileDescriptors:F,originalStreams:w,onInternalError:U,controller:x})=>{let L=rp(Z,H),j={originalStreams:w,fileDescriptors:F,subprocess:Z,exitPromise:L,propagating:!1},c=yi({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:z,verboseInfo:q,streamInfo:j}),R=ii({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:z,verboseInfo:q,streamInfo:j}),M=[],N=ai({subprocess:Z,buffer:X,maxBuffer:$,ipc:v,ipcOutput:M,verboseInfo:q}),D=vU1(w,Z,j),P=HU1(F,j);try{return await Promise.race([Promise.all([{},ep(L),Promise.all(c),R,N,Ry(Z,V),...D,...P]),U,VU1(Z,x),...Ly(Z,Q,H,x),...ul({subprocess:Z,cancelSignal:K,gracefulCancel:W,context:H,controller:x}),...xy({subprocess:Z,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,context:H,controller:x})])}catch(f){return H.terminationReason??="other",Promise.all([{error:f},L,Promise.all(c.map((E)=>nM(E))),nM(R),ni(N,M),Promise.allSettled(D),Promise.allSettled(P)])}},vU1=(Z,J,X)=>Z.map(($,Y)=>$===J.stdio[Y]?void 0:FG($,Y,X)),HU1=(Z,J)=>Z.flatMap(({stdioItems:X},$)=>X.filter(({value:Y,stream:Q=Y})=>H9(Q,{checkOpen:!1})&&!z9(Q)).map(({type:Y,value:Q,stream:K=Q})=>FG(K,$,J,{isSameDirection:H4.has(Y),stopOnExit:Y==="native"}))),VU1=async(Z,{signal:J})=>{let[X]=await zU1(Z,"error",{signal:J});throw X};var oi=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),wG=(Z,J,X)=>{let $=Z[X];if(!$.has(J))$.set(J,[]);let Y=$.get(J),Q=e9();return Y.push(Q),{resolve:Q.resolve.bind(Q),promises:Y}},GK=async({resolve:Z,promises:J},X)=>{Z();let[$]=await Promise.race([Promise.allSettled([!0,X]),Promise.all([!1,...J])]);return!$};import{Readable as qU1}from"node:stream";import{callbackify as FU1}from"node:util";import{finished as ri}from"node:stream/promises";var rM=async(Z)=>{if(Z===void 0)return;try{await tM(Z)}catch{}},ti=async(Z)=>{if(Z===void 0)return;try{await eM(Z)}catch{}},tM=async(Z)=>{await ri(Z,{cleanup:!0,readable:!1,writable:!0})},eM=async(Z)=>{await ri(Z,{cleanup:!0,readable:!0,writable:!1})},hF=async(Z,J)=>{if(await Z,J)throw J},bF=(Z,J,X)=>{if(X&&!SF(X))Z.destroy(X);else if(J)Z.destroy()};var ei=({subprocess:Z,concurrentStreams:J,encoding:X},{from:$,binary:Y=!0,preserveNewlines:Q=!0}={})=>{let K=Y||f5.has(X),{subprocessStdout:W,waitReadableDestroy:G}=ZR(Z,$,J),{readableEncoding:z,readableObjectMode:v,readableHighWaterMark:V}=JR(W,K),{read:H,onStdoutDataDone:q}=XR({subprocessStdout:W,subprocess:Z,binary:K,encoding:X,preserveNewlines:Q}),F=new qU1({read:H,destroy:FU1(YR.bind(void 0,{subprocessStdout:W,subprocess:Z,waitReadableDestroy:G})),highWaterMark:V,objectMode:v,encoding:z});return $R({subprocessStdout:W,onStdoutDataDone:q,readable:F,subprocess:Z}),F},ZR=(Z,J,X)=>{let $=JK(Z,J),Y=wG(X,$,"readableDestroy");return{subprocessStdout:$,waitReadableDestroy:Y}},JR=({readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X},$)=>$?{readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X}:{readableEncoding:Z,readableObjectMode:!0,readableHighWaterMark:aM},XR=({subprocessStdout:Z,subprocess:J,binary:X,encoding:$,preserveNewlines:Y})=>{let Q=e9(),K=_F({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:!X,encoding:$,preserveNewlines:Y});return{read(){wU1(this,K,Q)},onStdoutDataDone:Q}},wU1=async(Z,J,X)=>{try{let{value:$,done:Y}=await J.next();if(Y)X.resolve();else Z.push($)}catch{}},$R=async({subprocessStdout:Z,onStdoutDataDone:J,readable:X,subprocess:$,subprocessStdin:Y})=>{try{if(await eM(Z),await $,await rM(Y),await J,X.readable)X.push(null)}catch(Q){await rM(Y),Zg(X,Q)}},YR=async({subprocessStdout:Z,subprocess:J,waitReadableDestroy:X},$)=>{if(await GK(X,J))Zg(Z,$),await hF(J,$)},Zg=(Z,J)=>{bF(Z,Z.readable,J)};import{Writable as UU1}from"node:stream";import{callbackify as Jg}from"node:util";var Xg=({subprocess:Z,concurrentStreams:J},{to:X}={})=>{let{subprocessStdin:$,waitWritableFinal:Y,waitWritableDestroy:Q}=QR(Z,X,J),K=new UU1({...KR($,Z,Y),destroy:Jg(GR.bind(void 0,{subprocessStdin:$,subprocess:Z,waitWritableFinal:Y,waitWritableDestroy:Q})),highWaterMark:$.writableHighWaterMark,objectMode:$.writableObjectMode});return WR($,K),K},QR=(Z,J,X)=>{let $=eq(Z,J),Y=wG(X,$,"writableFinal"),Q=wG(X,$,"writableDestroy");return{subprocessStdin:$,waitWritableFinal:Y,waitWritableDestroy:Q}},KR=(Z,J,X)=>({write:xU1.bind(void 0,Z),final:Jg(BU1.bind(void 0,Z,J,X))}),xU1=(Z,J,X,$)=>{if(Z.write(J,X))$();else Z.once("drain",$)},BU1=async(Z,J,X)=>{if(await GK(X,J)){if(Z.writable)Z.end();await J}},WR=async(Z,J,X)=>{try{if(await tM(Z),J.writable)J.end()}catch($){await ti(X),$g(J,$)}},GR=async({subprocessStdin:Z,subprocess:J,waitWritableFinal:X,waitWritableDestroy:$},Y)=>{if(await GK(X,J),await GK($,J))$g(Z,Y),await hF(J,Y)},$g=(Z,J)=>{bF(Z,Z.writable,J)};import{Duplex as LU1}from"node:stream";import{callbackify as jU1}from"node:util";var Yg=({subprocess:Z,concurrentStreams:J,encoding:X},{from:$,to:Y,binary:Q=!0,preserveNewlines:K=!0}={})=>{let W=Q||f5.has(X),{subprocessStdout:G,waitReadableDestroy:z}=ZR(Z,$,J),{subprocessStdin:v,waitWritableFinal:V,waitWritableDestroy:H}=QR(Z,Y,J),{readableEncoding:q,readableObjectMode:F,readableHighWaterMark:w}=JR(G,W),{read:U,onStdoutDataDone:x}=XR({subprocessStdout:G,subprocess:Z,binary:W,encoding:X,preserveNewlines:K}),L=new LU1({read:U,...KR(v,Z,V),destroy:jU1(cU1.bind(void 0,{subprocessStdout:G,subprocessStdin:v,subprocess:Z,waitReadableDestroy:z,waitWritableFinal:V,waitWritableDestroy:H})),readableHighWaterMark:w,writableHighWaterMark:v.writableHighWaterMark,readableObjectMode:F,writableObjectMode:v.writableObjectMode,encoding:q});return $R({subprocessStdout:G,onStdoutDataDone:x,readable:L,subprocess:Z,subprocessStdin:v}),WR(v,L,G),L},cU1=async({subprocessStdout:Z,subprocessStdin:J,subprocess:X,waitReadableDestroy:$,waitWritableFinal:Y,waitWritableDestroy:Q},K)=>{await Promise.all([YR({subprocessStdout:Z,subprocess:X,waitReadableDestroy:$},K),GR({subprocessStdin:J,subprocess:X,waitWritableFinal:Y,waitWritableDestroy:Q},K)])};var zR=(Z,J,{from:X,binary:$=!1,preserveNewlines:Y=!1}={})=>{let Q=$||f5.has(J),K=JK(Z,X),W=_F({subprocessStdout:K,subprocess:Z,binary:Q,shouldEncode:!0,encoding:J,preserveNewlines:Y});return OU1(W,K,Z)},OU1=async function*(Z,J,X){try{yield*Z}finally{if(J.readable)J.destroy();await X}};var Qg=(Z,{encoding:J})=>{let X=oi();Z.readable=ei.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.writable=Xg.bind(void 0,{subprocess:Z,concurrentStreams:X}),Z.duplex=Yg.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.iterable=zR.bind(void 0,Z,J),Z[Symbol.asyncIterator]=zR.bind(void 0,Z,J,{})};var Kg=(Z,J)=>{for(let[X,$]of RU1){let Y=$.value.bind(J);Reflect.defineProperty(Z,X,{...$,value:Y})}},MU1=(async()=>{})().constructor.prototype,RU1=["then","catch","finally"].map((Z)=>[Z,Reflect.getOwnPropertyDescriptor(MU1,Z)]);var Wg=(Z,J,X,$)=>{let{file:Y,commandArguments:Q,command:K,escapedCommand:W,startTime:G,verboseInfo:z,options:v,fileDescriptors:V}=PU1(Z,J,X),{subprocess:H,promise:q}=TU1({file:Y,commandArguments:Q,options:v,startTime:G,verboseInfo:z,command:K,escapedCommand:W,fileDescriptors:V});return H.pipe=fF.bind(void 0,{source:H,sourcePromise:q,boundOptions:{},createNested:$}),Kg(H,q),Z7.set(H,{options:v,fileDescriptors:V}),H},PU1=(Z,J,X)=>{let{command:$,escapedCommand:Y,startTime:Q,verboseInfo:K}=lq(Z,J,X),{file:W,commandArguments:G,options:z}=vF(Z,J,X),v=CU1(z),V=Fi(v,K);return{file:W,commandArguments:G,command:$,escapedCommand:Y,startTime:Q,verboseInfo:K,options:v,fileDescriptors:V}},CU1=({timeout:Z,signal:J,...X})=>{if(J!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...X,timeoutDuration:Z}},TU1=({file:Z,commandArguments:J,options:X,startTime:$,verboseInfo:Y,command:Q,escapedCommand:K,fileDescriptors:W})=>{let G;try{G=DU1(Z,J,X)}catch(F){return vi({error:F,command:Q,escapedCommand:K,fileDescriptors:W,options:X,startTime:$,verboseInfo:Y})}let z=new AbortController;NU1(Number.POSITIVE_INFINITY,z.signal);let v=[...G.stdio];Ri(G,W,z),Ti(G,X,z);let V={},H=e9();G.kill=Al.bind(void 0,{kill:G.kill.bind(G),options:X,onInternalError:H,context:V,controller:z}),G.all=pi(G,X),Qg(G,X),Wi(G,X);let q=kU1({subprocess:G,options:X,startTime:$,verboseInfo:Y,fileDescriptors:W,originalStreams:v,command:Q,escapedCommand:K,context:V,onInternalError:H,controller:z});return{subprocess:G,promise:q}},kU1=async({subprocess:Z,options:J,startTime:X,verboseInfo:$,fileDescriptors:Y,originalStreams:Q,command:K,escapedCommand:W,context:G,onInternalError:z,controller:v})=>{let[V,[H,q],F,w,U]=await si({subprocess:Z,options:J,context:G,verboseInfo:$,fileDescriptors:Y,originalStreams:Q,onInternalError:z,controller:v});v.abort(),z.resolve();let x=F.map((c,R)=>QZ(c,J,R)),L=QZ(w,J,"all"),j=EU1({errorInfo:V,exitCode:H,signal:q,stdio:x,all:L,ipcOutput:U,context:G,options:J,command:K,escapedCommand:W,startTime:X});return QK(j,$,J)},EU1=({errorInfo:Z,exitCode:J,signal:X,stdio:$,all:Y,ipcOutput:Q,context:K,options:W,command:G,escapedCommand:z,startTime:v})=>("error"in Z)?zG({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 $Z,isForcefullyTerminated:K.isForcefullyTerminated,exitCode:J,signal:X,stdio:$,all:Y,ipcOutput:Q,options:W,startTime:v,isSync:!1}):LF({command:G,escapedCommand:z,stdio:$,all:Y,ipcOutput:Q,options:W,startTime:v});var AF=(Z,J)=>{let X=Object.fromEntries(Object.entries(J).map(([$,Y])=>[$,IU1($,Z[$],Y)]));return{...Z,...X}},IU1=(Z,J,X)=>{if(fU1.has(Z)&&U8(J)&&U8(X))return{...J,...X};return X},fU1=new Set(["env",...yO]);var cJ=(Z,J,X,$)=>{let Y=(K,W,G)=>cJ(K,W,X,G),Q=(...K)=>_U1({mapArguments:Z,deepOptions:X,boundOptions:J,setBoundExeca:$,createNested:Y},...K);if($!==void 0)$(Q,Y,J);return Q},_U1=({mapArguments:Z,deepOptions:J={},boundOptions:X={},setBoundExeca:$,createNested:Y},Q,...K)=>{if(U8(Q))return Y(Z,AF(X,Q),$);let{file:W,commandArguments:G,options:z,isSync:v}=SU1({mapArguments:Z,firstArgument:Q,nextArguments:K,deepOptions:J,boundOptions:X});return v?Ji(W,G,z):Wg(W,G,z,Y)},SU1=({mapArguments:Z,firstArgument:J,nextArguments:X,deepOptions:$,boundOptions:Y})=>{let Q=Fu(J)?wu(J,X):[J,...X],[K,W,G]=kq(...Q),z=AF(AF($,Y),G),{file:v=K,commandArguments:V=W,options:H=z,isSync:q=!1}=Z({file:K,commandArguments:W,options:z});return{file:v,commandArguments:V,options:H,isSync:q}};var Gg=({file:Z,commandArguments:J})=>vg(Z,J),zg=({file:Z,commandArguments:J})=>({...vg(Z,J),isSync:!0}),vg=(Z,J)=>{if(J.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${Z} ${J}.`);let[X,...$]=hU1(Z);return{file:X,commandArguments:$}},hU1=(Z)=>{if(typeof Z!=="string")throw new TypeError(`The command must be a string: ${String(Z)}.`);let J=Z.trim();if(J==="")return[];let X=[];for(let $ of J.split(bU1)){let Y=X.at(-1);if(Y&&Y.endsWith("\\"))X[X.length-1]=`${Y.slice(0,-1)} ${$}`;else X.push($)}return X},bU1=/ +/g;var Hg=(Z,J,X)=>{Z.sync=J(AU1,X),Z.s=Z.sync},Vg=({options:Z})=>qg(Z),AU1=({options:Z})=>({...qg(Z),isSync:!0}),qg=(Z)=>({options:{...mU1(Z),...Z}}),mU1=({input:Z,inputFile:J,stdio:X})=>Z===void 0&&J===void 0&&X===void 0?{stdin:"inherit"}:{},Fg={preferLocal:!0};var wg=cJ(()=>({})),JN6=cJ(()=>({isSync:!0})),XN6=cJ(Gg),$N6=cJ(zg),YN6=cJ(cy),QN6=cJ(Vg,{},Fg,Hg),{sendMessage:KN6,getOneMessage:WN6,getEachMessage:GN6,getCancelSignal:zN6}=Gi();var Sg=t(Pg(),1);var xG=(Z)=>{if(typeof Z!=="string")throw new TypeError("invalid pattern");if(Z.length>65536)throw new TypeError("pattern is too long")};var aU1={"[: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]},BG=(Z)=>Z.replace(/[[\]\\-]/g,"\\$&"),nU1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Cg=(Z)=>Z.join(""),Tg=(Z,J)=>{let X=J;if(Z.charAt(X)!=="[")throw new Error("not in a brace expression");let $=[],Y=[],Q=X+1,K=!1,W=!1,G=!1,z=!1,v=X,V="";Z:while(Q<Z.length){let w=Z.charAt(Q);if((w==="!"||w==="^")&&Q===X+1){z=!0,Q++;continue}if(w==="]"&&K&&!G){v=Q+1;break}if(K=!0,w==="\\"){if(!G){G=!0,Q++;continue}}if(w==="["&&!G){for(let[U,[x,L,j]]of Object.entries(aU1))if(Z.startsWith(U,Q)){if(V)return["$.",!1,Z.length-X,!0];if(Q+=U.length,j)Y.push(x);else $.push(x);W=W||L;continue Z}}if(G=!1,V){if(w>V)$.push(BG(V)+"-"+BG(w));else if(w===V)$.push(BG(w));V="",Q++;continue}if(Z.startsWith("-]",Q+1)){$.push(BG(w+"-")),Q+=2;continue}if(Z.startsWith("-",Q+1)){V=w,Q+=2;continue}$.push(BG(w)),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 w=$[0].length===2?$[0].slice(-1):$[0];return[nU1(w),!1,v-X,!1]}let H="["+(z?"^":"")+Cg($)+"]",q="["+(z?"":"^")+Cg(Y)+"]";return[$.length&&Y.length?"("+H+"|"+q+")":$.length?H:q,W,v-X,!0]};var V9=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/\[([^\/\\])\]/g,"$1"):Z.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var sU1=new Set(["!","?","+","*","@"]),kg=(Z)=>sU1.has(Z),oU1="(?!(?:^|/)\\.\\.?(?:$|/))",mF="(?!\\.)",rU1=new Set(["[","."]),tU1=new Set(["..","."]),eU1=new Set("().*{}+?[]^$\\!"),Zx1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),qR="[^/]",Eg=qR+"*?",Ig=qR+"+?";class $6{type;#Z;#J;#$=!1;#X=[];#Y;#v;#V;#W=!1;#G;#z;#H=!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.#V=this.#Z===this?[]:this.#Z.#V,Z==="!"&&!this.#Z.#W)this.#V.push(this);this.#v=this.#Y?this.#Y.#X.length:0}get hasMagic(){if(this.#J!==void 0)return this.#J;for(let Z of this.#X){if(typeof Z==="string")continue;if(Z.type||Z.hasMagic)return this.#J=!0}return this.#J}toString(){if(this.#z!==void 0)return this.#z;if(!this.type)return this.#z=this.#X.map((Z)=>String(Z)).join("");else return this.#z=this.type+"("+this.#X.map((Z)=>String(Z)).join("|")+")"}#Q(){if(this!==this.#Z)throw new Error("should only call on root");if(this.#W)return this;this.toString(),this.#W=!0;let Z;while(Z=this.#V.pop()){if(Z.type!=="!")continue;let J=Z,X=J.#Y;while(X){for(let $=J.#v+1;!X.type&&$<X.#X.length;$++)for(let Y of Z.#X){if(typeof Y==="string")throw new Error("string part in extglob AST??");Y.copyIn(X.#X[$])}J=X,X=J.#Y}}return this}push(...Z){for(let J of Z){if(J==="")continue;if(typeof J!=="string"&&!(J instanceof $6&&J.#Y===this))throw new Error("invalid part: "+J);this.#X.push(J)}}toJSON(){let Z=this.type===null?this.#X.slice().map((J)=>typeof J==="string"?J:J.toJSON()):[this.type,...this.#X.map((J)=>J.toJSON())];if(this.isStart()&&!this.type)Z.unshift([]);if(this.isEnd()&&(this===this.#Z||this.#Z.#W&&this.#Y?.type==="!"))Z.push({});return Z}isStart(){if(this.#Z===this)return!0;if(!this.#Y?.isStart())return!1;if(this.#v===0)return!0;let Z=this.#Y;for(let J=0;J<this.#v;J++){let X=Z.#X[J];if(!(X instanceof $6&&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 $6(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 H=X,q="";while(H<Z.length){let F=Z.charAt(H++);if(Y||F==="\\"){Y=!Y,q+=F;continue}if(Q){if(H===K+1){if(F==="^"||F==="!")W=!0}else if(F==="]"&&!(H===K+2&&W))Q=!1;q+=F;continue}else if(F==="["){Q=!0,K=H,W=!1,q+=F;continue}if(!$.noext&&kg(F)&&Z.charAt(H)==="("){J.push(q),q="";let w=new $6(F,J);H=$6.#F(Z,w,H,$),J.push(w);continue}q+=F}return J.push(q),H}let G=X+1,z=new $6(null,J),v=[],V="";while(G<Z.length){let H=Z.charAt(G++);if(Y||H==="\\"){Y=!Y,V+=H;continue}if(Q){if(G===K+1){if(H==="^"||H==="!")W=!0}else if(H==="]"&&!(G===K+2&&W))Q=!1;V+=H;continue}else if(H==="["){Q=!0,K=G,W=!1,V+=H;continue}if(kg(H)&&Z.charAt(G)==="("){z.push(V),V="";let q=new $6(H,z);z.push(q),G=$6.#F(Z,q,G,$);continue}if(H==="|"){z.push(V),V="",v.push(z),z=new $6(null,J);continue}if(H===")"){if(V===""&&J.#X.length===0)J.#H=!0;return z.push(V),V="",J.push(...v,z),G}V+=H}return J.type=null,J.#J=void 0,J.#X=[Z.substring(X-1)],G}static fromGlob(Z,J={}){let X=new $6(null,void 0,J);return $6.#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((H)=>{let[q,F,w,U]=typeof H==="string"?$6.#w(H,this.#J,W):H.toRegExpSource(Z);return this.#J=this.#J||w,this.#$=this.#$||U,q}).join(""),z="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&tU1.has(this.#X[0]))){let q=rU1,F=J&&q.has(G.charAt(0))||G.startsWith("\\.")&&q.has(G.charAt(2))||G.startsWith("\\.\\.")&&q.has(G.charAt(4)),w=!J&&!Z&&q.has(G.charAt(0));z=F?oU1:w?mF:""}}}let v="";if(this.isEnd()&&this.#Z.#W&&this.#Y?.type==="!")v="(?:$|\\/)";return[z+G+v,V9(G),this.#J=!!this.#J,this.#$]}let X=this.type==="*"||this.type==="+",$=this.type==="!"?"(?:(?!(?:":"(?:",Y=this.#U(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,V9(this.toString()),!1,!1]}let Q=!X||Z||J||!mF?"":this.#U(!0);if(Q===Y)Q="";if(Q)Y=`(?:${Y})(?:${Q})*?`;let K="";if(this.type==="!"&&this.#H)K=(this.isStart()&&!J?mF:"")+Ig;else{let W=this.type==="!"?"))"+(this.isStart()&&!J&&!Z?mF:"")+Eg+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&Q?")":this.type==="*"&&Q?")?":`)${this.type}`;K=$+Y+W}return[K,V9(Y),this.#J=!!this.#J,this.#$]}#U(Z){return this.#X.map((J)=>{if(typeof J==="string")throw new Error("string type in extglob ast??");let[X,$,Y,Q]=J.toRegExpSource(Z);return this.#$=this.#$||Q,X}).filter((J)=>!(this.isStart()&&this.isEnd())||!!J).join("|")}static#w(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+=(eU1.has(W)?"\\":"")+W;continue}if(W==="\\"){if(K===Z.length-1)Y+="\\\\";else $=!0;continue}if(W==="["){let[G,z,v,V]=Tg(Z,K);if(v){Y+=G,Q=Q||z,K+=v-1,J=J||V;continue}}if(W==="*"){if(X&&Z==="*")Y+=Ig;else Y+=Eg;J=!0;continue}if(W==="?"){Y+=qR,J=!0;continue}Y+=Zx1(W)}return[Y,V9(Z),!!J,Q]}}var zK=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/[?*()[\]]/g,"[$&]"):Z.replace(/[?*()[\]\\]/g,"\\$&")};var b6=(Z,J,X={})=>{if(xG(J),!X.nocomment&&J.charAt(0)==="#")return!1;return new q4(J,X).match(Z)},Jx1=/^\*+([^+@!?\*\[\(]*)$/,Xx1=(Z)=>(J)=>!J.startsWith(".")&&J.endsWith(Z),$x1=(Z)=>(J)=>J.endsWith(Z),Yx1=(Z)=>{return Z=Z.toLowerCase(),(J)=>!J.startsWith(".")&&J.toLowerCase().endsWith(Z)},Qx1=(Z)=>{return Z=Z.toLowerCase(),(J)=>J.toLowerCase().endsWith(Z)},Kx1=/^\*+\.\*+$/,Wx1=(Z)=>!Z.startsWith(".")&&Z.includes("."),Gx1=(Z)=>Z!=="."&&Z!==".."&&Z.includes("."),zx1=/^\.\*+$/,vx1=(Z)=>Z!=="."&&Z!==".."&&Z.startsWith("."),Hx1=/^\*+$/,Vx1=(Z)=>Z.length!==0&&!Z.startsWith("."),qx1=(Z)=>Z.length!==0&&Z!=="."&&Z!=="..",Fx1=/^\?+([^+@!?\*\[\(]*)?$/,wx1=([Z,J=""])=>{let X=hg([Z]);if(!J)return X;return J=J.toLowerCase(),($)=>X($)&&$.toLowerCase().endsWith(J)},Ux1=([Z,J=""])=>{let X=bg([Z]);if(!J)return X;return J=J.toLowerCase(),($)=>X($)&&$.toLowerCase().endsWith(J)},xx1=([Z,J=""])=>{let X=bg([Z]);return!J?X:($)=>X($)&&$.endsWith(J)},Bx1=([Z,J=""])=>{let X=hg([Z]);return!J?X:($)=>X($)&&$.endsWith(J)},hg=([Z])=>{let J=Z.length;return(X)=>X.length===J&&!X.startsWith(".")},bg=([Z])=>{let J=Z.length;return(X)=>X.length===J&&X!=="."&&X!==".."},Ag=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",fg={win32:{sep:"\\"},posix:{sep:"/"}},Lx1=Ag==="win32"?fg.win32.sep:fg.posix.sep;b6.sep=Lx1;var Y6=Symbol("globstar **");b6.GLOBSTAR=Y6;var jx1="[^/]",cx1=jx1+"*?",Ox1="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Mx1="(?:(?!(?:\\/|^)\\.).)*?",Rx1=(Z,J={})=>(X)=>b6(X,Z,J);b6.filter=Rx1;var V4=(Z,J={})=>Object.assign({},Z,J),Nx1=(Z)=>{if(!Z||typeof Z!=="object"||!Object.keys(Z).length)return b6;let J=b6;return Object.assign(($,Y,Q={})=>J($,Y,V4(Z,Q)),{Minimatch:class $ extends J.Minimatch{constructor(Y,Q={}){super(Y,V4(Z,Q))}static defaults(Y){return J.defaults(V4(Z,Y)).Minimatch}},AST:class $ extends J.AST{constructor(Y,Q,K={}){super(Y,Q,V4(Z,K))}static fromGlob(Y,Q={}){return J.AST.fromGlob(Y,V4(Z,Q))}},unescape:($,Y={})=>J.unescape($,V4(Z,Y)),escape:($,Y={})=>J.escape($,V4(Z,Y)),filter:($,Y={})=>J.filter($,V4(Z,Y)),defaults:($)=>J.defaults(V4(Z,$)),makeRe:($,Y={})=>J.makeRe($,V4(Z,Y)),braceExpand:($,Y={})=>J.braceExpand($,V4(Z,Y)),match:($,Y,Q={})=>J.match($,Y,V4(Z,Q)),sep:J.sep,GLOBSTAR:Y6})};b6.defaults=Nx1;var mg=(Z,J={})=>{if(xG(Z),J.nobrace||!/\{(?:(?!\{).)*\}/.test(Z))return[Z];return Sg.default(Z)};b6.braceExpand=mg;var Dx1=(Z,J={})=>new q4(Z,J).makeRe();b6.makeRe=Dx1;var Px1=(Z,J,X={})=>{let $=new q4(J,X);if(Z=Z.filter((Y)=>$.match(Y)),$.options.nonull&&!Z.length)Z.push(J);return Z};b6.match=Px1;var _g=/[?*]|[+@!]\(.*?\)|\[|\]/,Cx1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class q4{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Z,J={}){if(xG(Z),J=J||{},this.options=J,this.pattern=Z,this.platform=J.platform||Ag,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]==="?"||!_g.test(Y[2]))&&!_g.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]),w=!F&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&/^[a-z]:$/i.test(Z[3]),U=typeof J[0]==="string"&&/^[a-z]:$/i.test(J[0]),x=!U&&J[0]===""&&J[1]===""&&J[2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]),L=w?3:F?0:void 0,j=x?3:U?0:void 0;if(typeof L==="number"&&typeof j==="number"){let[c,R]=[Z[L],J[j]];if(c.toLowerCase()===R.toLowerCase()){if(J[j]=c,j>L)J=J.slice(j);else if(L>j)Z=Z.slice(L)}}}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===Y6){this.debug("GLOBSTAR",[J,z,v]);var V=Q,H=K+1;if(H===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(V<W){var q=Z[V];if(this.debug(`
|
398
398
|
globstar while`,Z,V,J,H,q),this.matchOne(Z.slice(V),J.slice(H),X))return this.debug("globstar found match!",V,W,q),!0;else{if(q==="."||q===".."||!$.dot&&q.charAt(0)==="."){this.debug("dot detected!",Z,V,J,H);break}this.debug("globstar swallow a segment, and continue"),V++}}if(X){if(this.debug(`
|
399
|
-
>>> no match, partial?`,Z,V,J,H),V===W)return!0}return!1}let F;if(typeof z==="string")F=v===z,this.debug("string match",z,v,F);else F=z.test(v),this.debug("pattern match",z,v,F);if(!F)return!1}if(Q===W&&K===G)return!0;else if(Q===W)return X;else if(K===G)return Q===W-1&&Z[Q]==="";else throw new Error("wtf?")}braceExpand(){return mg(this.pattern,this.options)}parse(Z){xG(Z);let J=this.options;if(Z==="**")return Y6;if(Z==="")return"";let X,$=null;if(X=Z.match(Hx1))$=J.dot?qx1:Vx1;else if(X=Z.match(Jx1))$=(J.nocase?J.dot?Qx1:Yx1:J.dot?$x1:Xx1)(X[1]);else if(X=Z.match(Fx1))$=(J.nocase?J.dot?Ux1:wx1:J.dot?xx1:Bx1)(X);else if(X=Z.match(Kx1))$=J.dot?Gx1:Wx1;else if(X=Z.match(zx1))$=vx1;let Y=$6.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?cx1:J.dot?Ox1:Mx1,$=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"?Cx1(z):z===Y6?Y6:z._src});return G.forEach((z,v)=>{let V=G[v+1],H=G[v-1];if(z!==Y6||H===Y6)return;if(H===void 0)if(V!==void 0&&V!==Y6)G[v+1]="(?:\\/|"+X+"\\/)?"+V;else G[v]=X;else if(V===void 0)G[v-1]=H+"(?:\\/|"+X+")?";else if(V!==Y6)G[v-1]=H+"(?:\\/|\\/"+X+"\\/)"+V,G[v+1]=Y6}),G.filter((z)=>z!==Y6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if(Y="^"+Q+Y+K+"$",this.negate)Y="^(?!"+Y+").+$";try{this.regexp=new RegExp(Y,[...$].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit(Z){if(this.preserveMultipleSlashes)return Z.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Z))return["",...Z.split(/\/+/)];else return Z.split(/\/+/)}match(Z,J=this.partial){if(this.debug("match",Z,this.pattern),this.comment)return!1;if(this.empty)return Z==="";if(Z==="/"&&J)return!0;let X=this.options;if(this.isWindows)Z=Z.split("\\").join("/");let $=this.slashSplit(Z);this.debug(this.pattern,"split",$);let Y=this.set;this.debug(this.pattern,"set",Y);let Q=$[$.length-1];if(!Q)for(let K=$.length-2;!Q&&K>=0;K--)Q=$[K];for(let K=0;K<Y.length;K++){let W=Y[K],G=$;if(X.matchBase&&W.length===1)G=[Q];if(this.matchOne(G,W,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return b6.defaults(Z).Minimatch}}b6.AST=$6;b6.Minimatch=q4;b6.escape=zK;b6.unescape=V9;import{fileURLToPath as K21}from"node:url";var vK=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,lg=new Set,FR=typeof process==="object"&&!!process?process:{},yg=(Z,J,X,$)=>{typeof FR.emitWarning==="function"?FR.emitWarning(Z,J,X,$):console.error(`[${X}] ${J}: ${Z}`)},uF=globalThis.AbortController,ug=globalThis.AbortSignal;if(typeof uF==="undefined"){ug=class X{onabort;_onabort=[];reason;aborted=!1;addEventListener($,Y){this._onabort.push(Y)}},uF=class X{constructor(){J()}signal=new ug;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=FR.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,yg("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 Tx1=(Z)=>!lg.has(Z),CN6=Symbol("type"),OJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),pg=(Z)=>!OJ(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?LG:null;class LG extends Array{constructor(Z){super(Z);this.fill(0)}}class HK{heap;length;static#Z=!1;static create(Z){let J=pg(Z);if(!J)return[];HK.#Z=!0;let X=new HK(Z,J);return HK.#Z=!1,X}constructor(Z,J){if(!HK.#Z)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new J(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}}class jG{#Z;#J;#$;#X;#Y;#v;#V;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#z;#H;#Q;#F;#U;#w;#B;#P;#L;#C;#O;#c;#j;#N;#x;#k;static unsafeExposeInternals(Z){return{starts:Z.#O,ttls:Z.#c,sizes:Z.#C,keyMap:Z.#z,keyList:Z.#H,valList:Z.#Q,next:Z.#F,prev:Z.#U,get head(){return Z.#w},get tail(){return Z.#B},free:Z.#P,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,$,Y)=>Z.#S(J,X,$,Y),moveToTail:(J)=>Z.#A(J),indexes:(J)=>Z.#D(J),rindexes:(J)=>Z.#T(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.#V}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:V,noUpdateTTL:H,maxSize:q=0,maxEntrySize:F=0,sizeCalculation:w,fetchMethod:U,memoMethod:x,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:j,allowStaleOnFetchRejection:c,allowStaleOnFetchAbort:R,ignoreFetchAbort:M}=Z;if(J!==0&&!OJ(J))throw new TypeError("max option must be a nonnegative integer");let N=J?pg(J):Array;if(!N)throw new Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=F||this.#J,this.sizeCalculation=w,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw new TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!=="function")throw new TypeError("memoMethod must be a function if defined");if(this.#V=x,U!==void 0&&typeof U!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#v=U,this.#N=!!U,this.#z=new Map,this.#H=new Array(J).fill(void 0),this.#Q=new Array(J).fill(void 0),this.#F=new N(J),this.#U=new N(J),this.#w=0,this.#B=0,this.#P=HK.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.#L=[];else this.#Y=void 0,this.#L=void 0;if(this.#j=!!this.#$,this.#k=!!this.#X,this.#x=!!this.#Y,this.noDisposeOnSet=!!V,this.noUpdateTTL=!!H,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!c,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!OJ(this.#J))throw new TypeError("maxSize must be a positive integer if specified")}if(!OJ(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#u()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!j,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=OJ($)||$===0?$:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!OJ(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(Tx1("LRU_CACHE_UNBOUNDED"))lg.add("LRU_CACHE_UNBOUNDED"),yg("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",jG)}}getRemainingTTL(Z){return this.#z.has(Z)?1/0:0}#K(){let Z=new LG(this.#Z),J=new LG(this.#Z);this.#c=Z,this.#O=J,this.#E=(Y,Q,K=vK.now())=>{if(J[Y]=Q!==0?K:0,Z[Y]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#R(Y))this.#I(this.#H[Y],"expire")},Q+1);if(W.unref)W.unref()}},this.#f=(Y)=>{J[Y]=Z[Y]!==0?vK.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=vK.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}}#f=()=>{};#M=()=>{};#E=()=>{};#R=()=>!1;#u(){let Z=new LG(this.#Z);this.#G=0,this.#C=Z,this.#_=(J)=>{this.#G-=Z[J],Z[J]=0},this.#l=(J,X,$,Y)=>{if(this.#q(X))return 0;if(!OJ($))if(Y){if(typeof Y!=="function")throw new TypeError("sizeCalculation must be a function");if($=Y(X,J),!OJ($))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return $},this.#h=(J,X,$)=>{if(Z[J]=X,this.#J){let Y=this.#J-Z[J];while(this.#G>Y)this.#b(!0)}if(this.#G+=Z[J],$)$.entrySize=X,$.totalCalculatedSize=this.#G}}#_=(Z)=>{};#h=(Z,J,X)=>{};#l=(Z,J,X,$)=>{if(X||$)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#D({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#B;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#w)break;else J=this.#U[J]}}*#T({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#w;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#B)break;else J=this.#F[J]}}#y(Z){return Z!==void 0&&this.#z.get(this.#H[Z])===Z}*entries(){for(let Z of this.#D())if(this.#Q[Z]!==void 0&&this.#H[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#H[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&this.#H[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#H[Z],this.#Q[Z]]}*keys(){for(let Z of this.#D()){let J=this.#H[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#T()){let J=this.#H[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#D())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#T())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.#D()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;if(Z(Y,this.#H[X],this))return this.get(this.#H[X],J)}}forEach(Z,J=this){for(let X of this.#D()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#H[X],this)}}rforEach(Z,J=this){for(let X of this.#T()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#H[X],this)}}purgeStale(){let Z=!1;for(let J of this.#T({allowStale:!0}))if(this.#R(J))this.#I(this.#H[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.#c&&this.#O){let Q=this.#c[J],K=this.#O[J];if(Q&&K){let W=Q-(vK.now()-K);Y.ttl=W,Y.start=Date.now()}}if(this.#C)Y.size=this.#C[J];return Y}dump(){let Z=[];for(let J of this.#D({allowStale:!0})){let X=this.#H[J],$=this.#Q[J],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0||X===void 0)continue;let Q={value:Y};if(this.#c&&this.#O){Q.ttl=this.#c[J];let K=vK.now()-this.#O[J];Q.start=Math.floor(Date.now()-K)}if(this.#C)Q.size=this.#C[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=vK.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.#I(Z,"set"),this}let v=this.#W===0?void 0:this.#z.get(Z);if(v===void 0){if(v=this.#W===0?this.#B:this.#P.length!==0?this.#P.pop():this.#W===this.#Z?this.#b(!1):this.#W,this.#H[v]=Z,this.#Q[v]=J,this.#z.set(Z,v),this.#F[this.#B]=v,this.#U[v]=this.#B,this.#B=v,this.#W++,this.#h(v,z,W),W)W.set="add";if(G=!1,this.#k)this.#X?.(J,Z,"add")}else{this.#A(v);let V=this.#Q[v];if(J!==V){if(this.#N&&this.#q(V)){V.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:H}=V;if(H!==void 0&&!Q){if(this.#j)this.#$?.(H,Z,"set");if(this.#x)this.#L?.push([H,Z,"set"])}}else if(!Q){if(this.#j)this.#$?.(V,Z,"set");if(this.#x)this.#L?.push([V,Z,"set"])}if(this.#_(v),this.#h(v,z,W),this.#Q[v]=J,W){W.set="replace";let H=V&&this.#q(V)?V.__staleWhileFetching:V;if(H!==void 0)W.oldValue=H}}else if(W)W.set="update";if(this.#k)this.onInsert?.(J,Z,J===V?"update":"replace")}if($!==0&&!this.#c)this.#K();if(this.#c){if(!G)this.#E(v,$,Y);if(W)this.#M(W,v)}if(!Q&&this.#x&&this.#L){let V=this.#L,H;while(H=V?.shift())this.#Y?.(...H)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#w];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.#L){let Z=this.#L,J;while(J=Z?.shift())this.#Y?.(...J)}}}#b(Z){let J=this.#w,X=this.#H[J],$=this.#Q[J];if(this.#N&&this.#q($))$.__abortController.abort(new Error("evicted"));else if(this.#j||this.#x){if(this.#j)this.#$?.($,X,"evict");if(this.#x)this.#L?.push([$,X,"evict"])}if(this.#_(J),Z)this.#H[J]=void 0,this.#Q[J]=void 0,this.#P.push(J);if(this.#W===1)this.#w=this.#B=0,this.#P.length=0;else this.#w=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.#f(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}#S(Z,J,X,$){let Y=J===void 0?void 0:this.#Q[J];if(this.#q(Y))return Y;let Q=new uF,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:$},G=(F,w=!1)=>{let{aborted:U}=Q.signal,x=X.ignoreFetchAbort&&F!==void 0;if(X.status)if(U&&!w){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,x)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(U&&!x&&!w)return v(Q.signal.reason);let L=H;if(this.#Q[J]===H)if(F===void 0)if(L.__staleWhileFetching)this.#Q[J]=L.__staleWhileFetching;else this.#I(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:w}=Q.signal,U=w&&X.allowStaleOnFetchAbort,x=U||X.allowStaleOnFetchRejection,L=x||X.noDeleteOnFetchRejection,j=H;if(this.#Q[J]===H){if(!L||j.__staleWhileFetching===void 0)this.#I(Z,"fetch");else if(!U)this.#Q[J]=j.__staleWhileFetching}if(x){if(X.status&&j.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return j.__staleWhileFetching}else if(j.__returned===j)throw F},V=(F,w)=>{let U=this.#v?.(Z,Y,W);if(U&&U instanceof Promise)U.then((x)=>F(x===void 0?void 0:x),w);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 H=new Promise(V).then(G,z),q=Object.assign(H,{__abortController:Q,__staleWhileFetching:Y,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#z.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#N)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof uF}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:V=this.allowStaleOnFetchRejection,ignoreFetchAbort:H=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:F,forceRefresh:w=!1,status:U,signal:x}=J;if(!this.#N){if(U)U.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,status:U})}let L={allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:z,noDeleteOnFetchRejection:v,allowStaleOnFetchRejection:V,allowStaleOnFetchAbort:q,ignoreFetchAbort:H,status:U,signal:x},j=this.#z.get(Z);if(j===void 0){if(U)U.fetch="miss";let c=this.#S(Z,j,L,F);return c.__returned=c}else{let c=this.#Q[j];if(this.#q(c)){let P=X&&c.__staleWhileFetching!==void 0;if(U){if(U.fetch="inflight",P)U.returnedStale=!0}return P?c.__staleWhileFetching:c.__returned=c}let R=this.#R(j);if(!w&&!R){if(U)U.fetch="hit";if(this.#A(j),$)this.#f(j);if(U)this.#M(U,j);return c}let M=this.#S(Z,j,L,F),D=M.__staleWhileFetching!==void 0&&X;if(U){if(U.fetch=R?"stale":"refresh",D&&R)U.returnedStale=!0}return D?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw new Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#V;if(!X)throw new Error("no memoMethod provided to constructor");let{context:$,forceRefresh:Y,...Q}=J,K=this.get(Z,Q);if(!Y&&K!==void 0)return K;let W=X(Z,K,{options:Q,context:$});return this.set(Z,W,Q),W}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,status:Q}=J,K=this.#z.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#M(Q,K);if(this.#R(K)){if(Q)Q.get="stale";if(!G){if(!Y)this.#I(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.#f(K);return W}}else if(Q)Q.get="miss"}#p(Z,J){this.#U[J]=Z,this.#F[Z]=J}#A(Z){if(Z!==this.#B){if(Z===this.#w)this.#w=this.#F[Z];else this.#p(this.#U[Z],this.#F[Z]);this.#p(this.#B,Z),this.#B=Z}}delete(Z){return this.#I(Z,"delete")}#I(Z,J){let X=!1;if(this.#W!==0){let $=this.#z.get(Z);if($!==void 0)if(X=!0,this.#W===1)this.#m(J);else{this.#_($);let Y=this.#Q[$];if(this.#q(Y))Y.__abortController.abort(new Error("deleted"));else if(this.#j||this.#x){if(this.#j)this.#$?.(Y,Z,J);if(this.#x)this.#L?.push([Y,Z,J])}if(this.#z.delete(Z),this.#H[$]=void 0,this.#Q[$]=void 0,$===this.#B)this.#B=this.#U[$];else if($===this.#w)this.#w=this.#F[$];else{let Q=this.#U[$];this.#F[Q]=this.#F[$];let K=this.#F[$];this.#U[K]=this.#U[$]}this.#W--,this.#P.push($)}}if(this.#x&&this.#L?.length){let $=this.#L,Y;while(Y=$?.shift())this.#Y?.(...Y)}return X}clear(){return this.#m("delete")}#m(Z){for(let J of this.#T({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(new Error("deleted"));else{let $=this.#H[J];if(this.#j)this.#$?.(X,$,Z);if(this.#x)this.#L?.push([X,$,Z])}}if(this.#z.clear(),this.#Q.fill(void 0),this.#H.fill(void 0),this.#c&&this.#O)this.#c.fill(0),this.#O.fill(0);if(this.#C)this.#C.fill(0);if(this.#w=0,this.#B=0,this.#P.length=0,this.#G=0,this.#W=0,this.#x&&this.#L){let J=this.#L,X;while(X=J?.shift())this.#Y?.(...X)}}}import{posix as ux1,win32 as RR}from"node:path";import{fileURLToPath as lx1}from"node:url";import{lstatSync as yx1,readdir as px1,readdirSync as ix1,readlinkSync as gx1,realpathSync as dx1}from"fs";import*as ax1 from"node:fs";import{lstat as sx1,readdir as ox1,readlink as rx1,realpath as tx1}from"node:fs/promises";import{EventEmitter as jR}from"node:events";import ng from"node:stream";import{StringDecoder as kx1}from"node:string_decoder";var ig=typeof process==="object"&&process?process:{stdout:null,stderr:null},Ex1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof O$||Z instanceof ng||Ix1(Z)||fx1(Z)),Ix1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof jR&&typeof Z.pipe==="function"&&Z.pipe!==ng.Writable.prototype.pipe,fx1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof jR&&typeof Z.write==="function"&&typeof Z.end==="function",KZ=Symbol("EOF"),WZ=Symbol("maybeEmitEnd"),MJ=Symbol("emittedEnd"),lF=Symbol("emittingEnd"),cG=Symbol("emittedError"),yF=Symbol("closed"),gg=Symbol("read"),pF=Symbol("flush"),dg=Symbol("flushChunk"),q9=Symbol("encoding"),VK=Symbol("decoder"),i8=Symbol("flowing"),OG=Symbol("paused"),qK=Symbol("resume"),g8=Symbol("buffer"),A6=Symbol("pipes"),d8=Symbol("bufferLength"),wR=Symbol("bufferPush"),iF=Symbol("bufferShift"),x6=Symbol("objectMode"),x8=Symbol("destroyed"),UR=Symbol("error"),xR=Symbol("emitData"),ag=Symbol("emitEnd"),BR=Symbol("emitEnd2"),X7=Symbol("async"),LR=Symbol("abort"),gF=Symbol("aborted"),MG=Symbol("signal"),c$=Symbol("dataListeners"),_5=Symbol("discarded"),RG=(Z)=>Promise.resolve().then(Z),_x1=(Z)=>Z(),Sx1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",hx1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,bx1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class cR{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[qK](),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 sg extends cR{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 Ax1=(Z)=>!!Z.objectMode,mx1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class O$ extends jR{[i8]=!1;[OG]=!1;[A6]=[];[g8]=[];[x6];[q9];[X7];[VK];[KZ]=!1;[MJ]=!1;[lF]=!1;[yF]=!1;[cG]=null;[d8]=0;[x8]=!1;[MG];[gF]=!1;[c$]=0;[_5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(Ax1(J))this[x6]=!0,this[q9]=null;else if(mx1(J))this[q9]=J.encoding,this[x6]=!1;else this[x6]=!1,this[q9]=null;if(this[X7]=!!J.async,this[VK]=this[q9]?new kx1(this[q9]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[g8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[A6]});let{signal:X}=J;if(X)if(this[MG]=X,X.aborted)this[LR]();else X.addEventListener("abort",()=>this[LR]())}get bufferLength(){return this[d8]}get encoding(){return this[q9]}set encoding(Z){throw new Error("Encoding must be set at instantiation time")}setEncoding(Z){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[x6]}set objectMode(Z){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[X7]}set["async"](Z){this[X7]=this[X7]||!!Z}[LR](){this[gF]=!0,this.emit("abort",this[MG]?.reason),this.destroy(this[MG]?.reason)}get aborted(){return this[gF]}set aborted(Z){}write(Z,J,X){if(this[gF])return!1;if(this[KZ])throw new Error("write after end");if(this[x8])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof J==="function")X=J,J="utf8";if(!J)J="utf8";let $=this[X7]?RG:_x1;if(!this[x6]&&!Buffer.isBuffer(Z)){if(bx1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(hx1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[x6]){if(this[i8]&&this[d8]!==0)this[pF](!0);if(this[i8])this.emit("data",Z);else this[wR](Z);if(this[d8]!==0)this.emit("readable");if(X)$(X);return this[i8]}if(!Z.length){if(this[d8]!==0)this.emit("readable");if(X)$(X);return this[i8]}if(typeof Z==="string"&&!(J===this[q9]&&!this[VK]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[q9])Z=this[VK].write(Z);if(this[i8]&&this[d8]!==0)this[pF](!0);if(this[i8])this.emit("data",Z);else this[wR](Z);if(this[d8]!==0)this.emit("readable");if(X)$(X);return this[i8]}read(Z){if(this[x8])return null;if(this[_5]=!1,this[d8]===0||Z===0||Z&&Z>this[d8])return this[WZ](),null;if(this[x6])Z=null;if(this[g8].length>1&&!this[x6])this[g8]=[this[q9]?this[g8].join(""):Buffer.concat(this[g8],this[d8])];let J=this[gg](Z||null,this[g8][0]);return this[WZ](),J}[gg](Z,J){if(this[x6])this[iF]();else{let X=J;if(Z===X.length||Z===null)this[iF]();else if(typeof X==="string")this[g8][0]=X.slice(Z),J=X.slice(0,Z),this[d8]-=Z;else this[g8][0]=X.subarray(Z),J=X.subarray(0,Z),this[d8]-=Z}if(this.emit("data",J),!this[g8].length&&!this[KZ])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[KZ]=!0,this.writable=!1,this[i8]||!this[OG])this[WZ]();return this}[qK](){if(this[x8])return;if(!this[c$]&&!this[A6].length)this[_5]=!0;if(this[OG]=!1,this[i8]=!0,this.emit("resume"),this[g8].length)this[pF]();else if(this[KZ])this[WZ]();else this.emit("drain")}resume(){return this[qK]()}pause(){this[i8]=!1,this[OG]=!0,this[_5]=!1}get destroyed(){return this[x8]}get flowing(){return this[i8]}get paused(){return this[OG]}[wR](Z){if(this[x6])this[d8]+=1;else this[d8]+=Z.length;this[g8].push(Z)}[iF](){if(this[x6])this[d8]-=1;else this[d8]-=this[g8][0].length;return this[g8].shift()}[pF](Z=!1){do;while(this[dg](this[iF]())&&this[g8].length);if(!Z&&!this[g8].length&&!this[KZ])this.emit("drain")}[dg](Z){return this.emit("data",Z),this[i8]}pipe(Z,J){if(this[x8])return Z;this[_5]=!1;let X=this[MJ];if(J=J||{},Z===ig.stdout||Z===ig.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[A6].push(!J.proxyErrors?new cR(this,Z,J):new sg(this,Z,J)),this[X7])RG(()=>this[qK]());else this[qK]();return Z}unpipe(Z){let J=this[A6].find((X)=>X.dest===Z);if(J){if(this[A6].length===1){if(this[i8]&&this[c$]===0)this[i8]=!1;this[A6]=[]}else this[A6].splice(this[A6].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[_5]=!1,this[c$]++,!this[A6].length&&!this[i8])this[qK]()}else if(Z==="readable"&&this[d8]!==0)super.emit("readable");else if(Sx1(Z)&&this[MJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[cG]){let $=J;if(this[X7])RG(()=>$.call(this,this[cG]));else $.call(this,this[cG])}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[_5]&&!this[A6].length)this[i8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[c$]=0,!this[_5]&&!this[A6].length)this[i8]=!1}return J}get emittedEnd(){return this[MJ]}[WZ](){if(!this[lF]&&!this[MJ]&&!this[x8]&&this[g8].length===0&&this[KZ]){if(this[lF]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[yF])this.emit("close");this[lF]=!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[x6]&&!X?!1:this[X7]?(RG(()=>this[xR](X)),!0):this[xR](X);else if(Z==="end")return this[ag]();else if(Z==="close"){if(this[yF]=!0,!this[MJ]&&!this[x8])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Z==="error"){this[cG]=X,super.emit(UR,X);let Y=!this[MG]||this.listeners("error").length?super.emit("error",X):!1;return this[WZ](),Y}else if(Z==="resume"){let Y=super.emit("resume");return this[WZ](),Y}else if(Z==="finish"||Z==="prefinish"){let Y=super.emit(Z);return this.removeAllListeners(Z),Y}let $=super.emit(Z,...J);return this[WZ](),$}[xR](Z){for(let X of this[A6])if(X.dest.write(Z)===!1)this.pause();let J=this[_5]?!1:super.emit("data",Z);return this[WZ](),J}[ag](){if(this[MJ])return!1;return this[MJ]=!0,this.readable=!1,this[X7]?(RG(()=>this[BR]()),!0):this[BR]()}[BR](){if(this[VK]){let J=this[VK].end();if(J){for(let X of this[A6])X.dest.write(J);if(!this[_5])super.emit("data",J)}}for(let J of this[A6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[x6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[x6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[x6])throw new Error("cannot concat in objectMode");let Z=await this.collect();return this[q9]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(x8,()=>J(new Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[_5]=!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[KZ])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[KZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(x8,z),J(),Y({done:!0,value:void 0})},z=()=>K(new Error("stream destroyed"));return new Promise((v,V)=>{Q=V,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[_5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(UR,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(UR,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[_5]=!0,this[g8].length=0,this[d8]=0;let J=this;if(typeof J.close==="function"&&!this[yF])J.close();if(Z)this.emit("error",Z);else this.emit(x8);return this}static get isStream(){return Ex1}}var nx1=dx1.native,DG={lstatSync:yx1,readdir:px1,readdirSync:ix1,readlinkSync:gx1,realpathSync:nx1,promises:{lstat:sx1,readdir:ox1,readlink:rx1,realpath:tx1}},Zd=(Z)=>!Z||Z===DG||Z===ax1?DG:{...DG,...Z,promises:{...DG.promises,...Z.promises||{}}},Jd=/^\\\\\?\\([a-z]:)\\?$/i,ex1=(Z)=>Z.replace(/\//g,"\\").replace(Jd,"$1\\"),Z21=/[\\\/]/,w4=0,Xd=1,$d=2,$7=4,Yd=6,Qd=8,M$=10,Kd=12,F4=15,NG=~F4,OR=16,og=32,PG=64,F9=128,dF=256,nF=512,rg=PG|F9|nF,J21=1023,MR=(Z)=>Z.isFile()?Qd:Z.isDirectory()?$7:Z.isSymbolicLink()?M$:Z.isCharacterDevice()?$d:Z.isBlockDevice()?Yd:Z.isSocket()?Kd:Z.isFIFO()?Xd:w4,tg=new Map,CG=(Z)=>{let J=tg.get(Z);if(J)return J;let X=Z.normalize("NFKD");return tg.set(Z,X),X},eg=new Map,aF=(Z)=>{let J=eg.get(Z);if(J)return J;let X=CG(Z.toLowerCase());return eg.set(Z,X),X};class NR extends jG{constructor(){super({max:256})}}class Wd extends jG{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var Gd=Symbol("PathScurry setAsCwd");class m6{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}#V;get rdev(){return this.#V}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#z;get size(){return this.#z}#H;get blocks(){return this.#H}#Q;get atimeMs(){return this.#Q}#F;get mtimeMs(){return this.#F}#U;get ctimeMs(){return this.#U}#w;get birthtimeMs(){return this.#w}#B;get atime(){return this.#B}#P;get mtime(){return this.#P}#L;get ctime(){return this.#L}#C;get birthtime(){return this.#C}#O;#c;#j;#N;#x;#k;#K;#f;#M;#E;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=w4,X,$,Y,Q,K){if(this.name=Z,this.#O=Y?aF(Z):CG(Z),this.#K=J&J21,this.nocase=Y,this.roots=$,this.root=X||this,this.#f=Q,this.#j=K.fullpath,this.#x=K.relative,this.#k=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=Zd(K.fs)}depth(){if(this.#c!==void 0)return this.#c;if(!this.parent)return this.#c=0;return this.#c=this.parent.depth()+1}childrenCache(){return this.#f}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.#f.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#f.set(this,J),this.#K&=~OR,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),$=this.nocase?aF(Z):CG(Z);for(let W of X)if(W.#O===$)return W;let Y=this.parent?this.sep:"",Q=this.#j?this.#j+Y+Z:void 0,K=this.newChild(Z,w4,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=F9;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.#k!==void 0)return this.#k;let Z=this.name,J=this.parent;if(!J)return this.#k=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#j!==void 0)return this.#j;let Z=this.name,J=this.parent;if(!J)return this.#j=this.name;let $=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#j=$}fullpathPosix(){if(this.#N!==void 0)return this.#N;if(this.sep==="/")return this.#N=this.fullpath();if(!this.parent){let $=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test($))return this.#N=`//?/${$}`;else return this.#N=$}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#N=X}isUnknown(){return(this.#K&F4)===w4}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&F4)===Qd}isDirectory(){return(this.#K&F4)===$7}isCharacterDevice(){return(this.#K&F4)===$d}isBlockDevice(){return(this.#K&F4)===Yd}isFIFO(){return(this.#K&F4)===Xd}isSocket(){return(this.#K&F4)===Kd}isSymbolicLink(){return(this.#K&M$)===M$}lstatCached(){return this.#K&og?this:void 0}readlinkCached(){return this.#M}realpathCached(){return this.#E}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&F4;return!(Z!==w4&&Z!==M$||this.#K&dF||this.#K&F9)}calledReaddir(){return!!(this.#K&OR)}isENOENT(){return!!(this.#K&F9)}isNamed(Z){return!this.nocase?this.#O===CG(Z):this.#O===aF(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|=OR;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#_()}}#_(){if(this.#K&F9)return;this.#K=(this.#K|F9)&NG,this.#h()}#h(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#_()}#l(){this.#K|=nF,this.#D()}#D(){if(this.#K&PG)return;let Z=this.#K;if((Z&F4)===$7)Z&=NG;this.#K=Z|PG,this.#h()}#T(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#D();else if(Z==="ENOENT")this.#_();else this.children().provisional=0}#y(Z=""){if(Z==="ENOTDIR")this.parent.#D();else if(Z==="ENOENT")this.#_()}#b(Z=""){let J=this.#K;if(J|=dF,Z==="ENOENT")J|=F9;if(Z==="EINVAL"||Z==="UNKNOWN")J&=NG;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#D()}#S(Z,J){return this.#p(Z,J)||this.#q(Z,J)}#q(Z,J){let X=MR(Z),$=this.newChild(Z.name,X,{parent:this}),Y=$.#K&F4;if(Y!==$7&&Y!==M$&&Y!==w4)$.#K|=PG;return J.unshift($),J.provisional++,$}#p(Z,J){for(let X=J.provisional;X<J.length;X++){let $=J[X];if((this.nocase?aF(Z.name):CG(Z.name))!==$.#O)continue;return this.#A(Z,$,X,J)}}#A(Z,J,X,$){let Y=J.name;if(J.#K=J.#K&NG|MR(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&F9)===0)try{return this.#I(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#y(Z.code)}}lstatSync(){if((this.#K&F9)===0)try{return this.#I(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#y(Z.code)}}#I(Z){let{atime:J,atimeMs:X,birthtime:$,birthtimeMs:Y,blksize:Q,blocks:K,ctime:W,ctimeMs:G,dev:z,gid:v,ino:V,mode:H,mtime:q,mtimeMs:F,nlink:w,rdev:U,size:x,uid:L}=Z;this.#B=J,this.#Q=X,this.#C=$,this.#w=Y,this.#W=Q,this.#H=K,this.#L=W,this.#U=G,this.#J=z,this.#v=v,this.#G=V,this.#$=H,this.#P=q,this.#F=F,this.#X=w,this.#V=U,this.#z=x,this.#Y=L;let j=MR(Z);if(this.#K=this.#K&NG|j|og,j!==w4&&j!==$7&&j!==M$)this.#K|=PG}#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.#T(Y.code),X.provisional=0;else{for(let K of Q)this.#S(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.#S($,Z);this.#u(Z)}catch($){this.#T($.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.#S(X,Z);this.#u(Z)}catch(X){this.#T(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&rg)return!1;let Z=F4&this.#K;if(!(Z===w4||Z===$7||Z===M$))return!1;return!0}shouldWalk(Z,J){return(this.#K&$7)===$7&&!(this.#K&rg)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#E)return this.#E;if((nF|dF|F9)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#E=this.resolve(Z)}catch(Z){this.#l()}}realpathSync(){if(this.#E)return this.#E;if((nF|dF|F9)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#E=this.resolve(Z)}catch(Z){this.#l()}}[Gd](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),$.#k=X.join("/"),$=$.parent,X.push("..");$=Z;while($&&$.parent&&!J.has($))$.#x=void 0,$.#k=void 0,$=$.parent}}class sF extends m6{sep="\\";splitSep=Z21;constructor(Z,J=w4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}newChild(Z,J=w4,X={}){return new sF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return RR.parse(Z).root}getRoot(Z){if(Z=ex1(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 TG(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(Jd,"$1\\"),Z===J}}class oF extends m6{splitSep="/";sep="/";constructor(Z,J=w4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=w4,X={}){return new oF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class DR{root;rootPath;roots;cwd;#Z;#J;#$;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:$,childrenCacheSize:Y=16384,fs:Q=DG}={}){if(this.#X=Zd(Q),Z instanceof URL||Z.startsWith("file://"))Z=lx1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new NR,this.#J=new NR,this.#$=new Wd(Y);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if($===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=$,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let G=this.root,z=W.length-1,v=J.sep,V=this.rootPath,H=!1;for(let q of W){let F=z--;G=G.child(q,{relative:new Array(F).fill("..").join(v),relativePosix:new Array(F).fill("..").join("/"),fullpath:V+=(H?"":v)+q}),H=!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 m6))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 m6))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 m6))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 m6))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 m6))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 m6))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 m6))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,V)=>{W.add(v),v.readdirCB((H,q)=>{if(H)return V(H);let F=q.length;if(!F)return V();let w=()=>{if(--F===0)V()};for(let U of q){if(!Y||Y(U))K.push(X?U:U.fullpath());if($&&U.isSymbolicLink())U.realpath().then((x)=>x?.isUnknown()?x.lstat():x).then((x)=>x?.shouldWalk(W,Q)?G(x,w):w());else if(U.shouldWalk(W,Q))G(U,w);else w()}},!0)},z=Z;return new Promise((v,V)=>{G(z,(H)=>{if(H)return V(H);v(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof m6))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 V=v;if(v.isSymbolicLink()){if(!($&&(V=v.realpathSync())))continue;if(V.isUnknown())V.lstatSync()}if(V.shouldWalk(W,Q))W.add(V)}}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 m6))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 m6))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 m6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new O$({objectMode:!0});if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],z=0,v=()=>{let V=!1;while(!V){let H=G.shift();if(!H){if(z===0)K.end();return}z++,W.add(H);let q=(w,U,x=!1)=>{if(w)return K.emit("error",w);if($&&!x){let L=[];for(let j of U)if(j.isSymbolicLink())L.push(j.realpath().then((c)=>c?.isUnknown()?c.lstat():c));if(L.length){Promise.all(L).then(()=>q(null,U,!0));return}}for(let L of U)if(L&&(!Y||Y(L))){if(!K.write(X?L:L.fullpath()))V=!0}z--;for(let L of U){let j=L.realpathCached()||L;if(j.shouldWalk(W,Q))G.push(j)}if(V&&!K.flowing)K.once("drain",v);else if(!F)v()},F=!0;H.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 m6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new O$({objectMode:!0}),W=new Set;if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let G=[Z],z=0,v=()=>{let V=!1;while(!V){let H=G.shift();if(!H){if(z===0)K.end();return}z++,W.add(H);let q=H.readdirSync();for(let F of q)if(!Y||Y(F)){if(!K.write(X?F:F.fullpath()))V=!0}z--;for(let F of q){let w=F;if(F.isSymbolicLink()){if(!($&&(w=F.realpathSync())))continue;if(w.isUnknown())w.lstatSync()}if(w.shouldWalk(W,Q))G.push(w)}}if(V&&!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[Gd](J)}}class TG extends DR{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,RR,"\\",{...J,nocase:X});this.nocase=X;for(let $=this.cwd;$;$=$.parent)$.nocase=this.nocase}parseRootPath(Z){return RR.parse(Z).root.toUpperCase()}newRoot(Z){return new sF(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class kG extends DR{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,ux1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new oF(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class rF extends kG{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var uN6=process.platform==="win32"?sF:oF,zd=process.platform==="win32"?TG:process.platform==="darwin"?rF:kG;var X21=(Z)=>Z.length>=1,$21=(Z)=>Z.length>=1;class FK{#Z;#J;#$;length;#X;#Y;#v;#V;#W;#G;#z=!0;constructor(Z,J,X,$){if(!X21(Z))throw new TypeError("empty pattern list");if(!$21(J))throw new TypeError("empty glob list");if(J.length!==Z.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw new TypeError("index out of range");if(this.#Z=Z,this.#J=J,this.#$=X,this.#X=$,this.#$===0){if(this.isUNC()){let[Y,Q,K,W,...G]=this.#Z,[z,v,V,H,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let F=[Y,Q,K,W,""].join("/"),w=[z,v,V,H,""].join("/");this.#Z=[F,...G],this.#J=[w,...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.#$]===Y6}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 FK(this.#Z,this.#J,this.#$+1,this.#X),this.#Y.#G=this.#G,this.#Y.#W=this.#W,this.#Y.#V=this.#V,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.#V!==void 0?this.#V:this.#V=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 Y21=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class EG{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:$,noglobstar:Y,platform:Q=Y21}){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 q4(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let $=J.set[X],Y=J.globParts[X];if(!$||!Y)throw new Error("invalid pattern object");while($[0]==="."&&Y[0]===".")$.shift(),Y.shift();let Q=new FK($,Y,0,this.platform),K=new q4(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 PR{store;constructor(Z=new Map){this.store=Z}copy(){return new PR(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 vd{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 Hd{store=new Map;add(Z,J){if(!Z.canReaddir())return;let X=this.store.get(Z);if(X){if(!X.find(($)=>$.globString()===J.globString()))X.push(J)}else this.store.set(Z,[J])}get(Z){let J=this.store.get(Z);if(!J)throw new Error("attempting to walk unknown path");return J}entries(){return this.keys().map((Z)=>[Z,this.store.get(Z)])}keys(){return[...this.store.keys()].filter((Z)=>Z.canReaddir())}}class IG{hasWalkedCache;matches=new vd;subwalks=new Hd;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new PR}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===Y6){if(!$.isSymbolicLink()||this.follow||Y.checkFollowGlobstar())this.subwalks.add($,Y);let v=G?.pattern(),V=G?.rest();if(!G||(v===""||v===".")&&!V)this.matches.add($,K,v===""||v===".");else if(v===".."){let H=$.parent||$;if(!V)this.matches.add(H,K,!0);else if(!this.hasWalkedCache.hasWalked(H,V))this.subwalks.add(H,V)}}else if(W instanceof RegExp)this.subwalks.add($,Y)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new IG(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===Y6)$.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 Q21=(Z,J)=>typeof Z==="string"?new EG([Z],J):Array.isArray(Z)?new EG(Z,J):Z;class CR{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=Q21(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw new Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#X(Z){return this.seen.has(Z)||!!this.#J?.ignored?.(Z)}#Y(Z){return!!this.#J?.childrenIgnored?.(Z)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Z=void 0;while(!this.paused&&(Z=this.#Z.shift()))Z()}onResume(Z){if(this.signal?.aborted)return;if(!this.paused)Z();else this.#Z.push(Z)}async matchCheck(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||await Z.realpath(),!X)return;Z=X}let Y=Z.isUnknown()||this.opts.stat?await Z.lstat():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=await Y.realpath();if(Q&&(Q.isUnknown()||this.opts.stat))await Q.lstat()}return this.matchCheckTest(Y,J)}matchCheckTest(Z,J){return Z&&(this.maxDepth===1/0||Z.depth()<=this.maxDepth)&&(!J||Z.canReaddir())&&(!this.opts.nodir||!Z.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Z.isSymbolicLink()||!Z.realpathCached()?.isDirectory())&&!this.#X(Z)?Z:void 0}matchCheckSync(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||Z.realpathSync(),!X)return;Z=X}let Y=Z.isUnknown()||this.opts.stat?Z.lstatSync():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=Y.realpathSync();if(Q&&(Q?.isUnknown()||this.opts.stat))Q.lstatSync()}return this.matchCheckTest(Y,J)}matchFinish(Z,J){if(this.#X(Z))return;if(!this.includeChildMatches&&this.#J?.add){let Y=`${Z.relativePosix()}/**`;this.#J.add(Y)}let X=this.opts.absolute===void 0?J:this.opts.absolute;this.seen.add(Z);let $=this.opts.mark&&Z.isDirectory()?this.#$:"";if(this.opts.withFileTypes)this.matchEmit(Z);else if(X){let Y=this.opts.posix?Z.fullpathPosix():Z.fullpath();this.matchEmit(Y+$)}else{let Y=this.opts.posix?Z.relativePosix():Z.relative(),Q=this.opts.dotRelative&&!Y.startsWith(".."+this.#$)?"."+this.#$:"";this.matchEmit(!Y?"."+$:Q+Y+$)}}async match(Z,J,X){let $=await this.matchCheck(Z,X);if($)this.matchFinish($,J)}matchSync(Z,J,X){let $=this.matchCheckSync(Z,X);if($)this.matchFinish($,J)}walkCB(Z,J,X){if(this.signal?.aborted)X();this.walkCB2(Z,J,new IG(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 IG(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 tF extends CR{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 eF extends CR{results;constructor(Z,J,X){super(Z,J,X);this.results=new O$({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 W21=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Y7{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Z,J){if(!J)throw new TypeError("glob options required");if(this.withFileTypes=!!J.withFileTypes,this.signal=J.signal,this.follow=!!J.follow,this.dot=!!J.dot,this.dotRelative=!!J.dotRelative,this.nodir=!!J.nodir,this.mark=!!J.mark,!J.cwd)this.cwd="";else if(J.cwd instanceof URL||J.cwd.startsWith("file://"))J.cwd=K21(J.cwd);if(this.cwd=J.cwd||"",this.root=J.root,this.magicalBraces=!!J.magicalBraces,this.nobrace=!!J.nobrace,this.noext=!!J.noext,this.realpath=!!J.realpath,this.absolute=J.absolute,this.includeChildMatches=J.includeChildMatches!==!1,this.noglobstar=!!J.noglobstar,this.matchBase=!!J.matchBase,this.maxDepth=typeof J.maxDepth==="number"?J.maxDepth:1/0,this.stat=!!J.stat,this.ignore=J.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof Z==="string")Z=[Z];if(this.windowsPathsNoEscape=!!J.windowsPathsNoEscape||J.allowWindowsEscape===!1,this.windowsPathsNoEscape)Z=Z.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(J.noglobstar)throw new TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||W21,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?TG:J.platform==="darwin"?rF:J.platform?kG:zd;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 q4(W,$)),[Q,K]=Y.reduce((W,G)=>{return W[0].push(...G.set),W[1].push(...G.globParts),W},[[],[]]);this.patterns=Q.map((W,G)=>{let z=K[G];if(!z)throw new Error("invalid pattern object");return new FK(W,z,0,this.platform)})}async walk(){return[...await new tF(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 tF(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 eF(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 eF(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 TR=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new q4(X,J).hasMagic())return!0;return!1};function Jw(Z,J={}){return new Y7(Z,J).streamSync()}function qd(Z,J={}){return new Y7(Z,J).stream()}function Fd(Z,J={}){return new Y7(Z,J).walkSync()}async function Vd(Z,J={}){return new Y7(Z,J).walk()}function Xw(Z,J={}){return new Y7(Z,J).iterateSync()}function wd(Z,J={}){return new Y7(Z,J).iterate()}var G21=Jw,z21=Object.assign(qd,{sync:Jw}),v21=Xw,H21=Object.assign(wd,{sync:Xw}),V21=Object.assign(Fd,{stream:Jw,iterate:Xw}),Zw=Object.assign(Vd,{glob:Vd,globSync:Fd,sync:V21,globStream:qd,stream:z21,globStreamSync:Jw,streamSync:G21,globIterate:wd,iterate:H21,globIterateSync:Xw,iterateSync:v21,Glob:Y7,hasMagic:TR,escape:zK,unescape:V9});Zw.glob=Zw;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 H5{constructor(Z,J,X,$={}){if(this._name=void 0,this._parent=void 0,this._child=void 0,this._attributes=void 0,this._disposed=!1,this._name=Z,this._parent=J,this._child=X,this._attributes=$,!J.isOnGraph(X))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(Z){return this._child=Z,this}getAttributes(){return this._attributes}dispose(){if(this._disposed)return;this._parent._destroyRef(this),this._disposed=!0}isDisposed(){return this._disposed}}class wK 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 H5(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 fG(){return fG=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},fG.apply(this,arguments)}class B6{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 C0{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 a1{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 b0=Symbol("attributes"),w9=Symbol("immutableKeys");class UK extends kR{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[b0]=void 0,this[w9]=void 0,this.graph=Z,this[w9]=new Set,this[b0]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let $=Z[X];if($ instanceof UK){let Y=this.graph._createEdge(X,this,$);this[w9].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[b0]){let $=this[b0][X];if($ instanceof H5){let Y=$;if(Y.getChild()===Z)this.setRef(X,J,Y.getAttributes())}else if($ instanceof B6)for(let Y of $.listRefsByChild(Z)){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if($ instanceof C0){let Y=$.getRefByChild(Z);if(Y){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if($ instanceof a1)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[b0][Z]}set(Z,J){return this[b0][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[b0][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[w9].has(Z))throw new Error(`Cannot overwrite immutable attribute, "${Z}".`);let $=this[b0][Z];if($)$.dispose();if(!J)return this;let Y=this.graph._createEdge(Z,this,J,X);return this[b0][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 B6)for(let $ of X.listRefsByChild(J))$.dispose();else{let $=X.getRefByChild(J);if($)$.dispose()}return this}assertRefList(Z){let J=this[b0][Z];if(J instanceof B6||J instanceof C0)return J;throw new Error(`Expected RefList or RefSet for attribute "${Z}"`)}listRefMapKeys(Z){return this.assertRefMap(Z).keys()}listRefMapValues(Z){return this.assertRefMap(Z).values().map((J)=>J.getChild())}getRefMap(Z,J){let $=this.assertRefMap(Z).get(J);return $?$.getChild():null}setRefMap(Z,J,X,$){let Y=this.assertRefMap(Z),Q=Y.get(J);if(Q)Q.dispose();if(!X)return this;$=Object.assign($||{},{key:J});let K=this.graph._createEdge(Z,this,X,fG({},$,{key:J}));return Y.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[b0][Z];if(J instanceof a1)return J;throw new Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(fG({},Z,{target:this})),this.graph.dispatchEvent(fG({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[b0][J]===Z){if(this[b0][J]=null,this[w9].has(J))Z.getChild().dispose()}else if(this[b0][J]instanceof B6)this[b0][J].remove(Z);else if(this[b0][J]instanceof C0)this[b0][J].remove(Z);else if(this[b0][J]instanceof a1){let X=this[b0][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 Od="v4.1.1",Gw="@glb.bin",n;(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"})(n||(n={}));var zw;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(zw||(zw={}));var S5;(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"})(S5||(S5={}));var vw;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(vw||(vw={}));var GZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(GZ||(GZ={}));var DJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array},IR=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function q21(){var Z=new IR(3);if(IR!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function ER(Z){var J=Z[0],X=Z[1],$=Z[2];return Math.hypot(J,X,$)}function F21(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=q21();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 hR(Z){let J=Md(),X=Z.propertyType===n.NODE?[Z]:Z.listChildren();for(let $ of X)$.traverse((Y)=>{let Q=Y.getMesh();if(!Q)return;let K=w21(Q,Y.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))fR(K.min,J),fR(K.max,J)});return J}function w21(Z,J){let X=Md();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=F21(W,K,J),fR(W,X)}}return X}function fR(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 Md(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class r0{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let $=0;$<J.length;$++)X[$]=J.charCodeAt($);return X}else{let J=Z.split(",")[1],X=Z.indexOf("base64")>=0;return Buffer.from(J,X?"base64":"utf8")}}static encodeText(Z){return new TextEncoder().encode(Z)}static decodeText(Z){return new TextDecoder().decode(Z)}static concat(Z){let J=0;for(let Y of Z)J+=Y.byteLength;let X=new Uint8Array(J),$=0;for(let Y of Z)X.set(Y,$),$+=Y.byteLength;return X}static pad(Z,J=0){let X=this.padNumber(Z.byteLength);if(X===Z.byteLength)return Z;let $=new Uint8Array(X);if($.set(Z),J!==0)for(let Y=Z.byteLength;Y<X;Y++)$[Y]=J;return $}static padNumber(Z){return Math.ceil(Z/4)*4}static equals(Z,J){if(Z===J)return!0;if(Z.byteLength!==J.byteLength)return!1;let X=Z.byteLength;while(X--)if(Z[X]!==J[X])return!1;return!0}static toView(Z,J=0,X=1/0){return new Uint8Array(Z.buffer,Z.byteOffset+J,Math.min(Z.byteLength,X))}static assertView(Z){if(Z&&!ArrayBuffer.isView(Z))throw new Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class bR{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 Rd{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),U21(J,X),$=J.getUint8(X+1),$===192||$===193||$===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class qw{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(r0.decodeText(Z.slice(12,16))===qw.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}}qw.PNG_FRIED_CHUNK_NAME="CgBI";class zZ{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}`}}zZ.impls={"image/jpeg":new Rd,"image/png":new qw};function U21(Z,J){if(J>Z.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return Z}class vZ{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 zZ.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()}}function Ud(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function R$(Z){if(Ud(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Ud(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var _R,_G;(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"})(_G||(_G={}));class q5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=q5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=q5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=q5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=q5.Verbosity.ERROR)console.error(Z)}}_R=q5;q5.Verbosity=_G;q5.DEFAULT_INSTANCE=new _R(_R.Verbosity.INFO);function x21(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],V=Z[10],H=Z[11],q=Z[12],F=Z[13],w=Z[14],U=Z[15],x=J*K-X*Q,L=J*W-$*Q,j=J*G-Y*Q,c=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,N=z*F-v*q,D=z*w-V*q,P=z*U-H*q,f=v*w-V*F,E=v*U-H*F,_=V*U-H*w;return x*_-L*E+j*f+c*P-R*D+M*N}function B21(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],V=J[8],H=J[9],q=J[10],F=J[11],w=J[12],U=J[13],x=J[14],L=J[15],j=X[0],c=X[1],R=X[2],M=X[3];return Z[0]=j*$+c*W+R*V+M*w,Z[1]=j*Y+c*G+R*H+M*U,Z[2]=j*Q+c*z+R*q+M*x,Z[3]=j*K+c*v+R*F+M*L,j=X[4],c=X[5],R=X[6],M=X[7],Z[4]=j*$+c*W+R*V+M*w,Z[5]=j*Y+c*G+R*H+M*U,Z[6]=j*Q+c*z+R*q+M*x,Z[7]=j*K+c*v+R*F+M*L,j=X[8],c=X[9],R=X[10],M=X[11],Z[8]=j*$+c*W+R*V+M*w,Z[9]=j*Y+c*G+R*H+M*U,Z[10]=j*Q+c*z+R*q+M*x,Z[11]=j*K+c*v+R*F+M*L,j=X[12],c=X[13],R=X[14],M=X[15],Z[12]=j*$+c*W+R*V+M*w,Z[13]=j*Y+c*G+R*H+M*U,Z[14]=j*Q+c*z+R*q+M*x,Z[15]=j*K+c*v+R*F+M*L,Z}function L21(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 j21(Z,J){var X=new IR(3);L21(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,V=J[6]*Q,H=J[8]*$,q=J[9]*Y,F=J[10]*Q,w=K+v+F,U=0;if(w>0)U=Math.sqrt(w+1)*2,Z[3]=0.25*U,Z[0]=(V-q)/U,Z[1]=(H-G)/U,Z[2]=(W-z)/U;else if(K>v&&K>F)U=Math.sqrt(1+K-v-F)*2,Z[3]=(V-q)/U,Z[0]=0.25*U,Z[1]=(W+z)/U,Z[2]=(H+G)/U;else if(v>F)U=Math.sqrt(1+v-K-F)*2,Z[3]=(H-G)/U,Z[0]=(W+z)/U,Z[1]=0.25*U,Z[2]=(V+q)/U;else U=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/U,Z[0]=(H+G)/U,Z[1]=(V+q)/U,Z[2]=0.25*U;return Z}class a0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(a0.clamp(Z,0,1)*65535);case 5121:return Math.round(a0.clamp(Z,0,1)*255);case 5122:return Math.round(a0.clamp(Z,-1,1)*32767);case 5120:return Math.round(a0.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,$){let Y=ER([Z[0],Z[1],Z[2]]),Q=ER([Z[4],Z[5],Z[6]]),K=ER([Z[8],Z[9],Z[10]]);if(x21(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,V=1/K;G[0]*=z,G[1]*=z,G[2]*=z,G[4]*=v,G[5]*=v,G[6]*=v,G[8]*=V,G[9]*=V,G[10]*=V,j21(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,V=W+W,H=Q*z,q=Q*v,F=Q*V,w=K*v,U=K*V,x=W*V,L=G*z,j=G*v,c=G*V,R=X[0],M=X[1],N=X[2];return Y[0]=(1-(w+x))*R,Y[1]=(q+c)*R,Y[2]=(F-j)*R,Y[3]=0,Y[4]=(q-c)*M,Y[5]=(1-(H+x))*M,Y[6]=(U+L)*M,Y[7]=0,Y[8]=(F+j)*N,Y[9]=(U-L)*N,Y[10]=(1-(H+w))*N,Y[11]=0,Y[12]=Z[0],Y[13]=Z[1],Y[14]=Z[2],Y[15]=1,Y}}function c21(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),$=J.getChild();return X===$||X.equals($)}function O21(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 M21(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 Nd(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 Dd(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!R$(Z)||!R$(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(Hw(W)&&Hw(G)){if(!Nd(W,G))return!1}else if(R$(W)&&R$(G)){if(!Dd(W,G))return!1}else if(W!==G)return!1}return!0}function Hw(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var xd="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",R21=999,N21=6,Bd=new Set,D21=function Z(){let J="";for(let X=0;X<N21;X++)J+=xd.charAt(Math.floor(Math.random()*xd.length));return J},Pd=function Z(){for(let J=0;J<R21;J++){let X=D21();if(!Bd.has(X))return Bd.add(X),X}return""},Ld="https://null.example";class U4{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return vZ.basename(new URL(Z,Ld).pathname)}static extension(Z){return vZ.extension(new URL(Z,Ld).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)}}U4.DEFAULT_INIT={};U4.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var NJ=(Z)=>Z,P21=new Set;class Fw extends UK{constructor(Z,J=""){super(Z);this[b0].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,NJ)}copy(Z,J=NJ){for(let X in this[b0]){let $=this[b0][X];if($ instanceof H5){if(!this[w9].has(X))$.dispose()}else if($ instanceof B6||$ instanceof C0)for(let Y of $.values())Y.dispose();else if($ instanceof a1)for(let Y of $.values())Y.dispose()}for(let X in Z[b0]){let $=this[b0][X],Y=Z[b0][X];if(Y instanceof H5)if(this[w9].has(X))$.getChild().copy(J(Y.getChild()),J);else this.setRef(X,J(Y.getChild()),Y.getAttributes());else if(Y instanceof C0||Y instanceof B6)for(let Q of Y.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if(Y instanceof a1)for(let Q of Y.keys()){let K=Y.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(R$(Y))this[b0][X]=JSON.parse(JSON.stringify(Y));else if(Array.isArray(Y)||Y instanceof ArrayBuffer||ArrayBuffer.isView(Y))this[b0][X]=Y.slice();else this[b0][X]=Y}return this}equals(Z,J=P21){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[b0]){if(J.has(X))continue;let $=this[b0][X],Y=Z[b0][X];if($ instanceof H5||Y instanceof H5){if(!c21($,Y))return!1}else if($ instanceof C0||Y instanceof C0||$ instanceof B6||Y instanceof B6){if(!O21($,Y))return!1}else if($ instanceof a1||Y instanceof a1){if(!M21($,Y))return!1}else if(R$($)||R$(Y)){if(!Dd($,Y))return!1}else if(Hw($)||Hw(Y)){if(!Nd($,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 j6 extends Fw{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new a1})}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 _0 extends j6{init(){this.propertyType=n.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:_0.Type.SCALAR,componentType:_0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case _0.Type.SCALAR:return 1;case _0.Type.VEC2:return 2;case _0.Type.VEC3:return 3;case _0.Type.VEC4:return 4;case _0.Type.MAT2:return 4;case _0.Type.MAT3:return 9;case _0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case _0.ComponentType.BYTE:return 1;case _0.ComponentType.UNSIGNED_BYTE:return 1;case _0.ComponentType.SHORT:return 2;case _0.ComponentType.UNSIGNED_SHORT:return 2;case _0.ComponentType.UNSIGNED_INT:return 4;case _0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMin(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=a0.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]=a0.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 _0.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 a0.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]=a0.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]=a0.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]=a0.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?C21(Z):_0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}_0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};_0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function C21(Z){switch(Z.constructor){case Float32Array:return _0.ComponentType.FLOAT;case Uint32Array:return _0.ComponentType.UNSIGNED_INT;case Uint16Array:return _0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return _0.ComponentType.UNSIGNED_BYTE;case Int16Array:return _0.ComponentType.SHORT;case Int8Array:return _0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class AR extends j6{init(){this.propertyType=n.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new C0,samplers:new C0})}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 N$ extends j6{init(){this.propertyType=n.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)}}N$.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class xK extends j6{init(){this.propertyType=n.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:xK.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:S5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:S5.OTHER})}}xK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class mR extends j6{init(){this.propertyType=n.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class D$ extends j6{init(){this.propertyType=n.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:D$.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)}}D$.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class BK extends Fw{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}BK.EXTENSION_NAME=void 0;class V5 extends j6{init(){this.propertyType=n.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:V5.WrapMode.REPEAT,wrapT:V5.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)}}V5.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};V5.MagFilter={NEAREST:9728,LINEAR:9729};V5.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:$w,G:Yw,B:Qw,A:T21}=vw;class Q7 extends j6{init(){this.propertyType=n.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:Q7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new V5(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new V5(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new V5(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new V5(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new V5(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:$w|Yw|Qw|T21,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:$w|Yw|Qw,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:$w|Yw|Qw})}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:$w})}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:Yw|Qw})}}Q7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class hG extends j6{init(){this.propertyType=n.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new C0})}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 ww extends j6{init(){this.propertyType=n.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 C0})}copy(Z,J=NJ){if(J===NJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return a0.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 a0.decompose(Z,J,X,$),this.set("translation",J).set("rotation",X).set("scale",$)}getWorldTranslation(){let Z=[0,0,0];return a0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return a0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return a0.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())B21(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===n.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===n.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 B8 extends j6{init(){this.propertyType=n.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:B8.Mode.TRIANGLES,material:null,indices:null,attributes:new a1,targets:new C0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:S5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:S5.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)}}B8.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class uR extends Fw{init(){this.propertyType=n.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:S5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function u6(){return u6=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},u6.apply(null,arguments)}class LK extends j6{init(){this.propertyType=n.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new C0})}copy(Z,J=NJ){if(J===NJ)throw new Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class lR extends j6{init(){this.propertyType=n.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new C0})}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:S5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class P$ extends j6{init(){this.propertyType=n.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||zZ.extensionToMimeType(vZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=zZ.extensionToMimeType(vZ.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",r0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return zZ.getSize(Z,this.getMimeType())}}class C$ extends j6{init(){this.propertyType=n.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Od}`,version:"2.0"},defaultScene:null,accessors:new C0,animations:new C0,buffers:new C0,cameras:new C0,materials:new C0,meshes:new C0,nodes:new C0,scenes:new C0,skins:new C0,textures:new C0})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(Z,J=NJ){if(J===NJ)throw new Error("Root cannot be copied.");this.set("asset",u6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(u6({},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 LK)this.addRef("scenes",Z);else if(Z instanceof ww)this.addRef("nodes",Z);else if(Z instanceof D$)this.addRef("cameras",Z);else if(Z instanceof lR)this.addRef("skins",Z);else if(Z instanceof hG)this.addRef("meshes",Z);else if(Z instanceof Q7)this.addRef("materials",Z);else if(Z instanceof P$)this.addRef("textures",Z);else if(Z instanceof AR)this.addRef("animations",Z);else if(Z instanceof _0)this.addRef("accessors",Z);else if(Z instanceof mR)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 L6{static fromGraph(Z){return L6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new wK,this._root=new C$(this._graph),this._logger=q5.DEFAULT_INSTANCE,L6._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(($)=>$.extensionName===J)||new Z(this)}createScene(Z=""){return new LK(this._graph,Z)}createNode(Z=""){return new ww(this._graph,Z)}createCamera(Z=""){return new D$(this._graph,Z)}createSkin(Z=""){return new lR(this._graph,Z)}createMesh(Z=""){return new hG(this._graph,Z)}createPrimitive(){return new B8(this._graph)}createPrimitiveTarget(Z=""){return new uR(this._graph,Z)}createMaterial(Z=""){return new Q7(this._graph,Z)}createTexture(Z=""){return new P$(this._graph,Z)}createAnimation(Z=""){return new AR(this._graph,Z)}createAnimationChannel(Z=""){return new N$(this._graph,Z)}createAnimationSampler(Z=""){return new xK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new _0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new mR(this._graph,Z)}}L6._GRAPH_DOCUMENTS=new WeakMap;class Cd{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 BK&&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}}Cd.EXTENSION_NAME=void 0;class Td{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 jd={logger:q5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},k21=new Set([n.BUFFER,n.TEXTURE,n.MATERIAL,n.MESH,n.PRIMITIVE,n.NODE,n.SCENE]);class kd{static read(Z,J=jd){let X=u6({},jd,J),{json:$}=Z,Y=new L6().setLogger(X.logger);this.validate(Z,X);let Q=new Td(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(u6({},$.extras));let G=$.extensionsUsed||[],z=$.extensionsRequired||[];X.extensions.sort((M,N)=>M.EXTENSION_NAME>N.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let N=Y.createExtension(M).setRequired(z.includes(M.EXTENSION_NAME)),D=N.prereadTypes.filter((P)=>!k21.has(P));if(D.length)X.logger.warn(`Preread hooks for some types (${D.join()}), requested by extension ${N.extensionName}, are unsupported. Please file an issue or a PR.`);for(let P of N.readDependencies)N.install(P,X.dependencies[P])}let v=$.buffers||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.BUFFER)).forEach((M)=>M.preread(Q,n.BUFFER)),Q.buffers=v.map((M)=>{let N=Y.createBuffer(M.name);if(M.extras)N.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)N.setURI(M.uri);return N});let V=$.bufferViews||[];Q.bufferViewBuffers=V.map((M,N)=>{if(!Q.bufferViews[N]){let D=Z.json.buffers[M.buffer],P=D.uri?Z.resources[D.uri]:Z.resources[Gw],f=M.byteOffset||0;Q.bufferViews[N]=r0.toView(P,f,M.byteLength)}return Q.buffers[M.buffer]});let H=$.accessors||[];Q.accessors=H.map((M)=>{let N=Q.bufferViewBuffers[M.bufferView],D=Y.createAccessor(M.name,N).setType(M.type);if(M.extras)D.setExtras(M.extras);if(M.normalized!==void 0)D.setNormalized(M.normalized);if(M.bufferView===void 0)return D;return D.setArray(Ww(M,Q)),D});let q=$.images||[],F=$.textures||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.TEXTURE)).forEach((M)=>M.preread(Q,n.TEXTURE)),Q.textures=q.map((M)=>{let N=Y.createTexture(M.name);if(M.extras)N.setExtras(M.extras);if(M.bufferView!==void 0){let D=$.bufferViews[M.bufferView],P=Z.json.buffers[D.buffer],f=P.uri?Z.resources[P.uri]:Z.resources[Gw],E=D.byteOffset||0,_=D.byteLength,T=f.slice(E,E+_);N.setImage(T)}else if(M.uri!==void 0){if(N.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)N.setURI(M.uri)}if(M.mimeType!==void 0)N.setMimeType(M.mimeType);else if(M.uri){let D=vZ.extension(M.uri);N.setMimeType(zZ.extensionToMimeType(D))}return N}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.MATERIAL)).forEach((M)=>M.preread(Q,n.MATERIAL));let w=$.materials||[];Q.materials=w.map((M)=>{let N=Y.createMaterial(M.name);if(M.extras)N.setExtras(M.extras);if(M.alphaMode!==void 0)N.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)N.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)N.setDoubleSided(M.doubleSided);let D=M.pbrMetallicRoughness||{};if(D.baseColorFactor!==void 0)N.setBaseColorFactor(D.baseColorFactor);if(M.emissiveFactor!==void 0)N.setEmissiveFactor(M.emissiveFactor);if(D.metallicFactor!==void 0)N.setMetallicFactor(D.metallicFactor);if(D.roughnessFactor!==void 0)N.setRoughnessFactor(D.roughnessFactor);if(D.baseColorTexture!==void 0){let P=D.baseColorTexture,f=Q.textures[F[P.index].source];N.setBaseColorTexture(f),Q.setTextureInfo(N.getBaseColorTextureInfo(),P)}if(M.emissiveTexture!==void 0){let P=M.emissiveTexture,f=Q.textures[F[P.index].source];N.setEmissiveTexture(f),Q.setTextureInfo(N.getEmissiveTextureInfo(),P)}if(M.normalTexture!==void 0){let P=M.normalTexture,f=Q.textures[F[P.index].source];if(N.setNormalTexture(f),Q.setTextureInfo(N.getNormalTextureInfo(),P),M.normalTexture.scale!==void 0)N.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let P=M.occlusionTexture,f=Q.textures[F[P.index].source];if(N.setOcclusionTexture(f),Q.setTextureInfo(N.getOcclusionTextureInfo(),P),M.occlusionTexture.strength!==void 0)N.setOcclusionStrength(M.occlusionTexture.strength)}if(D.metallicRoughnessTexture!==void 0){let P=D.metallicRoughnessTexture,f=Q.textures[F[P.index].source];N.setMetallicRoughnessTexture(f),Q.setTextureInfo(N.getMetallicRoughnessTextureInfo(),P)}return N}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.MESH)).forEach((M)=>M.preread(Q,n.MESH));let U=$.meshes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.PRIMITIVE)).forEach((M)=>M.preread(Q,n.PRIMITIVE)),Q.meshes=U.map((M)=>{let N=Y.createMesh(M.name);if(M.extras)N.setExtras(M.extras);if(M.weights!==void 0)N.setWeights(M.weights);return(M.primitives||[]).forEach((P)=>{let f=Y.createPrimitive();if(P.extras)f.setExtras(P.extras);if(P.material!==void 0)f.setMaterial(Q.materials[P.material]);if(P.mode!==void 0)f.setMode(P.mode);for(let[T,k]of Object.entries(P.attributes||{}))f.setAttribute(T,Q.accessors[k]);if(P.indices!==void 0)f.setIndices(Q.accessors[P.indices]);let E=M.extras&&M.extras.targetNames||[];(P.targets||[]).forEach((T,k)=>{let h=E[k]||k.toString(),u=Y.createPrimitiveTarget(h);for(let[a,o]of Object.entries(T))u.setAttribute(a,Q.accessors[o]);f.addTarget(u)}),N.addPrimitive(f)}),N});let x=$.cameras||[];Q.cameras=x.map((M)=>{let N=Y.createCamera(M.name).setType(M.type);if(M.extras)N.setExtras(M.extras);if(M.type===D$.Type.PERSPECTIVE){let D=M.perspective;if(N.setYFov(D.yfov),N.setZNear(D.znear),D.zfar!==void 0)N.setZFar(D.zfar);if(D.aspectRatio!==void 0)N.setAspectRatio(D.aspectRatio)}else{let D=M.orthographic;N.setZNear(D.znear).setZFar(D.zfar).setXMag(D.xmag).setYMag(D.ymag)}return N});let L=$.nodes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.NODE)).forEach((M)=>M.preread(Q,n.NODE)),Q.nodes=L.map((M)=>{let N=Y.createNode(M.name);if(M.extras)N.setExtras(M.extras);if(M.translation!==void 0)N.setTranslation(M.translation);if(M.rotation!==void 0)N.setRotation(M.rotation);if(M.scale!==void 0)N.setScale(M.scale);if(M.matrix!==void 0){let D=[0,0,0],P=[0,0,0,1],f=[1,1,1];a0.decompose(M.matrix,D,P,f),N.setTranslation(D),N.setRotation(P),N.setScale(f)}if(M.weights!==void 0)N.setWeights(M.weights);return N});let j=$.skins||[];Q.skins=j.map((M)=>{let N=Y.createSkin(M.name);if(M.extras)N.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)N.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)N.setSkeleton(Q.nodes[M.skeleton]);for(let D of M.joints)N.addJoint(Q.nodes[D]);return N}),L.map((M,N)=>{let D=Q.nodes[N];if((M.children||[]).forEach((f)=>D.addChild(Q.nodes[f])),M.mesh!==void 0)D.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)D.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)D.setSkin(Q.skins[M.skin])});let c=$.animations||[];Q.animations=c.map((M)=>{let N=Y.createAnimation(M.name);if(M.extras)N.setExtras(M.extras);let P=(M.samplers||[]).map((E)=>{let _=Y.createAnimationSampler().setInput(Q.accessors[E.input]).setOutput(Q.accessors[E.output]).setInterpolation(E.interpolation||xK.Interpolation.LINEAR);if(E.extras)_.setExtras(E.extras);return N.addSampler(_),_});return(M.channels||[]).forEach((E)=>{let _=Y.createAnimationChannel().setSampler(P[E.sampler]).setTargetPath(E.target.path);if(E.target.node!==void 0)_.setTargetNode(Q.nodes[E.target.node]);if(E.extras)_.setExtras(E.extras);N.addChannel(_)}),N});let R=$.scenes||[];if(Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.SCENE)).forEach((M)=>M.preread(Q,n.SCENE)),Q.scenes=R.map((M)=>{let N=Y.createScene(M.name);if(M.extras)N.setExtras(M.extras);return(M.nodes||[]).map((P)=>Q.nodes[P]).forEach((P)=>N.addChild(P)),N}),$.scene!==void 0)Y.getRoot().setDefaultScene(Q.scenes[$.scene]);return Y.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),H.forEach((M,N)=>{let D=Q.accessors[N],P=!!M.sparse,f=!M.bufferView&&!D.getArray();if(P||f)D.setSparse(!0).setArray(I21(M,Q))}),Y}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let $ of X.extensionsRequired)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))throw new Error(`Missing required extension, "${$}".`)}if(X.extensionsUsed){for(let $ of X.extensionsUsed)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))J.logger.warn(`Missing optional extension, "${$}".`)}}}function E21(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=DJ[Z.componentType],K=_0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,z=new Q(Z.count*K),v=new DataView($.buffer,$.byteOffset,$.byteLength),V=Y.byteStride;for(let H=0;H<Z.count;H++)for(let q=0;q<K;q++){let F=G+H*V+q*W,w;switch(Z.componentType){case _0.ComponentType.FLOAT:w=v.getFloat32(F,!0);break;case _0.ComponentType.UNSIGNED_INT:w=v.getUint32(F,!0);break;case _0.ComponentType.UNSIGNED_SHORT:w=v.getUint16(F,!0);break;case _0.ComponentType.UNSIGNED_BYTE:w=v.getUint8(F);break;case _0.ComponentType.SHORT:w=v.getInt16(F,!0);break;case _0.ComponentType.BYTE:w=v.getInt8(F);break;default:throw new Error(`Unexpected componentType "${Z.componentType}".`)}z[H*K+q]=w}return z}function Ww(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=DJ[Z.componentType],K=_0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if(Y.byteStride!==void 0&&Y.byteStride!==G)return E21(Z,J);let z=$.byteOffset+(Z.byteOffset||0),v=Z.count*K*W;return new Q($.buffer.slice(z,z+v))}function I21(Z,J){let X=DJ[Z.componentType],$=_0.getElementSize(Z.type),Y;if(Z.bufferView!==void 0)Y=Ww(Z,J);else Y=new X(Z.count*$);let Q=Z.sparse;if(!Q)return Y;let K=Q.count,W=u6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=u6({},Z,Q.values,{count:K}),z=Ww(W,J),v=Ww(G,J);for(let V=0;V<W.count;V++)for(let H=0;H<$;H++)Y[z[V]*$+H]=v[V*$+H];return Y}var SG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(SG||(SG={}));class RJ{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 SR(Y>1,()=>X.basename||"buffer"),this.imageURIGenerator=new SR(Q>1,(K)=>f21(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===GZ.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 $=zZ.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,$),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let $=this.jsonDoc.resources;if(!(Z in $)){$[Z]=J;return}if(J===$[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let Y=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn(Y);return}throw new Error(Y)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return S5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:$}=X.getAttributes();if($)return $;if(X.getParent().propertyType!==n.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return S5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw new Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}RJ.BufferViewTarget=SG;RJ.BufferViewUsage=S5;RJ.USAGE_TO_TARGET={[S5.ARRAY_BUFFER]:SG.ARRAY_BUFFER,[S5.ELEMENT_ARRAY_BUFFER]:SG.ELEMENT_ARRAY_BUFFER};class SR{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 f21(Z,J){let X=Z.getGraph().listParentEdges(J).find(($)=>$.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:Kw}=RJ,{UNSIGNED_INT:_21,UNSIGNED_SHORT:S21,UNSIGNED_BYTE:h21}=_0.ComponentType,b21=new Set([n.ACCESSOR,n.BUFFER,n.MATERIAL,n.MESH]);class Ed{static write(Z,J){let X=Z.getGraph(),$=Z.getRoot(),Y={asset:u6({generator:`glTF-Transform ${Od}`},$.getAsset()),extras:u6({},$.getExtras())},Q={json:Y,resources:{}},K=new RJ(Z,Q,J),W=J.logger||q5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((U)=>U.EXTENSION_NAME)),z=Z.getRoot().listExtensionsUsed().filter((U)=>G.has(U.extensionName)).sort((U,x)=>U.extensionName>x.extensionName?1:-1),v=Z.getRoot().listExtensionsRequired().filter((U)=>G.has(U.extensionName)).sort((U,x)=>U.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 U of z){let x=U.prewriteTypes.filter((L)=>!b21.has(L));if(x.length)W.warn(`Prewrite hooks for some types (${x.join()}), requested by extension ${U.extensionName}, are unsupported. Please file an issue or a PR.`);for(let L of U.writeDependencies)U.install(L,J.dependencies[L])}function V(U,x,L,j){let c=[],R=0;for(let D of U){let P=K.createAccessorDef(D);P.bufferView=Y.bufferViews.length;let f=D.getArray(),E=r0.pad(r0.toView(f));P.byteOffset=R,R+=E.byteLength,c.push(E),K.accessorIndexMap.set(D,Y.accessors.length),Y.accessors.push(P)}let M=r0.concat(c),N={buffer:x,byteOffset:L,byteLength:M.byteLength};if(j)N.target=j;return Y.bufferViews.push(N),{buffers:c,byteLength:R}}function H(U,x,L){let j=U[0].getCount(),c=0;for(let P of U){let f=K.createAccessorDef(P);f.bufferView=Y.bufferViews.length,f.byteOffset=c;let E=P.getElementSize(),_=P.getComponentSize();c+=r0.padNumber(E*_),K.accessorIndexMap.set(P,Y.accessors.length),Y.accessors.push(f)}let R=j*c,M=new ArrayBuffer(R),N=new DataView(M);for(let P=0;P<j;P++){let f=0;for(let E of U){let _=E.getElementSize(),T=E.getComponentSize(),k=E.getComponentType(),h=E.getArray();for(let u=0;u<_;u++){let a=P*c+f+u*T,o=h[P*_+u];switch(k){case _0.ComponentType.FLOAT:N.setFloat32(a,o,!0);break;case _0.ComponentType.BYTE:N.setInt8(a,o);break;case _0.ComponentType.SHORT:N.setInt16(a,o,!0);break;case _0.ComponentType.UNSIGNED_BYTE:N.setUint8(a,o);break;case _0.ComponentType.UNSIGNED_SHORT:N.setUint16(a,o,!0);break;case _0.ComponentType.UNSIGNED_INT:N.setUint32(a,o,!0);break;default:throw new Error("Unexpected component type: "+k)}}f+=r0.padNumber(_*T)}}let D={buffer:x,byteOffset:L,byteLength:R,byteStride:c,target:RJ.BufferViewTarget.ARRAY_BUFFER};return Y.bufferViews.push(D),{byteLength:R,buffers:[new Uint8Array(M)]}}function q(U,x,L){let j=[],c=0,R=new Map,M=-1/0,N=!1;for(let k of U){let h=K.createAccessorDef(k);Y.accessors.push(h),K.accessorIndexMap.set(k,Y.accessors.length-1);let u=[],a=[],o=[],Q0=new Array(k.getElementSize()).fill(0);for(let t0=0,C8=k.getCount();t0<C8;t0++){if(k.getElement(t0,o),a0.eq(o,Q0,0))continue;M=Math.max(t0,M),u.push(t0);for(let g1=0;g1<o.length;g1++)a.push(o[g1])}let W0=u.length,E0={accessorDef:h,count:W0};if(R.set(k,E0),W0===0)continue;if(W0>k.getCount()/2)N=!0;let I0=DJ[k.getComponentType()];E0.indices=u,E0.values=new I0(a)}if(!Number.isFinite(M))return{buffers:j,byteLength:c};if(N)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let D=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,P=M<255?h21:M<65535?S21:_21,f={buffer:x,byteOffset:L+c,byteLength:0};for(let k of U){let h=R.get(k);if(h.count===0)continue;h.indicesByteOffset=f.byteLength;let u=r0.pad(r0.toView(new D(h.indices)));j.push(u),c+=u.byteLength,f.byteLength+=u.byteLength}Y.bufferViews.push(f);let E=Y.bufferViews.length-1,_={buffer:x,byteOffset:L+c,byteLength:0};for(let k of U){let h=R.get(k);if(h.count===0)continue;h.valuesByteOffset=_.byteLength;let u=r0.pad(r0.toView(h.values));j.push(u),c+=u.byteLength,_.byteLength+=u.byteLength}Y.bufferViews.push(_);let T=Y.bufferViews.length-1;for(let k of U){let h=R.get(k);if(h.count===0)continue;h.accessorDef.sparse={count:h.count,indices:{bufferView:E,byteOffset:h.indicesByteOffset,componentType:P},values:{bufferView:T,byteOffset:h.valuesByteOffset}}}return{buffers:j,byteLength:c}}if(Y.accessors=[],Y.bufferViews=[],Y.samplers=[],Y.textures=[],Y.images=$.listTextures().map((U,x)=>{let L=K.createPropertyDef(U);if(U.getMimeType())L.mimeType=U.getMimeType();let j=U.getImage();if(j)K.createImageData(L,j,U);return K.imageIndexMap.set(U,x),L}),z.filter((U)=>U.prewriteTypes.includes(n.ACCESSOR)).forEach((U)=>U.prewrite(K,n.ACCESSOR)),$.listAccessors().forEach((U)=>{let{accessorUsageGroupedByParent:x,accessorParents:L}=K;if(K.accessorIndexMap.has(U))return;let j=K.getAccessorUsage(U);if(K.addAccessorToUsageGroup(U,j),x.has(j)){let c=X.listParents(U).find((R)=>R.propertyType!==n.ROOT);L.set(U,c)}}),z.filter((U)=>U.prewriteTypes.includes(n.BUFFER)).forEach((U)=>U.prewrite(K,n.BUFFER)),($.listAccessors().length>0||K.otherBufferViews.size>0||$.listTextures().length>0&&J.format===GZ.GLB)&&$.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");if(Y.buffers=[],$.listBuffers().forEach((U,x)=>{let L=K.createPropertyDef(U),j=K.accessorUsageGroupedByParent,c=U.listParents().filter((_)=>_ instanceof _0),R=new Set(c.map((_)=>K.accessorParents.get(_))),M=new Map(Array.from(R).map((_,T)=>[_,T])),N={};for(let _ of c){var D;if(K.accessorIndexMap.has(_))continue;let T=K.getAccessorUsage(_),k=T;if(j.has(T)){let h=K.accessorParents.get(_);k+=`:${M.get(h)}`}N[D=k]||(N[D]={usage:T,accessors:[]}),N[k].accessors.push(_)}let P=[],f=Y.buffers.length,E=0;for(let{usage:_,accessors:T}of Object.values(N))if(_===Kw.ARRAY_BUFFER&&J.vertexLayout===zw.INTERLEAVED){let k=H(T,f,E);E+=k.byteLength;for(let h of k.buffers)P.push(h)}else if(_===Kw.ARRAY_BUFFER)for(let k of T){let h=H([k],f,E);E+=h.byteLength;for(let u of h.buffers)P.push(u)}else if(_===Kw.SPARSE){let k=q(T,f,E);E+=k.byteLength;for(let h of k.buffers)P.push(h)}else if(_===Kw.ELEMENT_ARRAY_BUFFER){let k=RJ.BufferViewTarget.ELEMENT_ARRAY_BUFFER,h=V(T,f,E,k);E+=h.byteLength;for(let u of h.buffers)P.push(u)}else{let k=V(T,f,E);E+=k.byteLength;for(let h of k.buffers)P.push(h)}if(K.imageBufferViews.length&&x===0){for(let _=0;_<K.imageBufferViews.length;_++)if(Y.bufferViews[Y.images[_].bufferView].byteOffset=E,E+=K.imageBufferViews[_].byteLength,P.push(K.imageBufferViews[_]),E%8){let T=8-E%8;E+=T,P.push(new Uint8Array(T))}}if(K.otherBufferViews.has(U))for(let _ of K.otherBufferViews.get(U))Y.bufferViews.push({buffer:f,byteOffset:E,byteLength:_.byteLength}),K.otherBufferViewsIndexMap.set(_,Y.bufferViews.length-1),E+=_.byteLength,P.push(_);if(E){let _;if(J.format===GZ.GLB)_=Gw;else _=K.bufferURIGenerator.createURI(U,"bin"),L.uri=_;L.byteLength=E,K.assignResourceURI(_,r0.concat(P),!0)}Y.buffers.push(L),K.bufferIndexMap.set(U,x)}),$.listAccessors().find((U)=>!U.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");z.filter((U)=>U.prewriteTypes.includes(n.MATERIAL)).forEach((U)=>U.prewrite(K,n.MATERIAL)),Y.materials=$.listMaterials().map((U,x)=>{let L=K.createPropertyDef(U);if(U.getAlphaMode()!==Q7.AlphaMode.OPAQUE)L.alphaMode=U.getAlphaMode();if(U.getAlphaMode()===Q7.AlphaMode.MASK)L.alphaCutoff=U.getAlphaCutoff();if(U.getDoubleSided())L.doubleSided=!0;if(L.pbrMetallicRoughness={},!a0.eq(U.getBaseColorFactor(),[1,1,1,1]))L.pbrMetallicRoughness.baseColorFactor=U.getBaseColorFactor();if(!a0.eq(U.getEmissiveFactor(),[0,0,0]))L.emissiveFactor=U.getEmissiveFactor();if(U.getRoughnessFactor()!==1)L.pbrMetallicRoughness.roughnessFactor=U.getRoughnessFactor();if(U.getMetallicFactor()!==1)L.pbrMetallicRoughness.metallicFactor=U.getMetallicFactor();if(U.getBaseColorTexture()){let j=U.getBaseColorTexture(),c=U.getBaseColorTextureInfo();L.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(j,c)}if(U.getEmissiveTexture()){let j=U.getEmissiveTexture(),c=U.getEmissiveTextureInfo();L.emissiveTexture=K.createTextureInfoDef(j,c)}if(U.getNormalTexture()){let j=U.getNormalTexture(),c=U.getNormalTextureInfo(),R=K.createTextureInfoDef(j,c);if(U.getNormalScale()!==1)R.scale=U.getNormalScale();L.normalTexture=R}if(U.getOcclusionTexture()){let j=U.getOcclusionTexture(),c=U.getOcclusionTextureInfo(),R=K.createTextureInfoDef(j,c);if(U.getOcclusionStrength()!==1)R.strength=U.getOcclusionStrength();L.occlusionTexture=R}if(U.getMetallicRoughnessTexture()){let j=U.getMetallicRoughnessTexture(),c=U.getMetallicRoughnessTextureInfo();L.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(j,c)}return K.materialIndexMap.set(U,x),L}),z.filter((U)=>U.prewriteTypes.includes(n.MESH)).forEach((U)=>U.prewrite(K,n.MESH)),Y.meshes=$.listMeshes().map((U,x)=>{let L=K.createPropertyDef(U),j=null;if(L.primitives=U.listPrimitives().map((c)=>{let R={attributes:{}};R.mode=c.getMode();let M=c.getMaterial();if(M)R.material=K.materialIndexMap.get(M);if(Object.keys(c.getExtras()).length)R.extras=c.getExtras();let N=c.getIndices();if(N)R.indices=K.accessorIndexMap.get(N);for(let D of c.listSemantics())R.attributes[D]=K.accessorIndexMap.get(c.getAttribute(D));for(let D of c.listTargets()){let P={};for(let f of D.listSemantics())P[f]=K.accessorIndexMap.get(D.getAttribute(f));R.targets=R.targets||[],R.targets.push(P)}if(c.listTargets().length&&!j)j=c.listTargets().map((D)=>D.getName());return R}),U.getWeights().length)L.weights=U.getWeights();if(j)L.extras=L.extras||{},L.extras.targetNames=j;return K.meshIndexMap.set(U,x),L}),Y.cameras=$.listCameras().map((U,x)=>{let L=K.createPropertyDef(U);if(L.type=U.getType(),L.type===D$.Type.PERSPECTIVE){L.perspective={znear:U.getZNear(),zfar:U.getZFar(),yfov:U.getYFov()};let j=U.getAspectRatio();if(j!==null)L.perspective.aspectRatio=j}else L.orthographic={znear:U.getZNear(),zfar:U.getZFar(),xmag:U.getXMag(),ymag:U.getYMag()};return K.cameraIndexMap.set(U,x),L}),Y.nodes=$.listNodes().map((U,x)=>{let L=K.createPropertyDef(U);if(!a0.eq(U.getTranslation(),[0,0,0]))L.translation=U.getTranslation();if(!a0.eq(U.getRotation(),[0,0,0,1]))L.rotation=U.getRotation();if(!a0.eq(U.getScale(),[1,1,1]))L.scale=U.getScale();if(U.getWeights().length)L.weights=U.getWeights();return K.nodeIndexMap.set(U,x),L}),Y.skins=$.listSkins().map((U,x)=>{let L=K.createPropertyDef(U),j=U.getInverseBindMatrices();if(j)L.inverseBindMatrices=K.accessorIndexMap.get(j);let c=U.getSkeleton();if(c)L.skeleton=K.nodeIndexMap.get(c);return L.joints=U.listJoints().map((R)=>K.nodeIndexMap.get(R)),K.skinIndexMap.set(U,x),L}),$.listNodes().forEach((U,x)=>{let L=Y.nodes[x],j=U.getMesh();if(j)L.mesh=K.meshIndexMap.get(j);let c=U.getCamera();if(c)L.camera=K.cameraIndexMap.get(c);let R=U.getSkin();if(R)L.skin=K.skinIndexMap.get(R);if(U.listChildren().length>0)L.children=U.listChildren().map((M)=>K.nodeIndexMap.get(M))}),Y.animations=$.listAnimations().map((U,x)=>{let L=K.createPropertyDef(U),j=new Map;return L.samplers=U.listSamplers().map((c,R)=>{let M=K.createPropertyDef(c);return M.input=K.accessorIndexMap.get(c.getInput()),M.output=K.accessorIndexMap.get(c.getOutput()),M.interpolation=c.getInterpolation(),j.set(c,R),M}),L.channels=U.listChannels().map((c)=>{let R=K.createPropertyDef(c);return R.sampler=j.get(c.getSampler()),R.target={node:K.nodeIndexMap.get(c.getTargetNode()),path:c.getTargetPath()},R}),K.animationIndexMap.set(U,x),L}),Y.scenes=$.listScenes().map((U,x)=>{let L=K.createPropertyDef(U);return L.nodes=U.listChildren().map((j)=>K.nodeIndexMap.get(j)),K.sceneIndexMap.set(U,x),L});let w=$.getDefaultScene();if(w)Y.scene=$.listScenes().indexOf(w);return Y.extensionsUsed=z.map((U)=>U.extensionName),Y.extensionsRequired=v.map((U)=>U.extensionName),z.forEach((U)=>U.write(K)),A21(Y),Q}}function A21(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 Vw;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(Vw||(Vw={}));class Id{constructor(){this._logger=q5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=zw.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=cd(J)?this._binaryToJSON(J):{json:JSON.parse(r0.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),kd.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(r0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some(($)=>m21(J,$)))throw new Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some(($)=>u21(J,$)))throw new Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(r0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===GZ.GLB&&Z.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Ed.write(Z,{format:J.format||GZ.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:u6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:GZ.GLB}),$=new Uint32Array([1179937895,2,12]),Y=JSON.stringify(J),Q=r0.pad(r0.encodeText(Y),32),K=r0.toView(new Uint32Array([Q.byteLength,1313821514])),W=r0.concat([K,Q]);$[$.length-1]+=W.byteLength;let G=Object.values(X)[0];if(!G||!G.byteLength)return r0.concat([r0.toView($),W]);let z=r0.pad(G,0),v=r0.toView(new Uint32Array([z.byteLength,5130562])),V=r0.concat([v,z]);return $[$.length-1]+=V.byteLength,r0.concat([r0.toView($),W,V])}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){r0.assertView(Z.resources[Y.uri]);return}if(Y.uri.match(/data:/)){let Q=`__${Pd()}.${vZ.extension(Y.uri)}`;Z.resources[Q]=r0.createBufferFromDataURI(Y.uri),Y.uri=Q}}(Z.json.images||[]).forEach((Y)=>{if(Y.bufferView===void 0&&Y.uri===void 0)throw new Error("Missing resource URI or buffer view.");J(Y)}),(Z.json.buffers||[]).forEach(J)}_copyJSON(Z){let{images:J,buffers:X}=Z.json;if(Z={json:u6({},Z.json),resources:u6({},Z.resources)},J)Z.json.images=J.map(($)=>u6({},$));if(X)Z.json.buffers=X.map(($)=>u6({},$));return Z}_binaryToJSON(Z){if(!cd(Z))throw new Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==Vw.JSON)throw new Error("Missing required GLB JSON chunk.");let X=20,$=J[0],Y=r0.decodeText(r0.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]!==Vw.BIN)return{json:Q,resources:{}};let G=W[0],z=r0.toView(Z,K+8,G);return{json:Q,resources:{[Gw]:z}}}}function m21(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function u21(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function cd(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 yR extends Id{constructor(Z=null,J=U4.DEFAULT_INIT){super();this._fetch=void 0,this._fetchConfig=void 0,this._init=void 0,this._fetchEnabled=!1,this._fetch=Z,this._fetchConfig=J,this._init=this.init()}async init(){if(this._init)return this._init;return Promise.all([import("fs"),import("path")]).then(([Z,J])=>{this._fs=Z.promises,this._path=J})}setAllowNetwork(Z){if(Z&&!this._fetch)throw new Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),U4.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw new Error("Network request blocked. Allow HTTP requests explicitly, if needed.");let X=await this._fetch(Z,this._fetchConfig);switch(J){case"view":return new Uint8Array(await X.arrayBuffer());case"text":return X.text()}}else switch(J){case"view":return this._fs.readFile(Z);case"text":return this._fs.readFile(Z,"utf8")}}resolve(Z,J){if(U4.isAbsoluteURL(Z)||U4.isAbsoluteURL(J))return U4.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(U4.isAbsoluteURL(Z))return U4.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:GZ.GLTF,basename:vZ.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 l21(Object.keys(Y),10))await Promise.all(z.map(async function(v){if(U4.isAbsoluteURL(v)){if(U4.extension(v)==="bin")throw new Error(`Cannot write buffer to path "${v}".`);return}let V=K.join(W,decodeURIComponent(v));await Q.mkdir(K.dirname(V),{recursive:!0}),await Q.writeFile(V,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 l21(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 Ts=t(pR(),1),ks=t(Vs(),1),IO1=t(Cs(),1);async function fO1(Z,J){if(!(Z instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:$}=await ks.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return Ts.default(new Uint8Array(X),[$.width,$.height,4],[4,4*$.width|0,1],0)}async function Es(Z,J){return fO1(Z)}var _O1="v4.1.3",cN="@glb.bin",s;(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"})(s||(s={}));var Is;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(Is||(Is={}));var A5;(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"})(A5||(A5={}));var m5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(m5||(m5={}));var wN;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(wN||(wN={}));var UN=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function SO1(){var Z=new UN(3);if(UN!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function FN(Z){var J=Z[0],X=Z[1],$=Z[2];return Math.hypot(J,X,$)}function hO1(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=SO1();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 hs(Z){let J=bs(),X=Z.propertyType===s.NODE?[Z]:Z.listChildren();for(let $ of X)$.traverse((Y)=>{let Q=Y.getMesh();if(!Q)return;let K=bO1(Q,Y.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))xN(K.min,J),xN(K.max,J)});return J}function bO1(Z,J){let X=bs();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=hO1(W,K,J),xN(W,X)}}return X}function xN(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 bs(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class c6{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let $=0;$<J.length;$++)X[$]=J.charCodeAt($);return X}else{let J=Z.split(",")[1],X=Z.indexOf("base64")>=0;return Buffer.from(J,X?"base64":"utf8")}}static encodeText(Z){return new TextEncoder().encode(Z)}static decodeText(Z){return new TextDecoder().decode(Z)}static concat(Z){let J=0;for(let Y of Z)J+=Y.byteLength;let X=new Uint8Array(J),$=0;for(let Y of Z)X.set(Y,$),$+=Y.byteLength;return X}static pad(Z,J=0){let X=this.padNumber(Z.byteLength);if(X===Z.byteLength)return Z;let $=new Uint8Array(X);if($.set(Z),J!==0)for(let Y=Z.byteLength;Y<X;Y++)$[Y]=J;return $}static padNumber(Z){return Math.ceil(Z/4)*4}static equals(Z,J){if(Z===J)return!0;if(Z.byteLength!==J.byteLength)return!1;let X=Z.byteLength;while(X--)if(Z[X]!==J[X])return!1;return!0}static toView(Z,J=0,X=1/0){return new Uint8Array(Z.buffer,Z.byteOffset+J,Math.min(Z.byteLength,X))}static assertView(Z){if(Z&&!ArrayBuffer.isView(Z))throw new Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class As{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),AO1(J,X),$=J.getUint8(X+1),$===192||$===193||$===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class iw{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(c6.decodeText(Z.slice(12,16))===iw.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}}iw.PNG_FRIED_CHUNK_NAME="CgBI";class x9{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}`}}x9.impls={"image/jpeg":new As,"image/png":new iw};function AO1(Z,J){if(J>Z.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return Z}class dG{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 x9.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()}}function fs(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function I$(Z){if(fs(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(fs(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var BN,LN;(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"})(LN||(LN={}));class H7{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=H7.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=H7.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=H7.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=H7.Verbosity.ERROR)console.error(Z)}}BN=H7;H7.Verbosity=LN;H7.DEFAULT_INSTANCE=new BN(BN.Verbosity.INFO);function mO1(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],V=Z[10],H=Z[11],q=Z[12],F=Z[13],w=Z[14],U=Z[15],x=J*K-X*Q,L=J*W-$*Q,j=J*G-Y*Q,c=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,N=z*F-v*q,D=z*w-V*q,P=z*U-H*q,f=v*w-V*F,E=v*U-H*F,_=V*U-H*w;return x*_-L*E+j*f+c*P-R*D+M*N}function uO1(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],V=J[8],H=J[9],q=J[10],F=J[11],w=J[12],U=J[13],x=J[14],L=J[15],j=X[0],c=X[1],R=X[2],M=X[3];return Z[0]=j*$+c*W+R*V+M*w,Z[1]=j*Y+c*G+R*H+M*U,Z[2]=j*Q+c*z+R*q+M*x,Z[3]=j*K+c*v+R*F+M*L,j=X[4],c=X[5],R=X[6],M=X[7],Z[4]=j*$+c*W+R*V+M*w,Z[5]=j*Y+c*G+R*H+M*U,Z[6]=j*Q+c*z+R*q+M*x,Z[7]=j*K+c*v+R*F+M*L,j=X[8],c=X[9],R=X[10],M=X[11],Z[8]=j*$+c*W+R*V+M*w,Z[9]=j*Y+c*G+R*H+M*U,Z[10]=j*Q+c*z+R*q+M*x,Z[11]=j*K+c*v+R*F+M*L,j=X[12],c=X[13],R=X[14],M=X[15],Z[12]=j*$+c*W+R*V+M*w,Z[13]=j*Y+c*G+R*H+M*U,Z[14]=j*Q+c*z+R*q+M*x,Z[15]=j*K+c*v+R*F+M*L,Z}function lO1(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 yO1(Z,J){var X=new UN(3);lO1(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,V=J[6]*Q,H=J[8]*$,q=J[9]*Y,F=J[10]*Q,w=K+v+F,U=0;if(w>0)U=Math.sqrt(w+1)*2,Z[3]=0.25*U,Z[0]=(V-q)/U,Z[1]=(H-G)/U,Z[2]=(W-z)/U;else if(K>v&&K>F)U=Math.sqrt(1+K-v-F)*2,Z[3]=(V-q)/U,Z[0]=0.25*U,Z[1]=(W+z)/U,Z[2]=(H+G)/U;else if(v>F)U=Math.sqrt(1+v-K-F)*2,Z[3]=(H-G)/U,Z[0]=(W+z)/U,Z[1]=0.25*U,Z[2]=(V+q)/U;else U=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/U,Z[0]=(H+G)/U,Z[1]=(V+q)/U,Z[2]=0.25*U;return Z}class X8{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(X8.clamp(Z,0,1)*65535);case 5121:return Math.round(X8.clamp(Z,0,1)*255);case 5122:return Math.round(X8.clamp(Z,-1,1)*32767);case 5120:return Math.round(X8.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,$){let Y=FN([Z[0],Z[1],Z[2]]),Q=FN([Z[4],Z[5],Z[6]]),K=FN([Z[8],Z[9],Z[10]]);if(mO1(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,V=1/K;G[0]*=z,G[1]*=z,G[2]*=z,G[4]*=v,G[5]*=v,G[6]*=v,G[8]*=V,G[9]*=V,G[10]*=V,yO1(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,V=W+W,H=Q*z,q=Q*v,F=Q*V,w=K*v,U=K*V,x=W*V,L=G*z,j=G*v,c=G*V,R=X[0],M=X[1],N=X[2];return Y[0]=(1-(w+x))*R,Y[1]=(q+c)*R,Y[2]=(F-j)*R,Y[3]=0,Y[4]=(q-c)*M,Y[5]=(1-(H+x))*M,Y[6]=(U+L)*M,Y[7]=0,Y[8]=(F+j)*N,Y[9]=(U-L)*N,Y[10]=(1-(H+w))*N,Y[11]=0,Y[12]=Z[0],Y[13]=Z[1],Y[14]=Z[2],Y[15]=1,Y}}function pO1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),$=J.getChild();return X===$||X.equals($)}function iO1(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 gO1(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 ms(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 us(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!I$(Z)||!I$(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(lw(W)&&lw(G)){if(!ms(W,G))return!1}else if(I$(W)&&I$(G)){if(!us(W,G))return!1}else if(W!==G)return!1}return!0}function lw(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var _s="https://null.example";class ON{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return dG.basename(new URL(Z,_s).pathname)}static extension(Z){return dG.extension(new URL(Z,_s).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)}}ON.DEFAULT_INIT={};ON.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var IJ=(Z)=>Z,dO1=new Set;class gw extends UK{constructor(Z,J=""){super(Z);this[b0].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,IJ)}copy(Z,J=IJ){for(let X in this[b0]){let $=this[b0][X];if($ instanceof H5){if(!this[w9].has(X))$.dispose()}else if($ instanceof B6||$ instanceof C0)for(let Y of $.values())Y.dispose();else if($ instanceof a1)for(let Y of $.values())Y.dispose()}for(let X in Z[b0]){let $=this[b0][X],Y=Z[b0][X];if(Y instanceof H5)if(this[w9].has(X))$.getChild().copy(J(Y.getChild()),J);else this.setRef(X,J(Y.getChild()),Y.getAttributes());else if(Y instanceof C0||Y instanceof B6)for(let Q of Y.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if(Y instanceof a1)for(let Q of Y.keys()){let K=Y.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(I$(Y))this[b0][X]=JSON.parse(JSON.stringify(Y));else if(Array.isArray(Y)||Y instanceof ArrayBuffer||ArrayBuffer.isView(Y))this[b0][X]=Y.slice();else this[b0][X]=Y}return this}equals(Z,J=dO1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[b0]){if(J.has(X))continue;let $=this[b0][X],Y=Z[b0][X];if($ instanceof H5||Y instanceof H5){if(!pO1($,Y))return!1}else if($ instanceof C0||Y instanceof C0||$ instanceof B6||Y instanceof B6){if(!iO1($,Y))return!1}else if($ instanceof a1||Y instanceof a1){if(!gO1($,Y))return!1}else if(I$($)||I$(Y)){if(!us($,Y))return!1}else if(lw($)||lw(Y)){if(!ms($,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 O6 extends gw{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new a1})}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 D0 extends O6{init(){this.propertyType=s.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:D0.Type.SCALAR,componentType:D0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case D0.Type.SCALAR:return 1;case D0.Type.VEC2:return 2;case D0.Type.VEC3:return 3;case D0.Type.VEC4:return 4;case D0.Type.MAT2:return 4;case D0.Type.MAT3:return 9;case D0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case D0.ComponentType.BYTE:return 1;case D0.ComponentType.UNSIGNED_BYTE:return 1;case D0.ComponentType.SHORT:return 2;case D0.ComponentType.UNSIGNED_SHORT:return 2;case D0.ComponentType.UNSIGNED_INT:return 4;case D0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMin(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=X8.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]=X8.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 D0.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 X8.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]=X8.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]=X8.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]=X8.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?aO1(Z):D0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}D0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};D0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function aO1(Z){switch(Z.constructor){case Float32Array:return D0.ComponentType.FLOAT;case Uint32Array:return D0.ComponentType.UNSIGNED_INT;case Uint16Array:return D0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return D0.ComponentType.UNSIGNED_BYTE;case Int16Array:return D0.ComponentType.SHORT;case Int8Array:return D0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class MN extends O6{init(){this.propertyType=s.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new C0,samplers:new C0})}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 nG extends O6{init(){this.propertyType=s.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)}}nG.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class TK extends O6{init(){this.propertyType=s.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:TK.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:A5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:A5.OTHER})}}TK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class RN extends O6{init(){this.propertyType=s.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class sG extends O6{init(){this.propertyType=s.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:sG.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)}}sG.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class p1 extends gw{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}p1.EXTENSION_NAME=void 0;class O1 extends O6{init(){this.propertyType=s.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:O1.WrapMode.REPEAT,wrapT:O1.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)}}O1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};O1.MagFilter={NEAREST:9728,LINEAR:9729};O1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:Aw,G:mw,B:uw,A:nO1}=m5;class oG extends O6{init(){this.propertyType=s.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:oG.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new O1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new O1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new O1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new O1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new O1(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:Aw|mw|uw|nO1,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:Aw|mw|uw,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:Aw|mw|uw})}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:Aw})}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:mw|uw})}}oG.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class NN extends O6{init(){this.propertyType=s.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new C0})}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 DN extends O6{init(){this.propertyType=s.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 C0})}copy(Z,J=IJ){if(J===IJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return X8.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 X8.decompose(Z,J,X,$),this.set("translation",J).set("rotation",X).set("scale",$)}getWorldTranslation(){let Z=[0,0,0];return X8.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return X8.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return X8.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())uO1(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===s.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===s.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 fJ extends O6{init(){this.propertyType=s.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:fJ.Mode.TRIANGLES,material:null,indices:null,attributes:new a1,targets:new C0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:A5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:A5.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)}}fJ.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class ls extends gw{init(){this.propertyType=s.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:A5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function yw(){return yw=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},yw.apply(null,arguments)}class PN extends O6{init(){this.propertyType=s.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new C0})}copy(Z,J=IJ){if(J===IJ)throw new Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class CN extends O6{init(){this.propertyType=s.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new C0})}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:A5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class TN extends O6{init(){this.propertyType=s.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||x9.extensionToMimeType(dG.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=x9.extensionToMimeType(dG.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",c6.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return x9.getSize(Z,this.getMimeType())}}class dw extends O6{init(){this.propertyType=s.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${_O1}`,version:"2.0"},defaultScene:null,accessors:new C0,animations:new C0,buffers:new C0,cameras:new C0,materials:new C0,meshes:new C0,nodes:new C0,scenes:new C0,skins:new C0,textures:new C0})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(Z,J=IJ){if(J===IJ)throw new Error("Root cannot be copied.");this.set("asset",yw({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(yw({},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 PN)this.addRef("scenes",Z);else if(Z instanceof DN)this.addRef("nodes",Z);else if(Z instanceof sG)this.addRef("cameras",Z);else if(Z instanceof CN)this.addRef("skins",Z);else if(Z instanceof NN)this.addRef("meshes",Z);else if(Z instanceof oG)this.addRef("materials",Z);else if(Z instanceof TN)this.addRef("textures",Z);else if(Z instanceof MN)this.addRef("animations",Z);else if(Z instanceof D0)this.addRef("accessors",Z);else if(Z instanceof RN)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 pw{static fromGraph(Z){return pw._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new wK,this._root=new dw(this._graph),this._logger=H7.DEFAULT_INSTANCE,pw._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(($)=>$.extensionName===J)||new Z(this)}createScene(Z=""){return new PN(this._graph,Z)}createNode(Z=""){return new DN(this._graph,Z)}createCamera(Z=""){return new sG(this._graph,Z)}createSkin(Z=""){return new CN(this._graph,Z)}createMesh(Z=""){return new NN(this._graph,Z)}createPrimitive(){return new fJ(this._graph)}createPrimitiveTarget(Z=""){return new ls(this._graph,Z)}createMaterial(Z=""){return new oG(this._graph,Z)}createTexture(Z=""){return new TN(this._graph,Z)}createAnimation(Z=""){return new MN(this._graph,Z)}createAnimationChannel(Z=""){return new nG(this._graph,Z)}createAnimationSampler(Z=""){return new TK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new D0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new RN(this._graph,Z)}}pw._GRAPH_DOCUMENTS=new WeakMap;class N1{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 p1&&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}}N1.EXTENSION_NAME=void 0;var cP6={logger:H7.DEFAULT_INSTANCE,extensions:[],dependencies:{}},OP6=new Set([s.BUFFER,s.TEXTURE,s.MATERIAL,s.MESH,s.PRIMITIVE,s.NODE,s.SCENE]);var aG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(aG||(aG={}));class _J{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 jN(Y>1,()=>X.basename||"buffer"),this.imageURIGenerator=new jN(Q>1,(K)=>sO1(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===wN.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 $=x9.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,$),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let $=this.jsonDoc.resources;if(!(Z in $)){$[Z]=J;return}if(J===$[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let Y=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn(Y);return}throw new Error(Y)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return A5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:$}=X.getAttributes();if($)return $;if(X.getParent().propertyType!==s.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return A5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw new Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}_J.BufferViewTarget=aG;_J.BufferViewUsage=A5;_J.USAGE_TO_TARGET={[A5.ARRAY_BUFFER]:aG.ARRAY_BUFFER,[A5.ELEMENT_ARRAY_BUFFER]:aG.ELEMENT_ARRAY_BUFFER};class jN{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 sO1(Z,J){let X=Z.getGraph().listParentEdges(J).find(($)=>$.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{UNSIGNED_INT:MP6,UNSIGNED_SHORT:RP6,UNSIGNED_BYTE:NP6}=D0.ComponentType,DP6=new Set([s.ACCESSOR,s.BUFFER,s.MATERIAL,s.MESH]);var Ss;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(Ss||(Ss={}));var ps=163,is=166;function oO1(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,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 kK{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 TP6=new Uint8Array([0]),i6=[171,75,84,88,32,50,48,187,13,10,26,10];function ys(Z){return new TextDecoder().decode(Z)}function aw(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,i6.length);if(J[0]!==i6[0]||J[1]!==i6[1]||J[2]!==i6[2]||J[3]!==i6[3]||J[4]!==i6[4]||J[5]!==i6[5]||J[6]!==i6[6]||J[7]!==i6[7]||J[8]!==i6[8]||J[9]!==i6[9]||J[10]!==i6[10]||J[11]!==i6[11])throw new Error("Missing KTX 2.0 identifier.");let X=oO1(),$=17*Uint32Array.BYTES_PER_ELEMENT,Y=new kK(Z,i6.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();let Q=Y._nextUint32();X.supercompressionScheme=Y._nextUint32();let K=Y._nextUint32(),W=Y._nextUint32(),G=Y._nextUint32(),z=Y._nextUint32(),v=Y._nextUint64(),V=Y._nextUint64(),H=Q*3*8,q=new kK(Z,i6.length+$,H,!0);for(let J6=0;J6<Q;J6++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+q._nextUint64(),q._nextUint64()),uncompressedByteLength:q._nextUint64()});let F=new kK(Z,K,W,!0);F._skip(4);let w=F._nextUint16(),U=F._nextUint16(),x=F._nextUint16(),L=F._nextUint16(),j=F._nextUint8(),c=F._nextUint8(),R=F._nextUint8(),M=F._nextUint8(),N=[F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8()],D=[F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8()],f={vendorId:w,descriptorType:U,versionNumber:x,colorModel:j,colorPrimaries:c,transferFunction:R,flags:M,texelBlockDimension:N,bytesPlane:D,samples:[]},E=6,_=4,T=(L/4-E)/_;for(let J6=0;J6<T;J6++){let s7={bitOffset:F._nextUint16(),bitLength:F._nextUint8(),channelType:F._nextUint8(),samplePosition:[F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(s7.channelType&64)s7.sampleLower=F._nextInt32(),s7.sampleUpper=F._nextInt32();else s7.sampleLower=F._nextUint32(),s7.sampleUpper=F._nextUint32();f.samples[J6]=s7}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(f);let k=new kK(Z,G,z,!0);while(k._offset<z){let J6=k._nextUint32(),s7=k._scan(J6),gV=ys(s7);if(X.keyValue[gV]=k._nextUint8Array(J6-s7.byteLength-1),gV.match(/^ktx/i)){let Um=ys(X.keyValue[gV]);X.keyValue[gV]=Um.substring(0,Um.lastIndexOf("\x00"))}let tG1=J6%4?4-J6%4:0;k._skip(tG1)}if(V<=0)return X;let h=new kK(Z,v,V,!0),u=h._nextUint16(),a=h._nextUint16(),o=h._nextUint32(),Q0=h._nextUint32(),W0=h._nextUint32(),E0=h._nextUint32(),I0=[];for(let J6=0;J6<Q;J6++)I0.push({imageFlags:h._nextUint32(),rgbSliceByteOffset:h._nextUint32(),rgbSliceByteLength:h._nextUint32(),alphaSliceByteOffset:h._nextUint32(),alphaSliceByteLength:h._nextUint32()});let t0=v+h._offset,C8=t0+o,g1=C8+Q0,s9=g1+W0,Y9=new Uint8Array(Z.buffer,Z.byteOffset+t0,o),lQ=new Uint8Array(Z.buffer,Z.byteOffset+C8,Q0),yQ=new Uint8Array(Z.buffer,Z.byteOffset+g1,W0),G$=new Uint8Array(Z.buffer,Z.byteOffset+s9,E0);return X.globalData={endpointCount:u,selectorCount:a,imageDescs:I0,endpointsData:Y9,selectorsData:lQ,tablesData:yQ,extendedData:G$},X}var _N="EXT_mesh_gpu_instancing",EN="EXT_meshopt_compression",rO1="EXT_texture_webp",tO1="EXT_texture_avif",Yo="KHR_draco_mesh_compression",SN="KHR_lights_punctual",hN="KHR_materials_anisotropy",bN="KHR_materials_clearcoat",AN="KHR_materials_diffuse_transmission",mN="KHR_materials_dispersion",uN="KHR_materials_emissive_strength",lN="KHR_materials_ior",yN="KHR_materials_iridescence",pN="KHR_materials_pbrSpecularGlossiness",iN="KHR_materials_sheen",gN="KHR_materials_specular",dN="KHR_materials_transmission",aN="KHR_materials_unlit",nN="KHR_materials_volume",a$="KHR_materials_variants",eO1="KHR_mesh_quantization",ZM1="KHR_texture_basisu",sN="KHR_texture_transform",nw="KHR_xmp_json_ld",IN="INSTANCE_ATTRIBUTE";class oN extends p1{init(){this.extensionName=_N,this.propertyType="InstancedMesh",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:IN})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}oN.EXTENSION_NAME=_N;var f$=_N;class rw extends N1{constructor(...Z){super(...Z);this.extensionName=f$,this.provideTypes=[s.NODE],this.prewriteTypes=[s.ACCESSOR]}createInstancedMesh(){return new oN(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[f$])return;let Q=$.extensions[f$],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[Y].setExtension(f$,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(IN);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,IN);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let $=X.getExtension(f$);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[f$]=K}}),this}}rw.EXTENSION_NAME=f$;function FZ(){return FZ=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},FZ.apply(null,arguments)}var Zz;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(Zz||(Zz={}));var IK;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(IK||(IK={}));var $8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})($8||($8={}));var{BYTE:JM1,SHORT:gs,FLOAT:XM1}=D0.ComponentType,{encodeNormalizedInt:ds,decodeNormalizedInt:fN}=X8;function $M1(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!==IK.ATTRIBUTES)return K;if(Y!==$8.NONE){let W=Z.getNormalized()?YM1(Z):new Float32Array(K.array);switch(Y){case $8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=XM1,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?gs:JM1,K.normalized=!0,W=Z.getElementSize()===3?KM1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case $8.QUATERNION:K.byteStride=8,K.componentType=gs,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw new Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>fN(G,Z.getComponentType())),K.max=K.max.map((G)=>fN(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>ds(G,K.componentType)),K.max=K.max.map((G)=>ds(G,K.componentType))}else if(K.byteStride%4)K.array=QM1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function YM1(Z){let J=Z.getComponentType(),X=Z.getArray(),$=new Float32Array(X.length);for(let Y=0;Y<X.length;Y++)$[Y]=fN(X[Y],J);return $}function QM1(Z,J){let $=c6.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 KM1(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 WM1(Z,J){if(J===_J.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some(($)=>{return $ instanceof fJ&&$.getMode()===fJ.Mode.TRIANGLES})?IK.TRIANGLES:IK.INDICES;return IK.ATTRIBUTES}function GM1(Z,J){let X=J.getGraph().listParentEdges(Z).filter(($)=>!($.getParent()instanceof dw));for(let $ of X){let Y=$.getName(),Q=$.getAttributes().key||"",K=$.getParent().propertyType===s.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=Qo(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 Qo(Z){for(let J of Z.listParents()){if(!(J instanceof TK))continue;for(let X of J.listParents()){if(!(X instanceof nG))continue;return X.getTargetPath()}}return null}function zM1(Z){if(!Z.extensions||!Z.extensions[EN])return!1;return!!Z.extensions[EN].fallback}var g6=EN,as={method:Zz.QUANTIZE};class Xz extends N1{constructor(...Z){super(...Z);this.extensionName=g6,this.prereadTypes=[s.BUFFER,s.PRIMITIVE],this.prewriteTypes=[s.BUFFER,s.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=as,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=FZ({},as,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${g6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${g6}]: Missing WASM support.`)}if(J===s.BUFFER)this._prereadBuffers(Z);else if(J===s.PRIMITIVE)this._prereadPrimitives(Z);return this}_prereadBuffers(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[g6])return;let Q=$.extensions[g6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,z=Q.byteStride,v=new Uint8Array(G*z),V=J.json.buffers[Q.buffer],H=V.uri?J.resources[V.uri]:J.resources[cN],q=c6.toView(H,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[g6])return;let Y=$.extensions[g6],Q=Z.buffers[Y.buffer],K=Z.buffers[$.buffer],W=J.json.buffers[$.buffer];if(zM1(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 D0)$.swap(J,X);J.dispose()}return this}prewrite(Z,J){if(J===s.ACCESSOR)this._prewriteAccessors(Z);else if(J===s.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 V of Y.listParents(v)){if(V.propertyType===s.ROOT)continue;let H=G.get(v);if(H===void 0)G.set(v,H=W++);return H}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let v of this.document.getRoot().listAccessors()){if(Qo(v)==="weights")continue;if(v.getSparse())continue;let V=Z.getAccessorUsage(v),H=Z.accessorUsageGroupedByParent.has(V)?z(v):null,q=WM1(v,V),F=$.method===Zz.FILTER?GM1(v,this.document):{filter:$8.NONE},w=$M1(v,X,q,F),{array:U,byteStride:x}=w,L=v.getBuffer();if(!L)throw new Error(`${g6}: Missing buffer for accessor.`);let j=this.document.getRoot().listBuffers().indexOf(L),c=[V,H,q,F.filter,x,j].join(":"),R=this._encoderBufferViews[c],M=this._encoderBufferViewData[c],N=this._encoderBufferViewAccessors[c];if(!R||!M)N=this._encoderBufferViewAccessors[c]=[],M=this._encoderBufferViewData[c]=[],R=this._encoderBufferViews[c]={buffer:K,target:_J.USAGE_TO_TARGET[V],byteOffset:0,byteLength:0,byteStride:V===_J.BufferViewUsage.ARRAY_BUFFER?x:void 0,extensions:{[g6]:{buffer:j,byteOffset:0,byteLength:0,mode:q,filter:F.filter!==$8.NONE?F.filter:void 0,byteStride:x,count:0}}};let D=Z.createAccessorDef(v);if(D.componentType=w.componentType,D.normalized=w.normalized,D.byteOffset=R.byteLength,D.min&&w.min)D.min=w.min;if(D.max&&w.max)D.max=w.max;Z.accessorIndexMap.set(v,J.accessors.length),J.accessors.push(D),N.push(D),M.push(new Uint8Array(U.buffer,U.byteOffset,U.byteLength)),R.byteLength+=U.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[g6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:z}=$.extensions[g6],v=c6.concat(Y),V=J.encodeGltfBuffer(v,W,G,z),H=c6.pad(V);$.extensions[g6].byteLength=V.byteLength,Y.length=0,Y.push(H),K.push(H),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],V=v.byteOffset||0;Object.assign(v,K),v.byteOffset=J;let H=v.extensions[g6];H.byteOffset=V,J+=c6.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,$=Z.bufferIndexMap.get(X),Y=Z.jsonDoc.json.buffers[$];return Y.byteLength=J,Y.extensions={[g6]:{fallback:!0}},X.dispose(),this}}Xz.EXTENSION_NAME=g6;Xz.EncoderMethod=Zz;var rG=tO1;class Ko{match(Z){return Z.length>=12&&c6.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=ns(J,0);if(!X)return null;let $=X.end;while(X=ns(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 tw extends N1{constructor(...Z){super(...Z);this.extensionName=rG,this.prereadTypes=[s.TEXTURE]}static register(){x9.registerFormat("image/avif",new Ko)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[rG])X.source=X.extensions[rG].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[rG]={source:Q.source},delete Q.source})}}),this}}tw.EXTENSION_NAME=rG;function ns(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:c6.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}var tG=rO1;class Wo{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=c6.decodeText(Z.slice(0,4)),X=c6.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=c6.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),V=1+((G&63)<<8|W),H=1+((v&15)<<10|z<<2|(G&192)>>6);return[V,H]}Y+=8+K+K%2}return null}getChannels(Z){return 4}}class ew extends N1{constructor(...Z){super(...Z);this.extensionName=tG,this.prereadTypes=[s.TEXTURE]}static register(){x9.registerFormat("image/webp",new Wo)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[tG])X.source=X.extensions[tG].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[tG]={source:Q.source},delete Q.source})}}),this}}ew.EXTENSION_NAME=tG;var ss=Yo,b8,Go,zo;function vM1(Z,J){let X=new b8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==b8.TRIANGULAR_MESH)throw new Error(`[${ss}] Unknown geometry type.`);let Y=new b8.Mesh;if(!Z.DecodeBufferToMesh(X,Y).ok()||Y.ptr===0)throw new Error(`[${ss}] Decoding failure.`);return Y}finally{b8.destroy(X)}}function HM1(Z,J){let $=J.num_faces()*3,Y,Q;if(J.num_points()<=65534){let K=$*Uint16Array.BYTES_PER_ELEMENT;Y=b8._malloc(K),Z.GetTrianglesUInt16Array(J,K,Y),Q=new Uint16Array(b8.HEAPU16.buffer,Y,$).slice()}else{let K=$*Uint32Array.BYTES_PER_ELEMENT;Y=b8._malloc(K),Z.GetTrianglesUInt32Array(J,K,Y),Q=new Uint32Array(b8.HEAPU32.buffer,Y,$).slice()}return b8._free(Y),Q}function VM1(Z,J,X,$){let Y=zo[$.componentType],Q=Go[$.componentType],K=X.num_components(),G=J.num_points()*K,z=G*Q.BYTES_PER_ELEMENT,v=b8._malloc(z);Z.GetAttributeDataArrayForAllPoints(J,X,Y,z,v);let V=new Q(b8.HEAPF32.buffer,v,G).slice();return b8._free(v),V}function qM1(Z){b8=Z,Go={[D0.ComponentType.FLOAT]:Float32Array,[D0.ComponentType.UNSIGNED_INT]:Uint32Array,[D0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[D0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[D0.ComponentType.SHORT]:Int16Array,[D0.ComponentType.BYTE]:Int8Array},zo={[D0.ComponentType.FLOAT]:b8.DT_FLOAT32,[D0.ComponentType.UNSIGNED_INT]:b8.DT_UINT32,[D0.ComponentType.UNSIGNED_SHORT]:b8.DT_UINT16,[D0.ComponentType.UNSIGNED_BYTE]:b8.DT_UINT8,[D0.ComponentType.SHORT]:b8.DT_INT16,[D0.ComponentType.BYTE]:b8.DT_INT8}}var B4,Jz;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(Jz||(Jz={}));var L4;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(L4||(L4={}));var vo={[L4.POSITION]:14,[L4.NORMAL]:10,[L4.COLOR]:8,[L4.TEX_COORD]:12,[L4.GENERIC]:12},os={decodeSpeed:5,encodeSpeed:5,method:Jz.EDGEBREAKER,quantizationBits:vo,quantizationVolume:"mesh"};function FM1(Z){B4=Z}function wM1(Z,J=os){let X=FZ({},os,J);X.quantizationBits=FZ({},vo,J.quantizationBits);let $=new B4.MeshBuilder,Y=new B4.Mesh,Q=new B4.ExpertEncoder(Y),K={},W=new B4.DracoInt8Array,G=Z.listTargets().length>0,z=!1;for(let w of Z.listSemantics()){let U=Z.getAttribute(w);if(U.getSparse()){z=!0;continue}let x=UM1(w),L=xM1($,U.getComponentType(),Y,B4[x],U.getCount(),U.getElementSize(),U.getArray());if(L===-1)throw new Error(`Error compressing "${w}" attribute.`);if(K[w]=L,X.quantizationVolume==="mesh"||w!=="POSITION")Q.SetAttributeQuantization(L,X.quantizationBits[x]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:j}=X,c=Math.max(j.max[0]-j.min[0],j.max[1]-j.min[1],j.max[2]-j.min[2]);Q.SetAttributeExplicitQuantization(L,X.quantizationBits[x],U.getElementSize(),j.min,c)}else throw new Error("Invalid quantization volume state.")}let v=Z.getIndices();if(!v)throw new sw("Primitive must have indices.");if($.AddFacesToMesh(Y,v.getCount()/3,v.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===Jz.SEQUENTIAL||G||z)Q.SetEncodingMethod(B4.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(B4.MESH_EDGEBREAKER_ENCODING);let V=Q.EncodeToDracoBuffer(!(G||z),W);if(V<=0)throw new sw("Error applying Draco compression.");let H=new Uint8Array(V);for(let w=0;w<V;++w)H[w]=W.GetValue(w);let q=Q.GetNumberOfEncodedPoints(),F=Q.GetNumberOfEncodedFaces()*3;return B4.destroy(W),B4.destroy(Y),B4.destroy($),B4.destroy(Q),{numVertices:q,numIndices:F,data:H,attributeIDs:K}}function UM1(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 xM1(Z,J,X,$,Y,Q,K){switch(J){case D0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,$,Y,Q,K);case D0.ComponentType.BYTE:return Z.AddInt8Attribute(X,$,Y,Q,K);case D0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,$,Y,Q,K);case D0.ComponentType.SHORT:return Z.AddInt16Attribute(X,$,Y,Q,K);case D0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,$,Y,Q,K);case D0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,$,Y,Q,K);default:throw new Error(`Unexpected component type, "${J}".`)}}class sw extends Error{}var j8=Yo;class $z extends N1{constructor(...Z){super(...Z);this.extensionName=j8,this.prereadTypes=[s.PRIMITIVE],this.prewriteTypes=[s.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,qM1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,FM1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw new Error(`[${j8}] 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[j8])continue;let W=K.extensions[j8],[G,z]=$.get(W.bufferView)||[];if(!z||!G){let v=X.json.bufferViews[W.bufferView],V=X.json.buffers[v.buffer],H=V.uri?X.resources[V.uri]:X.resources[cN],q=v.byteOffset||0,F=v.byteLength,w=c6.toView(H,q,F);G=new this._decoderModule.Decoder,z=vM1(G,w),$.set(W.bufferView,[G,z]),J.debug(`[${j8}] Decompressed ${w.byteLength} bytes.`)}for(let v in W.attributes){let V=Z.jsonDoc.json.accessors[K.attributes[v]],H=G.GetAttributeByUniqueId(z,W.attributes[v]),q=VM1(G,z,H,V);Z.accessors[K.attributes[v]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(HM1(G,z))}}finally{for(let[Y,Q]of Array.from($.values()))this._decoderModule.destroy(Y),this._decoderModule.destroy(Q)}return this}read(Z){return this}prewrite(Z,J){if(!this._encoderModule)throw new Error(`[${j8}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${j8}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let $=BM1(this.document),Y=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${j8}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=hs(this.document.getRoot().listScenes().pop());for(let K of Array.from($.keys())){let W=$.get(K);if(!W)throw new Error("Unexpected primitive.");if(Y.has(W)){Y.set(W,Y.get(W));continue}let G=K.getIndices(),z=Z.jsonDoc.json.accessors,v;try{v=wM1(K,FZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof sw){X.warn(`[${j8}]: ${q.message} Skipping primitive compression.`);continue}throw q}Y.set(W,v);let V=Z.createAccessorDef(G);if(V.count=v.numIndices,Z.accessorIndexMap.set(G,z.length),z.push(V),v.numVertices>65534&&D0.getComponentSize(V.componentType)<=2)V.componentType=D0.ComponentType.UNSIGNED_INT;else if(v.numVertices>254&&D0.getComponentSize(V.componentType)<=1)V.componentType=D0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let F=K.getAttribute(q);if(v.attributeIDs[q]===void 0)continue;let w=Z.createAccessorDef(F);w.count=v.numVertices,Z.accessorIndexMap.set(F,z.length),z.push(w)}let H=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(H))Z.otherBufferViews.set(H,[]);Z.otherBufferViews.get(H).push(v.data)}return X.debug(`[${j8}] Compressed ${$.size} primitives.`),Z.extensionData[j8]={primitiveHashMap:$,primitiveEncodingMap:Y},this}write(Z){let J=Z.extensionData[j8];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[j8]={bufferView:Z.otherBufferViewsIndexMap.get(G.data),attributes:G.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter(($)=>$!==j8),X.extensionsRequired=(X.extensionsRequired||[]).filter(($)=>$!==j8)}return this}}$z.EXTENSION_NAME=j8;$z.EncoderMethod=Jz;function BM1(Z){let J=Z.getLogger(),X=new Set,$=new Set,Y=0,Q=0;for(let V of Z.getRoot().listMeshes())for(let H of V.listPrimitives())if(!H.getIndices())$.add(H),Y++;else if(H.getMode()!==fJ.Mode.TRIANGLES)$.add(H),Q++;else X.add(H);if(Y>0)J.warn(`[${j8}] Skipping Draco compression of ${Y} non-indexed primitives.`);if(Q>0)J.warn(`[${j8}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),W=new Map;for(let V=0;V<K.length;V++)W.set(K[V],V);let G=new Map,z=new Set,v=new Map;for(let V of Array.from(X)){let H=rs(V,W);if(z.has(H)){v.set(V,H);continue}if(G.has(V.getIndices())){let q=V.getIndices(),F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),V.swap(q,F)}for(let q of V.listAttributes())if(G.has(q)){let F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),V.swap(q,F)}H=rs(V,W),z.add(H),v.set(V,H),G.set(V.getIndices(),H);for(let q of V.listAttributes())G.set(q,H)}for(let V of Array.from(G.keys())){let H=new Set(V.listParents().map((q)=>q.propertyType));if(H.size!==2||!H.has(s.PRIMITIVE)||!H.has(s.ROOT))throw new Error(`[${j8}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let V of Array.from(X)){let H=v.get(V),q=V.getIndices();if(G.get(q)!==H||V.listAttributes().some((F)=>G.get(F)!==H))throw new Error(`[${j8}] Draco primitives must share all, or no, accessors.`)}for(let V of Array.from($)){let H=V.getIndices();if(G.has(H)||V.listAttributes().some((q)=>G.has(q)))throw new Error(`[${j8}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return v}function rs(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 fK extends p1{init(){this.extensionName=SN,this.propertyType="Light",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:fK.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)}}fK.EXTENSION_NAME=SN;fK.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};var V7=SN;class rN extends N1{constructor(...Z){super(...Z);this.extensionName=V7}createLight(Z=""){return new fK(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[V7])return this;let Y=(J.json.extensions[V7].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[V7])return;let W=Q.extensions[V7];Z.nodes[K].setExtension(V7,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(!X8.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()===fK.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(V7);if(Q){let K=Z.nodeIndexMap.get(Y),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[V7]={light:$.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[V7]={lights:X},this}}rN.EXTENSION_NAME=V7;var{R:LM1,G:jM1,B:cM1}=m5;class tN extends p1{init(){this.extensionName=hN,this.propertyType="Anisotropy",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new O1(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:LM1|jM1|cM1})}}tN.EXTENSION_NAME=hN;var _$=hN;class eN extends N1{constructor(...Z){super(...Z);this.extensionName=_$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createAnisotropy(){return new tN(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[_$]){let K=this.createAnisotropy();Z.materials[Q].setExtension(_$,K);let W=Y.extensions[_$];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(_$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[_$]={};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}}eN.EXTENSION_NAME=_$;var{R:ts,G:es,B:OM1}=m5;class ZD extends p1{init(){this.extensionName=bN,this.propertyType="Clearcoat",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new O1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new O1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new O1(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:ts})}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:es})}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:ts|es|OM1})}}ZD.EXTENSION_NAME=bN;var S$=bN;class JD extends N1{constructor(...Z){super(...Z);this.extensionName=S$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createClearcoat(){return new ZD(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[S$]){let K=this.createClearcoat();Z.materials[Q].setExtension(S$,K);let W=Y.extensions[S$];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(S$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[S$]={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}}JD.EXTENSION_NAME=S$;var{R:MM1,G:RM1,B:NM1,A:DM1}=m5;class XD extends p1{init(){this.extensionName=AN,this.propertyType="DiffuseTransmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new O1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new O1(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:DM1})}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:MM1|RM1|NM1})}}XD.EXTENSION_NAME=AN;var h$=AN;class $D extends N1{constructor(...Z){super(...Z);this.extensionName=h$}createDiffuseTransmission(){return new XD(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[h$]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(h$,K);let W=Y.extensions[h$];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(h$);if(!$)continue;let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[h$]={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}}$D.EXTENSION_NAME=h$;class YD extends p1{init(){this.extensionName=mN,this.propertyType="Dispersion",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}YD.EXTENSION_NAME=mN;var b$=mN;class QD extends N1{constructor(...Z){super(...Z);this.extensionName=b$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createDispersion(){return new YD(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[b$]){let Q=this.createDispersion();Z.materials[Y].setExtension(b$,Q);let K=$.extensions[b$];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(b$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[b$]={dispersion:$.getDispersion()}}}),this}}QD.EXTENSION_NAME=b$;class KD extends p1{init(){this.extensionName=uN,this.propertyType="EmissiveStrength",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}KD.EXTENSION_NAME=uN;var A$=uN;class WD extends N1{constructor(...Z){super(...Z);this.extensionName=A$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createEmissiveStrength(){return new KD(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[A$]){let Q=this.createEmissiveStrength();Z.materials[Y].setExtension(A$,Q);let K=$.extensions[A$];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(A$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[A$]={emissiveStrength:$.getEmissiveStrength()}}}),this}}WD.EXTENSION_NAME=A$;class GD extends p1{init(){this.extensionName=lN,this.propertyType="IOR",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}GD.EXTENSION_NAME=lN;var m$=lN;class ZU extends N1{constructor(...Z){super(...Z);this.extensionName=m$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIOR(){return new GD(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[m$]){let Q=this.createIOR();Z.materials[Y].setExtension(m$,Q);let K=$.extensions[m$];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(m$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[m$]={ior:$.getIOR()}}}),this}}ZU.EXTENSION_NAME=m$;var{R:PM1,G:CM1}=m5;class zD extends p1{init(){this.extensionName=yN,this.propertyType="Iridescence",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new O1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new O1(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:PM1})}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:CM1})}}zD.EXTENSION_NAME=yN;var u$=yN;class vD extends N1{constructor(...Z){super(...Z);this.extensionName=u$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIridescence(){return new zD(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[u$]){let K=this.createIridescence();Z.materials[Q].setExtension(u$,K);let W=Y.extensions[u$];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(u$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[u$]={};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}}vD.EXTENSION_NAME=u$;var{R:Zo,G:Jo,B:Xo,A:$o}=m5;class HD extends p1{init(){this.extensionName=pN,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new O1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new O1(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:Zo|Jo|Xo|$o,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:Zo|Jo|Xo|$o})}}HD.EXTENSION_NAME=pN;var l$=pN;class JU extends N1{constructor(...Z){super(...Z);this.extensionName=l$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createPBRSpecularGlossiness(){return new HD(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[l$]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(l$,K);let W=Y.extensions[l$];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(l$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[l$]={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}}JU.EXTENSION_NAME=l$;var{R:TM1,G:kM1,B:EM1,A:IM1}=m5;class VD extends p1{init(){this.extensionName=iN,this.propertyType="Sheen",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new O1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new O1(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:TM1|kM1|EM1,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:IM1})}}VD.EXTENSION_NAME=iN;var y$=iN;class qD extends N1{constructor(...Z){super(...Z);this.extensionName=y$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSheen(){return new VD(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[y$]){let K=this.createSheen();Z.materials[Q].setExtension(y$,K);let W=Y.extensions[y$];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(y$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[y$]={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}}qD.EXTENSION_NAME=y$;var{R:fM1,G:_M1,B:SM1,A:hM1}=m5;class FD extends p1{init(){this.extensionName=gN,this.propertyType="Specular",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new O1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new O1(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:hM1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:fM1|_M1|SM1,isColor:!0})}}FD.EXTENSION_NAME=gN;var p$=gN;class XU extends N1{constructor(...Z){super(...Z);this.extensionName=p$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSpecular(){return new FD(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[p$]){let K=this.createSpecular();Z.materials[Q].setExtension(p$,K);let W=Y.extensions[p$];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(p$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[p$]={};if($.getSpecularFactor()!==1)K.specularFactor=$.getSpecularFactor();if(!X8.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}}XU.EXTENSION_NAME=p$;var{R:bM1}=m5;class wD extends p1{init(){this.extensionName=dN,this.propertyType="Transmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new O1(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:bM1})}}wD.EXTENSION_NAME=dN;var i$=dN;class UD extends N1{constructor(...Z){super(...Z);this.extensionName=i$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createTransmission(){return new wD(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[i$]){let K=this.createTransmission();Z.materials[Q].setExtension(i$,K);let W=Y.extensions[i$];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(i$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[i$]={transmissionFactor:$.getTransmissionFactor()};if($.getTransmissionTexture()){let W=$.getTransmissionTexture(),G=$.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}UD.EXTENSION_NAME=i$;class xD extends p1{init(){this.extensionName=aN,this.propertyType="Unlit",this.parentTypes=[s.MATERIAL]}}xD.EXTENSION_NAME=aN;var EK=aN;class $U extends N1{constructor(...Z){super(...Z);this.extensionName=EK,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createUnlit(){return new xD(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[EK])Z.materials[$].setExtension(EK,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(EK)){let $=Z.materialIndexMap.get(X),Y=J.json.materials[$];Y.extensions=Y.extensions||{},Y.extensions[EK]={}}}),this}}$U.EXTENSION_NAME=EK;class BD extends p1{init(){this.extensionName=a$,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new C0})}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")}}BD.EXTENSION_NAME=a$;class LD extends p1{init(){this.extensionName=a$,this.propertyType="MappingList",this.parentTypes=[s.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new C0})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}LD.EXTENSION_NAME=a$;class ow extends p1{init(){this.extensionName=a$,this.propertyType="Variant",this.parentTypes=["MappingList"]}}ow.EXTENSION_NAME=a$;var q7=a$;class jD extends N1{constructor(...Z){super(...Z);this.extensionName=q7}createMappingList(){return new LD(this.document.getGraph())}createVariant(Z=""){return new ow(this.document.getGraph(),Z)}createMapping(){return new BD(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof ow)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[q7])return this;let Y=(J.json.extensions[q7].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((v,V)=>{if(!v.extensions||!v.extensions[q7])return;let H=this.createMappingList(),q=v.extensions[q7];for(let F of q.mappings){let w=this.createMapping();if(F.material!==void 0)w.setMaterial(Z.materials[F.material]);for(let U of F.variants||[])w.addVariant(Y[U]);H.addMapping(w)}G.listPrimitives()[V].setExtension(q7,H)})}),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(q7);if(!z)return;let v=Z.jsonDoc.json.meshes[K].primitives[G],V=z.listMappings().map((H)=>{let q=Z.createPropertyDef(H),F=H.getMaterial();if(F)q.material=Z.materialIndexMap.get(F);return q.variants=H.listVariants().map((w)=>Y.get(w)),q});v.extensions=v.extensions||{},v.extensions[q7]={mappings:V}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[q7]={variants:$},this}}jD.EXTENSION_NAME=q7;var{G:AM1}=m5;class cD extends p1{init(){this.extensionName=nN,this.propertyType="Volume",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new O1(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:AM1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}cD.EXTENSION_NAME=nN;var g$=nN;class OD extends N1{constructor(...Z){super(...Z);this.extensionName=g$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createVolume(){return new cD(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[g$]){let K=this.createVolume();Z.materials[Q].setExtension(g$,K);let W=Y.extensions[g$];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(g$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[g$]={};if($.getThicknessFactor()>0)K.thicknessFactor=$.getThicknessFactor();if(Number.isFinite($.getAttenuationDistance()))K.attenuationDistance=$.getAttenuationDistance();if(!X8.eq($.getAttenuationColor(),[1,1,1]))K.attenuationColor=$.getAttenuationColor();if($.getThicknessTexture()){let W=$.getThicknessTexture(),G=$.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}OD.EXTENSION_NAME=g$;var Ho=eO1;class Yz extends N1{constructor(...Z){super(...Z);this.extensionName=Ho}read(Z){return this}write(Z){return this}}Yz.EXTENSION_NAME=Ho;var eG=ZM1;class Vo{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=aw(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=aw(Z).dataFormatDescriptor[0];if(X.colorModel===ps)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===is)return(X.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=aw(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 MD extends N1{constructor(...Z){super(...Z);this.extensionName=eG,this.prereadTypes=[s.TEXTURE]}static register(){x9.registerFormat("image/ktx2",new Vo)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[eG]){let X=J.extensions[eG];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[eG]={source:Y.source},delete Y.source})}}),this}}MD.EXTENSION_NAME=eG;class RD extends p1{init(){this.extensionName=sN,this.propertyType="Transform",this.parentTypes=[s.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)}}RD.EXTENSION_NAME=sN;var d$=sN;class ND extends N1{constructor(...Z){super(...Z);this.extensionName=d$}createTransform(){return new RD(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[d$])continue;let $=this.createTransform(),Y=X.extensions[d$];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(d$,$)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,$]of J){let Y=X.getExtension(d$);if(!Y)continue;$.extensions=$.extensions||{};let Q={},K=X8.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[d$]=Q}return this}}ND.EXTENSION_NAME=d$;var mM1=[s.ROOT,s.SCENE,s.NODE,s.MESH,s.MATERIAL,s.TEXTURE,s.ANIMATION];class DD extends p1{init(){this.extensionName=nw,this.propertyType="Packet",this.parentTypes=mM1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",FZ({},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=FZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=kN(this.get("context")),J=kN(this.get("properties"));return FZ({"@context":Z},J)}fromJSONLD(Z){Z=kN(Z);let J=Z["@context"];if(J)this.set("context",J);return delete Z["@context"],this.set("properties",Z)}_assertContext(Z){if(!(Z.split(":")[0]in this.get("context")))throw new Error(`${nw}: Missing context for term, "${Z}".`)}}DD.EXTENSION_NAME=nw;function kN(Z){return JSON.parse(JSON.stringify(Z))}var qZ=nw;class PD extends N1{constructor(...Z){super(...Z);this.extensionName=qZ}createPacket(){return new DD(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[qZ];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 V=z[v];if(V.extensions&&V.extensions[qZ]){let H=V.extensions[qZ];W[G][v].setExtension(qZ,Q[H.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 s.ROOT:Q=J.asset;break;case s.SCENE:Q=J.scenes[Z.sceneIndexMap.get(Y)];break;case s.NODE:Q=J.nodes[Z.nodeIndexMap.get(Y)];break;case s.MESH:Q=J.meshes[Z.meshIndexMap.get(Y)];break;case s.MATERIAL:Q=J.materials[Z.materialIndexMap.get(Y)];break;case s.TEXTURE:Q=J.images[Z.imageIndexMap.get(Y)];break;case s.ANIMATION:Q=J.animations[Z.animationIndexMap.get(Y)];break;default:Q=null,this.document.getLogger().warn(`[${qZ}]: Unsupported parent property, "${Y.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[qZ]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[qZ]={packets:X};return this}}PD.EXTENSION_NAME=qZ;var uM1=[$z,rN,eN,JD,$D,QD,WD,ZU,vD,JU,XU,qD,UD,$U,jD,OD,Yz,MD,ND,PD],fP6=[rw,Xz,tw,ew,...uM1];var lM1=t(pR(),1);function hK(){return hK=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},hK.apply(null,arguments)}var{POINTS:qo,LINES:YU,LINE_STRIP:yM1,LINE_LOOP:pM1,TRIANGLES:QU,TRIANGLE_STRIP:iM1,TRIANGLE_FAN:gM1}=B8.Mode;function AJ(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function F7(Z,J){let X=hK({},Z);for(let $ in J)if(J[$]!==void 0)X[$]=J[$];return X}function fo(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case B8.Mode.POINTS:return J?J.getCount():X.getCount();case B8.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case B8.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case B8.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case B8.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case B8.Mode.TRIANGLE_STRIP:case B8.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw new Error("Unexpected mode: "+Z.getMode())}}var dM1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function ED(Z){return dM1.format(Z)}function aM1(Z,J,X=2){let $=Z>J?"–":"+",Y="%";return $+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function vU(Z,J){return`${ED(Z)} → ${ED(J)} (${aM1(Z,J)})`}function AD(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 nM1(Z,J,X){Z.swap(J,X);for(let $ of Z.listTargets())$.swap(J,X)}function sM1(Z,J){if(Z==null&&J==null)return!0;if(Z==null||J==null)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 wZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function oM1(Z,J=Z){let X=mD(Z,J);for(let $=0;$<X.length;$++)X[$]=$;return X}function mD(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function rM1(Z){return Z.listParents().some((J)=>J.propertyType!==n.ROOT)}function _o(Z){for(let J in Z)return!1;return!0}function So(Z){let J=L6.fromGraph(Z.getGraph()),X=Z.getMaterial(),$=J.getRoot().listMaterials().indexOf(X),Y=eM1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let z=Z.getAttribute(G),v=z.getElementSize(),V=z.getComponentType();return`${G}:${v}:${V}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((z)=>{let v=Z.getAttribute(z),V=v.getElementSize(),H=v.getComponentType();return`${z}:${V}:${H}`}).join("+")}).join("~");return`${$}|${Y}|${Q}|${K}|${W}`}function tM1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var eM1={[qo]:qo,[YU]:YU,[yM1]:YU,[pM1]:YU,[QU]:QU,[iM1]:QU,[gM1]:QU},_K="center",Fo={pivot:"center"};function ho(Z=Fo){let J=F7(Fo,Z);return AJ(_K,(X)=>{let $=X.getLogger(),Y=X.getRoot(),Q=Y.listAnimations().length>0||Y.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{$.debug(`${_K}: Scene ${W+1} / ${Y.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let v=hR(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(`${_K}: Pivot "${G.join(", ")}".`);let z=[-1*G[0],-1*G[1],-1*G[2]];if(Q){$.debug(`${_K}: Model contains animation or skin. Adding a wrapper node.`);let v=X.createNode("Pivot").setTranslation(z);K.listChildren().forEach((V)=>v.addChild(V)),K.addChild(v)}else $.debug(`${_K}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((v)=>{let V=v.getTranslation();v.setTranslation([V[0]+z[0],V[1]+z[1],V[2]+z[2]])})}),$.debug(`${_K}: Complete.`)})}function ZR1(Z){let J=new Set,X=Z,$;while($=X.getParentNode()){if(J.has($))throw new Error("Circular dependency in scene graph.");J.add($),X=$}return X.listParents().filter((Y)=>Y instanceof LK)}function JR1(Z){let J=ZR1(Z),X=Z.getParentNode();if(!X)return Z;Z.setMatrix(Z.getWorldMatrix()),X.removeChild(Z);for(let $ of J)$.addChild(Z);return Z}var bK=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function XR1(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],V=J[9],H=J[10],q=J[11],F=J[12],w=J[13],U=J[14],x=J[15],L=X*W-$*K,j=X*G-Y*K,c=X*z-Q*K,R=$*G-Y*W,M=$*z-Q*W,N=Y*z-Q*G,D=v*w-V*F,P=v*U-H*F,f=v*x-q*F,E=V*U-H*w,_=V*x-q*w,T=H*x-q*U,k=L*T-j*_+c*E+R*f-M*P+N*D;if(!k)return null;return k=1/k,Z[0]=(W*T-G*_+z*E)*k,Z[1]=(Y*_-$*T-Q*E)*k,Z[2]=(w*N-U*M+x*R)*k,Z[3]=(H*M-V*N-q*R)*k,Z[4]=(G*f-K*T-z*P)*k,Z[5]=(X*T-Y*f+Q*P)*k,Z[6]=(U*c-F*N-x*j)*k,Z[7]=(v*N-H*c+q*j)*k,Z[8]=(K*_-W*f+z*D)*k,Z[9]=($*f-X*_-Q*D)*k,Z[10]=(F*M-w*c+x*L)*k,Z[11]=(V*c-v*M-q*L)*k,Z[12]=(W*P-K*E-G*D)*k,Z[13]=(X*E-$*P+Y*D)*k,Z[14]=(w*j-F*R-U*L)*k,Z[15]=(v*R-V*j+H*L)*k,Z}function $R1(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],V=Z[10],H=Z[11],q=Z[12],F=Z[13],w=Z[14],U=Z[15],x=J*K-X*Q,L=J*W-$*Q,j=J*G-Y*Q,c=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,N=z*F-v*q,D=z*w-V*q,P=z*U-H*q,f=v*w-V*F,E=v*U-H*F,_=V*U-H*w;return x*_-L*E+j*f+c*P-R*D+M*N}function bo(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],V=J[8],H=J[9],q=J[10],F=J[11],w=J[12],U=J[13],x=J[14],L=J[15],j=X[0],c=X[1],R=X[2],M=X[3];return Z[0]=j*$+c*W+R*V+M*w,Z[1]=j*Y+c*G+R*H+M*U,Z[2]=j*Q+c*z+R*q+M*x,Z[3]=j*K+c*v+R*F+M*L,j=X[4],c=X[5],R=X[6],M=X[7],Z[4]=j*$+c*W+R*V+M*w,Z[5]=j*Y+c*G+R*H+M*U,Z[6]=j*Q+c*z+R*q+M*x,Z[7]=j*K+c*v+R*F+M*L,j=X[8],c=X[9],R=X[10],M=X[11],Z[8]=j*$+c*W+R*V+M*w,Z[9]=j*Y+c*G+R*H+M*U,Z[10]=j*Q+c*z+R*q+M*x,Z[11]=j*K+c*v+R*F+M*L,j=X[12],c=X[13],R=X[14],M=X[15],Z[12]=j*$+c*W+R*V+M*w,Z[13]=j*Y+c*G+R*H+M*U,Z[14]=j*Q+c*z+R*q+M*x,Z[15]=j*K+c*v+R*F+M*L,Z}function YR1(){var Z=new bK(9);if(bK!=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 QR1(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 KR1(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 WR1(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],V=v*K-W*z,H=-v*Q+W*G,q=z*Q-K*G,F=X*V+$*H+Y*q;if(!F)return null;return F=1/F,Z[0]=V*F,Z[1]=(-v*$+Y*z)*F,Z[2]=(W*$-Y*K)*F,Z[3]=H*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 HU(){var Z=new bK(3);if(bK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function GR1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function Ao(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 zR1(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 vR1(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 HR1=GR1;(function(){var Z=HU();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 hJ="dedup",CD={keepUniqueNames:!1,propertyTypes:[n.ACCESSOR,n.MESH,n.TEXTURE,n.MATERIAL,n.SKIN]};function mo(Z=CD){let J=F7(CD,Z),X=new Set(J.propertyTypes);for(let $ of J.propertyTypes)if(!CD.propertyTypes.includes($))throw new Error(`${hJ}: Unsupported deduplication on type "${$}".`);return AJ(hJ,($)=>{let Y=$.getLogger();if(X.has(n.ACCESSOR))VR1($);if(X.has(n.TEXTURE))FR1($,J);if(X.has(n.MATERIAL))wR1($,J);if(X.has(n.MESH))qR1($,J);if(X.has(n.SKIN))UR1($,J);Y.debug(`${hJ}: Complete.`)})}function VR1(Z){let J=Z.getLogger(),X=new Map,$=new Map,Y=new Map,Q=new Map,K=Z.getRoot().listMeshes();K.forEach((V)=>{V.listPrimitives().forEach((H)=>{H.listAttributes().forEach((q)=>W(q,$)),W(H.getIndices(),X)})});for(let V of Z.getRoot().listAnimations())for(let H of V.listSamplers())W(H.getInput(),Y),W(H.getOutput(),Q);function W(V,H){if(!V)return;let q=[V.getCount(),V.getType(),V.getComponentType(),V.getNormalized(),V.getSparse()].join(":"),F=H.get(q);if(!F)H.set(q,F=new Set);F.add(V)}function G(V,H){for(let q=0;q<V.length;q++){let F=V[q],w=r0.toView(F.getArray());if(H.has(F))continue;for(let U=q+1;U<V.length;U++){let x=V[U];if(H.has(x))continue;if(r0.equals(w,r0.toView(x.getArray())))H.set(x,F)}}}let z=0,v=new Map;for(let V of[$,X,Y,Q])for(let H of V.values())z+=H.size,G(Array.from(H),v);J.debug(`${hJ}: Merged ${v.size} of ${z} accessors.`),K.forEach((V)=>{V.listPrimitives().forEach((H)=>{H.listAttributes().forEach((F)=>{if(v.has(F))H.swap(F,v.get(F))});let q=H.getIndices();if(q&&v.has(q))H.swap(q,v.get(q))})});for(let V of Z.getRoot().listAnimations())for(let H of V.listSamplers()){let q=H.getInput(),F=H.getOutput();if(q&&v.has(q))H.swap(q,v.get(q));if(F&&v.has(F))H.swap(F,v.get(F))}Array.from(v.keys()).forEach((V)=>V.dispose())}function qR1(Z,J){let X=Z.getLogger(),$=Z.getRoot(),Y=new Map;$.listAccessors().forEach((W,G)=>Y.set(W,G)),$.listMaterials().forEach((W,G)=>Y.set(W,G));let Q=$.listMeshes().length,K=new Map;for(let W of $.listMeshes()){let G=[];for(let v of W.listPrimitives())G.push(uo(v,Y));let z="";if(J.keepUniqueNames)z+=W.getName()+";";if(z+=G.join(";"),K.has(z)){let v=K.get(z);W.listParents().forEach((V)=>{if(V.propertyType!==n.ROOT)V.swap(W,v)}),W.dispose()}else K.set(z,W)}X.debug(`${hJ}: Merged ${Q-K.size} of ${Q} meshes.`)}function FR1(Z,J){let X=Z.getLogger(),$=Z.getRoot(),Y=$.listTextures(),Q=new Map;for(let K=0;K<Y.length;K++){let W=Y[K],G=W.getImage();if(Q.has(W))continue;for(let z=K+1;z<Y.length;z++){let v=Y[z],V=v.getImage();if(Q.has(v))continue;if(W.getMimeType()!==v.getMimeType())continue;if(J.keepUniqueNames&&W.getName()!==v.getName())continue;let H=W.getSize(),q=v.getSize();if(!H||!q)continue;if(H[0]!==q[0])continue;if(H[1]!==q[1])continue;if(!G||!V)continue;if(r0.equals(G,V))Q.set(v,W)}}X.debug(`${hJ}: Merged ${Q.size} of ${$.listTextures().length} textures.`),Array.from(Q.entries()).forEach(([K,W])=>{K.listParents().forEach((G)=>{if(!(G instanceof C$))G.swap(K,W)}),K.dispose()})}function wR1(Z,J){let X=Z.getLogger(),Y=Z.getRoot().listMaterials(),Q=new Map,K=new Map,W=new Set;if(!J.keepUniqueNames)W.add("name");for(let G=0;G<Y.length;G++){let z=Y[G];if(Q.has(z))continue;if(wo(z,K))continue;for(let v=G+1;v<Y.length;v++){let V=Y[v];if(Q.has(V))continue;if(wo(V,K))continue;if(z.equals(V,W))Q.set(V,z)}}X.debug(`${hJ}: Merged ${Q.size} of ${Y.length} materials.`),Array.from(Q.entries()).forEach(([G,z])=>{G.listParents().forEach((v)=>{if(!(v instanceof C$))v.swap(G,z)}),G.dispose()})}function UR1(Z,J){let X=Z.getLogger(),Y=Z.getRoot().listSkins(),Q=new Map,K=new Set(["joints"]);if(!J.keepUniqueNames)K.add("name");for(let W=0;W<Y.length;W++){let G=Y[W];if(Q.has(G))continue;for(let z=W+1;z<Y.length;z++){let v=Y[z];if(Q.has(v))continue;if(G.equals(v,K)&&sM1(G.listJoints(),v.listJoints()))Q.set(v,G)}}X.debug(`${hJ}: Merged ${Q.size} of ${Y.length} skins.`),Array.from(Q.entries()).forEach(([W,G])=>{W.listParents().forEach((z)=>{if(!(z instanceof C$))z.swap(W,G)}),W.dispose()})}function uo(Z,J){let X=[];for(let $ of Z.listSemantics()){let Y=Z.getAttribute($);X.push($+":"+J.get(Y))}if(Z instanceof B8){let $=Z.getIndices();if($)X.push("indices:"+J.get($));let Y=Z.getMaterial();if(Y)X.push("material:"+J.get(Y));X.push("mode:"+Z.getMode());for(let Q of Z.listTargets())X.push("target:"+uo(Q,J))}return X.join(",")}function wo(Z,J){if(J.has(Z))return J.get(Z);let X=Z.getGraph(),$=new Set,Y=X.listParentEdges(Z);while(Y.length>0){let Q=Y.pop();if(Q.getAttributes().modifyChild===!0)return J.set(Z,!0),!0;let K=Q.getChild();if($.has(K))continue;for(let W of X.listChildEdges(K))Y.push(W)}return J.set(Z,!1),!1}function lo(){var Z=new bK(4);if(bK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function xR1(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 BR1(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 LR1(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 jR1(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 cR1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3];return Math.hypot(J,X,$,Y)}var yo=BR1,OR1=LR1,po=cR1;(function(){var Z=lo();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 MR1=/color|emissive|diffuse/i;function RR1(Z){return Z.getGraph().listParentEdges(Z).some((Y)=>{return Y.getAttributes().isColor||MR1.test(Y.getName())})?"srgb":null}function NR1(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 P$)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 V5&&K.has(W.getName()))$.add(G);else if(G instanceof BK)Y(G)}}return Y(Z),Array.from($)}function DR1(Z){let X=L6.fromGraph(Z.getGraph()).getRoot(),$=Z.getGraph().listParentEdges(Z).filter((Y)=>Y.getParent()!==X).map((Y)=>Y.getName());return Array.from(new Set($))}var SK="prune",ID=0.011764705882352941,Uo={propertyTypes:[n.NODE,n.SKIN,n.MESH,n.CAMERA,n.PRIMITIVE,n.PRIMITIVE_TARGET,n.ANIMATION,n.MATERIAL,n.TEXTURE,n.ACCESSOR,n.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function VU(Z=Uo){let J=F7(Uo,Z),X=new Set(J.propertyTypes),$=J.keepExtras;return AJ(SK,async(Y)=>{let Q=Y.getLogger(),K=Y.getRoot(),W=Y.getGraph(),G=new io,z=(v)=>G.dispose(v.target);if(W.addEventListener("node:dispose",z),X.has(n.MESH))for(let v of K.listMeshes()){if(v.listPrimitives().length>0)continue;v.dispose()}if(X.has(n.NODE)){if(!J.keepLeaves)for(let v of K.listScenes())go(W,v,$);for(let v of K.listNodes())j4(v,$)}if(X.has(n.SKIN))for(let v of K.listSkins())j4(v,$);if(X.has(n.MESH))for(let v of K.listMeshes())j4(v,$);if(X.has(n.CAMERA))for(let v of K.listCameras())j4(v,$);if(X.has(n.PRIMITIVE))xo(W,n.PRIMITIVE,$);if(X.has(n.PRIMITIVE_TARGET))xo(W,n.PRIMITIVE_TARGET,$);if(!J.keepAttributes&&X.has(n.ACCESSOR)){let v=new Map;for(let V of K.listMeshes())for(let H of V.listPrimitives()){let q=H.getMaterial();if(!q)continue;let F=ao(Y,H,q),w=CR1(H,F);Bo(H,w),H.listTargets().forEach((U)=>Bo(U,w)),v.has(q)?v.get(q).add(H):v.set(q,new Set([H]))}for(let[V,H]of v)TR1(V,Array.from(H))}if(!J.keepIndices&&X.has(n.ACCESSOR))for(let v of K.listMeshes())for(let V of v.listPrimitives())PR1(V);if(X.has(n.ANIMATION))for(let v of K.listAnimations()){for(let V of v.listChannels())if(!V.getTargetNode())V.dispose();if(!v.listChannels().length){let V=v.listSamplers();j4(v,$),V.forEach((H)=>j4(H,$))}else v.listSamplers().forEach((V)=>j4(V,$))}if(X.has(n.MATERIAL))K.listMaterials().forEach((v)=>j4(v,$));if(X.has(n.TEXTURE)){if(K.listTextures().forEach((v)=>j4(v,$)),!J.keepSolidTextures)await kR1(Y)}if(X.has(n.ACCESSOR))K.listAccessors().forEach((v)=>j4(v,$));if(X.has(n.BUFFER))K.listBuffers().forEach((v)=>j4(v,$));if(W.removeEventListener("node:dispose",z),!G.empty()){let v=G.entries().map(([V,H])=>`${V} (${H})`).join(", ");Q.info(`${SK}: Removed types... ${v}`)}else Q.debug(`${SK}: No unused properties found.`);Q.debug(`${SK}: Complete.`)})}class io{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 j4(Z,J){let X=Z.listParents().filter((Y)=>!(Y instanceof C$||Y instanceof N$)),$=J&&!_o(Z.getExtras());if(!X.length&&!$)Z.dispose()}function xo(Z,J,X){for(let $ of Z.listEdges()){let Y=$.getParent();if(Y.propertyType===J)j4(Y,X)}}function go(Z,J,X){if(J.listChildren().forEach((K)=>go(Z,K,X)),J instanceof LK)return;let $=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==n.ROOT&&W!==n.SCENE&&W!==n.NODE}),Y=Z.listChildren(J).length===0,Q=X&&!_o(J.getExtras());if(Y&&!$&&!Q)J.dispose()}function Bo(Z,J){for(let X of J)Z.setAttribute(X,null)}function PR1(Z){let J=Z.getIndices(),X=J&&J.getArray(),$=Z.listAttributes()[0];if(!X||!$)return;if(J.getCount()!==$.getCount())return;for(let Y=0,Q=X.length;Y<Q;Y++)if(Y!==X[Y])return;Z.setIndices(null)}function CR1(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 ao(Z,J,X,$=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let z of Q)if(z.getChild()instanceof P$)K.add(z.getName());for(let z of Q){let v=z.getName(),V=z.getChild();if(V instanceof V5){if(K.has(v.replace(/Info$/,"")))$.add(`TEXCOORD_${V.getTexCoord()}`)}if(V instanceof P$&&v.match(/normalTexture/i))$.add("TANGENT");if(V instanceof BK)ao(Z,J,V,$)}let W=X instanceof Q7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===B8.Mode.POINTS;if(W&&!G)$.add("NORMAL");return $}function TR1(Z,J){let X=NR1(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 V=G.getAttribute(v);if(!V)continue;let H=K.get(v);if(H===v)continue;G.setAttribute(H,V),G.setAttribute(v,null)}}}async function kR1(Z){let J=Z.getRoot(),X=Z.getGraph(),$=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await IR1(K);if(!G)return;if(RR1(K)==="srgb")bR.convertSRGBToLinear(G,G);let z=K.getName()||K.getURI(),v=(W=K.getSize())==null?void 0:W.join("x"),V=DR1(K);for(let H of X.listParentEdges(K)){let q=H.getParent();if(q!==J&&ER1(q,G,H.getName(),$))H.dispose()}if(K.listParents().length===1)K.dispose(),$.debug(`${SK}: Removed solid-color texture "${z}" (${v}px ${V.join(", ")})`)});await Promise.all(Q)}function ER1(Z,J,X,$){if(Z instanceof Q7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(OR1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(HR1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=ID;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return po(yo(lo(),J,[0.5,0.5,1,1]))<=ID}return $.warn(`${SK}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function IR1(Z){let J=await fR1(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(po(yo(Y,$,X))/255>ID)return null}return jR1(Y,xR1(Y,$,X),0.00196078431372549)}async function fR1(Z){try{return await Es(Z.getImage(),Z.getMimeType())}catch(J){return null}}var SJ=4294967295;class no{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of AD(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=r0.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 _R1(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 _R1(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 SR1(Z,J,X,$,Y=SJ){let Q=J-1,W=X.hash($)&Q;for(let G=0;G<=Q;G++){let z=Z[W];if(z===Y||X.equal(z,$))return W;W=W+G+1&Q}throw new Error("Hash table full.")}var Q6;(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"})(Q6||(Q6={}));function bJ(Z,J){let X=Z.getAttribute("POSITION"),$=Z.getIndices();switch(J){case Q6.RENDER:return $?$.getCount():X.getCount();case Q6.RENDER_CACHED:return $?new Set($.getArray()).size:X.getCount();case Q6.UPLOAD_NAIVE:case Q6.UPLOAD:return X.getCount();case Q6.DISTINCT:case Q6.DISTINCT_POSITION:return hR1(J);case Q6.UNUSED:return $?X.getCount()-new Set($.getArray()).size:0;default:return bR1(J)}}function hR1(Z){throw new Error(`Not implemented: ${Z}`)}function bR1(Z){throw new Error(`Unexpected value: ${Z}`)}function Kz(Z,J,X){let $=L6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=AR1(Z);let Y=Z.getIndices(),Q=Y?Y.getArray():null,K=bJ(Z,Q6.RENDER),W=$.createAccessor(),G=K,z=mD(G,X);for(let V=0;V<G;V++)z[V]=J[Q?Q[V]:V];Z.setIndices(W.setArray(z));let v=AD(Z);for(let V of Z.listAttributes()){let H=wZ($,V);fD(V,Y,J,H,X),Z.swap(V,H)}for(let V of Z.listTargets())for(let H of V.listAttributes()){let q=wZ($,H);fD(H,Y,J,q,X),V.swap(H,q)}if(Y&&Y.listParents().length===1)Y.dispose();for(let V of v)if(V.listParents().length===1)V.dispose();return Z}function fD(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 V=0;V<G;V++){let H=W?W[V]:V,q=X[H];if(v[q])continue;for(let F=0;F<Q;F++)z[q*Q+F]=K[H*Q+F];v[q]=1}return $.setArray(z)}function AR1(Z){let J=bJ(Z,Q6.UPLOAD),X=Z.getIndices(),$=X?X.getArray():null;if(!X||!$)return[oM1(J,1e6),J];let Y=new Uint32Array(J).fill(SJ),Q=0;for(let K=0;K<$.length;K++){let W=$[K];if(Y[W]===SJ)Y[W]=Q++}return[Y,Q]}var _D="weld",WU={overwrite:!0,cleanup:!0};function uD(Z=WU){let J=F7(WU,Z);return AJ(_D,async(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes()){for(let Q of Y.listPrimitives())if(qU(Q,J),bJ(Q,Q6.RENDER)===0)Q.dispose();if(Y.listPrimitives().length===0)Y.dispose()}if(J.cleanup)await X.transform(VU({propertyTypes:[n.ACCESSOR,n.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),mo({propertyTypes:[n.ACCESSOR]}));$.debug(`${_D}: Complete.`)})}function qU(Z,J=WU){let X=Z.getGraph(),Y=L6.fromGraph(X).getLogger(),Q=hK({},WU,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===B8.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 no(Z),V=tM1(K+K/4),H=new Uint32Array(V).fill(SJ),q=new Uint32Array(K).fill(SJ),F=0;for(let w=0;w<z;w++){let U=G?G[w]:w;if(q[U]!==SJ)continue;let x=SR1(H,V,v,U,SJ),L=H[x];if(L===SJ)H[x]=U,q[U]=F++;else q[U]=q[L]}Y.debug(`${_D}: ${vU(K,F)} vertices.`),Kz(Z,q,F)}var{FLOAT:mR1}=_0.ComponentType;function so(Z,J){let X=Z.getAttribute("POSITION");if(X)Lo(J,X);let $=Z.getAttribute("NORMAL");if($)jo(J,$);let Y=Z.getAttribute("TANGENT");if(Y)co(J,Y);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)Lo(J,K);let W=Q.getAttribute("NORMAL");if(W)jo(J,W);let G=Q.getAttribute("TANGENT");if(G)co(J,G)}if($R1(J)<0)uR1(Z)}function Lo(Z,J){let X=J.getComponentType(),$=J.getNormalized(),Y=J.getArray(),Q=X===mR1?Y:new Float32Array(Y.length),K=HU();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=a0.decodeNormalizedInt(Y[W*3],X),K[1]=a0.decodeNormalizedInt(Y[W*3+1],X),K[2]=a0.decodeNormalizedInt(Y[W*3+2],X);else K[0]=Y[W*3],K[1]=Y[W*3+1],K[2]=Y[W*3+2];zR1(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 jo(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=YR1();QR1(Q,Z),WR1(Q,Q),KR1(Q,Q);let K=HU();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=a0.decodeNormalizedInt(X[W*3],Y),K[1]=a0.decodeNormalizedInt(X[W*3+1],Y),K[2]=a0.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(vR1(K,K,Q),Ao(K,K),$)X[W*3]=a0.decodeNormalizedInt(K[0],Y),X[W*3+1]=a0.decodeNormalizedInt(K[1],Y),X[W*3+2]=a0.decodeNormalizedInt(K[2],Y);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function co(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=HU();for(let K=0,W=J.getCount();K<W;K++){if($)Q[0]=a0.decodeNormalizedInt(X[K*4],Y),Q[1]=a0.decodeNormalizedInt(X[K*4+1],Y),Q[2]=a0.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],Ao(Q,Q),$)X[K*4]=a0.decodeNormalizedInt(Q[0],Y),X[K*4+1]=a0.decodeNormalizedInt(Q[1],Y),X[K*4+2]=a0.decodeNormalizedInt(Q[2],Y);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function uR1(Z){if(Z.getMode()!==B8.Mode.TRIANGLES)return;if(!Z.getIndices())qU(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 lR1(Z,J){for(let X of Z.listPrimitives()){let $=yR1(X,Z);if(X!==$)Z.removePrimitive(X).addPrimitive($)}for(let X of Z.listPrimitives())Kz(X),so(X,J)}function yR1(Z,J){if(Z.listParents().some(($)=>$ instanceof hG&&$!==J))Z=Z.clone();for(let $ of Z.listTargets())if($.listParents().some((Q)=>Q instanceof B8&&Q!==Z))Z.removeTarget($).addTarget($.clone());return Z}var Oo=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function oo(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!a0.eq(X,Oo))lR1(J,X);for(let $ of Z.listChildren()){let Y=$.getMatrix();bo(Y,Y,X),$.setMatrix(Y)}return Z.setMatrix(Oo)}var{LINES:pR1,LINE_STRIP:iR1,LINE_LOOP:gR1,TRIANGLES:dR1,TRIANGLE_STRIP:aR1,TRIANGLE_FAN:nR1}=B8.Mode;function sR1(Z){let J=Z.getGraph(),X=L6.fromGraph(J);if(!Z.getIndices())qU(Z);let $=Z.getIndices(),Y=$.getArray(),Q=fo(Z),W=new DJ[$.getComponentType()](Q*2),G=Z.getMode();if(G===iR1)for(let v=0;v<Q;v++)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else if(G===gR1)for(let v=0;v<Q;v++)if(v<Q-1)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else W[v*2]=Y[v],W[v*2+1]=Y[0];else throw new Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(pR1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(wZ(X,$).setArray(W));else $.setArray(W)}function ro(Z){let J=Z.getGraph(),X=L6.fromGraph(J);if(!Z.getIndices())qU(Z);let $=Z.getIndices(),Y=$.getArray(),Q=fo(Z),W=new DJ[$.getComponentType()](Q*3),G=Z.getMode();if(G===aR1)for(let v=0,V=Y.length;v<V-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===nR1)for(let v=0;v<Q;v++)W[v*3]=Y[0],W[v*3+1]=Y[v+1],W[v*3+2]=Y[v+2];else throw new Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(dR1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(wZ(X,$).setArray(W));else $.setArray(W)}var Mo="dequantize",GU={pattern:/^((?!JOINTS_).)*$/};function to(Z=GU){let J=F7(GU,Z);return AJ(Mo,(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes())for(let Q of Y.listPrimitives())oR1(Q,J);X.createExtension(Yz).dispose(),$.debug(`${Mo}: Complete.`)})}function oR1(Z,J=GU){let X=F7(GU,J);for(let $ of Z.listSemantics())if(X.pattern.test($))SD(Z.getAttribute($));for(let $ of Z.listTargets())for(let Y of $.listSemantics())if(X.pattern.test(Y))SD($.getAttribute(Y))}function SD(Z){let J=Z.getArray();if(!J)return;let X=zU(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function zU(Z,J,X){let $=new Float32Array(Z.length);for(let Y=0,Q=Z.length;Y<Q;Y++)if(X)$[Y]=a0.decodeNormalizedInt(Z[Y],J);else $[Y]=Z[Y];return $}var{TEXTURE_INFO:eo,ROOT:mP6}=n;function Zr(Z){let J=new L6().setLogger(Z.getLogger()),X=lD(J,Z);return rR1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function rR1(Z,J,X){X||(X=lD(Z,J));for(let $ of J.getRoot().listExtensionsUsed()){let Y=Z.createExtension($.constructor);if($.isRequired())Y.setRequired(!0)}return tR1(Z,J,eR1(J),X)}function tR1(Z,J,X,$){$||($=lD(Z,J));let Y=new Map;for(let Q of X)if(!Y.has(Q)&&Q.propertyType!==eo)Y.set(Q,$(Q));for(let[Q,K]of Y.entries())K.copy(Q,$);return Y}function lD(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return($)=>{if($.propertyType===eo)return $;let Y=X.get($);if(!Y)Y=new $.constructor(Z.getGraph()),X.set($,Y);return Y}}function eR1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}var TD="flatten",Ro={cleanup:!0};function Jr(Z=Ro){let J=F7(Ro,Z);return AJ(TD,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 V=v.getTargetNode();if(V&&v.getTargetPath()!=="weights")K.add(V)}let W=new Set,G=new Set;for(let z of $.listScenes())z.traverse((v)=>{let V=v.getParentNode();if(!V)return;if(Q.has(V)||W.has(V))W.add(v);if(K.has(V)||G.has(V))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;JR1(v)});if(K.size)Y.debug(`${TD}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(VU({propertyTypes:[n.NODE],keepLeaves:!1}));Y.debug(`${TD}: Complete.`)})}function Xr(Z){return hR(Z)}var ZN1={skipValidation:!1},No=4294967295,{LINE_STRIP:JN1,LINE_LOOP:XN1,TRIANGLE_STRIP:$N1,TRIANGLE_FAN:YN1}=B8.Mode;function QN1(Z,J={}){let X=F7(ZN1,J),$=Z[0],Y=L6.fromGraph($.getGraph());if(!X.skipValidation&&new Set(Z.map(So)).size>1)throw new Error("Requires >=2 Primitives, sharing the same Material and Mode, with compatible vertex attributes and indices.");for(let q of Z)switch(q.getMode()){case JN1:case XN1:sR1(q);break;case $N1:case YN1:ro(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],w=F.getIndices(),U=F.getAttribute("POSITION").getCount(),x=w?w.getArray():null,L=w?w.getCount():U,j=new Uint32Array(U).fill(No);for(let c=0;c<L;c++){let R=x?x[c]:c;if(j[R]===No)j[R]=W++,K[q]++}Q.push(j),G+=L}let z=Y.createPrimitive().setMode($.getMode()).setMaterial($.getMaterial());for(let q of $.listSemantics()){let F=$.getAttribute(q),w=DJ[F.getComponentType()],U=wZ(Y,F).setArray(new w(W*F.getElementSize()));z.setAttribute(q,U)}let v=$.getIndices(),V=v?wZ(Y,v).setArray(mD(G,W)):null;z.setIndices(V);let H=0;for(let q=0;q<Q.length;q++){let F=Z[q],w=F.getIndices(),U=w?w.getCount():-1,x=Q[q];if(w&&V)WN1(w,x,V,H),H+=U;for(let L of z.listSemantics()){let j=F.getAttribute(L),c=z.getAttribute(L);KN1(j,w,x,c)}}return z}function KN1(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,V=J?J.getCount():K;v<V;v++){let H=Q?Q[v]:v,q=X[H];if(z[q])continue;for(let F=0;F<Y;F++)G[q*Y+F]=W[H*Y+F];z[q]=1}}function WN1(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 hD="join",{ROOT:GN1,NODE:zN1,MESH:vN1,PRIMITIVE:HN1,ACCESSOR:VN1}=n,kD=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Do={keepMeshes:!1,keepNamed:!1,cleanup:!0};function $r(Z=Do){let J=F7(Do,Z);return AJ(hD,async(X)=>{let $=X.getRoot(),Y=X.getLogger();for(let Q of $.listScenes())Po(X,Q,J),Q.traverse((K)=>Po(X,K,J));if(J.cleanup)await X.transform(VU({propertyTypes:[zN1,vN1,HN1,VN1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));Y.debug(`${hD}: Complete.`)})}function Po(Z,J,X){let $=Z.getLogger(),Y={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let z=Q[G];if(z.listParents().some((H)=>H instanceof N$))continue;let V=z.getMesh();if(!V)continue;if(z.getExtension("EXT_mesh_gpu_instancing"))continue;if(z.getSkin())continue;for(let H of V.listPrimitives()){if(H.listTargets().length>0)continue;let q=H.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;Kz(H),FN1(H);let F=So(H),w=V.getName()||z.getName();if(X.keepMeshes||X.keepNamed&&w)F+=`|${G}`;if(!(F in Y))Y[F]={prims:[],primMeshes:[],primNodes:[],dstNode:z,dstMesh:void 0};let U=Y[F];U.prims.push(H),U.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((V)=>{return V.propertyType!==GN1&&G!==V}))G.setMesh(z.clone())}for(let G of K){let{dstNode:z,primNodes:v}=G;G.dstMesh=z.getMesh(),G.primMeshes=v.map((V)=>V.getMesh())}for(let G of K){let{prims:z,primNodes:v,primMeshes:V,dstNode:H,dstMesh:q}=G,F=H.getMatrix();for(let x=0;x<z.length;x++){let L=v[x],j=V[x],c=z[x];if(j.removePrimitive(c),rM1(c))c=z[x]=qN1(z[x]);if(L!==H)bo(kD,XR1(kD,F),L.getMatrix()),so(c,kD)}let w=QN1(z),U=w.listAttributes()[0].getCount();q.addPrimitive(w),$.debug(`${hD}: Joined Primitives (${z.length}) containing ${ED(U)} vertices under Node "${H.getName()}".`)}}function qN1(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 FN1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)SD(X)}}var{TRANSLATION:uP6,ROTATION:lP6,SCALE:yP6,WEIGHTS:pP6}=N$.TargetPath;var wN1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var iP6=hK({level:"high"},wN1);var UN1="unweld";function xN1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let $=Z.getGraph(),Y=L6.fromGraph($),Q=Y.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,Co(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,Co(Y,z,X,J)),z.listParents().length===1)z.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${UN1}: ${vU(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function Co(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,V=X.getCount();v<V;v++)for(let H=0;H<G;H++)K[v*G+H]=Y[W[v]*G+H];if(!$.has(J))$.set(J,new Map);let z=wZ(Z,J).setArray(K);return $.get(J).set(X,z),z}var To;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(To||(To={}));var BN1=0.000001;function LN1(Z,J,X,$=0.0001){let Y=J.length/Z.length,Q=new Array(Y).fill(0),K=new Array(Y).fill(0),W=new Array(Y).fill(0),G=new Array(Y).fill(0),z=Z.length-1,v=1;for(let V=1;V<z;++V){let H=Z[v-1],q=Z[V],F=Z[V+1],w=(q-H)/(F-H),U=!1;if(q!==F&&(V!==1||q!==Z[0])){if(Qz(J,v-1,G),Qz(J,V,K),Qz(J,V+1,W),X==="slerp"){let x=ON1(Q,G,W,w),L=Eo(G,K)+Eo(K,W);U=!KU(K,x,$)||L+Number.EPSILON>=Math.PI}else if(X==="lerp"){let x=cN1(Q,G,W,w);U=!KU(K,x,$)}else if(X==="step")U=!KU(K,G)||!KU(K,W)}if(U){if(V!==v)Z[v]=Z[V],ko(J,v,Qz(J,V,Q));v++}}if(z>0)Z[v]=Z[z],ko(J,v,Qz(J,z,Q)),v++;return v}function Qz(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)X[$]=Z[J*Y+$];return X}function ko(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)Z[J*Y+$]=X[$]}function KU(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 jN1(Z,J,X){return Z*(1-X)+J*X}function cN1(Z,J,X,$){for(let Y=0;Y<J.length;Y++)Z[Y]=jN1(J[Y],X[Y],$);return Z}function ON1(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],V=X[3],H,q,F,w,U;if(q=Y*G+Q*z+K*v+W*V,q<0)q=-q,G=-G,z=-z,v=-v,V=-V;if(1-q>BN1)H=Math.acos(q),F=Math.sin(H),w=Math.sin((1-$)*H)/F,U=Math.sin($*H)/F;else w=1-$,U=$;return Z[0]=w*Y+U*G,Z[1]=w*Q+U*z,Z[2]=w*K+U*v,Z[3]=w*W+U*V,Z}function Eo(Z,J){let X=MN1(Z,J);return Math.acos(2*X*X-1)}function MN1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var gP6=new Float32Array(0),dP6={ready:Promise.resolve(),resample:LN1,tolerance:0.0001,cleanup:!0};var n$="simplify",{POINTS:Yr,LINES:RN1,LINE_STRIP:NN1,LINE_LOOP:DN1,TRIANGLES:PN1,TRIANGLE_STRIP:Qr,TRIANGLE_FAN:Kr}=B8.Mode,Wr={ratio:0,error:0.0001,lockBorder:!1,cleanup:!0};function Gr(Z){let J=F7(Wr,Z),X=J.simplifier;if(!X)throw new Error(`${n$}: simplifier dependency required — install "meshoptimizer".`);return AJ(n$,async($)=>{let Y=$.getLogger();await X.ready,await $.transform(uD({overwrite:!1,cleanup:J.cleanup}));let Q=0;for(let K of $.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G===PN1||G===Qr||G===Kr){if(Io(W,J),bJ(W,Q6.RENDER)===0)W.dispose()}else if(W.getMode()===Yr&&!!X.simplifyPoints){if(Io(W,J),bJ(W,Q6.RENDER)===0)W.dispose()}else Q++}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)Y.warn(`${n$}: Skipping simplification of ${Q} primitives: Unsupported draw mode.`);if(J.cleanup)await $.transform(VU({propertyTypes:[n.ACCESSOR,n.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),mo({propertyTypes:[n.ACCESSOR]}));Y.debug(`${n$}: Complete.`)})}function Io(Z,J){let X=hK({},Wr,J),$=X.simplifier,Y=Z.getGraph(),Q=L6.fromGraph(Y),K=Q.getLogger();switch(Z.getMode()){case Yr:return CN1(Q,Z,X);case RN1:case NN1:case DN1:return K.warn(`${n$}: Skipping primitive simplification: Unsupported draw mode.`),Z;case Qr:case Kr:ro(Z);break}let W=bJ(Z,Q6.UPLOAD),G=bJ(Z,Q6.RENDER);if(G<W/2)Kz(Z);let z=Z.getAttribute("POSITION"),v=Z.getIndices(),V=z.getArray(),H=v.getArray();if(!(V instanceof Float32Array))V=zU(V,z.getComponentType(),z.getNormalized());if(!(H instanceof Uint32Array))H=new Uint32Array(H);let q=Math.floor(X.ratio*G/3)*3,F=X.lockBorder?["LockBorder"]:[],[w,U]=$.simplify(H,V,3,q,X.error,F);if(Z.setIndices(wZ(Q,v).setArray(w)),v.listParents().length===1)v.dispose();Kz(Z);let x=bJ(Z,Q6.UPLOAD);if(x<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${n$}: ${vU(W,x)} vertices, error: ${U.toFixed(4)}.`),Z}function CN1(Z,J,X){let $=X.simplifier,Y=Z.getLogger();if(J.getIndices())xN1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),z=K.getArray(),v=W?W.getArray():void 0,V=W?W.getComponentSize():void 0;if(!(z instanceof Float32Array))z=zU(z,K.getComponentType(),K.getNormalized());if(v&&!(v instanceof Float32Array))v=zU(v,K.getComponentType(),K.getNormalized());$.useExperimentalFeatures=!0;let H=Math.floor(X.ratio*G),q=$.simplifyPoints(z,3,H,v,V);$.useExperimentalFeatures=!1;let[F,w]=$.compactMesh(q);Y.debug(`${n$}: ${vU(K.getCount(),w)} vertices.`);for(let U of AD(J)){let x=wZ(Z,U);if(fD(U,null,F,x,w),nM1(J,U,x),U.listParents().length===1)U.dispose()}return J}var bD;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(bD||(bD={}));var aP6={resizeFilter:bD.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var wr=t(Fr(),1);var AK={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DIRECTORIES:[(()=>{try{return u5.dirname(p.resolve("@hytopia.com/assets"))}catch{return null}})(),u5.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 U5{static instance=new U5;optimize=!0;optimizeEveryStart=!1;_modelUriDocuments=new Map;_modelUriBoundingBoxes=new Map;_modelUriNodeNames=new Map;_modelUriTrimeshes=new Map;constructor(){}async preloadModels(){let Z=await this._getAbsoluteModelPaths();console.log(`ModelRegistry.preloadModels(): Preloading ${Z.length} models...`);for(let J of Z){if(this.optimize)await this._resolveOptimizedModelPath(J);await this._loadModelData(J)}console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models!`)}getAnimationNames(Z){let J=this._modelUriDocuments.get(Z);if(!J)y.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J.getRoot().listAnimations().map(($)=>$.getName())}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=u5.normalize(Z);for(let X of AK.DIRECTORIES){let $=u5.normalize(X);if(J.startsWith($))return u5.relative($,J).replace(/\\/g,"/")}return u5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of AK.DIRECTORIES){let X=u5.resolve(process.cwd(),J);if(!mJ.existsSync(X))continue;let $=await Zw("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let Y of $)Z.push(u5.join(X,Y))}return Z}async _loadModelData(Z){let J=await new yR().read(Z),X=Xr(J.getRoot().listScenes()[0]),$=J.getRoot().listNodes().map((Q)=>Q.getName()),Y=this._absoluteModelPathToModelUri(Z);this._modelUriDocuments.set(Y,J),this._modelUriBoundingBoxes.set(Y,{min:{x:X.min[0],y:X.min[1],z:X.min[2]},max:{x:X.max[0],y:X.max[1],z:X.max[2]}}),this._modelUriNodeNames.set(Y,$),this._modelUriTrimeshes.set(Y,await this._buildTrimesh(Y))}async _resolveOptimizedModelPath(Z){let J=this._buildOptimizedModelPath(Z);if(!this.optimizeEveryStart&&this._isOptimizedVersionValid(Z))return J;return await this._optimizeModel(Z,J)}_isOptimizedVersionValid(Z){let J=`${this._buildOptimizedModelPath(Z)}${AK.CHECKSUM_EXT}`;if(!mJ.existsSync(J))return!1;let X=this._calculateChecksum(Z),$=mJ.readFileSync(J,"utf8");return X===$}_calculateChecksum(Z){if(!mJ.existsSync(Z))return"";let J=mJ.readFileSync(Z);return fN1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=u5.basename(Z),X=J.replace(/\.[^/.]+$/,""),$=u5.dirname(Z),Y=u5.join($,AK.OPTIMIZED_DIR,X);return u5.join(Y,J)}async _buildTrimesh(Z,J=1,X=0.001){let $=this._modelUriDocuments.get(Z);if(!$)y.fatalError(`ModelRegistry._buildTrimesh(): Model ${Z} not found!`);let Y=Zr($);Y.setLogger(new q5(_G.WARN)),await Y.transform(ho({pivot:"center"}),Jr(),$r(),uD(),Gr({simplifier:wr.MeshoptSimplifier,ratio:J,error:X}),to());for(let z of Y.getRoot().listScenes())for(let v of z.listChildren())oo(v);let Q=Y.getRoot().listMeshes()[0];if(!Q){y.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root mesh!`);return}let K=Q.listPrimitives()[0];if(!K){y.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root primitive!`);return}let W=K.getAttribute("POSITION"),G=K.getIndices();if(!W||!G){y.error(`ModelRegistry._buildTrimesh(): Model ${Z} missing required geometry data!`);return}return{vertices:W.getArray(),indices:G.getArray()}}async _optimizeModel(Z,J){let X=u5.dirname(J);mJ.rmSync(X,{recursive:!0,force:!0}),mJ.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let $ of AK.OPTIMIZER_RUNS){let Y=J.replace(/(\.[^/.]+)$/,`${$.suffix}$1`),{stderr:Q}=await wg("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 mJ.writeFileSync(`${J}${AK.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var Hz;((Y)=>{Y.DYNAMIC="dynamic";Y.FIXED="fixed";Y.KINEMATIC_POSITION="kinematic_position";Y.KINEMATIC_VELOCITY="kinematic_velocity"})(Hz||={});var dD=0.001,Ur="dynamic";class s$ extends L0{_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??=Ur,this._rigidBodyDesc=this._createRigidBodyDesc(Z),this._rigidBodyType=Z.type,this._applyRigidBodyOptions(Z),this._autoAddToSimulation(Z)}get additionalMass(){if(!this._requireNotRemoved("additionalMass"))return 0;return this._additionalMass}get additionalSolverIterations(){if(!this._requireNotRemoved("additionalSolverIterations"))return 0;return this._rigidBody?this._rigidBody.additionalSolverIterations():this._rigidBodyDesc.additionalSolverIterations}get angularDamping(){if(!this._requireNotRemoved("angularDamping"))return 0;return this._rigidBody?this._rigidBody.angularDamping():this._rigidBodyDesc.angularDamping}get angularVelocity(){if(!this._requireNotRemoved("angularVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.angvel():this._rigidBodyDesc.angvel}get colliders(){return this._colliders}get dominanceGroup(){if(!this._requireNotRemoved("dominanceGroup"))return 0;return this._rigidBody?this._rigidBody.dominanceGroup():this._rigidBodyDesc.dominanceGroup}get directionFromRotation(){let{x:Z,y:J,z:X,w:$}=this.rotation;return{x:-2*(Z*X+$*J),y:-2*(J*X-$*Z),z:-(1-2*(Z*Z+J*J))}}get effectiveAngularInertia(){if(!this._requireNotRemoved("effectiveAngularInertia"))return;return this._rigidBody?this._rigidBody.effectiveAngularInertia():void 0}get effectiveInverseMass(){if(!this._requireNotRemoved("effectiveInverseMass"))return;return this._rigidBody?this._rigidBody.effectiveInvMass():void 0}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("effectiveWorldInversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.effectiveWorldInvInertiaSqrt():void 0}get enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get inversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("inversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.invPrincipalInertiaSqrt():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(Z){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(Z,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(Z)}setAdditionalMassProperties(Z){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:J,centerOfMass:X,principalAngularInertia:$,principalAngularInertiaLocalFrame:Y}=Z;this._rigidBody?this._rigidBody.setAdditionalMassProperties(J,X,$,Y,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMassProperties(J,X,$,Y)}setAdditionalSolverIterations(Z){if(!this._requireDynamic("setAdditionalSolverIterations"))return;if(!this._requireNotRemoved("setAdditionalSolverIterations"))return;this._rigidBody?this._rigidBody.setAdditionalSolverIterations(Z):this._rigidBodyDesc.setAdditionalSolverIterations(Z)}setAngularDamping(Z){if(!this._requireDynamic("setAngularDamping"))return;if(!this._requireNotRemoved("setAngularDamping"))return;this._rigidBody?this._rigidBody.setAngularDamping(Z):this._rigidBodyDesc.setAngularDamping(Z)}setAngularVelocity(Z){if(!this._requireNotKinematicPositionBased("setAngularVelocity"))return;if(!this._requireNotRemoved("setAngularVelocity"))return;this._rigidBody?this._rigidBody.setAngvel(Z,!this._explicitSleep):this._rigidBodyDesc.setAngvel(Z)}setCcdEnabled(Z){if(!this._requireDynamic("setCcdEnabled"))return;if(!this._requireNotRemoved("setCcdEnabled"))return;this._rigidBody?this._rigidBody.enableCcd(Z):this._rigidBodyDesc.setCcdEnabled(Z)}setDominanceGroup(Z){if(!this._requireDynamic("setDominanceGroup"))return;if(!this._requireNotRemoved("setDominanceGroup"))return;this._rigidBody?this._rigidBody.setDominanceGroup(Z):this._rigidBodyDesc.setDominanceGroup(Z)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._rigidBody?this._rigidBody.setEnabled(Z):this._rigidBodyDesc.setEnabled(Z)}setEnabledPositions(Z){if(!this._requireDynamic("setEnabledPositions"))return;if(!this._requireNotRemoved("setEnabledPositions"))return;this._rigidBody?this._rigidBody.setEnabledTranslations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledTranslations(Z.x,Z.y,Z.z),this._enabledPositions=Z}setEnabledRotations(Z){if(!this._requireDynamic("setEnabledRotations"))return;if(!this._requireNotRemoved("setEnabledRotations"))return;this._rigidBody?this._rigidBody.setEnabledRotations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledRotations(Z.x,Z.y,Z.z),this._enabledRotations=Z}setGravityScale(Z){if(!this._requireDynamic("setGravityScale"))return;if(!this._requireNotRemoved("setGravityScale"))return;this._rigidBody?this._rigidBody.setGravityScale(Z,!this._explicitSleep):this._rigidBodyDesc.setGravityScale(Z)}setLinearDamping(Z){if(!this._requireDynamic("setLinearDamping"))return;if(!this._requireNotRemoved("setLinearDamping"))return;this._rigidBody?this._rigidBody.setLinearDamping(Z):this._rigidBodyDesc.setLinearDamping(Z)}setLinearVelocity(Z){if(!this._requireNotKinematicPositionBased("setLinearVelocity"))return;if(!this._requireNotRemoved("setLinearVelocity"))return;this._rigidBody?this._rigidBody.setLinvel(Z,!this._explicitSleep):this._rigidBodyDesc.setLinvel(Z.x,Z.y,Z.z)}setNextKinematicRotation(Z){if(!this._requireKinematic("setNextKinematicRotation"))return;if(!this._requireNotRemoved("setNextKinematicRotation"))return;this._rigidBody?this._rigidBody.setNextKinematicRotation(Z):this._rigidBodyDesc.setRotation(Z)}setNextKinematicPosition(Z){if(!this._requireKinematic("setNextKinematicPosition"))return;if(!this._requireNotRemoved("setNextKinematicPosition"))return;this._rigidBody?this._rigidBody.setNextKinematicTranslation(Z):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setPosition(Z){if(!this._requireNotRemoved("setPosition"))return;this._rigidBody?this._rigidBody.setTranslation(Z,!this._explicitSleep):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setRotation(Z){if(!this._requireNotRemoved("setRotation"))return;this._rigidBody?this._rigidBody.setRotation(Z,!this._explicitSleep):this._rigidBodyDesc.setRotation(Z)}setSleeping(Z){if(!this._requireDynamic("setSleeping"))return;if(!this._requireNotRemoved("setSleeping"))return;this._rigidBody?Z?this._rigidBody.sleep():this._rigidBody.wakeUp():this._rigidBodyDesc.sleeping=Z,this._explicitSleep=Z}setSoftCcdPrediction(Z){if(!this._requireDynamic("setSoftCcdPrediction"))return;if(!this._requireNotRemoved("setSoftCcdPrediction"))return;this._rigidBody?this._rigidBody.setSoftCcdPrediction(Z):this._rigidBodyDesc.setSoftCcdPrediction(Z)}setCollisionGroupsForSolidColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSolidColliders"))return;this._colliders.forEach((J)=>{if(J.isSensor)return;J.setCollisionGroups(Z)})}setCollisionGroupsForSensorColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSensorColliders"))return;this._colliders.forEach((J)=>{if(!J.isSensor)return;J.setCollisionGroups(Z)})}setType(Z){if(!this._requireNotRemoved("setType"))return;let X={["dynamic"]:Q1.RigidBodyType.Dynamic,["fixed"]:Q1.RigidBodyType.Fixed,["kinematic_position"]:Q1.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:Q1.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 l5({...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 l5(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??Ur;return{["dynamic"]:()=>Q1.RigidBodyDesc.dynamic(),["fixed"]:()=>Q1.RigidBodyDesc.fixed(),["kinematic_position"]:()=>Q1.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>Q1.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)<dD&&Math.abs(Z.y)<dD&&Math.abs(Z.z)<dD}}var aD;((Y)=>{Y[Y.Average=0]="Average";Y[Y.Min=1]="Min";Y[Y.Multiply=2]="Multiply";Y[Y.Max=3]="Max"})(aD||={});var Vz;((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"})(Vz||={});class l5 extends L0{_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 $=U5.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,V=W*J/2,H=(L)=>Math.max(0.01,L),q=()=>({shape:"block",halfExtents:{x:H(Y*J/2),y:H(Q*J/2),z:H(K*J/2)}}),F=()=>({shape:"round-cylinder",radius:H(V),halfHeight:H(Q*J/2),borderRadius:H(V*0.1)}),w=()=>{let L=U5.instance.getTrimesh(Z,J);if(!L)return;return{shape:"trimesh",vertices:L.vertices,indices:L.indices}},U=()=>({shape:"wedge",extents:{x:Y*J,y:Q*J,z:K*J}}),x=()=>({shape:"capsule",radius:H(V),halfHeight:H(Q*J/2-V)});if(X)switch(X){case"block":return q();case"capsule":return x();case"round-cylinder":return F();case"trimesh":{let L=w();if(!L){y.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return L}case"wedge":return U();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?G9.decodeRawCollisionGroups(this._collider.collisionGroups()):G9.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=G9.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|Q1.ActiveEvents.COLLISION_EVENTS:J&~Q1.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|Q1.ActiveEvents.CONTACT_FORCE_EVENTS:J&~Q1.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 Q1.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)y.fatalError("Block collider must have halfExtents!");return Q1.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 Q1.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)y.fatalError("Cone collider must have radius and halfHeight!");return Q1.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)y.fatalError("Cylinder collider must have radius and halfHeight!");return Q1.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 Q1.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 Q1.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)y.fatalError("Voxels collider must have coordinates and size!");return Q1.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=Q1.ColliderDesc.convexHull($);if(!Y)throw y.fatalError("Failed to create convex hull for wedge collider!"),new 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(Q1.ActiveCollisionTypes.DYNAMIC_DYNAMIC|Q1.ActiveCollisionTypes.DYNAMIC_KINEMATIC|Q1.ActiveCollisionTypes.DYNAMIC_FIXED|Q1.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Q1.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 _N1={shape:"voxels"},nD;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(nD||={});class y5 extends L0{_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,..._N1}}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 l5({...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(G9.isDefaultCollisionGroups(J.collisionGroups))J.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return J}serialize(){return P0.serializeBlockType(this)}}var sD;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(sD||={});class qz extends L0{_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 y5{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 P0.serializeBlockTypeRegistry(this)}}var DC={};pQ(DC,{worldSchema:()=>NC,worldPacketDefinition:()=>z80,vectorSchema:()=>v1,vectorBooleanSchema:()=>If1,uiSchema:()=>MC,uiPacketDefinition:()=>W80,uiDatasSchema:()=>RC,uiDatasPacketDefinition:()=>G80,uiDataSendPacketDefinition:()=>d10,uiDataSchema:()=>bz,syncResponseSchema:()=>OC,syncResponsePacketDefinition:()=>K80,syncRequestSchema:()=>oP,syncRequestPacketDefinition:()=>g10,stateRequestSchema:()=>sP,stateRequestPacketDefinition:()=>i10,sceneUIsSchema:()=>cC,sceneUIsPacketDefinition:()=>Q80,sceneUISchema:()=>jC,rgbColorSchema:()=>R6,registeredPackets:()=>$x,quaternionSchema:()=>GC,playersSchema:()=>LC,playersPacketDefinition:()=>Y80,playerSchema:()=>BC,physicsDebugRenderSchema:()=>xC,physicsDebugRenderPacketDefinition:()=>X80,physicsDebugRaycastsSchema:()=>UC,physicsDebugRaycastsPacketDefinition:()=>$80,physicsDebugRaycastSchema:()=>wC,particleEmittersSchema:()=>FC,particleEmittersPacketDefinition:()=>J80,particleEmitterSchema:()=>qC,outboundPackets:()=>Xx,modelNodeOverrideSchema:()=>WC,lightsSchema:()=>VC,lightsPacketDefinition:()=>Z80,lightSchema:()=>HC,isValidPacket:()=>_f1,inputSchema:()=>nP,inputPacketDefinition:()=>p10,inboundPackets:()=>Jx,hexColorSchema:()=>dP,heartbeatSchema:()=>gP,heartbeatPacketDefinition:()=>u10,entitySchema:()=>zC,entitiesSchema:()=>vC,entitiesPacketDefinition:()=>e10,definePacket:()=>k0,debugConfigSchema:()=>aP,debugConfigPacketDefinition:()=>y10,createPacket:()=>Of1,connectionSchema:()=>iP,connectionPacketDefinition:()=>m10,chunksSchema:()=>KC,chunksPacketDefinition:()=>t10,chunkSchema:()=>QC,chatMessagesSchema:()=>YC,chatMessagesPacketDefinition:()=>r10,chatMessageSendPacketDefinition:()=>l10,chatMessageSchema:()=>hz,cameraSchema:()=>$C,cameraPacketDefinition:()=>o10,blocksSchema:()=>ZC,blocksPacketDefinition:()=>n10,blockTypesSchema:()=>XC,blockTypesPacketDefinition:()=>s10,blockTypeSchema:()=>JC,blockSchema:()=>eP,bidirectionalPackets:()=>Zx,audiosSchema:()=>tP,audiosPacketDefinition:()=>a10,audioSchema:()=>rP,PacketId:()=>P1});var Zx={};pQ(Zx,{heartbeatPacketDefinition:()=>u10,connectionPacketDefinition:()=>m10});var yP=t(b10(),1);class pP extends yP.default{static instance=new yP.default}var P1;((P)=>{P[P.SYNC_REQUEST=0]="SYNC_REQUEST";P[P.INPUT=1]="INPUT";P[P.STATE_REQUEST=2]="STATE_REQUEST";P[P.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";P[P.UI_DATA_SEND=4]="UI_DATA_SEND";P[P.SYNC_RESPONSE=32]="SYNC_RESPONSE";P[P.AUDIOS=33]="AUDIOS";P[P.BLOCKS=34]="BLOCKS";P[P.BLOCK_TYPES=35]="BLOCK_TYPES";P[P.CHAT_MESSAGES=36]="CHAT_MESSAGES";P[P.CHUNKS=37]="CHUNKS";P[P.ENTITIES=38]="ENTITIES";P[P.WORLD=39]="WORLD";P[P.CAMERA=40]="CAMERA";P[P.UI=41]="UI";P[P.UI_DATAS=42]="UI_DATAS";P[P.SCENE_UIS=43]="SCENE_UIS";P[P.LIGHTS=44]="LIGHTS";P[P.PLAYERS=45]="PLAYERS";P[P.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";P[P.CONNECTION=116]="CONNECTION";P[P.HEARTBEAT=117]="HEARTBEAT";P[P.DEBUG_CONFIG=128]="DEBUG_CONFIG";P[P.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";P[P.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(P1||={});function Of1(Z,J,X){if(!Z.validate(J))throw new Error(`Invalid payload for packet with id ${Z.id}. Error: ${pP.instance.errorsText(Z.validate.errors)}`);let $=[Z.id,J];if(typeof X==="number")$.push(X);return $}function k0(Z,J){return{id:Z,schema:J,validate:pP.instance.compile(J)}}var Mf1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},A10={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},Rf1={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},Nf1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},Df1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},Pf1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},Cf1={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},Tf1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:Nf1,ic:{type:"array",items:Rf1},d:A10,s:Pf1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},kf1={type:"object",properties:{i:{type:"string"},d:A10},required:["i","d"],additionalProperties:!1},Ef1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:Cf1},required:["l","s"],additionalProperties:!1},iP={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},c:{...kf1,nullable:!0},ca:{...Mf1,nullable:!0},d:{type:"array",items:{...Ef1},nullable:!0},pa:{...Df1,nullable:!0},t:{type:"array",items:{...Tf1},nullable:!0}},additionalProperties:!1};var m10=k0(116,iP);var gP={type:"null",nullable:!0};var u10=k0(117,gP);var Jx={};pQ(Jx,{uiDataSendPacketDefinition:()=>d10,syncRequestPacketDefinition:()=>g10,stateRequestPacketDefinition:()=>i10,inputPacketDefinition:()=>p10,debugConfigPacketDefinition:()=>y10,chatMessageSendPacketDefinition:()=>l10});var dP={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var hz={type:"object",properties:{m:{type:"string"},c:{...dP,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var l10=k0(3,hz);var aP={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var y10=k0(128,aP);var nP={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 p10=k0(1,nP);var sP={type:"object",properties:{},additionalProperties:!1};var i10=k0(2,sP);var oP={type:"null",nullable:!0};var g10=k0(0,oP);var bz={type:"object",properties:{},additionalProperties:!0};var d10=k0(4,bz);var Xx={};pQ(Xx,{worldPacketDefinition:()=>z80,uiPacketDefinition:()=>W80,uiDatasPacketDefinition:()=>G80,syncResponsePacketDefinition:()=>K80,sceneUIsPacketDefinition:()=>Q80,playersPacketDefinition:()=>Y80,physicsDebugRenderPacketDefinition:()=>X80,physicsDebugRaycastsPacketDefinition:()=>$80,particleEmittersPacketDefinition:()=>J80,lightsPacketDefinition:()=>Z80,entitiesPacketDefinition:()=>e10,chunksPacketDefinition:()=>t10,chatMessagesPacketDefinition:()=>r10,cameraPacketDefinition:()=>o10,blocksPacketDefinition:()=>n10,blockTypesPacketDefinition:()=>s10,audiosPacketDefinition:()=>a10});var v1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var rP={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:{...v1,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 tP={type:"array",items:{...rP}};var a10=k0(33,tP);var eP={type:"object",properties:{i:{type:"number"},c:v1},required:["i","c"],additionalProperties:!1};var ZC={type:"array",items:{...eP}};var n10=k0(34,ZC);var JC={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 XC={type:"array",items:{...JC}};var s10=k0(35,XC);var $C={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:{...v1,nullable:!0},p:{...v1,nullable:!0},pt:{...v1,nullable:!0},pl:{...v1,nullable:!0},s:{type:"array",items:{type:"string"},nullable:!0},sa:{type:"number",nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var YC={type:"array",items:{...hz}};var QC={type:"object",properties:{c:v1,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 KC={type:"array",items:{...QC}};var R6={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 WC={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:{...R6,nullable:!0}},required:["n"],additionalProperties:!1};var GC={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var zC={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:{...v1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...WC},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...v1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...GC,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...R6,nullable:!0}},required:["i"],additionalProperties:!1};var vC={type:"array",items:{...zC}};var HC={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...R6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...v1,nullable:!0},p:{...v1,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:{...v1,nullable:!0}},required:["i"],additionalProperties:!1};var VC={type:"array",items:{...HC}};var qC={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},b:{type:"number",nullable:!0},ce:{...R6,nullable:!0},cev:{...R6,nullable:!0},cs:{...R6,nullable:!0},csv:{...R6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...v1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...v1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...v1,nullable:!0},pa:{type:"boolean",nullable:!0},pv:{...v1,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:{...v1,nullable:!0},vv:{...v1,nullable:!0}},required:["i"],additionalProperties:!1};var FC={type:"array",items:{...qC}};var wC={type:"object",properties:{o:{...v1},d:{...v1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var UC={type:"array",items:{...wC}};var xC={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var BC={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 LC={type:"array",items:{...BC}};var jC={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...v1,nullable:!0},p:{...v1,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 cC={type:"array",items:{...jC}};var OC={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var MC={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var RC={type:"array",items:{...bz}};var If1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var NC={type:"object",properties:{i:{type:"number"},ac:{...R6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...R6,nullable:!0},di:{type:"number",nullable:!0},dp:{...v1,nullable:!0},fc:{...R6,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 o10=k0(40,$C);var r10=k0(36,YC);var t10=k0(37,KC);var e10=k0(38,vC);var Z80=k0(44,VC);var J80=k0(46,FC);var X80=k0(192,xC);var $80=k0(193,UC);var Y80=k0(45,LC);var Q80=k0(43,cC);var K80=k0(32,OC);var W80=k0(41,MC);var G80=k0(42,RC);var z80=k0(39,NC);var $x=new Map,ff1={...Zx,...Jx,...Xx};for(let Z of Object.values(ff1))if("id"in Z&&"schema"in Z){let J=Z;if($x.has(J.id))throw new Error(`Packet with id ${J.id} is already registered.`);$x.set(J.id,J)}function _f1(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=$x.get(Z[0]);return!!J&&J.validate(Z[1])}var $0=DC;var _80=t(I80(),1);import XY from"fs";import f80 from"path";var mz="./dev/persistence";class x7{static instance=new x7;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;constructor(){try{this._creativeGateway=new _80.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,V,J,H),V===W)return!0}return!1}let F;if(typeof z==="string")F=v===z,this.debug("string match",z,v,F);else F=z.test(v),this.debug("pattern match",z,v,F);if(!F)return!1}if(Q===W&&K===G)return!0;else if(Q===W)return X;else if(K===G)return Q===W-1&&Z[Q]==="";else throw new Error("wtf?")}braceExpand(){return mg(this.pattern,this.options)}parse(Z){xG(Z);let J=this.options;if(Z==="**")return Y6;if(Z==="")return"";let X,$=null;if(X=Z.match(Hx1))$=J.dot?qx1:Vx1;else if(X=Z.match(Jx1))$=(J.nocase?J.dot?Qx1:Yx1:J.dot?$x1:Xx1)(X[1]);else if(X=Z.match(Fx1))$=(J.nocase?J.dot?Ux1:wx1:J.dot?xx1:Bx1)(X);else if(X=Z.match(Kx1))$=J.dot?Gx1:Wx1;else if(X=Z.match(zx1))$=vx1;let Y=$6.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?cx1:J.dot?Ox1:Mx1,$=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"?Cx1(z):z===Y6?Y6:z._src});return G.forEach((z,v)=>{let V=G[v+1],H=G[v-1];if(z!==Y6||H===Y6)return;if(H===void 0)if(V!==void 0&&V!==Y6)G[v+1]="(?:\\/|"+X+"\\/)?"+V;else G[v]=X;else if(V===void 0)G[v-1]=H+"(?:\\/|"+X+")?";else if(V!==Y6)G[v-1]=H+"(?:\\/|\\/"+X+"\\/)"+V,G[v+1]=Y6}),G.filter((z)=>z!==Y6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if(Y="^"+Q+Y+K+"$",this.negate)Y="^(?!"+Y+").+$";try{this.regexp=new RegExp(Y,[...$].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit(Z){if(this.preserveMultipleSlashes)return Z.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Z))return["",...Z.split(/\/+/)];else return Z.split(/\/+/)}match(Z,J=this.partial){if(this.debug("match",Z,this.pattern),this.comment)return!1;if(this.empty)return Z==="";if(Z==="/"&&J)return!0;let X=this.options;if(this.isWindows)Z=Z.split("\\").join("/");let $=this.slashSplit(Z);this.debug(this.pattern,"split",$);let Y=this.set;this.debug(this.pattern,"set",Y);let Q=$[$.length-1];if(!Q)for(let K=$.length-2;!Q&&K>=0;K--)Q=$[K];for(let K=0;K<Y.length;K++){let W=Y[K],G=$;if(X.matchBase&&W.length===1)G=[Q];if(this.matchOne(G,W,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return b6.defaults(Z).Minimatch}}b6.AST=$6;b6.Minimatch=q4;b6.escape=zK;b6.unescape=V9;import{fileURLToPath as K21}from"node:url";var vK=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,lg=new Set,FR=typeof process==="object"&&!!process?process:{},yg=(Z,J,X,$)=>{typeof FR.emitWarning==="function"?FR.emitWarning(Z,J,X,$):console.error(`[${X}] ${J}: ${Z}`)},uF=globalThis.AbortController,ug=globalThis.AbortSignal;if(typeof uF==="undefined"){ug=class X{onabort;_onabort=[];reason;aborted=!1;addEventListener($,Y){this._onabort.push(Y)}},uF=class X{constructor(){J()}signal=new ug;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=FR.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,yg("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 Tx1=(Z)=>!lg.has(Z),CN6=Symbol("type"),OJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),pg=(Z)=>!OJ(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?LG:null;class LG extends Array{constructor(Z){super(Z);this.fill(0)}}class HK{heap;length;static#Z=!1;static create(Z){let J=pg(Z);if(!J)return[];HK.#Z=!0;let X=new HK(Z,J);return HK.#Z=!1,X}constructor(Z,J){if(!HK.#Z)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new J(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}}class jG{#Z;#J;#$;#X;#Y;#v;#V;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#z;#H;#Q;#F;#U;#w;#B;#P;#L;#C;#O;#c;#j;#N;#x;#k;static unsafeExposeInternals(Z){return{starts:Z.#O,ttls:Z.#c,sizes:Z.#C,keyMap:Z.#z,keyList:Z.#H,valList:Z.#Q,next:Z.#F,prev:Z.#U,get head(){return Z.#w},get tail(){return Z.#B},free:Z.#P,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,$,Y)=>Z.#S(J,X,$,Y),moveToTail:(J)=>Z.#A(J),indexes:(J)=>Z.#D(J),rindexes:(J)=>Z.#T(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.#V}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:V,noUpdateTTL:H,maxSize:q=0,maxEntrySize:F=0,sizeCalculation:w,fetchMethod:U,memoMethod:x,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:j,allowStaleOnFetchRejection:c,allowStaleOnFetchAbort:R,ignoreFetchAbort:M}=Z;if(J!==0&&!OJ(J))throw new TypeError("max option must be a nonnegative integer");let N=J?pg(J):Array;if(!N)throw new Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=F||this.#J,this.sizeCalculation=w,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw new TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!=="function")throw new TypeError("memoMethod must be a function if defined");if(this.#V=x,U!==void 0&&typeof U!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#v=U,this.#N=!!U,this.#z=new Map,this.#H=new Array(J).fill(void 0),this.#Q=new Array(J).fill(void 0),this.#F=new N(J),this.#U=new N(J),this.#w=0,this.#B=0,this.#P=HK.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.#L=[];else this.#Y=void 0,this.#L=void 0;if(this.#j=!!this.#$,this.#k=!!this.#X,this.#x=!!this.#Y,this.noDisposeOnSet=!!V,this.noUpdateTTL=!!H,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!c,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!OJ(this.#J))throw new TypeError("maxSize must be a positive integer if specified")}if(!OJ(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#u()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!j,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=OJ($)||$===0?$:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!OJ(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(Tx1("LRU_CACHE_UNBOUNDED"))lg.add("LRU_CACHE_UNBOUNDED"),yg("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",jG)}}getRemainingTTL(Z){return this.#z.has(Z)?1/0:0}#K(){let Z=new LG(this.#Z),J=new LG(this.#Z);this.#c=Z,this.#O=J,this.#E=(Y,Q,K=vK.now())=>{if(J[Y]=Q!==0?K:0,Z[Y]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#R(Y))this.#I(this.#H[Y],"expire")},Q+1);if(W.unref)W.unref()}},this.#f=(Y)=>{J[Y]=Z[Y]!==0?vK.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=vK.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}}#f=()=>{};#M=()=>{};#E=()=>{};#R=()=>!1;#u(){let Z=new LG(this.#Z);this.#G=0,this.#C=Z,this.#_=(J)=>{this.#G-=Z[J],Z[J]=0},this.#l=(J,X,$,Y)=>{if(this.#q(X))return 0;if(!OJ($))if(Y){if(typeof Y!=="function")throw new TypeError("sizeCalculation must be a function");if($=Y(X,J),!OJ($))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return $},this.#h=(J,X,$)=>{if(Z[J]=X,this.#J){let Y=this.#J-Z[J];while(this.#G>Y)this.#b(!0)}if(this.#G+=Z[J],$)$.entrySize=X,$.totalCalculatedSize=this.#G}}#_=(Z)=>{};#h=(Z,J,X)=>{};#l=(Z,J,X,$)=>{if(X||$)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#D({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#B;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#w)break;else J=this.#U[J]}}*#T({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#w;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#B)break;else J=this.#F[J]}}#y(Z){return Z!==void 0&&this.#z.get(this.#H[Z])===Z}*entries(){for(let Z of this.#D())if(this.#Q[Z]!==void 0&&this.#H[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#H[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&this.#H[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#H[Z],this.#Q[Z]]}*keys(){for(let Z of this.#D()){let J=this.#H[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#T()){let J=this.#H[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#D())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#T())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.#D()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;if(Z(Y,this.#H[X],this))return this.get(this.#H[X],J)}}forEach(Z,J=this){for(let X of this.#D()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#H[X],this)}}rforEach(Z,J=this){for(let X of this.#T()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#H[X],this)}}purgeStale(){let Z=!1;for(let J of this.#T({allowStale:!0}))if(this.#R(J))this.#I(this.#H[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.#c&&this.#O){let Q=this.#c[J],K=this.#O[J];if(Q&&K){let W=Q-(vK.now()-K);Y.ttl=W,Y.start=Date.now()}}if(this.#C)Y.size=this.#C[J];return Y}dump(){let Z=[];for(let J of this.#D({allowStale:!0})){let X=this.#H[J],$=this.#Q[J],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0||X===void 0)continue;let Q={value:Y};if(this.#c&&this.#O){Q.ttl=this.#c[J];let K=vK.now()-this.#O[J];Q.start=Math.floor(Date.now()-K)}if(this.#C)Q.size=this.#C[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=vK.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.#I(Z,"set"),this}let v=this.#W===0?void 0:this.#z.get(Z);if(v===void 0){if(v=this.#W===0?this.#B:this.#P.length!==0?this.#P.pop():this.#W===this.#Z?this.#b(!1):this.#W,this.#H[v]=Z,this.#Q[v]=J,this.#z.set(Z,v),this.#F[this.#B]=v,this.#U[v]=this.#B,this.#B=v,this.#W++,this.#h(v,z,W),W)W.set="add";if(G=!1,this.#k)this.#X?.(J,Z,"add")}else{this.#A(v);let V=this.#Q[v];if(J!==V){if(this.#N&&this.#q(V)){V.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:H}=V;if(H!==void 0&&!Q){if(this.#j)this.#$?.(H,Z,"set");if(this.#x)this.#L?.push([H,Z,"set"])}}else if(!Q){if(this.#j)this.#$?.(V,Z,"set");if(this.#x)this.#L?.push([V,Z,"set"])}if(this.#_(v),this.#h(v,z,W),this.#Q[v]=J,W){W.set="replace";let H=V&&this.#q(V)?V.__staleWhileFetching:V;if(H!==void 0)W.oldValue=H}}else if(W)W.set="update";if(this.#k)this.onInsert?.(J,Z,J===V?"update":"replace")}if($!==0&&!this.#c)this.#K();if(this.#c){if(!G)this.#E(v,$,Y);if(W)this.#M(W,v)}if(!Q&&this.#x&&this.#L){let V=this.#L,H;while(H=V?.shift())this.#Y?.(...H)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#w];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.#L){let Z=this.#L,J;while(J=Z?.shift())this.#Y?.(...J)}}}#b(Z){let J=this.#w,X=this.#H[J],$=this.#Q[J];if(this.#N&&this.#q($))$.__abortController.abort(new Error("evicted"));else if(this.#j||this.#x){if(this.#j)this.#$?.($,X,"evict");if(this.#x)this.#L?.push([$,X,"evict"])}if(this.#_(J),Z)this.#H[J]=void 0,this.#Q[J]=void 0,this.#P.push(J);if(this.#W===1)this.#w=this.#B=0,this.#P.length=0;else this.#w=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.#f(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}#S(Z,J,X,$){let Y=J===void 0?void 0:this.#Q[J];if(this.#q(Y))return Y;let Q=new uF,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:$},G=(F,w=!1)=>{let{aborted:U}=Q.signal,x=X.ignoreFetchAbort&&F!==void 0;if(X.status)if(U&&!w){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,x)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(U&&!x&&!w)return v(Q.signal.reason);let L=H;if(this.#Q[J]===H)if(F===void 0)if(L.__staleWhileFetching)this.#Q[J]=L.__staleWhileFetching;else this.#I(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:w}=Q.signal,U=w&&X.allowStaleOnFetchAbort,x=U||X.allowStaleOnFetchRejection,L=x||X.noDeleteOnFetchRejection,j=H;if(this.#Q[J]===H){if(!L||j.__staleWhileFetching===void 0)this.#I(Z,"fetch");else if(!U)this.#Q[J]=j.__staleWhileFetching}if(x){if(X.status&&j.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return j.__staleWhileFetching}else if(j.__returned===j)throw F},V=(F,w)=>{let U=this.#v?.(Z,Y,W);if(U&&U instanceof Promise)U.then((x)=>F(x===void 0?void 0:x),w);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 H=new Promise(V).then(G,z),q=Object.assign(H,{__abortController:Q,__staleWhileFetching:Y,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#z.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#N)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof uF}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:V=this.allowStaleOnFetchRejection,ignoreFetchAbort:H=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:F,forceRefresh:w=!1,status:U,signal:x}=J;if(!this.#N){if(U)U.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,status:U})}let L={allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:z,noDeleteOnFetchRejection:v,allowStaleOnFetchRejection:V,allowStaleOnFetchAbort:q,ignoreFetchAbort:H,status:U,signal:x},j=this.#z.get(Z);if(j===void 0){if(U)U.fetch="miss";let c=this.#S(Z,j,L,F);return c.__returned=c}else{let c=this.#Q[j];if(this.#q(c)){let P=X&&c.__staleWhileFetching!==void 0;if(U){if(U.fetch="inflight",P)U.returnedStale=!0}return P?c.__staleWhileFetching:c.__returned=c}let R=this.#R(j);if(!w&&!R){if(U)U.fetch="hit";if(this.#A(j),$)this.#f(j);if(U)this.#M(U,j);return c}let M=this.#S(Z,j,L,F),D=M.__staleWhileFetching!==void 0&&X;if(U){if(U.fetch=R?"stale":"refresh",D&&R)U.returnedStale=!0}return D?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw new Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#V;if(!X)throw new Error("no memoMethod provided to constructor");let{context:$,forceRefresh:Y,...Q}=J,K=this.get(Z,Q);if(!Y&&K!==void 0)return K;let W=X(Z,K,{options:Q,context:$});return this.set(Z,W,Q),W}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,status:Q}=J,K=this.#z.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#M(Q,K);if(this.#R(K)){if(Q)Q.get="stale";if(!G){if(!Y)this.#I(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.#f(K);return W}}else if(Q)Q.get="miss"}#p(Z,J){this.#U[J]=Z,this.#F[Z]=J}#A(Z){if(Z!==this.#B){if(Z===this.#w)this.#w=this.#F[Z];else this.#p(this.#U[Z],this.#F[Z]);this.#p(this.#B,Z),this.#B=Z}}delete(Z){return this.#I(Z,"delete")}#I(Z,J){let X=!1;if(this.#W!==0){let $=this.#z.get(Z);if($!==void 0)if(X=!0,this.#W===1)this.#m(J);else{this.#_($);let Y=this.#Q[$];if(this.#q(Y))Y.__abortController.abort(new Error("deleted"));else if(this.#j||this.#x){if(this.#j)this.#$?.(Y,Z,J);if(this.#x)this.#L?.push([Y,Z,J])}if(this.#z.delete(Z),this.#H[$]=void 0,this.#Q[$]=void 0,$===this.#B)this.#B=this.#U[$];else if($===this.#w)this.#w=this.#F[$];else{let Q=this.#U[$];this.#F[Q]=this.#F[$];let K=this.#F[$];this.#U[K]=this.#U[$]}this.#W--,this.#P.push($)}}if(this.#x&&this.#L?.length){let $=this.#L,Y;while(Y=$?.shift())this.#Y?.(...Y)}return X}clear(){return this.#m("delete")}#m(Z){for(let J of this.#T({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(new Error("deleted"));else{let $=this.#H[J];if(this.#j)this.#$?.(X,$,Z);if(this.#x)this.#L?.push([X,$,Z])}}if(this.#z.clear(),this.#Q.fill(void 0),this.#H.fill(void 0),this.#c&&this.#O)this.#c.fill(0),this.#O.fill(0);if(this.#C)this.#C.fill(0);if(this.#w=0,this.#B=0,this.#P.length=0,this.#G=0,this.#W=0,this.#x&&this.#L){let J=this.#L,X;while(X=J?.shift())this.#Y?.(...X)}}}import{posix as ux1,win32 as RR}from"node:path";import{fileURLToPath as lx1}from"node:url";import{lstatSync as yx1,readdir as px1,readdirSync as ix1,readlinkSync as gx1,realpathSync as dx1}from"fs";import*as ax1 from"node:fs";import{lstat as sx1,readdir as ox1,readlink as rx1,realpath as tx1}from"node:fs/promises";import{EventEmitter as jR}from"node:events";import ng from"node:stream";import{StringDecoder as kx1}from"node:string_decoder";var ig=typeof process==="object"&&process?process:{stdout:null,stderr:null},Ex1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof O$||Z instanceof ng||Ix1(Z)||fx1(Z)),Ix1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof jR&&typeof Z.pipe==="function"&&Z.pipe!==ng.Writable.prototype.pipe,fx1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof jR&&typeof Z.write==="function"&&typeof Z.end==="function",KZ=Symbol("EOF"),WZ=Symbol("maybeEmitEnd"),MJ=Symbol("emittedEnd"),lF=Symbol("emittingEnd"),cG=Symbol("emittedError"),yF=Symbol("closed"),gg=Symbol("read"),pF=Symbol("flush"),dg=Symbol("flushChunk"),q9=Symbol("encoding"),VK=Symbol("decoder"),i8=Symbol("flowing"),OG=Symbol("paused"),qK=Symbol("resume"),g8=Symbol("buffer"),A6=Symbol("pipes"),d8=Symbol("bufferLength"),wR=Symbol("bufferPush"),iF=Symbol("bufferShift"),x6=Symbol("objectMode"),x8=Symbol("destroyed"),UR=Symbol("error"),xR=Symbol("emitData"),ag=Symbol("emitEnd"),BR=Symbol("emitEnd2"),X7=Symbol("async"),LR=Symbol("abort"),gF=Symbol("aborted"),MG=Symbol("signal"),c$=Symbol("dataListeners"),_5=Symbol("discarded"),RG=(Z)=>Promise.resolve().then(Z),_x1=(Z)=>Z(),Sx1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",hx1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,bx1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class cR{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[qK](),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 sg extends cR{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 Ax1=(Z)=>!!Z.objectMode,mx1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class O$ extends jR{[i8]=!1;[OG]=!1;[A6]=[];[g8]=[];[x6];[q9];[X7];[VK];[KZ]=!1;[MJ]=!1;[lF]=!1;[yF]=!1;[cG]=null;[d8]=0;[x8]=!1;[MG];[gF]=!1;[c$]=0;[_5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(Ax1(J))this[x6]=!0,this[q9]=null;else if(mx1(J))this[q9]=J.encoding,this[x6]=!1;else this[x6]=!1,this[q9]=null;if(this[X7]=!!J.async,this[VK]=this[q9]?new kx1(this[q9]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[g8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[A6]});let{signal:X}=J;if(X)if(this[MG]=X,X.aborted)this[LR]();else X.addEventListener("abort",()=>this[LR]())}get bufferLength(){return this[d8]}get encoding(){return this[q9]}set encoding(Z){throw new Error("Encoding must be set at instantiation time")}setEncoding(Z){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[x6]}set objectMode(Z){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[X7]}set["async"](Z){this[X7]=this[X7]||!!Z}[LR](){this[gF]=!0,this.emit("abort",this[MG]?.reason),this.destroy(this[MG]?.reason)}get aborted(){return this[gF]}set aborted(Z){}write(Z,J,X){if(this[gF])return!1;if(this[KZ])throw new Error("write after end");if(this[x8])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof J==="function")X=J,J="utf8";if(!J)J="utf8";let $=this[X7]?RG:_x1;if(!this[x6]&&!Buffer.isBuffer(Z)){if(bx1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(hx1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[x6]){if(this[i8]&&this[d8]!==0)this[pF](!0);if(this[i8])this.emit("data",Z);else this[wR](Z);if(this[d8]!==0)this.emit("readable");if(X)$(X);return this[i8]}if(!Z.length){if(this[d8]!==0)this.emit("readable");if(X)$(X);return this[i8]}if(typeof Z==="string"&&!(J===this[q9]&&!this[VK]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[q9])Z=this[VK].write(Z);if(this[i8]&&this[d8]!==0)this[pF](!0);if(this[i8])this.emit("data",Z);else this[wR](Z);if(this[d8]!==0)this.emit("readable");if(X)$(X);return this[i8]}read(Z){if(this[x8])return null;if(this[_5]=!1,this[d8]===0||Z===0||Z&&Z>this[d8])return this[WZ](),null;if(this[x6])Z=null;if(this[g8].length>1&&!this[x6])this[g8]=[this[q9]?this[g8].join(""):Buffer.concat(this[g8],this[d8])];let J=this[gg](Z||null,this[g8][0]);return this[WZ](),J}[gg](Z,J){if(this[x6])this[iF]();else{let X=J;if(Z===X.length||Z===null)this[iF]();else if(typeof X==="string")this[g8][0]=X.slice(Z),J=X.slice(0,Z),this[d8]-=Z;else this[g8][0]=X.subarray(Z),J=X.subarray(0,Z),this[d8]-=Z}if(this.emit("data",J),!this[g8].length&&!this[KZ])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[KZ]=!0,this.writable=!1,this[i8]||!this[OG])this[WZ]();return this}[qK](){if(this[x8])return;if(!this[c$]&&!this[A6].length)this[_5]=!0;if(this[OG]=!1,this[i8]=!0,this.emit("resume"),this[g8].length)this[pF]();else if(this[KZ])this[WZ]();else this.emit("drain")}resume(){return this[qK]()}pause(){this[i8]=!1,this[OG]=!0,this[_5]=!1}get destroyed(){return this[x8]}get flowing(){return this[i8]}get paused(){return this[OG]}[wR](Z){if(this[x6])this[d8]+=1;else this[d8]+=Z.length;this[g8].push(Z)}[iF](){if(this[x6])this[d8]-=1;else this[d8]-=this[g8][0].length;return this[g8].shift()}[pF](Z=!1){do;while(this[dg](this[iF]())&&this[g8].length);if(!Z&&!this[g8].length&&!this[KZ])this.emit("drain")}[dg](Z){return this.emit("data",Z),this[i8]}pipe(Z,J){if(this[x8])return Z;this[_5]=!1;let X=this[MJ];if(J=J||{},Z===ig.stdout||Z===ig.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[A6].push(!J.proxyErrors?new cR(this,Z,J):new sg(this,Z,J)),this[X7])RG(()=>this[qK]());else this[qK]();return Z}unpipe(Z){let J=this[A6].find((X)=>X.dest===Z);if(J){if(this[A6].length===1){if(this[i8]&&this[c$]===0)this[i8]=!1;this[A6]=[]}else this[A6].splice(this[A6].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[_5]=!1,this[c$]++,!this[A6].length&&!this[i8])this[qK]()}else if(Z==="readable"&&this[d8]!==0)super.emit("readable");else if(Sx1(Z)&&this[MJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[cG]){let $=J;if(this[X7])RG(()=>$.call(this,this[cG]));else $.call(this,this[cG])}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[_5]&&!this[A6].length)this[i8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[c$]=0,!this[_5]&&!this[A6].length)this[i8]=!1}return J}get emittedEnd(){return this[MJ]}[WZ](){if(!this[lF]&&!this[MJ]&&!this[x8]&&this[g8].length===0&&this[KZ]){if(this[lF]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[yF])this.emit("close");this[lF]=!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[x6]&&!X?!1:this[X7]?(RG(()=>this[xR](X)),!0):this[xR](X);else if(Z==="end")return this[ag]();else if(Z==="close"){if(this[yF]=!0,!this[MJ]&&!this[x8])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Z==="error"){this[cG]=X,super.emit(UR,X);let Y=!this[MG]||this.listeners("error").length?super.emit("error",X):!1;return this[WZ](),Y}else if(Z==="resume"){let Y=super.emit("resume");return this[WZ](),Y}else if(Z==="finish"||Z==="prefinish"){let Y=super.emit(Z);return this.removeAllListeners(Z),Y}let $=super.emit(Z,...J);return this[WZ](),$}[xR](Z){for(let X of this[A6])if(X.dest.write(Z)===!1)this.pause();let J=this[_5]?!1:super.emit("data",Z);return this[WZ](),J}[ag](){if(this[MJ])return!1;return this[MJ]=!0,this.readable=!1,this[X7]?(RG(()=>this[BR]()),!0):this[BR]()}[BR](){if(this[VK]){let J=this[VK].end();if(J){for(let X of this[A6])X.dest.write(J);if(!this[_5])super.emit("data",J)}}for(let J of this[A6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[x6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[x6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[x6])throw new Error("cannot concat in objectMode");let Z=await this.collect();return this[q9]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(x8,()=>J(new Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[_5]=!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[KZ])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[KZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(x8,z),J(),Y({done:!0,value:void 0})},z=()=>K(new Error("stream destroyed"));return new Promise((v,V)=>{Q=V,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[_5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(UR,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(UR,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[_5]=!0,this[g8].length=0,this[d8]=0;let J=this;if(typeof J.close==="function"&&!this[yF])J.close();if(Z)this.emit("error",Z);else this.emit(x8);return this}static get isStream(){return Ex1}}var nx1=dx1.native,DG={lstatSync:yx1,readdir:px1,readdirSync:ix1,readlinkSync:gx1,realpathSync:nx1,promises:{lstat:sx1,readdir:ox1,readlink:rx1,realpath:tx1}},Zd=(Z)=>!Z||Z===DG||Z===ax1?DG:{...DG,...Z,promises:{...DG.promises,...Z.promises||{}}},Jd=/^\\\\\?\\([a-z]:)\\?$/i,ex1=(Z)=>Z.replace(/\//g,"\\").replace(Jd,"$1\\"),Z21=/[\\\/]/,w4=0,Xd=1,$d=2,$7=4,Yd=6,Qd=8,M$=10,Kd=12,F4=15,NG=~F4,OR=16,og=32,PG=64,F9=128,dF=256,nF=512,rg=PG|F9|nF,J21=1023,MR=(Z)=>Z.isFile()?Qd:Z.isDirectory()?$7:Z.isSymbolicLink()?M$:Z.isCharacterDevice()?$d:Z.isBlockDevice()?Yd:Z.isSocket()?Kd:Z.isFIFO()?Xd:w4,tg=new Map,CG=(Z)=>{let J=tg.get(Z);if(J)return J;let X=Z.normalize("NFKD");return tg.set(Z,X),X},eg=new Map,aF=(Z)=>{let J=eg.get(Z);if(J)return J;let X=CG(Z.toLowerCase());return eg.set(Z,X),X};class NR extends jG{constructor(){super({max:256})}}class Wd extends jG{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var Gd=Symbol("PathScurry setAsCwd");class m6{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}#V;get rdev(){return this.#V}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#z;get size(){return this.#z}#H;get blocks(){return this.#H}#Q;get atimeMs(){return this.#Q}#F;get mtimeMs(){return this.#F}#U;get ctimeMs(){return this.#U}#w;get birthtimeMs(){return this.#w}#B;get atime(){return this.#B}#P;get mtime(){return this.#P}#L;get ctime(){return this.#L}#C;get birthtime(){return this.#C}#O;#c;#j;#N;#x;#k;#K;#f;#M;#E;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=w4,X,$,Y,Q,K){if(this.name=Z,this.#O=Y?aF(Z):CG(Z),this.#K=J&J21,this.nocase=Y,this.roots=$,this.root=X||this,this.#f=Q,this.#j=K.fullpath,this.#x=K.relative,this.#k=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=Zd(K.fs)}depth(){if(this.#c!==void 0)return this.#c;if(!this.parent)return this.#c=0;return this.#c=this.parent.depth()+1}childrenCache(){return this.#f}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.#f.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#f.set(this,J),this.#K&=~OR,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),$=this.nocase?aF(Z):CG(Z);for(let W of X)if(W.#O===$)return W;let Y=this.parent?this.sep:"",Q=this.#j?this.#j+Y+Z:void 0,K=this.newChild(Z,w4,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=F9;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.#k!==void 0)return this.#k;let Z=this.name,J=this.parent;if(!J)return this.#k=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#j!==void 0)return this.#j;let Z=this.name,J=this.parent;if(!J)return this.#j=this.name;let $=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#j=$}fullpathPosix(){if(this.#N!==void 0)return this.#N;if(this.sep==="/")return this.#N=this.fullpath();if(!this.parent){let $=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test($))return this.#N=`//?/${$}`;else return this.#N=$}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#N=X}isUnknown(){return(this.#K&F4)===w4}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&F4)===Qd}isDirectory(){return(this.#K&F4)===$7}isCharacterDevice(){return(this.#K&F4)===$d}isBlockDevice(){return(this.#K&F4)===Yd}isFIFO(){return(this.#K&F4)===Xd}isSocket(){return(this.#K&F4)===Kd}isSymbolicLink(){return(this.#K&M$)===M$}lstatCached(){return this.#K&og?this:void 0}readlinkCached(){return this.#M}realpathCached(){return this.#E}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&F4;return!(Z!==w4&&Z!==M$||this.#K&dF||this.#K&F9)}calledReaddir(){return!!(this.#K&OR)}isENOENT(){return!!(this.#K&F9)}isNamed(Z){return!this.nocase?this.#O===CG(Z):this.#O===aF(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|=OR;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#_()}}#_(){if(this.#K&F9)return;this.#K=(this.#K|F9)&NG,this.#h()}#h(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#_()}#l(){this.#K|=nF,this.#D()}#D(){if(this.#K&PG)return;let Z=this.#K;if((Z&F4)===$7)Z&=NG;this.#K=Z|PG,this.#h()}#T(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#D();else if(Z==="ENOENT")this.#_();else this.children().provisional=0}#y(Z=""){if(Z==="ENOTDIR")this.parent.#D();else if(Z==="ENOENT")this.#_()}#b(Z=""){let J=this.#K;if(J|=dF,Z==="ENOENT")J|=F9;if(Z==="EINVAL"||Z==="UNKNOWN")J&=NG;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#D()}#S(Z,J){return this.#p(Z,J)||this.#q(Z,J)}#q(Z,J){let X=MR(Z),$=this.newChild(Z.name,X,{parent:this}),Y=$.#K&F4;if(Y!==$7&&Y!==M$&&Y!==w4)$.#K|=PG;return J.unshift($),J.provisional++,$}#p(Z,J){for(let X=J.provisional;X<J.length;X++){let $=J[X];if((this.nocase?aF(Z.name):CG(Z.name))!==$.#O)continue;return this.#A(Z,$,X,J)}}#A(Z,J,X,$){let Y=J.name;if(J.#K=J.#K&NG|MR(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&F9)===0)try{return this.#I(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#y(Z.code)}}lstatSync(){if((this.#K&F9)===0)try{return this.#I(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#y(Z.code)}}#I(Z){let{atime:J,atimeMs:X,birthtime:$,birthtimeMs:Y,blksize:Q,blocks:K,ctime:W,ctimeMs:G,dev:z,gid:v,ino:V,mode:H,mtime:q,mtimeMs:F,nlink:w,rdev:U,size:x,uid:L}=Z;this.#B=J,this.#Q=X,this.#C=$,this.#w=Y,this.#W=Q,this.#H=K,this.#L=W,this.#U=G,this.#J=z,this.#v=v,this.#G=V,this.#$=H,this.#P=q,this.#F=F,this.#X=w,this.#V=U,this.#z=x,this.#Y=L;let j=MR(Z);if(this.#K=this.#K&NG|j|og,j!==w4&&j!==$7&&j!==M$)this.#K|=PG}#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.#T(Y.code),X.provisional=0;else{for(let K of Q)this.#S(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.#S($,Z);this.#u(Z)}catch($){this.#T($.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.#S(X,Z);this.#u(Z)}catch(X){this.#T(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&rg)return!1;let Z=F4&this.#K;if(!(Z===w4||Z===$7||Z===M$))return!1;return!0}shouldWalk(Z,J){return(this.#K&$7)===$7&&!(this.#K&rg)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#E)return this.#E;if((nF|dF|F9)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#E=this.resolve(Z)}catch(Z){this.#l()}}realpathSync(){if(this.#E)return this.#E;if((nF|dF|F9)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#E=this.resolve(Z)}catch(Z){this.#l()}}[Gd](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),$.#k=X.join("/"),$=$.parent,X.push("..");$=Z;while($&&$.parent&&!J.has($))$.#x=void 0,$.#k=void 0,$=$.parent}}class sF extends m6{sep="\\";splitSep=Z21;constructor(Z,J=w4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}newChild(Z,J=w4,X={}){return new sF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return RR.parse(Z).root}getRoot(Z){if(Z=ex1(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 TG(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(Jd,"$1\\"),Z===J}}class oF extends m6{splitSep="/";sep="/";constructor(Z,J=w4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=w4,X={}){return new oF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class DR{root;rootPath;roots;cwd;#Z;#J;#$;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:$,childrenCacheSize:Y=16384,fs:Q=DG}={}){if(this.#X=Zd(Q),Z instanceof URL||Z.startsWith("file://"))Z=lx1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new NR,this.#J=new NR,this.#$=new Wd(Y);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if($===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=$,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let G=this.root,z=W.length-1,v=J.sep,V=this.rootPath,H=!1;for(let q of W){let F=z--;G=G.child(q,{relative:new Array(F).fill("..").join(v),relativePosix:new Array(F).fill("..").join("/"),fullpath:V+=(H?"":v)+q}),H=!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 m6))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 m6))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 m6))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 m6))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 m6))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 m6))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 m6))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,V)=>{W.add(v),v.readdirCB((H,q)=>{if(H)return V(H);let F=q.length;if(!F)return V();let w=()=>{if(--F===0)V()};for(let U of q){if(!Y||Y(U))K.push(X?U:U.fullpath());if($&&U.isSymbolicLink())U.realpath().then((x)=>x?.isUnknown()?x.lstat():x).then((x)=>x?.shouldWalk(W,Q)?G(x,w):w());else if(U.shouldWalk(W,Q))G(U,w);else w()}},!0)},z=Z;return new Promise((v,V)=>{G(z,(H)=>{if(H)return V(H);v(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof m6))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 V=v;if(v.isSymbolicLink()){if(!($&&(V=v.realpathSync())))continue;if(V.isUnknown())V.lstatSync()}if(V.shouldWalk(W,Q))W.add(V)}}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 m6))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 m6))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 m6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new O$({objectMode:!0});if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],z=0,v=()=>{let V=!1;while(!V){let H=G.shift();if(!H){if(z===0)K.end();return}z++,W.add(H);let q=(w,U,x=!1)=>{if(w)return K.emit("error",w);if($&&!x){let L=[];for(let j of U)if(j.isSymbolicLink())L.push(j.realpath().then((c)=>c?.isUnknown()?c.lstat():c));if(L.length){Promise.all(L).then(()=>q(null,U,!0));return}}for(let L of U)if(L&&(!Y||Y(L))){if(!K.write(X?L:L.fullpath()))V=!0}z--;for(let L of U){let j=L.realpathCached()||L;if(j.shouldWalk(W,Q))G.push(j)}if(V&&!K.flowing)K.once("drain",v);else if(!F)v()},F=!0;H.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 m6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new O$({objectMode:!0}),W=new Set;if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let G=[Z],z=0,v=()=>{let V=!1;while(!V){let H=G.shift();if(!H){if(z===0)K.end();return}z++,W.add(H);let q=H.readdirSync();for(let F of q)if(!Y||Y(F)){if(!K.write(X?F:F.fullpath()))V=!0}z--;for(let F of q){let w=F;if(F.isSymbolicLink()){if(!($&&(w=F.realpathSync())))continue;if(w.isUnknown())w.lstatSync()}if(w.shouldWalk(W,Q))G.push(w)}}if(V&&!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[Gd](J)}}class TG extends DR{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,RR,"\\",{...J,nocase:X});this.nocase=X;for(let $=this.cwd;$;$=$.parent)$.nocase=this.nocase}parseRootPath(Z){return RR.parse(Z).root.toUpperCase()}newRoot(Z){return new sF(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class kG extends DR{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,ux1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new oF(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class rF extends kG{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var uN6=process.platform==="win32"?sF:oF,zd=process.platform==="win32"?TG:process.platform==="darwin"?rF:kG;var X21=(Z)=>Z.length>=1,$21=(Z)=>Z.length>=1;class FK{#Z;#J;#$;length;#X;#Y;#v;#V;#W;#G;#z=!0;constructor(Z,J,X,$){if(!X21(Z))throw new TypeError("empty pattern list");if(!$21(J))throw new TypeError("empty glob list");if(J.length!==Z.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw new TypeError("index out of range");if(this.#Z=Z,this.#J=J,this.#$=X,this.#X=$,this.#$===0){if(this.isUNC()){let[Y,Q,K,W,...G]=this.#Z,[z,v,V,H,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let F=[Y,Q,K,W,""].join("/"),w=[z,v,V,H,""].join("/");this.#Z=[F,...G],this.#J=[w,...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.#$]===Y6}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 FK(this.#Z,this.#J,this.#$+1,this.#X),this.#Y.#G=this.#G,this.#Y.#W=this.#W,this.#Y.#V=this.#V,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.#V!==void 0?this.#V:this.#V=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 Y21=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class EG{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:$,noglobstar:Y,platform:Q=Y21}){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 q4(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let $=J.set[X],Y=J.globParts[X];if(!$||!Y)throw new Error("invalid pattern object");while($[0]==="."&&Y[0]===".")$.shift(),Y.shift();let Q=new FK($,Y,0,this.platform),K=new q4(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 PR{store;constructor(Z=new Map){this.store=Z}copy(){return new PR(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 vd{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 Hd{store=new Map;add(Z,J){if(!Z.canReaddir())return;let X=this.store.get(Z);if(X){if(!X.find(($)=>$.globString()===J.globString()))X.push(J)}else this.store.set(Z,[J])}get(Z){let J=this.store.get(Z);if(!J)throw new Error("attempting to walk unknown path");return J}entries(){return this.keys().map((Z)=>[Z,this.store.get(Z)])}keys(){return[...this.store.keys()].filter((Z)=>Z.canReaddir())}}class IG{hasWalkedCache;matches=new vd;subwalks=new Hd;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new PR}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===Y6){if(!$.isSymbolicLink()||this.follow||Y.checkFollowGlobstar())this.subwalks.add($,Y);let v=G?.pattern(),V=G?.rest();if(!G||(v===""||v===".")&&!V)this.matches.add($,K,v===""||v===".");else if(v===".."){let H=$.parent||$;if(!V)this.matches.add(H,K,!0);else if(!this.hasWalkedCache.hasWalked(H,V))this.subwalks.add(H,V)}}else if(W instanceof RegExp)this.subwalks.add($,Y)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new IG(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===Y6)$.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 Q21=(Z,J)=>typeof Z==="string"?new EG([Z],J):Array.isArray(Z)?new EG(Z,J):Z;class CR{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=Q21(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw new Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#X(Z){return this.seen.has(Z)||!!this.#J?.ignored?.(Z)}#Y(Z){return!!this.#J?.childrenIgnored?.(Z)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Z=void 0;while(!this.paused&&(Z=this.#Z.shift()))Z()}onResume(Z){if(this.signal?.aborted)return;if(!this.paused)Z();else this.#Z.push(Z)}async matchCheck(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||await Z.realpath(),!X)return;Z=X}let Y=Z.isUnknown()||this.opts.stat?await Z.lstat():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=await Y.realpath();if(Q&&(Q.isUnknown()||this.opts.stat))await Q.lstat()}return this.matchCheckTest(Y,J)}matchCheckTest(Z,J){return Z&&(this.maxDepth===1/0||Z.depth()<=this.maxDepth)&&(!J||Z.canReaddir())&&(!this.opts.nodir||!Z.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Z.isSymbolicLink()||!Z.realpathCached()?.isDirectory())&&!this.#X(Z)?Z:void 0}matchCheckSync(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||Z.realpathSync(),!X)return;Z=X}let Y=Z.isUnknown()||this.opts.stat?Z.lstatSync():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=Y.realpathSync();if(Q&&(Q?.isUnknown()||this.opts.stat))Q.lstatSync()}return this.matchCheckTest(Y,J)}matchFinish(Z,J){if(this.#X(Z))return;if(!this.includeChildMatches&&this.#J?.add){let Y=`${Z.relativePosix()}/**`;this.#J.add(Y)}let X=this.opts.absolute===void 0?J:this.opts.absolute;this.seen.add(Z);let $=this.opts.mark&&Z.isDirectory()?this.#$:"";if(this.opts.withFileTypes)this.matchEmit(Z);else if(X){let Y=this.opts.posix?Z.fullpathPosix():Z.fullpath();this.matchEmit(Y+$)}else{let Y=this.opts.posix?Z.relativePosix():Z.relative(),Q=this.opts.dotRelative&&!Y.startsWith(".."+this.#$)?"."+this.#$:"";this.matchEmit(!Y?"."+$:Q+Y+$)}}async match(Z,J,X){let $=await this.matchCheck(Z,X);if($)this.matchFinish($,J)}matchSync(Z,J,X){let $=this.matchCheckSync(Z,X);if($)this.matchFinish($,J)}walkCB(Z,J,X){if(this.signal?.aborted)X();this.walkCB2(Z,J,new IG(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 IG(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 tF extends CR{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 eF extends CR{results;constructor(Z,J,X){super(Z,J,X);this.results=new O$({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 W21=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Y7{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Z,J){if(!J)throw new TypeError("glob options required");if(this.withFileTypes=!!J.withFileTypes,this.signal=J.signal,this.follow=!!J.follow,this.dot=!!J.dot,this.dotRelative=!!J.dotRelative,this.nodir=!!J.nodir,this.mark=!!J.mark,!J.cwd)this.cwd="";else if(J.cwd instanceof URL||J.cwd.startsWith("file://"))J.cwd=K21(J.cwd);if(this.cwd=J.cwd||"",this.root=J.root,this.magicalBraces=!!J.magicalBraces,this.nobrace=!!J.nobrace,this.noext=!!J.noext,this.realpath=!!J.realpath,this.absolute=J.absolute,this.includeChildMatches=J.includeChildMatches!==!1,this.noglobstar=!!J.noglobstar,this.matchBase=!!J.matchBase,this.maxDepth=typeof J.maxDepth==="number"?J.maxDepth:1/0,this.stat=!!J.stat,this.ignore=J.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof Z==="string")Z=[Z];if(this.windowsPathsNoEscape=!!J.windowsPathsNoEscape||J.allowWindowsEscape===!1,this.windowsPathsNoEscape)Z=Z.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(J.noglobstar)throw new TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||W21,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?TG:J.platform==="darwin"?rF:J.platform?kG:zd;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 q4(W,$)),[Q,K]=Y.reduce((W,G)=>{return W[0].push(...G.set),W[1].push(...G.globParts),W},[[],[]]);this.patterns=Q.map((W,G)=>{let z=K[G];if(!z)throw new Error("invalid pattern object");return new FK(W,z,0,this.platform)})}async walk(){return[...await new tF(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 tF(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 eF(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 eF(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 TR=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new q4(X,J).hasMagic())return!0;return!1};function Jw(Z,J={}){return new Y7(Z,J).streamSync()}function qd(Z,J={}){return new Y7(Z,J).stream()}function Fd(Z,J={}){return new Y7(Z,J).walkSync()}async function Vd(Z,J={}){return new Y7(Z,J).walk()}function Xw(Z,J={}){return new Y7(Z,J).iterateSync()}function wd(Z,J={}){return new Y7(Z,J).iterate()}var G21=Jw,z21=Object.assign(qd,{sync:Jw}),v21=Xw,H21=Object.assign(wd,{sync:Xw}),V21=Object.assign(Fd,{stream:Jw,iterate:Xw}),Zw=Object.assign(Vd,{glob:Vd,globSync:Fd,sync:V21,globStream:qd,stream:z21,globStreamSync:Jw,streamSync:G21,globIterate:wd,iterate:H21,globIterateSync:Xw,iterateSync:v21,Glob:Y7,hasMagic:TR,escape:zK,unescape:V9});Zw.glob=Zw;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 H5{constructor(Z,J,X,$={}){if(this._name=void 0,this._parent=void 0,this._child=void 0,this._attributes=void 0,this._disposed=!1,this._name=Z,this._parent=J,this._child=X,this._attributes=$,!J.isOnGraph(X))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(Z){return this._child=Z,this}getAttributes(){return this._attributes}dispose(){if(this._disposed)return;this._parent._destroyRef(this),this._disposed=!0}isDisposed(){return this._disposed}}class wK 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 H5(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 fG(){return fG=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},fG.apply(this,arguments)}class B6{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 C0{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 a1{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 b0=Symbol("attributes"),w9=Symbol("immutableKeys");class UK extends kR{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[b0]=void 0,this[w9]=void 0,this.graph=Z,this[w9]=new Set,this[b0]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let $=Z[X];if($ instanceof UK){let Y=this.graph._createEdge(X,this,$);this[w9].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[b0]){let $=this[b0][X];if($ instanceof H5){let Y=$;if(Y.getChild()===Z)this.setRef(X,J,Y.getAttributes())}else if($ instanceof B6)for(let Y of $.listRefsByChild(Z)){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if($ instanceof C0){let Y=$.getRefByChild(Z);if(Y){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if($ instanceof a1)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[b0][Z]}set(Z,J){return this[b0][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[b0][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[w9].has(Z))throw new Error(`Cannot overwrite immutable attribute, "${Z}".`);let $=this[b0][Z];if($)$.dispose();if(!J)return this;let Y=this.graph._createEdge(Z,this,J,X);return this[b0][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 B6)for(let $ of X.listRefsByChild(J))$.dispose();else{let $=X.getRefByChild(J);if($)$.dispose()}return this}assertRefList(Z){let J=this[b0][Z];if(J instanceof B6||J instanceof C0)return J;throw new Error(`Expected RefList or RefSet for attribute "${Z}"`)}listRefMapKeys(Z){return this.assertRefMap(Z).keys()}listRefMapValues(Z){return this.assertRefMap(Z).values().map((J)=>J.getChild())}getRefMap(Z,J){let $=this.assertRefMap(Z).get(J);return $?$.getChild():null}setRefMap(Z,J,X,$){let Y=this.assertRefMap(Z),Q=Y.get(J);if(Q)Q.dispose();if(!X)return this;$=Object.assign($||{},{key:J});let K=this.graph._createEdge(Z,this,X,fG({},$,{key:J}));return Y.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[b0][Z];if(J instanceof a1)return J;throw new Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(fG({},Z,{target:this})),this.graph.dispatchEvent(fG({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[b0][J]===Z){if(this[b0][J]=null,this[w9].has(J))Z.getChild().dispose()}else if(this[b0][J]instanceof B6)this[b0][J].remove(Z);else if(this[b0][J]instanceof C0)this[b0][J].remove(Z);else if(this[b0][J]instanceof a1){let X=this[b0][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 Od="v4.1.1",Gw="@glb.bin",n;(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"})(n||(n={}));var zw;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(zw||(zw={}));var S5;(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"})(S5||(S5={}));var vw;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(vw||(vw={}));var GZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(GZ||(GZ={}));var DJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array},IR=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function q21(){var Z=new IR(3);if(IR!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function ER(Z){var J=Z[0],X=Z[1],$=Z[2];return Math.hypot(J,X,$)}function F21(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=q21();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 hR(Z){let J=Md(),X=Z.propertyType===n.NODE?[Z]:Z.listChildren();for(let $ of X)$.traverse((Y)=>{let Q=Y.getMesh();if(!Q)return;let K=w21(Q,Y.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))fR(K.min,J),fR(K.max,J)});return J}function w21(Z,J){let X=Md();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=F21(W,K,J),fR(W,X)}}return X}function fR(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 Md(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class r0{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let $=0;$<J.length;$++)X[$]=J.charCodeAt($);return X}else{let J=Z.split(",")[1],X=Z.indexOf("base64")>=0;return Buffer.from(J,X?"base64":"utf8")}}static encodeText(Z){return new TextEncoder().encode(Z)}static decodeText(Z){return new TextDecoder().decode(Z)}static concat(Z){let J=0;for(let Y of Z)J+=Y.byteLength;let X=new Uint8Array(J),$=0;for(let Y of Z)X.set(Y,$),$+=Y.byteLength;return X}static pad(Z,J=0){let X=this.padNumber(Z.byteLength);if(X===Z.byteLength)return Z;let $=new Uint8Array(X);if($.set(Z),J!==0)for(let Y=Z.byteLength;Y<X;Y++)$[Y]=J;return $}static padNumber(Z){return Math.ceil(Z/4)*4}static equals(Z,J){if(Z===J)return!0;if(Z.byteLength!==J.byteLength)return!1;let X=Z.byteLength;while(X--)if(Z[X]!==J[X])return!1;return!0}static toView(Z,J=0,X=1/0){return new Uint8Array(Z.buffer,Z.byteOffset+J,Math.min(Z.byteLength,X))}static assertView(Z){if(Z&&!ArrayBuffer.isView(Z))throw new Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class bR{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 Rd{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),U21(J,X),$=J.getUint8(X+1),$===192||$===193||$===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class qw{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(r0.decodeText(Z.slice(12,16))===qw.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}}qw.PNG_FRIED_CHUNK_NAME="CgBI";class zZ{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}`}}zZ.impls={"image/jpeg":new Rd,"image/png":new qw};function U21(Z,J){if(J>Z.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return Z}class vZ{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 zZ.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()}}function Ud(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function R$(Z){if(Ud(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Ud(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var _R,_G;(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"})(_G||(_G={}));class q5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=q5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=q5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=q5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=q5.Verbosity.ERROR)console.error(Z)}}_R=q5;q5.Verbosity=_G;q5.DEFAULT_INSTANCE=new _R(_R.Verbosity.INFO);function x21(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],V=Z[10],H=Z[11],q=Z[12],F=Z[13],w=Z[14],U=Z[15],x=J*K-X*Q,L=J*W-$*Q,j=J*G-Y*Q,c=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,N=z*F-v*q,D=z*w-V*q,P=z*U-H*q,f=v*w-V*F,E=v*U-H*F,_=V*U-H*w;return x*_-L*E+j*f+c*P-R*D+M*N}function B21(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],V=J[8],H=J[9],q=J[10],F=J[11],w=J[12],U=J[13],x=J[14],L=J[15],j=X[0],c=X[1],R=X[2],M=X[3];return Z[0]=j*$+c*W+R*V+M*w,Z[1]=j*Y+c*G+R*H+M*U,Z[2]=j*Q+c*z+R*q+M*x,Z[3]=j*K+c*v+R*F+M*L,j=X[4],c=X[5],R=X[6],M=X[7],Z[4]=j*$+c*W+R*V+M*w,Z[5]=j*Y+c*G+R*H+M*U,Z[6]=j*Q+c*z+R*q+M*x,Z[7]=j*K+c*v+R*F+M*L,j=X[8],c=X[9],R=X[10],M=X[11],Z[8]=j*$+c*W+R*V+M*w,Z[9]=j*Y+c*G+R*H+M*U,Z[10]=j*Q+c*z+R*q+M*x,Z[11]=j*K+c*v+R*F+M*L,j=X[12],c=X[13],R=X[14],M=X[15],Z[12]=j*$+c*W+R*V+M*w,Z[13]=j*Y+c*G+R*H+M*U,Z[14]=j*Q+c*z+R*q+M*x,Z[15]=j*K+c*v+R*F+M*L,Z}function L21(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 j21(Z,J){var X=new IR(3);L21(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,V=J[6]*Q,H=J[8]*$,q=J[9]*Y,F=J[10]*Q,w=K+v+F,U=0;if(w>0)U=Math.sqrt(w+1)*2,Z[3]=0.25*U,Z[0]=(V-q)/U,Z[1]=(H-G)/U,Z[2]=(W-z)/U;else if(K>v&&K>F)U=Math.sqrt(1+K-v-F)*2,Z[3]=(V-q)/U,Z[0]=0.25*U,Z[1]=(W+z)/U,Z[2]=(H+G)/U;else if(v>F)U=Math.sqrt(1+v-K-F)*2,Z[3]=(H-G)/U,Z[0]=(W+z)/U,Z[1]=0.25*U,Z[2]=(V+q)/U;else U=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/U,Z[0]=(H+G)/U,Z[1]=(V+q)/U,Z[2]=0.25*U;return Z}class a0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(a0.clamp(Z,0,1)*65535);case 5121:return Math.round(a0.clamp(Z,0,1)*255);case 5122:return Math.round(a0.clamp(Z,-1,1)*32767);case 5120:return Math.round(a0.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,$){let Y=ER([Z[0],Z[1],Z[2]]),Q=ER([Z[4],Z[5],Z[6]]),K=ER([Z[8],Z[9],Z[10]]);if(x21(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,V=1/K;G[0]*=z,G[1]*=z,G[2]*=z,G[4]*=v,G[5]*=v,G[6]*=v,G[8]*=V,G[9]*=V,G[10]*=V,j21(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,V=W+W,H=Q*z,q=Q*v,F=Q*V,w=K*v,U=K*V,x=W*V,L=G*z,j=G*v,c=G*V,R=X[0],M=X[1],N=X[2];return Y[0]=(1-(w+x))*R,Y[1]=(q+c)*R,Y[2]=(F-j)*R,Y[3]=0,Y[4]=(q-c)*M,Y[5]=(1-(H+x))*M,Y[6]=(U+L)*M,Y[7]=0,Y[8]=(F+j)*N,Y[9]=(U-L)*N,Y[10]=(1-(H+w))*N,Y[11]=0,Y[12]=Z[0],Y[13]=Z[1],Y[14]=Z[2],Y[15]=1,Y}}function c21(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),$=J.getChild();return X===$||X.equals($)}function O21(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 M21(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 Nd(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 Dd(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!R$(Z)||!R$(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(Hw(W)&&Hw(G)){if(!Nd(W,G))return!1}else if(R$(W)&&R$(G)){if(!Dd(W,G))return!1}else if(W!==G)return!1}return!0}function Hw(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var xd="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",R21=999,N21=6,Bd=new Set,D21=function Z(){let J="";for(let X=0;X<N21;X++)J+=xd.charAt(Math.floor(Math.random()*xd.length));return J},Pd=function Z(){for(let J=0;J<R21;J++){let X=D21();if(!Bd.has(X))return Bd.add(X),X}return""},Ld="https://null.example";class U4{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return vZ.basename(new URL(Z,Ld).pathname)}static extension(Z){return vZ.extension(new URL(Z,Ld).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)}}U4.DEFAULT_INIT={};U4.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var NJ=(Z)=>Z,P21=new Set;class Fw extends UK{constructor(Z,J=""){super(Z);this[b0].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,NJ)}copy(Z,J=NJ){for(let X in this[b0]){let $=this[b0][X];if($ instanceof H5){if(!this[w9].has(X))$.dispose()}else if($ instanceof B6||$ instanceof C0)for(let Y of $.values())Y.dispose();else if($ instanceof a1)for(let Y of $.values())Y.dispose()}for(let X in Z[b0]){let $=this[b0][X],Y=Z[b0][X];if(Y instanceof H5)if(this[w9].has(X))$.getChild().copy(J(Y.getChild()),J);else this.setRef(X,J(Y.getChild()),Y.getAttributes());else if(Y instanceof C0||Y instanceof B6)for(let Q of Y.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if(Y instanceof a1)for(let Q of Y.keys()){let K=Y.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(R$(Y))this[b0][X]=JSON.parse(JSON.stringify(Y));else if(Array.isArray(Y)||Y instanceof ArrayBuffer||ArrayBuffer.isView(Y))this[b0][X]=Y.slice();else this[b0][X]=Y}return this}equals(Z,J=P21){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[b0]){if(J.has(X))continue;let $=this[b0][X],Y=Z[b0][X];if($ instanceof H5||Y instanceof H5){if(!c21($,Y))return!1}else if($ instanceof C0||Y instanceof C0||$ instanceof B6||Y instanceof B6){if(!O21($,Y))return!1}else if($ instanceof a1||Y instanceof a1){if(!M21($,Y))return!1}else if(R$($)||R$(Y)){if(!Dd($,Y))return!1}else if(Hw($)||Hw(Y)){if(!Nd($,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 j6 extends Fw{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new a1})}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 _0 extends j6{init(){this.propertyType=n.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:_0.Type.SCALAR,componentType:_0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case _0.Type.SCALAR:return 1;case _0.Type.VEC2:return 2;case _0.Type.VEC3:return 3;case _0.Type.VEC4:return 4;case _0.Type.MAT2:return 4;case _0.Type.MAT3:return 9;case _0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case _0.ComponentType.BYTE:return 1;case _0.ComponentType.UNSIGNED_BYTE:return 1;case _0.ComponentType.SHORT:return 2;case _0.ComponentType.UNSIGNED_SHORT:return 2;case _0.ComponentType.UNSIGNED_INT:return 4;case _0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMin(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=a0.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]=a0.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 _0.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 a0.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]=a0.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]=a0.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]=a0.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?C21(Z):_0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}_0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};_0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function C21(Z){switch(Z.constructor){case Float32Array:return _0.ComponentType.FLOAT;case Uint32Array:return _0.ComponentType.UNSIGNED_INT;case Uint16Array:return _0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return _0.ComponentType.UNSIGNED_BYTE;case Int16Array:return _0.ComponentType.SHORT;case Int8Array:return _0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class AR extends j6{init(){this.propertyType=n.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new C0,samplers:new C0})}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 N$ extends j6{init(){this.propertyType=n.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)}}N$.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class xK extends j6{init(){this.propertyType=n.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:xK.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:S5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:S5.OTHER})}}xK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class mR extends j6{init(){this.propertyType=n.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class D$ extends j6{init(){this.propertyType=n.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:D$.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)}}D$.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class BK extends Fw{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}BK.EXTENSION_NAME=void 0;class V5 extends j6{init(){this.propertyType=n.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:V5.WrapMode.REPEAT,wrapT:V5.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)}}V5.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};V5.MagFilter={NEAREST:9728,LINEAR:9729};V5.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:$w,G:Yw,B:Qw,A:T21}=vw;class Q7 extends j6{init(){this.propertyType=n.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:Q7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new V5(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new V5(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new V5(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new V5(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new V5(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:$w|Yw|Qw|T21,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:$w|Yw|Qw,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:$w|Yw|Qw})}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:$w})}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:Yw|Qw})}}Q7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class hG extends j6{init(){this.propertyType=n.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new C0})}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 ww extends j6{init(){this.propertyType=n.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 C0})}copy(Z,J=NJ){if(J===NJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return a0.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 a0.decompose(Z,J,X,$),this.set("translation",J).set("rotation",X).set("scale",$)}getWorldTranslation(){let Z=[0,0,0];return a0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return a0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return a0.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())B21(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===n.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===n.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 B8 extends j6{init(){this.propertyType=n.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:B8.Mode.TRIANGLES,material:null,indices:null,attributes:new a1,targets:new C0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:S5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:S5.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)}}B8.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class uR extends Fw{init(){this.propertyType=n.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:S5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function u6(){return u6=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},u6.apply(null,arguments)}class LK extends j6{init(){this.propertyType=n.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new C0})}copy(Z,J=NJ){if(J===NJ)throw new Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class lR extends j6{init(){this.propertyType=n.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new C0})}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:S5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class P$ extends j6{init(){this.propertyType=n.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||zZ.extensionToMimeType(vZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=zZ.extensionToMimeType(vZ.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",r0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return zZ.getSize(Z,this.getMimeType())}}class C$ extends j6{init(){this.propertyType=n.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Od}`,version:"2.0"},defaultScene:null,accessors:new C0,animations:new C0,buffers:new C0,cameras:new C0,materials:new C0,meshes:new C0,nodes:new C0,scenes:new C0,skins:new C0,textures:new C0})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(Z,J=NJ){if(J===NJ)throw new Error("Root cannot be copied.");this.set("asset",u6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(u6({},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 LK)this.addRef("scenes",Z);else if(Z instanceof ww)this.addRef("nodes",Z);else if(Z instanceof D$)this.addRef("cameras",Z);else if(Z instanceof lR)this.addRef("skins",Z);else if(Z instanceof hG)this.addRef("meshes",Z);else if(Z instanceof Q7)this.addRef("materials",Z);else if(Z instanceof P$)this.addRef("textures",Z);else if(Z instanceof AR)this.addRef("animations",Z);else if(Z instanceof _0)this.addRef("accessors",Z);else if(Z instanceof mR)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 L6{static fromGraph(Z){return L6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new wK,this._root=new C$(this._graph),this._logger=q5.DEFAULT_INSTANCE,L6._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(($)=>$.extensionName===J)||new Z(this)}createScene(Z=""){return new LK(this._graph,Z)}createNode(Z=""){return new ww(this._graph,Z)}createCamera(Z=""){return new D$(this._graph,Z)}createSkin(Z=""){return new lR(this._graph,Z)}createMesh(Z=""){return new hG(this._graph,Z)}createPrimitive(){return new B8(this._graph)}createPrimitiveTarget(Z=""){return new uR(this._graph,Z)}createMaterial(Z=""){return new Q7(this._graph,Z)}createTexture(Z=""){return new P$(this._graph,Z)}createAnimation(Z=""){return new AR(this._graph,Z)}createAnimationChannel(Z=""){return new N$(this._graph,Z)}createAnimationSampler(Z=""){return new xK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new _0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new mR(this._graph,Z)}}L6._GRAPH_DOCUMENTS=new WeakMap;class Cd{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 BK&&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}}Cd.EXTENSION_NAME=void 0;class Td{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 jd={logger:q5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},k21=new Set([n.BUFFER,n.TEXTURE,n.MATERIAL,n.MESH,n.PRIMITIVE,n.NODE,n.SCENE]);class kd{static read(Z,J=jd){let X=u6({},jd,J),{json:$}=Z,Y=new L6().setLogger(X.logger);this.validate(Z,X);let Q=new Td(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(u6({},$.extras));let G=$.extensionsUsed||[],z=$.extensionsRequired||[];X.extensions.sort((M,N)=>M.EXTENSION_NAME>N.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let N=Y.createExtension(M).setRequired(z.includes(M.EXTENSION_NAME)),D=N.prereadTypes.filter((P)=>!k21.has(P));if(D.length)X.logger.warn(`Preread hooks for some types (${D.join()}), requested by extension ${N.extensionName}, are unsupported. Please file an issue or a PR.`);for(let P of N.readDependencies)N.install(P,X.dependencies[P])}let v=$.buffers||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.BUFFER)).forEach((M)=>M.preread(Q,n.BUFFER)),Q.buffers=v.map((M)=>{let N=Y.createBuffer(M.name);if(M.extras)N.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)N.setURI(M.uri);return N});let V=$.bufferViews||[];Q.bufferViewBuffers=V.map((M,N)=>{if(!Q.bufferViews[N]){let D=Z.json.buffers[M.buffer],P=D.uri?Z.resources[D.uri]:Z.resources[Gw],f=M.byteOffset||0;Q.bufferViews[N]=r0.toView(P,f,M.byteLength)}return Q.buffers[M.buffer]});let H=$.accessors||[];Q.accessors=H.map((M)=>{let N=Q.bufferViewBuffers[M.bufferView],D=Y.createAccessor(M.name,N).setType(M.type);if(M.extras)D.setExtras(M.extras);if(M.normalized!==void 0)D.setNormalized(M.normalized);if(M.bufferView===void 0)return D;return D.setArray(Ww(M,Q)),D});let q=$.images||[],F=$.textures||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.TEXTURE)).forEach((M)=>M.preread(Q,n.TEXTURE)),Q.textures=q.map((M)=>{let N=Y.createTexture(M.name);if(M.extras)N.setExtras(M.extras);if(M.bufferView!==void 0){let D=$.bufferViews[M.bufferView],P=Z.json.buffers[D.buffer],f=P.uri?Z.resources[P.uri]:Z.resources[Gw],E=D.byteOffset||0,_=D.byteLength,T=f.slice(E,E+_);N.setImage(T)}else if(M.uri!==void 0){if(N.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)N.setURI(M.uri)}if(M.mimeType!==void 0)N.setMimeType(M.mimeType);else if(M.uri){let D=vZ.extension(M.uri);N.setMimeType(zZ.extensionToMimeType(D))}return N}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.MATERIAL)).forEach((M)=>M.preread(Q,n.MATERIAL));let w=$.materials||[];Q.materials=w.map((M)=>{let N=Y.createMaterial(M.name);if(M.extras)N.setExtras(M.extras);if(M.alphaMode!==void 0)N.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)N.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)N.setDoubleSided(M.doubleSided);let D=M.pbrMetallicRoughness||{};if(D.baseColorFactor!==void 0)N.setBaseColorFactor(D.baseColorFactor);if(M.emissiveFactor!==void 0)N.setEmissiveFactor(M.emissiveFactor);if(D.metallicFactor!==void 0)N.setMetallicFactor(D.metallicFactor);if(D.roughnessFactor!==void 0)N.setRoughnessFactor(D.roughnessFactor);if(D.baseColorTexture!==void 0){let P=D.baseColorTexture,f=Q.textures[F[P.index].source];N.setBaseColorTexture(f),Q.setTextureInfo(N.getBaseColorTextureInfo(),P)}if(M.emissiveTexture!==void 0){let P=M.emissiveTexture,f=Q.textures[F[P.index].source];N.setEmissiveTexture(f),Q.setTextureInfo(N.getEmissiveTextureInfo(),P)}if(M.normalTexture!==void 0){let P=M.normalTexture,f=Q.textures[F[P.index].source];if(N.setNormalTexture(f),Q.setTextureInfo(N.getNormalTextureInfo(),P),M.normalTexture.scale!==void 0)N.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let P=M.occlusionTexture,f=Q.textures[F[P.index].source];if(N.setOcclusionTexture(f),Q.setTextureInfo(N.getOcclusionTextureInfo(),P),M.occlusionTexture.strength!==void 0)N.setOcclusionStrength(M.occlusionTexture.strength)}if(D.metallicRoughnessTexture!==void 0){let P=D.metallicRoughnessTexture,f=Q.textures[F[P.index].source];N.setMetallicRoughnessTexture(f),Q.setTextureInfo(N.getMetallicRoughnessTextureInfo(),P)}return N}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.MESH)).forEach((M)=>M.preread(Q,n.MESH));let U=$.meshes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.PRIMITIVE)).forEach((M)=>M.preread(Q,n.PRIMITIVE)),Q.meshes=U.map((M)=>{let N=Y.createMesh(M.name);if(M.extras)N.setExtras(M.extras);if(M.weights!==void 0)N.setWeights(M.weights);return(M.primitives||[]).forEach((P)=>{let f=Y.createPrimitive();if(P.extras)f.setExtras(P.extras);if(P.material!==void 0)f.setMaterial(Q.materials[P.material]);if(P.mode!==void 0)f.setMode(P.mode);for(let[T,k]of Object.entries(P.attributes||{}))f.setAttribute(T,Q.accessors[k]);if(P.indices!==void 0)f.setIndices(Q.accessors[P.indices]);let E=M.extras&&M.extras.targetNames||[];(P.targets||[]).forEach((T,k)=>{let h=E[k]||k.toString(),u=Y.createPrimitiveTarget(h);for(let[a,o]of Object.entries(T))u.setAttribute(a,Q.accessors[o]);f.addTarget(u)}),N.addPrimitive(f)}),N});let x=$.cameras||[];Q.cameras=x.map((M)=>{let N=Y.createCamera(M.name).setType(M.type);if(M.extras)N.setExtras(M.extras);if(M.type===D$.Type.PERSPECTIVE){let D=M.perspective;if(N.setYFov(D.yfov),N.setZNear(D.znear),D.zfar!==void 0)N.setZFar(D.zfar);if(D.aspectRatio!==void 0)N.setAspectRatio(D.aspectRatio)}else{let D=M.orthographic;N.setZNear(D.znear).setZFar(D.zfar).setXMag(D.xmag).setYMag(D.ymag)}return N});let L=$.nodes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.NODE)).forEach((M)=>M.preread(Q,n.NODE)),Q.nodes=L.map((M)=>{let N=Y.createNode(M.name);if(M.extras)N.setExtras(M.extras);if(M.translation!==void 0)N.setTranslation(M.translation);if(M.rotation!==void 0)N.setRotation(M.rotation);if(M.scale!==void 0)N.setScale(M.scale);if(M.matrix!==void 0){let D=[0,0,0],P=[0,0,0,1],f=[1,1,1];a0.decompose(M.matrix,D,P,f),N.setTranslation(D),N.setRotation(P),N.setScale(f)}if(M.weights!==void 0)N.setWeights(M.weights);return N});let j=$.skins||[];Q.skins=j.map((M)=>{let N=Y.createSkin(M.name);if(M.extras)N.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)N.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)N.setSkeleton(Q.nodes[M.skeleton]);for(let D of M.joints)N.addJoint(Q.nodes[D]);return N}),L.map((M,N)=>{let D=Q.nodes[N];if((M.children||[]).forEach((f)=>D.addChild(Q.nodes[f])),M.mesh!==void 0)D.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)D.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)D.setSkin(Q.skins[M.skin])});let c=$.animations||[];Q.animations=c.map((M)=>{let N=Y.createAnimation(M.name);if(M.extras)N.setExtras(M.extras);let P=(M.samplers||[]).map((E)=>{let _=Y.createAnimationSampler().setInput(Q.accessors[E.input]).setOutput(Q.accessors[E.output]).setInterpolation(E.interpolation||xK.Interpolation.LINEAR);if(E.extras)_.setExtras(E.extras);return N.addSampler(_),_});return(M.channels||[]).forEach((E)=>{let _=Y.createAnimationChannel().setSampler(P[E.sampler]).setTargetPath(E.target.path);if(E.target.node!==void 0)_.setTargetNode(Q.nodes[E.target.node]);if(E.extras)_.setExtras(E.extras);N.addChannel(_)}),N});let R=$.scenes||[];if(Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(n.SCENE)).forEach((M)=>M.preread(Q,n.SCENE)),Q.scenes=R.map((M)=>{let N=Y.createScene(M.name);if(M.extras)N.setExtras(M.extras);return(M.nodes||[]).map((P)=>Q.nodes[P]).forEach((P)=>N.addChild(P)),N}),$.scene!==void 0)Y.getRoot().setDefaultScene(Q.scenes[$.scene]);return Y.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),H.forEach((M,N)=>{let D=Q.accessors[N],P=!!M.sparse,f=!M.bufferView&&!D.getArray();if(P||f)D.setSparse(!0).setArray(I21(M,Q))}),Y}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let $ of X.extensionsRequired)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))throw new Error(`Missing required extension, "${$}".`)}if(X.extensionsUsed){for(let $ of X.extensionsUsed)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))J.logger.warn(`Missing optional extension, "${$}".`)}}}function E21(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=DJ[Z.componentType],K=_0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,z=new Q(Z.count*K),v=new DataView($.buffer,$.byteOffset,$.byteLength),V=Y.byteStride;for(let H=0;H<Z.count;H++)for(let q=0;q<K;q++){let F=G+H*V+q*W,w;switch(Z.componentType){case _0.ComponentType.FLOAT:w=v.getFloat32(F,!0);break;case _0.ComponentType.UNSIGNED_INT:w=v.getUint32(F,!0);break;case _0.ComponentType.UNSIGNED_SHORT:w=v.getUint16(F,!0);break;case _0.ComponentType.UNSIGNED_BYTE:w=v.getUint8(F);break;case _0.ComponentType.SHORT:w=v.getInt16(F,!0);break;case _0.ComponentType.BYTE:w=v.getInt8(F);break;default:throw new Error(`Unexpected componentType "${Z.componentType}".`)}z[H*K+q]=w}return z}function Ww(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=DJ[Z.componentType],K=_0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if(Y.byteStride!==void 0&&Y.byteStride!==G)return E21(Z,J);let z=$.byteOffset+(Z.byteOffset||0),v=Z.count*K*W;return new Q($.buffer.slice(z,z+v))}function I21(Z,J){let X=DJ[Z.componentType],$=_0.getElementSize(Z.type),Y;if(Z.bufferView!==void 0)Y=Ww(Z,J);else Y=new X(Z.count*$);let Q=Z.sparse;if(!Q)return Y;let K=Q.count,W=u6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=u6({},Z,Q.values,{count:K}),z=Ww(W,J),v=Ww(G,J);for(let V=0;V<W.count;V++)for(let H=0;H<$;H++)Y[z[V]*$+H]=v[V*$+H];return Y}var SG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(SG||(SG={}));class RJ{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 SR(Y>1,()=>X.basename||"buffer"),this.imageURIGenerator=new SR(Q>1,(K)=>f21(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===GZ.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 $=zZ.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,$),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let $=this.jsonDoc.resources;if(!(Z in $)){$[Z]=J;return}if(J===$[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let Y=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn(Y);return}throw new Error(Y)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return S5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:$}=X.getAttributes();if($)return $;if(X.getParent().propertyType!==n.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return S5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw new Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}RJ.BufferViewTarget=SG;RJ.BufferViewUsage=S5;RJ.USAGE_TO_TARGET={[S5.ARRAY_BUFFER]:SG.ARRAY_BUFFER,[S5.ELEMENT_ARRAY_BUFFER]:SG.ELEMENT_ARRAY_BUFFER};class SR{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 f21(Z,J){let X=Z.getGraph().listParentEdges(J).find(($)=>$.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:Kw}=RJ,{UNSIGNED_INT:_21,UNSIGNED_SHORT:S21,UNSIGNED_BYTE:h21}=_0.ComponentType,b21=new Set([n.ACCESSOR,n.BUFFER,n.MATERIAL,n.MESH]);class Ed{static write(Z,J){let X=Z.getGraph(),$=Z.getRoot(),Y={asset:u6({generator:`glTF-Transform ${Od}`},$.getAsset()),extras:u6({},$.getExtras())},Q={json:Y,resources:{}},K=new RJ(Z,Q,J),W=J.logger||q5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((U)=>U.EXTENSION_NAME)),z=Z.getRoot().listExtensionsUsed().filter((U)=>G.has(U.extensionName)).sort((U,x)=>U.extensionName>x.extensionName?1:-1),v=Z.getRoot().listExtensionsRequired().filter((U)=>G.has(U.extensionName)).sort((U,x)=>U.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 U of z){let x=U.prewriteTypes.filter((L)=>!b21.has(L));if(x.length)W.warn(`Prewrite hooks for some types (${x.join()}), requested by extension ${U.extensionName}, are unsupported. Please file an issue or a PR.`);for(let L of U.writeDependencies)U.install(L,J.dependencies[L])}function V(U,x,L,j){let c=[],R=0;for(let D of U){let P=K.createAccessorDef(D);P.bufferView=Y.bufferViews.length;let f=D.getArray(),E=r0.pad(r0.toView(f));P.byteOffset=R,R+=E.byteLength,c.push(E),K.accessorIndexMap.set(D,Y.accessors.length),Y.accessors.push(P)}let M=r0.concat(c),N={buffer:x,byteOffset:L,byteLength:M.byteLength};if(j)N.target=j;return Y.bufferViews.push(N),{buffers:c,byteLength:R}}function H(U,x,L){let j=U[0].getCount(),c=0;for(let P of U){let f=K.createAccessorDef(P);f.bufferView=Y.bufferViews.length,f.byteOffset=c;let E=P.getElementSize(),_=P.getComponentSize();c+=r0.padNumber(E*_),K.accessorIndexMap.set(P,Y.accessors.length),Y.accessors.push(f)}let R=j*c,M=new ArrayBuffer(R),N=new DataView(M);for(let P=0;P<j;P++){let f=0;for(let E of U){let _=E.getElementSize(),T=E.getComponentSize(),k=E.getComponentType(),h=E.getArray();for(let u=0;u<_;u++){let a=P*c+f+u*T,o=h[P*_+u];switch(k){case _0.ComponentType.FLOAT:N.setFloat32(a,o,!0);break;case _0.ComponentType.BYTE:N.setInt8(a,o);break;case _0.ComponentType.SHORT:N.setInt16(a,o,!0);break;case _0.ComponentType.UNSIGNED_BYTE:N.setUint8(a,o);break;case _0.ComponentType.UNSIGNED_SHORT:N.setUint16(a,o,!0);break;case _0.ComponentType.UNSIGNED_INT:N.setUint32(a,o,!0);break;default:throw new Error("Unexpected component type: "+k)}}f+=r0.padNumber(_*T)}}let D={buffer:x,byteOffset:L,byteLength:R,byteStride:c,target:RJ.BufferViewTarget.ARRAY_BUFFER};return Y.bufferViews.push(D),{byteLength:R,buffers:[new Uint8Array(M)]}}function q(U,x,L){let j=[],c=0,R=new Map,M=-1/0,N=!1;for(let k of U){let h=K.createAccessorDef(k);Y.accessors.push(h),K.accessorIndexMap.set(k,Y.accessors.length-1);let u=[],a=[],o=[],Q0=new Array(k.getElementSize()).fill(0);for(let t0=0,C8=k.getCount();t0<C8;t0++){if(k.getElement(t0,o),a0.eq(o,Q0,0))continue;M=Math.max(t0,M),u.push(t0);for(let g1=0;g1<o.length;g1++)a.push(o[g1])}let W0=u.length,E0={accessorDef:h,count:W0};if(R.set(k,E0),W0===0)continue;if(W0>k.getCount()/2)N=!0;let I0=DJ[k.getComponentType()];E0.indices=u,E0.values=new I0(a)}if(!Number.isFinite(M))return{buffers:j,byteLength:c};if(N)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let D=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,P=M<255?h21:M<65535?S21:_21,f={buffer:x,byteOffset:L+c,byteLength:0};for(let k of U){let h=R.get(k);if(h.count===0)continue;h.indicesByteOffset=f.byteLength;let u=r0.pad(r0.toView(new D(h.indices)));j.push(u),c+=u.byteLength,f.byteLength+=u.byteLength}Y.bufferViews.push(f);let E=Y.bufferViews.length-1,_={buffer:x,byteOffset:L+c,byteLength:0};for(let k of U){let h=R.get(k);if(h.count===0)continue;h.valuesByteOffset=_.byteLength;let u=r0.pad(r0.toView(h.values));j.push(u),c+=u.byteLength,_.byteLength+=u.byteLength}Y.bufferViews.push(_);let T=Y.bufferViews.length-1;for(let k of U){let h=R.get(k);if(h.count===0)continue;h.accessorDef.sparse={count:h.count,indices:{bufferView:E,byteOffset:h.indicesByteOffset,componentType:P},values:{bufferView:T,byteOffset:h.valuesByteOffset}}}return{buffers:j,byteLength:c}}if(Y.accessors=[],Y.bufferViews=[],Y.samplers=[],Y.textures=[],Y.images=$.listTextures().map((U,x)=>{let L=K.createPropertyDef(U);if(U.getMimeType())L.mimeType=U.getMimeType();let j=U.getImage();if(j)K.createImageData(L,j,U);return K.imageIndexMap.set(U,x),L}),z.filter((U)=>U.prewriteTypes.includes(n.ACCESSOR)).forEach((U)=>U.prewrite(K,n.ACCESSOR)),$.listAccessors().forEach((U)=>{let{accessorUsageGroupedByParent:x,accessorParents:L}=K;if(K.accessorIndexMap.has(U))return;let j=K.getAccessorUsage(U);if(K.addAccessorToUsageGroup(U,j),x.has(j)){let c=X.listParents(U).find((R)=>R.propertyType!==n.ROOT);L.set(U,c)}}),z.filter((U)=>U.prewriteTypes.includes(n.BUFFER)).forEach((U)=>U.prewrite(K,n.BUFFER)),($.listAccessors().length>0||K.otherBufferViews.size>0||$.listTextures().length>0&&J.format===GZ.GLB)&&$.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");if(Y.buffers=[],$.listBuffers().forEach((U,x)=>{let L=K.createPropertyDef(U),j=K.accessorUsageGroupedByParent,c=U.listParents().filter((_)=>_ instanceof _0),R=new Set(c.map((_)=>K.accessorParents.get(_))),M=new Map(Array.from(R).map((_,T)=>[_,T])),N={};for(let _ of c){var D;if(K.accessorIndexMap.has(_))continue;let T=K.getAccessorUsage(_),k=T;if(j.has(T)){let h=K.accessorParents.get(_);k+=`:${M.get(h)}`}N[D=k]||(N[D]={usage:T,accessors:[]}),N[k].accessors.push(_)}let P=[],f=Y.buffers.length,E=0;for(let{usage:_,accessors:T}of Object.values(N))if(_===Kw.ARRAY_BUFFER&&J.vertexLayout===zw.INTERLEAVED){let k=H(T,f,E);E+=k.byteLength;for(let h of k.buffers)P.push(h)}else if(_===Kw.ARRAY_BUFFER)for(let k of T){let h=H([k],f,E);E+=h.byteLength;for(let u of h.buffers)P.push(u)}else if(_===Kw.SPARSE){let k=q(T,f,E);E+=k.byteLength;for(let h of k.buffers)P.push(h)}else if(_===Kw.ELEMENT_ARRAY_BUFFER){let k=RJ.BufferViewTarget.ELEMENT_ARRAY_BUFFER,h=V(T,f,E,k);E+=h.byteLength;for(let u of h.buffers)P.push(u)}else{let k=V(T,f,E);E+=k.byteLength;for(let h of k.buffers)P.push(h)}if(K.imageBufferViews.length&&x===0){for(let _=0;_<K.imageBufferViews.length;_++)if(Y.bufferViews[Y.images[_].bufferView].byteOffset=E,E+=K.imageBufferViews[_].byteLength,P.push(K.imageBufferViews[_]),E%8){let T=8-E%8;E+=T,P.push(new Uint8Array(T))}}if(K.otherBufferViews.has(U))for(let _ of K.otherBufferViews.get(U))Y.bufferViews.push({buffer:f,byteOffset:E,byteLength:_.byteLength}),K.otherBufferViewsIndexMap.set(_,Y.bufferViews.length-1),E+=_.byteLength,P.push(_);if(E){let _;if(J.format===GZ.GLB)_=Gw;else _=K.bufferURIGenerator.createURI(U,"bin"),L.uri=_;L.byteLength=E,K.assignResourceURI(_,r0.concat(P),!0)}Y.buffers.push(L),K.bufferIndexMap.set(U,x)}),$.listAccessors().find((U)=>!U.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");z.filter((U)=>U.prewriteTypes.includes(n.MATERIAL)).forEach((U)=>U.prewrite(K,n.MATERIAL)),Y.materials=$.listMaterials().map((U,x)=>{let L=K.createPropertyDef(U);if(U.getAlphaMode()!==Q7.AlphaMode.OPAQUE)L.alphaMode=U.getAlphaMode();if(U.getAlphaMode()===Q7.AlphaMode.MASK)L.alphaCutoff=U.getAlphaCutoff();if(U.getDoubleSided())L.doubleSided=!0;if(L.pbrMetallicRoughness={},!a0.eq(U.getBaseColorFactor(),[1,1,1,1]))L.pbrMetallicRoughness.baseColorFactor=U.getBaseColorFactor();if(!a0.eq(U.getEmissiveFactor(),[0,0,0]))L.emissiveFactor=U.getEmissiveFactor();if(U.getRoughnessFactor()!==1)L.pbrMetallicRoughness.roughnessFactor=U.getRoughnessFactor();if(U.getMetallicFactor()!==1)L.pbrMetallicRoughness.metallicFactor=U.getMetallicFactor();if(U.getBaseColorTexture()){let j=U.getBaseColorTexture(),c=U.getBaseColorTextureInfo();L.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(j,c)}if(U.getEmissiveTexture()){let j=U.getEmissiveTexture(),c=U.getEmissiveTextureInfo();L.emissiveTexture=K.createTextureInfoDef(j,c)}if(U.getNormalTexture()){let j=U.getNormalTexture(),c=U.getNormalTextureInfo(),R=K.createTextureInfoDef(j,c);if(U.getNormalScale()!==1)R.scale=U.getNormalScale();L.normalTexture=R}if(U.getOcclusionTexture()){let j=U.getOcclusionTexture(),c=U.getOcclusionTextureInfo(),R=K.createTextureInfoDef(j,c);if(U.getOcclusionStrength()!==1)R.strength=U.getOcclusionStrength();L.occlusionTexture=R}if(U.getMetallicRoughnessTexture()){let j=U.getMetallicRoughnessTexture(),c=U.getMetallicRoughnessTextureInfo();L.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(j,c)}return K.materialIndexMap.set(U,x),L}),z.filter((U)=>U.prewriteTypes.includes(n.MESH)).forEach((U)=>U.prewrite(K,n.MESH)),Y.meshes=$.listMeshes().map((U,x)=>{let L=K.createPropertyDef(U),j=null;if(L.primitives=U.listPrimitives().map((c)=>{let R={attributes:{}};R.mode=c.getMode();let M=c.getMaterial();if(M)R.material=K.materialIndexMap.get(M);if(Object.keys(c.getExtras()).length)R.extras=c.getExtras();let N=c.getIndices();if(N)R.indices=K.accessorIndexMap.get(N);for(let D of c.listSemantics())R.attributes[D]=K.accessorIndexMap.get(c.getAttribute(D));for(let D of c.listTargets()){let P={};for(let f of D.listSemantics())P[f]=K.accessorIndexMap.get(D.getAttribute(f));R.targets=R.targets||[],R.targets.push(P)}if(c.listTargets().length&&!j)j=c.listTargets().map((D)=>D.getName());return R}),U.getWeights().length)L.weights=U.getWeights();if(j)L.extras=L.extras||{},L.extras.targetNames=j;return K.meshIndexMap.set(U,x),L}),Y.cameras=$.listCameras().map((U,x)=>{let L=K.createPropertyDef(U);if(L.type=U.getType(),L.type===D$.Type.PERSPECTIVE){L.perspective={znear:U.getZNear(),zfar:U.getZFar(),yfov:U.getYFov()};let j=U.getAspectRatio();if(j!==null)L.perspective.aspectRatio=j}else L.orthographic={znear:U.getZNear(),zfar:U.getZFar(),xmag:U.getXMag(),ymag:U.getYMag()};return K.cameraIndexMap.set(U,x),L}),Y.nodes=$.listNodes().map((U,x)=>{let L=K.createPropertyDef(U);if(!a0.eq(U.getTranslation(),[0,0,0]))L.translation=U.getTranslation();if(!a0.eq(U.getRotation(),[0,0,0,1]))L.rotation=U.getRotation();if(!a0.eq(U.getScale(),[1,1,1]))L.scale=U.getScale();if(U.getWeights().length)L.weights=U.getWeights();return K.nodeIndexMap.set(U,x),L}),Y.skins=$.listSkins().map((U,x)=>{let L=K.createPropertyDef(U),j=U.getInverseBindMatrices();if(j)L.inverseBindMatrices=K.accessorIndexMap.get(j);let c=U.getSkeleton();if(c)L.skeleton=K.nodeIndexMap.get(c);return L.joints=U.listJoints().map((R)=>K.nodeIndexMap.get(R)),K.skinIndexMap.set(U,x),L}),$.listNodes().forEach((U,x)=>{let L=Y.nodes[x],j=U.getMesh();if(j)L.mesh=K.meshIndexMap.get(j);let c=U.getCamera();if(c)L.camera=K.cameraIndexMap.get(c);let R=U.getSkin();if(R)L.skin=K.skinIndexMap.get(R);if(U.listChildren().length>0)L.children=U.listChildren().map((M)=>K.nodeIndexMap.get(M))}),Y.animations=$.listAnimations().map((U,x)=>{let L=K.createPropertyDef(U),j=new Map;return L.samplers=U.listSamplers().map((c,R)=>{let M=K.createPropertyDef(c);return M.input=K.accessorIndexMap.get(c.getInput()),M.output=K.accessorIndexMap.get(c.getOutput()),M.interpolation=c.getInterpolation(),j.set(c,R),M}),L.channels=U.listChannels().map((c)=>{let R=K.createPropertyDef(c);return R.sampler=j.get(c.getSampler()),R.target={node:K.nodeIndexMap.get(c.getTargetNode()),path:c.getTargetPath()},R}),K.animationIndexMap.set(U,x),L}),Y.scenes=$.listScenes().map((U,x)=>{let L=K.createPropertyDef(U);return L.nodes=U.listChildren().map((j)=>K.nodeIndexMap.get(j)),K.sceneIndexMap.set(U,x),L});let w=$.getDefaultScene();if(w)Y.scene=$.listScenes().indexOf(w);return Y.extensionsUsed=z.map((U)=>U.extensionName),Y.extensionsRequired=v.map((U)=>U.extensionName),z.forEach((U)=>U.write(K)),A21(Y),Q}}function A21(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 Vw;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(Vw||(Vw={}));class Id{constructor(){this._logger=q5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=zw.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=cd(J)?this._binaryToJSON(J):{json:JSON.parse(r0.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),kd.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(r0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some(($)=>m21(J,$)))throw new Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some(($)=>u21(J,$)))throw new Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(r0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===GZ.GLB&&Z.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Ed.write(Z,{format:J.format||GZ.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:u6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:GZ.GLB}),$=new Uint32Array([1179937895,2,12]),Y=JSON.stringify(J),Q=r0.pad(r0.encodeText(Y),32),K=r0.toView(new Uint32Array([Q.byteLength,1313821514])),W=r0.concat([K,Q]);$[$.length-1]+=W.byteLength;let G=Object.values(X)[0];if(!G||!G.byteLength)return r0.concat([r0.toView($),W]);let z=r0.pad(G,0),v=r0.toView(new Uint32Array([z.byteLength,5130562])),V=r0.concat([v,z]);return $[$.length-1]+=V.byteLength,r0.concat([r0.toView($),W,V])}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){r0.assertView(Z.resources[Y.uri]);return}if(Y.uri.match(/data:/)){let Q=`__${Pd()}.${vZ.extension(Y.uri)}`;Z.resources[Q]=r0.createBufferFromDataURI(Y.uri),Y.uri=Q}}(Z.json.images||[]).forEach((Y)=>{if(Y.bufferView===void 0&&Y.uri===void 0)throw new Error("Missing resource URI or buffer view.");J(Y)}),(Z.json.buffers||[]).forEach(J)}_copyJSON(Z){let{images:J,buffers:X}=Z.json;if(Z={json:u6({},Z.json),resources:u6({},Z.resources)},J)Z.json.images=J.map(($)=>u6({},$));if(X)Z.json.buffers=X.map(($)=>u6({},$));return Z}_binaryToJSON(Z){if(!cd(Z))throw new Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==Vw.JSON)throw new Error("Missing required GLB JSON chunk.");let X=20,$=J[0],Y=r0.decodeText(r0.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]!==Vw.BIN)return{json:Q,resources:{}};let G=W[0],z=r0.toView(Z,K+8,G);return{json:Q,resources:{[Gw]:z}}}}function m21(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function u21(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function cd(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 yR extends Id{constructor(Z=null,J=U4.DEFAULT_INIT){super();this._fetch=void 0,this._fetchConfig=void 0,this._init=void 0,this._fetchEnabled=!1,this._fetch=Z,this._fetchConfig=J,this._init=this.init()}async init(){if(this._init)return this._init;return Promise.all([import("fs"),import("path")]).then(([Z,J])=>{this._fs=Z.promises,this._path=J})}setAllowNetwork(Z){if(Z&&!this._fetch)throw new Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),U4.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw new Error("Network request blocked. Allow HTTP requests explicitly, if needed.");let X=await this._fetch(Z,this._fetchConfig);switch(J){case"view":return new Uint8Array(await X.arrayBuffer());case"text":return X.text()}}else switch(J){case"view":return this._fs.readFile(Z);case"text":return this._fs.readFile(Z,"utf8")}}resolve(Z,J){if(U4.isAbsoluteURL(Z)||U4.isAbsoluteURL(J))return U4.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(U4.isAbsoluteURL(Z))return U4.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:GZ.GLTF,basename:vZ.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 l21(Object.keys(Y),10))await Promise.all(z.map(async function(v){if(U4.isAbsoluteURL(v)){if(U4.extension(v)==="bin")throw new Error(`Cannot write buffer to path "${v}".`);return}let V=K.join(W,decodeURIComponent(v));await Q.mkdir(K.dirname(V),{recursive:!0}),await Q.writeFile(V,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 l21(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 Ts=t(pR(),1),ks=t(Vs(),1),IO1=t(Cs(),1);async function fO1(Z,J){if(!(Z instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:$}=await ks.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return Ts.default(new Uint8Array(X),[$.width,$.height,4],[4,4*$.width|0,1],0)}async function Es(Z,J){return fO1(Z)}var _O1="v4.1.3",cN="@glb.bin",s;(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"})(s||(s={}));var Is;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(Is||(Is={}));var A5;(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"})(A5||(A5={}));var m5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(m5||(m5={}));var wN;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(wN||(wN={}));var UN=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function SO1(){var Z=new UN(3);if(UN!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function FN(Z){var J=Z[0],X=Z[1],$=Z[2];return Math.hypot(J,X,$)}function hO1(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=SO1();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 hs(Z){let J=bs(),X=Z.propertyType===s.NODE?[Z]:Z.listChildren();for(let $ of X)$.traverse((Y)=>{let Q=Y.getMesh();if(!Q)return;let K=bO1(Q,Y.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))xN(K.min,J),xN(K.max,J)});return J}function bO1(Z,J){let X=bs();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=hO1(W,K,J),xN(W,X)}}return X}function xN(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 bs(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class c6{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let $=0;$<J.length;$++)X[$]=J.charCodeAt($);return X}else{let J=Z.split(",")[1],X=Z.indexOf("base64")>=0;return Buffer.from(J,X?"base64":"utf8")}}static encodeText(Z){return new TextEncoder().encode(Z)}static decodeText(Z){return new TextDecoder().decode(Z)}static concat(Z){let J=0;for(let Y of Z)J+=Y.byteLength;let X=new Uint8Array(J),$=0;for(let Y of Z)X.set(Y,$),$+=Y.byteLength;return X}static pad(Z,J=0){let X=this.padNumber(Z.byteLength);if(X===Z.byteLength)return Z;let $=new Uint8Array(X);if($.set(Z),J!==0)for(let Y=Z.byteLength;Y<X;Y++)$[Y]=J;return $}static padNumber(Z){return Math.ceil(Z/4)*4}static equals(Z,J){if(Z===J)return!0;if(Z.byteLength!==J.byteLength)return!1;let X=Z.byteLength;while(X--)if(Z[X]!==J[X])return!1;return!0}static toView(Z,J=0,X=1/0){return new Uint8Array(Z.buffer,Z.byteOffset+J,Math.min(Z.byteLength,X))}static assertView(Z){if(Z&&!ArrayBuffer.isView(Z))throw new Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class As{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),AO1(J,X),$=J.getUint8(X+1),$===192||$===193||$===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class iw{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(c6.decodeText(Z.slice(12,16))===iw.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}}iw.PNG_FRIED_CHUNK_NAME="CgBI";class x9{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}`}}x9.impls={"image/jpeg":new As,"image/png":new iw};function AO1(Z,J){if(J>Z.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return Z}class dG{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 x9.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()}}function fs(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function I$(Z){if(fs(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(fs(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var BN,LN;(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"})(LN||(LN={}));class H7{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=H7.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=H7.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=H7.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=H7.Verbosity.ERROR)console.error(Z)}}BN=H7;H7.Verbosity=LN;H7.DEFAULT_INSTANCE=new BN(BN.Verbosity.INFO);function mO1(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],V=Z[10],H=Z[11],q=Z[12],F=Z[13],w=Z[14],U=Z[15],x=J*K-X*Q,L=J*W-$*Q,j=J*G-Y*Q,c=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,N=z*F-v*q,D=z*w-V*q,P=z*U-H*q,f=v*w-V*F,E=v*U-H*F,_=V*U-H*w;return x*_-L*E+j*f+c*P-R*D+M*N}function uO1(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],V=J[8],H=J[9],q=J[10],F=J[11],w=J[12],U=J[13],x=J[14],L=J[15],j=X[0],c=X[1],R=X[2],M=X[3];return Z[0]=j*$+c*W+R*V+M*w,Z[1]=j*Y+c*G+R*H+M*U,Z[2]=j*Q+c*z+R*q+M*x,Z[3]=j*K+c*v+R*F+M*L,j=X[4],c=X[5],R=X[6],M=X[7],Z[4]=j*$+c*W+R*V+M*w,Z[5]=j*Y+c*G+R*H+M*U,Z[6]=j*Q+c*z+R*q+M*x,Z[7]=j*K+c*v+R*F+M*L,j=X[8],c=X[9],R=X[10],M=X[11],Z[8]=j*$+c*W+R*V+M*w,Z[9]=j*Y+c*G+R*H+M*U,Z[10]=j*Q+c*z+R*q+M*x,Z[11]=j*K+c*v+R*F+M*L,j=X[12],c=X[13],R=X[14],M=X[15],Z[12]=j*$+c*W+R*V+M*w,Z[13]=j*Y+c*G+R*H+M*U,Z[14]=j*Q+c*z+R*q+M*x,Z[15]=j*K+c*v+R*F+M*L,Z}function lO1(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 yO1(Z,J){var X=new UN(3);lO1(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,V=J[6]*Q,H=J[8]*$,q=J[9]*Y,F=J[10]*Q,w=K+v+F,U=0;if(w>0)U=Math.sqrt(w+1)*2,Z[3]=0.25*U,Z[0]=(V-q)/U,Z[1]=(H-G)/U,Z[2]=(W-z)/U;else if(K>v&&K>F)U=Math.sqrt(1+K-v-F)*2,Z[3]=(V-q)/U,Z[0]=0.25*U,Z[1]=(W+z)/U,Z[2]=(H+G)/U;else if(v>F)U=Math.sqrt(1+v-K-F)*2,Z[3]=(H-G)/U,Z[0]=(W+z)/U,Z[1]=0.25*U,Z[2]=(V+q)/U;else U=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/U,Z[0]=(H+G)/U,Z[1]=(V+q)/U,Z[2]=0.25*U;return Z}class X8{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(X8.clamp(Z,0,1)*65535);case 5121:return Math.round(X8.clamp(Z,0,1)*255);case 5122:return Math.round(X8.clamp(Z,-1,1)*32767);case 5120:return Math.round(X8.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,$){let Y=FN([Z[0],Z[1],Z[2]]),Q=FN([Z[4],Z[5],Z[6]]),K=FN([Z[8],Z[9],Z[10]]);if(mO1(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,V=1/K;G[0]*=z,G[1]*=z,G[2]*=z,G[4]*=v,G[5]*=v,G[6]*=v,G[8]*=V,G[9]*=V,G[10]*=V,yO1(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,V=W+W,H=Q*z,q=Q*v,F=Q*V,w=K*v,U=K*V,x=W*V,L=G*z,j=G*v,c=G*V,R=X[0],M=X[1],N=X[2];return Y[0]=(1-(w+x))*R,Y[1]=(q+c)*R,Y[2]=(F-j)*R,Y[3]=0,Y[4]=(q-c)*M,Y[5]=(1-(H+x))*M,Y[6]=(U+L)*M,Y[7]=0,Y[8]=(F+j)*N,Y[9]=(U-L)*N,Y[10]=(1-(H+w))*N,Y[11]=0,Y[12]=Z[0],Y[13]=Z[1],Y[14]=Z[2],Y[15]=1,Y}}function pO1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),$=J.getChild();return X===$||X.equals($)}function iO1(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 gO1(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 ms(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 us(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!I$(Z)||!I$(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(lw(W)&&lw(G)){if(!ms(W,G))return!1}else if(I$(W)&&I$(G)){if(!us(W,G))return!1}else if(W!==G)return!1}return!0}function lw(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var _s="https://null.example";class ON{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return dG.basename(new URL(Z,_s).pathname)}static extension(Z){return dG.extension(new URL(Z,_s).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)}}ON.DEFAULT_INIT={};ON.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var IJ=(Z)=>Z,dO1=new Set;class gw extends UK{constructor(Z,J=""){super(Z);this[b0].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,IJ)}copy(Z,J=IJ){for(let X in this[b0]){let $=this[b0][X];if($ instanceof H5){if(!this[w9].has(X))$.dispose()}else if($ instanceof B6||$ instanceof C0)for(let Y of $.values())Y.dispose();else if($ instanceof a1)for(let Y of $.values())Y.dispose()}for(let X in Z[b0]){let $=this[b0][X],Y=Z[b0][X];if(Y instanceof H5)if(this[w9].has(X))$.getChild().copy(J(Y.getChild()),J);else this.setRef(X,J(Y.getChild()),Y.getAttributes());else if(Y instanceof C0||Y instanceof B6)for(let Q of Y.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if(Y instanceof a1)for(let Q of Y.keys()){let K=Y.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(I$(Y))this[b0][X]=JSON.parse(JSON.stringify(Y));else if(Array.isArray(Y)||Y instanceof ArrayBuffer||ArrayBuffer.isView(Y))this[b0][X]=Y.slice();else this[b0][X]=Y}return this}equals(Z,J=dO1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[b0]){if(J.has(X))continue;let $=this[b0][X],Y=Z[b0][X];if($ instanceof H5||Y instanceof H5){if(!pO1($,Y))return!1}else if($ instanceof C0||Y instanceof C0||$ instanceof B6||Y instanceof B6){if(!iO1($,Y))return!1}else if($ instanceof a1||Y instanceof a1){if(!gO1($,Y))return!1}else if(I$($)||I$(Y)){if(!us($,Y))return!1}else if(lw($)||lw(Y)){if(!ms($,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 O6 extends gw{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new a1})}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 D0 extends O6{init(){this.propertyType=s.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:D0.Type.SCALAR,componentType:D0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case D0.Type.SCALAR:return 1;case D0.Type.VEC2:return 2;case D0.Type.VEC3:return 3;case D0.Type.VEC4:return 4;case D0.Type.MAT2:return 4;case D0.Type.MAT3:return 9;case D0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case D0.ComponentType.BYTE:return 1;case D0.ComponentType.UNSIGNED_BYTE:return 1;case D0.ComponentType.SHORT:return 2;case D0.ComponentType.UNSIGNED_SHORT:return 2;case D0.ComponentType.UNSIGNED_INT:return 4;case D0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMin(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=X8.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]=X8.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 D0.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 X8.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]=X8.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]=X8.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]=X8.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?aO1(Z):D0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}D0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};D0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function aO1(Z){switch(Z.constructor){case Float32Array:return D0.ComponentType.FLOAT;case Uint32Array:return D0.ComponentType.UNSIGNED_INT;case Uint16Array:return D0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return D0.ComponentType.UNSIGNED_BYTE;case Int16Array:return D0.ComponentType.SHORT;case Int8Array:return D0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class MN extends O6{init(){this.propertyType=s.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new C0,samplers:new C0})}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 nG extends O6{init(){this.propertyType=s.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)}}nG.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class TK extends O6{init(){this.propertyType=s.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:TK.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:A5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:A5.OTHER})}}TK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class RN extends O6{init(){this.propertyType=s.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class sG extends O6{init(){this.propertyType=s.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:sG.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)}}sG.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class p1 extends gw{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}p1.EXTENSION_NAME=void 0;class O1 extends O6{init(){this.propertyType=s.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:O1.WrapMode.REPEAT,wrapT:O1.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)}}O1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};O1.MagFilter={NEAREST:9728,LINEAR:9729};O1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:Aw,G:mw,B:uw,A:nO1}=m5;class oG extends O6{init(){this.propertyType=s.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:oG.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new O1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new O1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new O1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new O1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new O1(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:Aw|mw|uw|nO1,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:Aw|mw|uw,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:Aw|mw|uw})}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:Aw})}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:mw|uw})}}oG.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class NN extends O6{init(){this.propertyType=s.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new C0})}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 DN extends O6{init(){this.propertyType=s.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 C0})}copy(Z,J=IJ){if(J===IJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return X8.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 X8.decompose(Z,J,X,$),this.set("translation",J).set("rotation",X).set("scale",$)}getWorldTranslation(){let Z=[0,0,0];return X8.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return X8.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return X8.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())uO1(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===s.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===s.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 fJ extends O6{init(){this.propertyType=s.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:fJ.Mode.TRIANGLES,material:null,indices:null,attributes:new a1,targets:new C0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:A5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:A5.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)}}fJ.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class ls extends gw{init(){this.propertyType=s.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:A5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function yw(){return yw=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},yw.apply(null,arguments)}class PN extends O6{init(){this.propertyType=s.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new C0})}copy(Z,J=IJ){if(J===IJ)throw new Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class CN extends O6{init(){this.propertyType=s.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new C0})}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:A5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class TN extends O6{init(){this.propertyType=s.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||x9.extensionToMimeType(dG.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=x9.extensionToMimeType(dG.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",c6.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return x9.getSize(Z,this.getMimeType())}}class dw extends O6{init(){this.propertyType=s.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${_O1}`,version:"2.0"},defaultScene:null,accessors:new C0,animations:new C0,buffers:new C0,cameras:new C0,materials:new C0,meshes:new C0,nodes:new C0,scenes:new C0,skins:new C0,textures:new C0})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(Z,J=IJ){if(J===IJ)throw new Error("Root cannot be copied.");this.set("asset",yw({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(yw({},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 PN)this.addRef("scenes",Z);else if(Z instanceof DN)this.addRef("nodes",Z);else if(Z instanceof sG)this.addRef("cameras",Z);else if(Z instanceof CN)this.addRef("skins",Z);else if(Z instanceof NN)this.addRef("meshes",Z);else if(Z instanceof oG)this.addRef("materials",Z);else if(Z instanceof TN)this.addRef("textures",Z);else if(Z instanceof MN)this.addRef("animations",Z);else if(Z instanceof D0)this.addRef("accessors",Z);else if(Z instanceof RN)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 pw{static fromGraph(Z){return pw._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new wK,this._root=new dw(this._graph),this._logger=H7.DEFAULT_INSTANCE,pw._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(($)=>$.extensionName===J)||new Z(this)}createScene(Z=""){return new PN(this._graph,Z)}createNode(Z=""){return new DN(this._graph,Z)}createCamera(Z=""){return new sG(this._graph,Z)}createSkin(Z=""){return new CN(this._graph,Z)}createMesh(Z=""){return new NN(this._graph,Z)}createPrimitive(){return new fJ(this._graph)}createPrimitiveTarget(Z=""){return new ls(this._graph,Z)}createMaterial(Z=""){return new oG(this._graph,Z)}createTexture(Z=""){return new TN(this._graph,Z)}createAnimation(Z=""){return new MN(this._graph,Z)}createAnimationChannel(Z=""){return new nG(this._graph,Z)}createAnimationSampler(Z=""){return new TK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new D0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new RN(this._graph,Z)}}pw._GRAPH_DOCUMENTS=new WeakMap;class N1{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 p1&&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}}N1.EXTENSION_NAME=void 0;var cP6={logger:H7.DEFAULT_INSTANCE,extensions:[],dependencies:{}},OP6=new Set([s.BUFFER,s.TEXTURE,s.MATERIAL,s.MESH,s.PRIMITIVE,s.NODE,s.SCENE]);var aG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(aG||(aG={}));class _J{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 jN(Y>1,()=>X.basename||"buffer"),this.imageURIGenerator=new jN(Q>1,(K)=>sO1(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===wN.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 $=x9.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,$),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let $=this.jsonDoc.resources;if(!(Z in $)){$[Z]=J;return}if(J===$[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let Y=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn(Y);return}throw new Error(Y)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return A5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:$}=X.getAttributes();if($)return $;if(X.getParent().propertyType!==s.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return A5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw new Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}_J.BufferViewTarget=aG;_J.BufferViewUsage=A5;_J.USAGE_TO_TARGET={[A5.ARRAY_BUFFER]:aG.ARRAY_BUFFER,[A5.ELEMENT_ARRAY_BUFFER]:aG.ELEMENT_ARRAY_BUFFER};class jN{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 sO1(Z,J){let X=Z.getGraph().listParentEdges(J).find(($)=>$.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{UNSIGNED_INT:MP6,UNSIGNED_SHORT:RP6,UNSIGNED_BYTE:NP6}=D0.ComponentType,DP6=new Set([s.ACCESSOR,s.BUFFER,s.MATERIAL,s.MESH]);var Ss;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(Ss||(Ss={}));var ps=163,is=166;function oO1(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,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 kK{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 TP6=new Uint8Array([0]),i6=[171,75,84,88,32,50,48,187,13,10,26,10];function ys(Z){return new TextDecoder().decode(Z)}function aw(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,i6.length);if(J[0]!==i6[0]||J[1]!==i6[1]||J[2]!==i6[2]||J[3]!==i6[3]||J[4]!==i6[4]||J[5]!==i6[5]||J[6]!==i6[6]||J[7]!==i6[7]||J[8]!==i6[8]||J[9]!==i6[9]||J[10]!==i6[10]||J[11]!==i6[11])throw new Error("Missing KTX 2.0 identifier.");let X=oO1(),$=17*Uint32Array.BYTES_PER_ELEMENT,Y=new kK(Z,i6.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();let Q=Y._nextUint32();X.supercompressionScheme=Y._nextUint32();let K=Y._nextUint32(),W=Y._nextUint32(),G=Y._nextUint32(),z=Y._nextUint32(),v=Y._nextUint64(),V=Y._nextUint64(),H=Q*3*8,q=new kK(Z,i6.length+$,H,!0);for(let J6=0;J6<Q;J6++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+q._nextUint64(),q._nextUint64()),uncompressedByteLength:q._nextUint64()});let F=new kK(Z,K,W,!0);F._skip(4);let w=F._nextUint16(),U=F._nextUint16(),x=F._nextUint16(),L=F._nextUint16(),j=F._nextUint8(),c=F._nextUint8(),R=F._nextUint8(),M=F._nextUint8(),N=[F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8()],D=[F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8()],f={vendorId:w,descriptorType:U,versionNumber:x,colorModel:j,colorPrimaries:c,transferFunction:R,flags:M,texelBlockDimension:N,bytesPlane:D,samples:[]},E=6,_=4,T=(L/4-E)/_;for(let J6=0;J6<T;J6++){let s7={bitOffset:F._nextUint16(),bitLength:F._nextUint8(),channelType:F._nextUint8(),samplePosition:[F._nextUint8(),F._nextUint8(),F._nextUint8(),F._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(s7.channelType&64)s7.sampleLower=F._nextInt32(),s7.sampleUpper=F._nextInt32();else s7.sampleLower=F._nextUint32(),s7.sampleUpper=F._nextUint32();f.samples[J6]=s7}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(f);let k=new kK(Z,G,z,!0);while(k._offset<z){let J6=k._nextUint32(),s7=k._scan(J6),gV=ys(s7);if(X.keyValue[gV]=k._nextUint8Array(J6-s7.byteLength-1),gV.match(/^ktx/i)){let Um=ys(X.keyValue[gV]);X.keyValue[gV]=Um.substring(0,Um.lastIndexOf("\x00"))}let tG1=J6%4?4-J6%4:0;k._skip(tG1)}if(V<=0)return X;let h=new kK(Z,v,V,!0),u=h._nextUint16(),a=h._nextUint16(),o=h._nextUint32(),Q0=h._nextUint32(),W0=h._nextUint32(),E0=h._nextUint32(),I0=[];for(let J6=0;J6<Q;J6++)I0.push({imageFlags:h._nextUint32(),rgbSliceByteOffset:h._nextUint32(),rgbSliceByteLength:h._nextUint32(),alphaSliceByteOffset:h._nextUint32(),alphaSliceByteLength:h._nextUint32()});let t0=v+h._offset,C8=t0+o,g1=C8+Q0,s9=g1+W0,Y9=new Uint8Array(Z.buffer,Z.byteOffset+t0,o),lQ=new Uint8Array(Z.buffer,Z.byteOffset+C8,Q0),yQ=new Uint8Array(Z.buffer,Z.byteOffset+g1,W0),G$=new Uint8Array(Z.buffer,Z.byteOffset+s9,E0);return X.globalData={endpointCount:u,selectorCount:a,imageDescs:I0,endpointsData:Y9,selectorsData:lQ,tablesData:yQ,extendedData:G$},X}var _N="EXT_mesh_gpu_instancing",EN="EXT_meshopt_compression",rO1="EXT_texture_webp",tO1="EXT_texture_avif",Yo="KHR_draco_mesh_compression",SN="KHR_lights_punctual",hN="KHR_materials_anisotropy",bN="KHR_materials_clearcoat",AN="KHR_materials_diffuse_transmission",mN="KHR_materials_dispersion",uN="KHR_materials_emissive_strength",lN="KHR_materials_ior",yN="KHR_materials_iridescence",pN="KHR_materials_pbrSpecularGlossiness",iN="KHR_materials_sheen",gN="KHR_materials_specular",dN="KHR_materials_transmission",aN="KHR_materials_unlit",nN="KHR_materials_volume",a$="KHR_materials_variants",eO1="KHR_mesh_quantization",ZM1="KHR_texture_basisu",sN="KHR_texture_transform",nw="KHR_xmp_json_ld",IN="INSTANCE_ATTRIBUTE";class oN extends p1{init(){this.extensionName=_N,this.propertyType="InstancedMesh",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:IN})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}oN.EXTENSION_NAME=_N;var f$=_N;class rw extends N1{constructor(...Z){super(...Z);this.extensionName=f$,this.provideTypes=[s.NODE],this.prewriteTypes=[s.ACCESSOR]}createInstancedMesh(){return new oN(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[f$])return;let Q=$.extensions[f$],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[Y].setExtension(f$,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(IN);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,IN);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let $=X.getExtension(f$);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[f$]=K}}),this}}rw.EXTENSION_NAME=f$;function FZ(){return FZ=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},FZ.apply(null,arguments)}var Zz;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(Zz||(Zz={}));var IK;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(IK||(IK={}));var $8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})($8||($8={}));var{BYTE:JM1,SHORT:gs,FLOAT:XM1}=D0.ComponentType,{encodeNormalizedInt:ds,decodeNormalizedInt:fN}=X8;function $M1(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!==IK.ATTRIBUTES)return K;if(Y!==$8.NONE){let W=Z.getNormalized()?YM1(Z):new Float32Array(K.array);switch(Y){case $8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=XM1,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?gs:JM1,K.normalized=!0,W=Z.getElementSize()===3?KM1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case $8.QUATERNION:K.byteStride=8,K.componentType=gs,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw new Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>fN(G,Z.getComponentType())),K.max=K.max.map((G)=>fN(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>ds(G,K.componentType)),K.max=K.max.map((G)=>ds(G,K.componentType))}else if(K.byteStride%4)K.array=QM1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function YM1(Z){let J=Z.getComponentType(),X=Z.getArray(),$=new Float32Array(X.length);for(let Y=0;Y<X.length;Y++)$[Y]=fN(X[Y],J);return $}function QM1(Z,J){let $=c6.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 KM1(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 WM1(Z,J){if(J===_J.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some(($)=>{return $ instanceof fJ&&$.getMode()===fJ.Mode.TRIANGLES})?IK.TRIANGLES:IK.INDICES;return IK.ATTRIBUTES}function GM1(Z,J){let X=J.getGraph().listParentEdges(Z).filter(($)=>!($.getParent()instanceof dw));for(let $ of X){let Y=$.getName(),Q=$.getAttributes().key||"",K=$.getParent().propertyType===s.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=Qo(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 Qo(Z){for(let J of Z.listParents()){if(!(J instanceof TK))continue;for(let X of J.listParents()){if(!(X instanceof nG))continue;return X.getTargetPath()}}return null}function zM1(Z){if(!Z.extensions||!Z.extensions[EN])return!1;return!!Z.extensions[EN].fallback}var g6=EN,as={method:Zz.QUANTIZE};class Xz extends N1{constructor(...Z){super(...Z);this.extensionName=g6,this.prereadTypes=[s.BUFFER,s.PRIMITIVE],this.prewriteTypes=[s.BUFFER,s.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=as,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=FZ({},as,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${g6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${g6}]: Missing WASM support.`)}if(J===s.BUFFER)this._prereadBuffers(Z);else if(J===s.PRIMITIVE)this._prereadPrimitives(Z);return this}_prereadBuffers(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[g6])return;let Q=$.extensions[g6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,z=Q.byteStride,v=new Uint8Array(G*z),V=J.json.buffers[Q.buffer],H=V.uri?J.resources[V.uri]:J.resources[cN],q=c6.toView(H,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[g6])return;let Y=$.extensions[g6],Q=Z.buffers[Y.buffer],K=Z.buffers[$.buffer],W=J.json.buffers[$.buffer];if(zM1(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 D0)$.swap(J,X);J.dispose()}return this}prewrite(Z,J){if(J===s.ACCESSOR)this._prewriteAccessors(Z);else if(J===s.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 V of Y.listParents(v)){if(V.propertyType===s.ROOT)continue;let H=G.get(v);if(H===void 0)G.set(v,H=W++);return H}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let v of this.document.getRoot().listAccessors()){if(Qo(v)==="weights")continue;if(v.getSparse())continue;let V=Z.getAccessorUsage(v),H=Z.accessorUsageGroupedByParent.has(V)?z(v):null,q=WM1(v,V),F=$.method===Zz.FILTER?GM1(v,this.document):{filter:$8.NONE},w=$M1(v,X,q,F),{array:U,byteStride:x}=w,L=v.getBuffer();if(!L)throw new Error(`${g6}: Missing buffer for accessor.`);let j=this.document.getRoot().listBuffers().indexOf(L),c=[V,H,q,F.filter,x,j].join(":"),R=this._encoderBufferViews[c],M=this._encoderBufferViewData[c],N=this._encoderBufferViewAccessors[c];if(!R||!M)N=this._encoderBufferViewAccessors[c]=[],M=this._encoderBufferViewData[c]=[],R=this._encoderBufferViews[c]={buffer:K,target:_J.USAGE_TO_TARGET[V],byteOffset:0,byteLength:0,byteStride:V===_J.BufferViewUsage.ARRAY_BUFFER?x:void 0,extensions:{[g6]:{buffer:j,byteOffset:0,byteLength:0,mode:q,filter:F.filter!==$8.NONE?F.filter:void 0,byteStride:x,count:0}}};let D=Z.createAccessorDef(v);if(D.componentType=w.componentType,D.normalized=w.normalized,D.byteOffset=R.byteLength,D.min&&w.min)D.min=w.min;if(D.max&&w.max)D.max=w.max;Z.accessorIndexMap.set(v,J.accessors.length),J.accessors.push(D),N.push(D),M.push(new Uint8Array(U.buffer,U.byteOffset,U.byteLength)),R.byteLength+=U.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[g6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:z}=$.extensions[g6],v=c6.concat(Y),V=J.encodeGltfBuffer(v,W,G,z),H=c6.pad(V);$.extensions[g6].byteLength=V.byteLength,Y.length=0,Y.push(H),K.push(H),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],V=v.byteOffset||0;Object.assign(v,K),v.byteOffset=J;let H=v.extensions[g6];H.byteOffset=V,J+=c6.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,$=Z.bufferIndexMap.get(X),Y=Z.jsonDoc.json.buffers[$];return Y.byteLength=J,Y.extensions={[g6]:{fallback:!0}},X.dispose(),this}}Xz.EXTENSION_NAME=g6;Xz.EncoderMethod=Zz;var rG=tO1;class Ko{match(Z){return Z.length>=12&&c6.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=ns(J,0);if(!X)return null;let $=X.end;while(X=ns(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 tw extends N1{constructor(...Z){super(...Z);this.extensionName=rG,this.prereadTypes=[s.TEXTURE]}static register(){x9.registerFormat("image/avif",new Ko)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[rG])X.source=X.extensions[rG].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[rG]={source:Q.source},delete Q.source})}}),this}}tw.EXTENSION_NAME=rG;function ns(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:c6.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}var tG=rO1;class Wo{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=c6.decodeText(Z.slice(0,4)),X=c6.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=c6.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),V=1+((G&63)<<8|W),H=1+((v&15)<<10|z<<2|(G&192)>>6);return[V,H]}Y+=8+K+K%2}return null}getChannels(Z){return 4}}class ew extends N1{constructor(...Z){super(...Z);this.extensionName=tG,this.prereadTypes=[s.TEXTURE]}static register(){x9.registerFormat("image/webp",new Wo)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[tG])X.source=X.extensions[tG].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[tG]={source:Q.source},delete Q.source})}}),this}}ew.EXTENSION_NAME=tG;var ss=Yo,b8,Go,zo;function vM1(Z,J){let X=new b8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==b8.TRIANGULAR_MESH)throw new Error(`[${ss}] Unknown geometry type.`);let Y=new b8.Mesh;if(!Z.DecodeBufferToMesh(X,Y).ok()||Y.ptr===0)throw new Error(`[${ss}] Decoding failure.`);return Y}finally{b8.destroy(X)}}function HM1(Z,J){let $=J.num_faces()*3,Y,Q;if(J.num_points()<=65534){let K=$*Uint16Array.BYTES_PER_ELEMENT;Y=b8._malloc(K),Z.GetTrianglesUInt16Array(J,K,Y),Q=new Uint16Array(b8.HEAPU16.buffer,Y,$).slice()}else{let K=$*Uint32Array.BYTES_PER_ELEMENT;Y=b8._malloc(K),Z.GetTrianglesUInt32Array(J,K,Y),Q=new Uint32Array(b8.HEAPU32.buffer,Y,$).slice()}return b8._free(Y),Q}function VM1(Z,J,X,$){let Y=zo[$.componentType],Q=Go[$.componentType],K=X.num_components(),G=J.num_points()*K,z=G*Q.BYTES_PER_ELEMENT,v=b8._malloc(z);Z.GetAttributeDataArrayForAllPoints(J,X,Y,z,v);let V=new Q(b8.HEAPF32.buffer,v,G).slice();return b8._free(v),V}function qM1(Z){b8=Z,Go={[D0.ComponentType.FLOAT]:Float32Array,[D0.ComponentType.UNSIGNED_INT]:Uint32Array,[D0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[D0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[D0.ComponentType.SHORT]:Int16Array,[D0.ComponentType.BYTE]:Int8Array},zo={[D0.ComponentType.FLOAT]:b8.DT_FLOAT32,[D0.ComponentType.UNSIGNED_INT]:b8.DT_UINT32,[D0.ComponentType.UNSIGNED_SHORT]:b8.DT_UINT16,[D0.ComponentType.UNSIGNED_BYTE]:b8.DT_UINT8,[D0.ComponentType.SHORT]:b8.DT_INT16,[D0.ComponentType.BYTE]:b8.DT_INT8}}var B4,Jz;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(Jz||(Jz={}));var L4;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(L4||(L4={}));var vo={[L4.POSITION]:14,[L4.NORMAL]:10,[L4.COLOR]:8,[L4.TEX_COORD]:12,[L4.GENERIC]:12},os={decodeSpeed:5,encodeSpeed:5,method:Jz.EDGEBREAKER,quantizationBits:vo,quantizationVolume:"mesh"};function FM1(Z){B4=Z}function wM1(Z,J=os){let X=FZ({},os,J);X.quantizationBits=FZ({},vo,J.quantizationBits);let $=new B4.MeshBuilder,Y=new B4.Mesh,Q=new B4.ExpertEncoder(Y),K={},W=new B4.DracoInt8Array,G=Z.listTargets().length>0,z=!1;for(let w of Z.listSemantics()){let U=Z.getAttribute(w);if(U.getSparse()){z=!0;continue}let x=UM1(w),L=xM1($,U.getComponentType(),Y,B4[x],U.getCount(),U.getElementSize(),U.getArray());if(L===-1)throw new Error(`Error compressing "${w}" attribute.`);if(K[w]=L,X.quantizationVolume==="mesh"||w!=="POSITION")Q.SetAttributeQuantization(L,X.quantizationBits[x]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:j}=X,c=Math.max(j.max[0]-j.min[0],j.max[1]-j.min[1],j.max[2]-j.min[2]);Q.SetAttributeExplicitQuantization(L,X.quantizationBits[x],U.getElementSize(),j.min,c)}else throw new Error("Invalid quantization volume state.")}let v=Z.getIndices();if(!v)throw new sw("Primitive must have indices.");if($.AddFacesToMesh(Y,v.getCount()/3,v.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===Jz.SEQUENTIAL||G||z)Q.SetEncodingMethod(B4.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(B4.MESH_EDGEBREAKER_ENCODING);let V=Q.EncodeToDracoBuffer(!(G||z),W);if(V<=0)throw new sw("Error applying Draco compression.");let H=new Uint8Array(V);for(let w=0;w<V;++w)H[w]=W.GetValue(w);let q=Q.GetNumberOfEncodedPoints(),F=Q.GetNumberOfEncodedFaces()*3;return B4.destroy(W),B4.destroy(Y),B4.destroy($),B4.destroy(Q),{numVertices:q,numIndices:F,data:H,attributeIDs:K}}function UM1(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 xM1(Z,J,X,$,Y,Q,K){switch(J){case D0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,$,Y,Q,K);case D0.ComponentType.BYTE:return Z.AddInt8Attribute(X,$,Y,Q,K);case D0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,$,Y,Q,K);case D0.ComponentType.SHORT:return Z.AddInt16Attribute(X,$,Y,Q,K);case D0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,$,Y,Q,K);case D0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,$,Y,Q,K);default:throw new Error(`Unexpected component type, "${J}".`)}}class sw extends Error{}var j8=Yo;class $z extends N1{constructor(...Z){super(...Z);this.extensionName=j8,this.prereadTypes=[s.PRIMITIVE],this.prewriteTypes=[s.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,qM1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,FM1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw new Error(`[${j8}] 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[j8])continue;let W=K.extensions[j8],[G,z]=$.get(W.bufferView)||[];if(!z||!G){let v=X.json.bufferViews[W.bufferView],V=X.json.buffers[v.buffer],H=V.uri?X.resources[V.uri]:X.resources[cN],q=v.byteOffset||0,F=v.byteLength,w=c6.toView(H,q,F);G=new this._decoderModule.Decoder,z=vM1(G,w),$.set(W.bufferView,[G,z]),J.debug(`[${j8}] Decompressed ${w.byteLength} bytes.`)}for(let v in W.attributes){let V=Z.jsonDoc.json.accessors[K.attributes[v]],H=G.GetAttributeByUniqueId(z,W.attributes[v]),q=VM1(G,z,H,V);Z.accessors[K.attributes[v]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(HM1(G,z))}}finally{for(let[Y,Q]of Array.from($.values()))this._decoderModule.destroy(Y),this._decoderModule.destroy(Q)}return this}read(Z){return this}prewrite(Z,J){if(!this._encoderModule)throw new Error(`[${j8}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${j8}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let $=BM1(this.document),Y=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${j8}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=hs(this.document.getRoot().listScenes().pop());for(let K of Array.from($.keys())){let W=$.get(K);if(!W)throw new Error("Unexpected primitive.");if(Y.has(W)){Y.set(W,Y.get(W));continue}let G=K.getIndices(),z=Z.jsonDoc.json.accessors,v;try{v=wM1(K,FZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof sw){X.warn(`[${j8}]: ${q.message} Skipping primitive compression.`);continue}throw q}Y.set(W,v);let V=Z.createAccessorDef(G);if(V.count=v.numIndices,Z.accessorIndexMap.set(G,z.length),z.push(V),v.numVertices>65534&&D0.getComponentSize(V.componentType)<=2)V.componentType=D0.ComponentType.UNSIGNED_INT;else if(v.numVertices>254&&D0.getComponentSize(V.componentType)<=1)V.componentType=D0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let F=K.getAttribute(q);if(v.attributeIDs[q]===void 0)continue;let w=Z.createAccessorDef(F);w.count=v.numVertices,Z.accessorIndexMap.set(F,z.length),z.push(w)}let H=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(H))Z.otherBufferViews.set(H,[]);Z.otherBufferViews.get(H).push(v.data)}return X.debug(`[${j8}] Compressed ${$.size} primitives.`),Z.extensionData[j8]={primitiveHashMap:$,primitiveEncodingMap:Y},this}write(Z){let J=Z.extensionData[j8];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[j8]={bufferView:Z.otherBufferViewsIndexMap.get(G.data),attributes:G.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter(($)=>$!==j8),X.extensionsRequired=(X.extensionsRequired||[]).filter(($)=>$!==j8)}return this}}$z.EXTENSION_NAME=j8;$z.EncoderMethod=Jz;function BM1(Z){let J=Z.getLogger(),X=new Set,$=new Set,Y=0,Q=0;for(let V of Z.getRoot().listMeshes())for(let H of V.listPrimitives())if(!H.getIndices())$.add(H),Y++;else if(H.getMode()!==fJ.Mode.TRIANGLES)$.add(H),Q++;else X.add(H);if(Y>0)J.warn(`[${j8}] Skipping Draco compression of ${Y} non-indexed primitives.`);if(Q>0)J.warn(`[${j8}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),W=new Map;for(let V=0;V<K.length;V++)W.set(K[V],V);let G=new Map,z=new Set,v=new Map;for(let V of Array.from(X)){let H=rs(V,W);if(z.has(H)){v.set(V,H);continue}if(G.has(V.getIndices())){let q=V.getIndices(),F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),V.swap(q,F)}for(let q of V.listAttributes())if(G.has(q)){let F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),V.swap(q,F)}H=rs(V,W),z.add(H),v.set(V,H),G.set(V.getIndices(),H);for(let q of V.listAttributes())G.set(q,H)}for(let V of Array.from(G.keys())){let H=new Set(V.listParents().map((q)=>q.propertyType));if(H.size!==2||!H.has(s.PRIMITIVE)||!H.has(s.ROOT))throw new Error(`[${j8}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let V of Array.from(X)){let H=v.get(V),q=V.getIndices();if(G.get(q)!==H||V.listAttributes().some((F)=>G.get(F)!==H))throw new Error(`[${j8}] Draco primitives must share all, or no, accessors.`)}for(let V of Array.from($)){let H=V.getIndices();if(G.has(H)||V.listAttributes().some((q)=>G.has(q)))throw new Error(`[${j8}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return v}function rs(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 fK extends p1{init(){this.extensionName=SN,this.propertyType="Light",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:fK.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)}}fK.EXTENSION_NAME=SN;fK.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};var V7=SN;class rN extends N1{constructor(...Z){super(...Z);this.extensionName=V7}createLight(Z=""){return new fK(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[V7])return this;let Y=(J.json.extensions[V7].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[V7])return;let W=Q.extensions[V7];Z.nodes[K].setExtension(V7,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(!X8.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()===fK.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(V7);if(Q){let K=Z.nodeIndexMap.get(Y),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[V7]={light:$.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[V7]={lights:X},this}}rN.EXTENSION_NAME=V7;var{R:LM1,G:jM1,B:cM1}=m5;class tN extends p1{init(){this.extensionName=hN,this.propertyType="Anisotropy",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new O1(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:LM1|jM1|cM1})}}tN.EXTENSION_NAME=hN;var _$=hN;class eN extends N1{constructor(...Z){super(...Z);this.extensionName=_$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createAnisotropy(){return new tN(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[_$]){let K=this.createAnisotropy();Z.materials[Q].setExtension(_$,K);let W=Y.extensions[_$];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(_$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[_$]={};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}}eN.EXTENSION_NAME=_$;var{R:ts,G:es,B:OM1}=m5;class ZD extends p1{init(){this.extensionName=bN,this.propertyType="Clearcoat",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new O1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new O1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new O1(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:ts})}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:es})}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:ts|es|OM1})}}ZD.EXTENSION_NAME=bN;var S$=bN;class JD extends N1{constructor(...Z){super(...Z);this.extensionName=S$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createClearcoat(){return new ZD(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[S$]){let K=this.createClearcoat();Z.materials[Q].setExtension(S$,K);let W=Y.extensions[S$];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(S$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[S$]={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}}JD.EXTENSION_NAME=S$;var{R:MM1,G:RM1,B:NM1,A:DM1}=m5;class XD extends p1{init(){this.extensionName=AN,this.propertyType="DiffuseTransmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new O1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new O1(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:DM1})}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:MM1|RM1|NM1})}}XD.EXTENSION_NAME=AN;var h$=AN;class $D extends N1{constructor(...Z){super(...Z);this.extensionName=h$}createDiffuseTransmission(){return new XD(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[h$]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(h$,K);let W=Y.extensions[h$];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(h$);if(!$)continue;let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[h$]={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}}$D.EXTENSION_NAME=h$;class YD extends p1{init(){this.extensionName=mN,this.propertyType="Dispersion",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}YD.EXTENSION_NAME=mN;var b$=mN;class QD extends N1{constructor(...Z){super(...Z);this.extensionName=b$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createDispersion(){return new YD(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[b$]){let Q=this.createDispersion();Z.materials[Y].setExtension(b$,Q);let K=$.extensions[b$];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(b$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[b$]={dispersion:$.getDispersion()}}}),this}}QD.EXTENSION_NAME=b$;class KD extends p1{init(){this.extensionName=uN,this.propertyType="EmissiveStrength",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}KD.EXTENSION_NAME=uN;var A$=uN;class WD extends N1{constructor(...Z){super(...Z);this.extensionName=A$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createEmissiveStrength(){return new KD(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[A$]){let Q=this.createEmissiveStrength();Z.materials[Y].setExtension(A$,Q);let K=$.extensions[A$];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(A$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[A$]={emissiveStrength:$.getEmissiveStrength()}}}),this}}WD.EXTENSION_NAME=A$;class GD extends p1{init(){this.extensionName=lN,this.propertyType="IOR",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}GD.EXTENSION_NAME=lN;var m$=lN;class ZU extends N1{constructor(...Z){super(...Z);this.extensionName=m$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIOR(){return new GD(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[m$]){let Q=this.createIOR();Z.materials[Y].setExtension(m$,Q);let K=$.extensions[m$];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(m$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[m$]={ior:$.getIOR()}}}),this}}ZU.EXTENSION_NAME=m$;var{R:PM1,G:CM1}=m5;class zD extends p1{init(){this.extensionName=yN,this.propertyType="Iridescence",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new O1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new O1(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:PM1})}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:CM1})}}zD.EXTENSION_NAME=yN;var u$=yN;class vD extends N1{constructor(...Z){super(...Z);this.extensionName=u$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIridescence(){return new zD(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[u$]){let K=this.createIridescence();Z.materials[Q].setExtension(u$,K);let W=Y.extensions[u$];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(u$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[u$]={};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}}vD.EXTENSION_NAME=u$;var{R:Zo,G:Jo,B:Xo,A:$o}=m5;class HD extends p1{init(){this.extensionName=pN,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new O1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new O1(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:Zo|Jo|Xo|$o,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:Zo|Jo|Xo|$o})}}HD.EXTENSION_NAME=pN;var l$=pN;class JU extends N1{constructor(...Z){super(...Z);this.extensionName=l$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createPBRSpecularGlossiness(){return new HD(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[l$]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(l$,K);let W=Y.extensions[l$];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(l$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[l$]={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}}JU.EXTENSION_NAME=l$;var{R:TM1,G:kM1,B:EM1,A:IM1}=m5;class VD extends p1{init(){this.extensionName=iN,this.propertyType="Sheen",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new O1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new O1(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:TM1|kM1|EM1,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:IM1})}}VD.EXTENSION_NAME=iN;var y$=iN;class qD extends N1{constructor(...Z){super(...Z);this.extensionName=y$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSheen(){return new VD(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[y$]){let K=this.createSheen();Z.materials[Q].setExtension(y$,K);let W=Y.extensions[y$];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(y$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[y$]={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}}qD.EXTENSION_NAME=y$;var{R:fM1,G:_M1,B:SM1,A:hM1}=m5;class FD extends p1{init(){this.extensionName=gN,this.propertyType="Specular",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new O1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new O1(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:hM1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:fM1|_M1|SM1,isColor:!0})}}FD.EXTENSION_NAME=gN;var p$=gN;class XU extends N1{constructor(...Z){super(...Z);this.extensionName=p$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSpecular(){return new FD(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[p$]){let K=this.createSpecular();Z.materials[Q].setExtension(p$,K);let W=Y.extensions[p$];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(p$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[p$]={};if($.getSpecularFactor()!==1)K.specularFactor=$.getSpecularFactor();if(!X8.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}}XU.EXTENSION_NAME=p$;var{R:bM1}=m5;class wD extends p1{init(){this.extensionName=dN,this.propertyType="Transmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new O1(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:bM1})}}wD.EXTENSION_NAME=dN;var i$=dN;class UD extends N1{constructor(...Z){super(...Z);this.extensionName=i$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createTransmission(){return new wD(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[i$]){let K=this.createTransmission();Z.materials[Q].setExtension(i$,K);let W=Y.extensions[i$];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(i$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[i$]={transmissionFactor:$.getTransmissionFactor()};if($.getTransmissionTexture()){let W=$.getTransmissionTexture(),G=$.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}UD.EXTENSION_NAME=i$;class xD extends p1{init(){this.extensionName=aN,this.propertyType="Unlit",this.parentTypes=[s.MATERIAL]}}xD.EXTENSION_NAME=aN;var EK=aN;class $U extends N1{constructor(...Z){super(...Z);this.extensionName=EK,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createUnlit(){return new xD(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[EK])Z.materials[$].setExtension(EK,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(EK)){let $=Z.materialIndexMap.get(X),Y=J.json.materials[$];Y.extensions=Y.extensions||{},Y.extensions[EK]={}}}),this}}$U.EXTENSION_NAME=EK;class BD extends p1{init(){this.extensionName=a$,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new C0})}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")}}BD.EXTENSION_NAME=a$;class LD extends p1{init(){this.extensionName=a$,this.propertyType="MappingList",this.parentTypes=[s.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new C0})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}LD.EXTENSION_NAME=a$;class ow extends p1{init(){this.extensionName=a$,this.propertyType="Variant",this.parentTypes=["MappingList"]}}ow.EXTENSION_NAME=a$;var q7=a$;class jD extends N1{constructor(...Z){super(...Z);this.extensionName=q7}createMappingList(){return new LD(this.document.getGraph())}createVariant(Z=""){return new ow(this.document.getGraph(),Z)}createMapping(){return new BD(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof ow)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[q7])return this;let Y=(J.json.extensions[q7].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((v,V)=>{if(!v.extensions||!v.extensions[q7])return;let H=this.createMappingList(),q=v.extensions[q7];for(let F of q.mappings){let w=this.createMapping();if(F.material!==void 0)w.setMaterial(Z.materials[F.material]);for(let U of F.variants||[])w.addVariant(Y[U]);H.addMapping(w)}G.listPrimitives()[V].setExtension(q7,H)})}),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(q7);if(!z)return;let v=Z.jsonDoc.json.meshes[K].primitives[G],V=z.listMappings().map((H)=>{let q=Z.createPropertyDef(H),F=H.getMaterial();if(F)q.material=Z.materialIndexMap.get(F);return q.variants=H.listVariants().map((w)=>Y.get(w)),q});v.extensions=v.extensions||{},v.extensions[q7]={mappings:V}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[q7]={variants:$},this}}jD.EXTENSION_NAME=q7;var{G:AM1}=m5;class cD extends p1{init(){this.extensionName=nN,this.propertyType="Volume",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new O1(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:AM1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}cD.EXTENSION_NAME=nN;var g$=nN;class OD extends N1{constructor(...Z){super(...Z);this.extensionName=g$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createVolume(){return new cD(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[g$]){let K=this.createVolume();Z.materials[Q].setExtension(g$,K);let W=Y.extensions[g$];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(g$);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[g$]={};if($.getThicknessFactor()>0)K.thicknessFactor=$.getThicknessFactor();if(Number.isFinite($.getAttenuationDistance()))K.attenuationDistance=$.getAttenuationDistance();if(!X8.eq($.getAttenuationColor(),[1,1,1]))K.attenuationColor=$.getAttenuationColor();if($.getThicknessTexture()){let W=$.getThicknessTexture(),G=$.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}OD.EXTENSION_NAME=g$;var Ho=eO1;class Yz extends N1{constructor(...Z){super(...Z);this.extensionName=Ho}read(Z){return this}write(Z){return this}}Yz.EXTENSION_NAME=Ho;var eG=ZM1;class Vo{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=aw(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=aw(Z).dataFormatDescriptor[0];if(X.colorModel===ps)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===is)return(X.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=aw(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 MD extends N1{constructor(...Z){super(...Z);this.extensionName=eG,this.prereadTypes=[s.TEXTURE]}static register(){x9.registerFormat("image/ktx2",new Vo)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[eG]){let X=J.extensions[eG];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[eG]={source:Y.source},delete Y.source})}}),this}}MD.EXTENSION_NAME=eG;class RD extends p1{init(){this.extensionName=sN,this.propertyType="Transform",this.parentTypes=[s.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)}}RD.EXTENSION_NAME=sN;var d$=sN;class ND extends N1{constructor(...Z){super(...Z);this.extensionName=d$}createTransform(){return new RD(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[d$])continue;let $=this.createTransform(),Y=X.extensions[d$];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(d$,$)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,$]of J){let Y=X.getExtension(d$);if(!Y)continue;$.extensions=$.extensions||{};let Q={},K=X8.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[d$]=Q}return this}}ND.EXTENSION_NAME=d$;var mM1=[s.ROOT,s.SCENE,s.NODE,s.MESH,s.MATERIAL,s.TEXTURE,s.ANIMATION];class DD extends p1{init(){this.extensionName=nw,this.propertyType="Packet",this.parentTypes=mM1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",FZ({},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=FZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=kN(this.get("context")),J=kN(this.get("properties"));return FZ({"@context":Z},J)}fromJSONLD(Z){Z=kN(Z);let J=Z["@context"];if(J)this.set("context",J);return delete Z["@context"],this.set("properties",Z)}_assertContext(Z){if(!(Z.split(":")[0]in this.get("context")))throw new Error(`${nw}: Missing context for term, "${Z}".`)}}DD.EXTENSION_NAME=nw;function kN(Z){return JSON.parse(JSON.stringify(Z))}var qZ=nw;class PD extends N1{constructor(...Z){super(...Z);this.extensionName=qZ}createPacket(){return new DD(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[qZ];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 V=z[v];if(V.extensions&&V.extensions[qZ]){let H=V.extensions[qZ];W[G][v].setExtension(qZ,Q[H.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 s.ROOT:Q=J.asset;break;case s.SCENE:Q=J.scenes[Z.sceneIndexMap.get(Y)];break;case s.NODE:Q=J.nodes[Z.nodeIndexMap.get(Y)];break;case s.MESH:Q=J.meshes[Z.meshIndexMap.get(Y)];break;case s.MATERIAL:Q=J.materials[Z.materialIndexMap.get(Y)];break;case s.TEXTURE:Q=J.images[Z.imageIndexMap.get(Y)];break;case s.ANIMATION:Q=J.animations[Z.animationIndexMap.get(Y)];break;default:Q=null,this.document.getLogger().warn(`[${qZ}]: Unsupported parent property, "${Y.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[qZ]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[qZ]={packets:X};return this}}PD.EXTENSION_NAME=qZ;var uM1=[$z,rN,eN,JD,$D,QD,WD,ZU,vD,JU,XU,qD,UD,$U,jD,OD,Yz,MD,ND,PD],fP6=[rw,Xz,tw,ew,...uM1];var lM1=t(pR(),1);function hK(){return hK=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},hK.apply(null,arguments)}var{POINTS:qo,LINES:YU,LINE_STRIP:yM1,LINE_LOOP:pM1,TRIANGLES:QU,TRIANGLE_STRIP:iM1,TRIANGLE_FAN:gM1}=B8.Mode;function AJ(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function F7(Z,J){let X=hK({},Z);for(let $ in J)if(J[$]!==void 0)X[$]=J[$];return X}function fo(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case B8.Mode.POINTS:return J?J.getCount():X.getCount();case B8.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case B8.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case B8.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case B8.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case B8.Mode.TRIANGLE_STRIP:case B8.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw new Error("Unexpected mode: "+Z.getMode())}}var dM1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function ED(Z){return dM1.format(Z)}function aM1(Z,J,X=2){let $=Z>J?"–":"+",Y="%";return $+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function vU(Z,J){return`${ED(Z)} → ${ED(J)} (${aM1(Z,J)})`}function AD(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 nM1(Z,J,X){Z.swap(J,X);for(let $ of Z.listTargets())$.swap(J,X)}function sM1(Z,J){if(Z==null&&J==null)return!0;if(Z==null||J==null)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 wZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function oM1(Z,J=Z){let X=mD(Z,J);for(let $=0;$<X.length;$++)X[$]=$;return X}function mD(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function rM1(Z){return Z.listParents().some((J)=>J.propertyType!==n.ROOT)}function _o(Z){for(let J in Z)return!1;return!0}function So(Z){let J=L6.fromGraph(Z.getGraph()),X=Z.getMaterial(),$=J.getRoot().listMaterials().indexOf(X),Y=eM1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let z=Z.getAttribute(G),v=z.getElementSize(),V=z.getComponentType();return`${G}:${v}:${V}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((z)=>{let v=Z.getAttribute(z),V=v.getElementSize(),H=v.getComponentType();return`${z}:${V}:${H}`}).join("+")}).join("~");return`${$}|${Y}|${Q}|${K}|${W}`}function tM1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var eM1={[qo]:qo,[YU]:YU,[yM1]:YU,[pM1]:YU,[QU]:QU,[iM1]:QU,[gM1]:QU},_K="center",Fo={pivot:"center"};function ho(Z=Fo){let J=F7(Fo,Z);return AJ(_K,(X)=>{let $=X.getLogger(),Y=X.getRoot(),Q=Y.listAnimations().length>0||Y.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{$.debug(`${_K}: Scene ${W+1} / ${Y.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let v=hR(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(`${_K}: Pivot "${G.join(", ")}".`);let z=[-1*G[0],-1*G[1],-1*G[2]];if(Q){$.debug(`${_K}: Model contains animation or skin. Adding a wrapper node.`);let v=X.createNode("Pivot").setTranslation(z);K.listChildren().forEach((V)=>v.addChild(V)),K.addChild(v)}else $.debug(`${_K}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((v)=>{let V=v.getTranslation();v.setTranslation([V[0]+z[0],V[1]+z[1],V[2]+z[2]])})}),$.debug(`${_K}: Complete.`)})}function ZR1(Z){let J=new Set,X=Z,$;while($=X.getParentNode()){if(J.has($))throw new Error("Circular dependency in scene graph.");J.add($),X=$}return X.listParents().filter((Y)=>Y instanceof LK)}function JR1(Z){let J=ZR1(Z),X=Z.getParentNode();if(!X)return Z;Z.setMatrix(Z.getWorldMatrix()),X.removeChild(Z);for(let $ of J)$.addChild(Z);return Z}var bK=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function XR1(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],V=J[9],H=J[10],q=J[11],F=J[12],w=J[13],U=J[14],x=J[15],L=X*W-$*K,j=X*G-Y*K,c=X*z-Q*K,R=$*G-Y*W,M=$*z-Q*W,N=Y*z-Q*G,D=v*w-V*F,P=v*U-H*F,f=v*x-q*F,E=V*U-H*w,_=V*x-q*w,T=H*x-q*U,k=L*T-j*_+c*E+R*f-M*P+N*D;if(!k)return null;return k=1/k,Z[0]=(W*T-G*_+z*E)*k,Z[1]=(Y*_-$*T-Q*E)*k,Z[2]=(w*N-U*M+x*R)*k,Z[3]=(H*M-V*N-q*R)*k,Z[4]=(G*f-K*T-z*P)*k,Z[5]=(X*T-Y*f+Q*P)*k,Z[6]=(U*c-F*N-x*j)*k,Z[7]=(v*N-H*c+q*j)*k,Z[8]=(K*_-W*f+z*D)*k,Z[9]=($*f-X*_-Q*D)*k,Z[10]=(F*M-w*c+x*L)*k,Z[11]=(V*c-v*M-q*L)*k,Z[12]=(W*P-K*E-G*D)*k,Z[13]=(X*E-$*P+Y*D)*k,Z[14]=(w*j-F*R-U*L)*k,Z[15]=(v*R-V*j+H*L)*k,Z}function $R1(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],V=Z[10],H=Z[11],q=Z[12],F=Z[13],w=Z[14],U=Z[15],x=J*K-X*Q,L=J*W-$*Q,j=J*G-Y*Q,c=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,N=z*F-v*q,D=z*w-V*q,P=z*U-H*q,f=v*w-V*F,E=v*U-H*F,_=V*U-H*w;return x*_-L*E+j*f+c*P-R*D+M*N}function bo(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],V=J[8],H=J[9],q=J[10],F=J[11],w=J[12],U=J[13],x=J[14],L=J[15],j=X[0],c=X[1],R=X[2],M=X[3];return Z[0]=j*$+c*W+R*V+M*w,Z[1]=j*Y+c*G+R*H+M*U,Z[2]=j*Q+c*z+R*q+M*x,Z[3]=j*K+c*v+R*F+M*L,j=X[4],c=X[5],R=X[6],M=X[7],Z[4]=j*$+c*W+R*V+M*w,Z[5]=j*Y+c*G+R*H+M*U,Z[6]=j*Q+c*z+R*q+M*x,Z[7]=j*K+c*v+R*F+M*L,j=X[8],c=X[9],R=X[10],M=X[11],Z[8]=j*$+c*W+R*V+M*w,Z[9]=j*Y+c*G+R*H+M*U,Z[10]=j*Q+c*z+R*q+M*x,Z[11]=j*K+c*v+R*F+M*L,j=X[12],c=X[13],R=X[14],M=X[15],Z[12]=j*$+c*W+R*V+M*w,Z[13]=j*Y+c*G+R*H+M*U,Z[14]=j*Q+c*z+R*q+M*x,Z[15]=j*K+c*v+R*F+M*L,Z}function YR1(){var Z=new bK(9);if(bK!=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 QR1(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 KR1(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 WR1(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],V=v*K-W*z,H=-v*Q+W*G,q=z*Q-K*G,F=X*V+$*H+Y*q;if(!F)return null;return F=1/F,Z[0]=V*F,Z[1]=(-v*$+Y*z)*F,Z[2]=(W*$-Y*K)*F,Z[3]=H*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 HU(){var Z=new bK(3);if(bK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function GR1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function Ao(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 zR1(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 vR1(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 HR1=GR1;(function(){var Z=HU();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 hJ="dedup",CD={keepUniqueNames:!1,propertyTypes:[n.ACCESSOR,n.MESH,n.TEXTURE,n.MATERIAL,n.SKIN]};function mo(Z=CD){let J=F7(CD,Z),X=new Set(J.propertyTypes);for(let $ of J.propertyTypes)if(!CD.propertyTypes.includes($))throw new Error(`${hJ}: Unsupported deduplication on type "${$}".`);return AJ(hJ,($)=>{let Y=$.getLogger();if(X.has(n.ACCESSOR))VR1($);if(X.has(n.TEXTURE))FR1($,J);if(X.has(n.MATERIAL))wR1($,J);if(X.has(n.MESH))qR1($,J);if(X.has(n.SKIN))UR1($,J);Y.debug(`${hJ}: Complete.`)})}function VR1(Z){let J=Z.getLogger(),X=new Map,$=new Map,Y=new Map,Q=new Map,K=Z.getRoot().listMeshes();K.forEach((V)=>{V.listPrimitives().forEach((H)=>{H.listAttributes().forEach((q)=>W(q,$)),W(H.getIndices(),X)})});for(let V of Z.getRoot().listAnimations())for(let H of V.listSamplers())W(H.getInput(),Y),W(H.getOutput(),Q);function W(V,H){if(!V)return;let q=[V.getCount(),V.getType(),V.getComponentType(),V.getNormalized(),V.getSparse()].join(":"),F=H.get(q);if(!F)H.set(q,F=new Set);F.add(V)}function G(V,H){for(let q=0;q<V.length;q++){let F=V[q],w=r0.toView(F.getArray());if(H.has(F))continue;for(let U=q+1;U<V.length;U++){let x=V[U];if(H.has(x))continue;if(r0.equals(w,r0.toView(x.getArray())))H.set(x,F)}}}let z=0,v=new Map;for(let V of[$,X,Y,Q])for(let H of V.values())z+=H.size,G(Array.from(H),v);J.debug(`${hJ}: Merged ${v.size} of ${z} accessors.`),K.forEach((V)=>{V.listPrimitives().forEach((H)=>{H.listAttributes().forEach((F)=>{if(v.has(F))H.swap(F,v.get(F))});let q=H.getIndices();if(q&&v.has(q))H.swap(q,v.get(q))})});for(let V of Z.getRoot().listAnimations())for(let H of V.listSamplers()){let q=H.getInput(),F=H.getOutput();if(q&&v.has(q))H.swap(q,v.get(q));if(F&&v.has(F))H.swap(F,v.get(F))}Array.from(v.keys()).forEach((V)=>V.dispose())}function qR1(Z,J){let X=Z.getLogger(),$=Z.getRoot(),Y=new Map;$.listAccessors().forEach((W,G)=>Y.set(W,G)),$.listMaterials().forEach((W,G)=>Y.set(W,G));let Q=$.listMeshes().length,K=new Map;for(let W of $.listMeshes()){let G=[];for(let v of W.listPrimitives())G.push(uo(v,Y));let z="";if(J.keepUniqueNames)z+=W.getName()+";";if(z+=G.join(";"),K.has(z)){let v=K.get(z);W.listParents().forEach((V)=>{if(V.propertyType!==n.ROOT)V.swap(W,v)}),W.dispose()}else K.set(z,W)}X.debug(`${hJ}: Merged ${Q-K.size} of ${Q} meshes.`)}function FR1(Z,J){let X=Z.getLogger(),$=Z.getRoot(),Y=$.listTextures(),Q=new Map;for(let K=0;K<Y.length;K++){let W=Y[K],G=W.getImage();if(Q.has(W))continue;for(let z=K+1;z<Y.length;z++){let v=Y[z],V=v.getImage();if(Q.has(v))continue;if(W.getMimeType()!==v.getMimeType())continue;if(J.keepUniqueNames&&W.getName()!==v.getName())continue;let H=W.getSize(),q=v.getSize();if(!H||!q)continue;if(H[0]!==q[0])continue;if(H[1]!==q[1])continue;if(!G||!V)continue;if(r0.equals(G,V))Q.set(v,W)}}X.debug(`${hJ}: Merged ${Q.size} of ${$.listTextures().length} textures.`),Array.from(Q.entries()).forEach(([K,W])=>{K.listParents().forEach((G)=>{if(!(G instanceof C$))G.swap(K,W)}),K.dispose()})}function wR1(Z,J){let X=Z.getLogger(),Y=Z.getRoot().listMaterials(),Q=new Map,K=new Map,W=new Set;if(!J.keepUniqueNames)W.add("name");for(let G=0;G<Y.length;G++){let z=Y[G];if(Q.has(z))continue;if(wo(z,K))continue;for(let v=G+1;v<Y.length;v++){let V=Y[v];if(Q.has(V))continue;if(wo(V,K))continue;if(z.equals(V,W))Q.set(V,z)}}X.debug(`${hJ}: Merged ${Q.size} of ${Y.length} materials.`),Array.from(Q.entries()).forEach(([G,z])=>{G.listParents().forEach((v)=>{if(!(v instanceof C$))v.swap(G,z)}),G.dispose()})}function UR1(Z,J){let X=Z.getLogger(),Y=Z.getRoot().listSkins(),Q=new Map,K=new Set(["joints"]);if(!J.keepUniqueNames)K.add("name");for(let W=0;W<Y.length;W++){let G=Y[W];if(Q.has(G))continue;for(let z=W+1;z<Y.length;z++){let v=Y[z];if(Q.has(v))continue;if(G.equals(v,K)&&sM1(G.listJoints(),v.listJoints()))Q.set(v,G)}}X.debug(`${hJ}: Merged ${Q.size} of ${Y.length} skins.`),Array.from(Q.entries()).forEach(([W,G])=>{W.listParents().forEach((z)=>{if(!(z instanceof C$))z.swap(W,G)}),W.dispose()})}function uo(Z,J){let X=[];for(let $ of Z.listSemantics()){let Y=Z.getAttribute($);X.push($+":"+J.get(Y))}if(Z instanceof B8){let $=Z.getIndices();if($)X.push("indices:"+J.get($));let Y=Z.getMaterial();if(Y)X.push("material:"+J.get(Y));X.push("mode:"+Z.getMode());for(let Q of Z.listTargets())X.push("target:"+uo(Q,J))}return X.join(",")}function wo(Z,J){if(J.has(Z))return J.get(Z);let X=Z.getGraph(),$=new Set,Y=X.listParentEdges(Z);while(Y.length>0){let Q=Y.pop();if(Q.getAttributes().modifyChild===!0)return J.set(Z,!0),!0;let K=Q.getChild();if($.has(K))continue;for(let W of X.listChildEdges(K))Y.push(W)}return J.set(Z,!1),!1}function lo(){var Z=new bK(4);if(bK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function xR1(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 BR1(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 LR1(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 jR1(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 cR1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3];return Math.hypot(J,X,$,Y)}var yo=BR1,OR1=LR1,po=cR1;(function(){var Z=lo();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 MR1=/color|emissive|diffuse/i;function RR1(Z){return Z.getGraph().listParentEdges(Z).some((Y)=>{return Y.getAttributes().isColor||MR1.test(Y.getName())})?"srgb":null}function NR1(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 P$)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 V5&&K.has(W.getName()))$.add(G);else if(G instanceof BK)Y(G)}}return Y(Z),Array.from($)}function DR1(Z){let X=L6.fromGraph(Z.getGraph()).getRoot(),$=Z.getGraph().listParentEdges(Z).filter((Y)=>Y.getParent()!==X).map((Y)=>Y.getName());return Array.from(new Set($))}var SK="prune",ID=0.011764705882352941,Uo={propertyTypes:[n.NODE,n.SKIN,n.MESH,n.CAMERA,n.PRIMITIVE,n.PRIMITIVE_TARGET,n.ANIMATION,n.MATERIAL,n.TEXTURE,n.ACCESSOR,n.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function VU(Z=Uo){let J=F7(Uo,Z),X=new Set(J.propertyTypes),$=J.keepExtras;return AJ(SK,async(Y)=>{let Q=Y.getLogger(),K=Y.getRoot(),W=Y.getGraph(),G=new io,z=(v)=>G.dispose(v.target);if(W.addEventListener("node:dispose",z),X.has(n.MESH))for(let v of K.listMeshes()){if(v.listPrimitives().length>0)continue;v.dispose()}if(X.has(n.NODE)){if(!J.keepLeaves)for(let v of K.listScenes())go(W,v,$);for(let v of K.listNodes())j4(v,$)}if(X.has(n.SKIN))for(let v of K.listSkins())j4(v,$);if(X.has(n.MESH))for(let v of K.listMeshes())j4(v,$);if(X.has(n.CAMERA))for(let v of K.listCameras())j4(v,$);if(X.has(n.PRIMITIVE))xo(W,n.PRIMITIVE,$);if(X.has(n.PRIMITIVE_TARGET))xo(W,n.PRIMITIVE_TARGET,$);if(!J.keepAttributes&&X.has(n.ACCESSOR)){let v=new Map;for(let V of K.listMeshes())for(let H of V.listPrimitives()){let q=H.getMaterial();if(!q)continue;let F=ao(Y,H,q),w=CR1(H,F);Bo(H,w),H.listTargets().forEach((U)=>Bo(U,w)),v.has(q)?v.get(q).add(H):v.set(q,new Set([H]))}for(let[V,H]of v)TR1(V,Array.from(H))}if(!J.keepIndices&&X.has(n.ACCESSOR))for(let v of K.listMeshes())for(let V of v.listPrimitives())PR1(V);if(X.has(n.ANIMATION))for(let v of K.listAnimations()){for(let V of v.listChannels())if(!V.getTargetNode())V.dispose();if(!v.listChannels().length){let V=v.listSamplers();j4(v,$),V.forEach((H)=>j4(H,$))}else v.listSamplers().forEach((V)=>j4(V,$))}if(X.has(n.MATERIAL))K.listMaterials().forEach((v)=>j4(v,$));if(X.has(n.TEXTURE)){if(K.listTextures().forEach((v)=>j4(v,$)),!J.keepSolidTextures)await kR1(Y)}if(X.has(n.ACCESSOR))K.listAccessors().forEach((v)=>j4(v,$));if(X.has(n.BUFFER))K.listBuffers().forEach((v)=>j4(v,$));if(W.removeEventListener("node:dispose",z),!G.empty()){let v=G.entries().map(([V,H])=>`${V} (${H})`).join(", ");Q.info(`${SK}: Removed types... ${v}`)}else Q.debug(`${SK}: No unused properties found.`);Q.debug(`${SK}: Complete.`)})}class io{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 j4(Z,J){let X=Z.listParents().filter((Y)=>!(Y instanceof C$||Y instanceof N$)),$=J&&!_o(Z.getExtras());if(!X.length&&!$)Z.dispose()}function xo(Z,J,X){for(let $ of Z.listEdges()){let Y=$.getParent();if(Y.propertyType===J)j4(Y,X)}}function go(Z,J,X){if(J.listChildren().forEach((K)=>go(Z,K,X)),J instanceof LK)return;let $=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==n.ROOT&&W!==n.SCENE&&W!==n.NODE}),Y=Z.listChildren(J).length===0,Q=X&&!_o(J.getExtras());if(Y&&!$&&!Q)J.dispose()}function Bo(Z,J){for(let X of J)Z.setAttribute(X,null)}function PR1(Z){let J=Z.getIndices(),X=J&&J.getArray(),$=Z.listAttributes()[0];if(!X||!$)return;if(J.getCount()!==$.getCount())return;for(let Y=0,Q=X.length;Y<Q;Y++)if(Y!==X[Y])return;Z.setIndices(null)}function CR1(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 ao(Z,J,X,$=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let z of Q)if(z.getChild()instanceof P$)K.add(z.getName());for(let z of Q){let v=z.getName(),V=z.getChild();if(V instanceof V5){if(K.has(v.replace(/Info$/,"")))$.add(`TEXCOORD_${V.getTexCoord()}`)}if(V instanceof P$&&v.match(/normalTexture/i))$.add("TANGENT");if(V instanceof BK)ao(Z,J,V,$)}let W=X instanceof Q7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===B8.Mode.POINTS;if(W&&!G)$.add("NORMAL");return $}function TR1(Z,J){let X=NR1(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 V=G.getAttribute(v);if(!V)continue;let H=K.get(v);if(H===v)continue;G.setAttribute(H,V),G.setAttribute(v,null)}}}async function kR1(Z){let J=Z.getRoot(),X=Z.getGraph(),$=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await IR1(K);if(!G)return;if(RR1(K)==="srgb")bR.convertSRGBToLinear(G,G);let z=K.getName()||K.getURI(),v=(W=K.getSize())==null?void 0:W.join("x"),V=DR1(K);for(let H of X.listParentEdges(K)){let q=H.getParent();if(q!==J&&ER1(q,G,H.getName(),$))H.dispose()}if(K.listParents().length===1)K.dispose(),$.debug(`${SK}: Removed solid-color texture "${z}" (${v}px ${V.join(", ")})`)});await Promise.all(Q)}function ER1(Z,J,X,$){if(Z instanceof Q7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(OR1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(HR1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=ID;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return po(yo(lo(),J,[0.5,0.5,1,1]))<=ID}return $.warn(`${SK}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function IR1(Z){let J=await fR1(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(po(yo(Y,$,X))/255>ID)return null}return jR1(Y,xR1(Y,$,X),0.00196078431372549)}async function fR1(Z){try{return await Es(Z.getImage(),Z.getMimeType())}catch(J){return null}}var SJ=4294967295;class no{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of AD(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=r0.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 _R1(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 _R1(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 SR1(Z,J,X,$,Y=SJ){let Q=J-1,W=X.hash($)&Q;for(let G=0;G<=Q;G++){let z=Z[W];if(z===Y||X.equal(z,$))return W;W=W+G+1&Q}throw new Error("Hash table full.")}var Q6;(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"})(Q6||(Q6={}));function bJ(Z,J){let X=Z.getAttribute("POSITION"),$=Z.getIndices();switch(J){case Q6.RENDER:return $?$.getCount():X.getCount();case Q6.RENDER_CACHED:return $?new Set($.getArray()).size:X.getCount();case Q6.UPLOAD_NAIVE:case Q6.UPLOAD:return X.getCount();case Q6.DISTINCT:case Q6.DISTINCT_POSITION:return hR1(J);case Q6.UNUSED:return $?X.getCount()-new Set($.getArray()).size:0;default:return bR1(J)}}function hR1(Z){throw new Error(`Not implemented: ${Z}`)}function bR1(Z){throw new Error(`Unexpected value: ${Z}`)}function Kz(Z,J,X){let $=L6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=AR1(Z);let Y=Z.getIndices(),Q=Y?Y.getArray():null,K=bJ(Z,Q6.RENDER),W=$.createAccessor(),G=K,z=mD(G,X);for(let V=0;V<G;V++)z[V]=J[Q?Q[V]:V];Z.setIndices(W.setArray(z));let v=AD(Z);for(let V of Z.listAttributes()){let H=wZ($,V);fD(V,Y,J,H,X),Z.swap(V,H)}for(let V of Z.listTargets())for(let H of V.listAttributes()){let q=wZ($,H);fD(H,Y,J,q,X),V.swap(H,q)}if(Y&&Y.listParents().length===1)Y.dispose();for(let V of v)if(V.listParents().length===1)V.dispose();return Z}function fD(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 V=0;V<G;V++){let H=W?W[V]:V,q=X[H];if(v[q])continue;for(let F=0;F<Q;F++)z[q*Q+F]=K[H*Q+F];v[q]=1}return $.setArray(z)}function AR1(Z){let J=bJ(Z,Q6.UPLOAD),X=Z.getIndices(),$=X?X.getArray():null;if(!X||!$)return[oM1(J,1e6),J];let Y=new Uint32Array(J).fill(SJ),Q=0;for(let K=0;K<$.length;K++){let W=$[K];if(Y[W]===SJ)Y[W]=Q++}return[Y,Q]}var _D="weld",WU={overwrite:!0,cleanup:!0};function uD(Z=WU){let J=F7(WU,Z);return AJ(_D,async(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes()){for(let Q of Y.listPrimitives())if(qU(Q,J),bJ(Q,Q6.RENDER)===0)Q.dispose();if(Y.listPrimitives().length===0)Y.dispose()}if(J.cleanup)await X.transform(VU({propertyTypes:[n.ACCESSOR,n.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),mo({propertyTypes:[n.ACCESSOR]}));$.debug(`${_D}: Complete.`)})}function qU(Z,J=WU){let X=Z.getGraph(),Y=L6.fromGraph(X).getLogger(),Q=hK({},WU,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===B8.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 no(Z),V=tM1(K+K/4),H=new Uint32Array(V).fill(SJ),q=new Uint32Array(K).fill(SJ),F=0;for(let w=0;w<z;w++){let U=G?G[w]:w;if(q[U]!==SJ)continue;let x=SR1(H,V,v,U,SJ),L=H[x];if(L===SJ)H[x]=U,q[U]=F++;else q[U]=q[L]}Y.debug(`${_D}: ${vU(K,F)} vertices.`),Kz(Z,q,F)}var{FLOAT:mR1}=_0.ComponentType;function so(Z,J){let X=Z.getAttribute("POSITION");if(X)Lo(J,X);let $=Z.getAttribute("NORMAL");if($)jo(J,$);let Y=Z.getAttribute("TANGENT");if(Y)co(J,Y);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)Lo(J,K);let W=Q.getAttribute("NORMAL");if(W)jo(J,W);let G=Q.getAttribute("TANGENT");if(G)co(J,G)}if($R1(J)<0)uR1(Z)}function Lo(Z,J){let X=J.getComponentType(),$=J.getNormalized(),Y=J.getArray(),Q=X===mR1?Y:new Float32Array(Y.length),K=HU();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=a0.decodeNormalizedInt(Y[W*3],X),K[1]=a0.decodeNormalizedInt(Y[W*3+1],X),K[2]=a0.decodeNormalizedInt(Y[W*3+2],X);else K[0]=Y[W*3],K[1]=Y[W*3+1],K[2]=Y[W*3+2];zR1(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 jo(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=YR1();QR1(Q,Z),WR1(Q,Q),KR1(Q,Q);let K=HU();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=a0.decodeNormalizedInt(X[W*3],Y),K[1]=a0.decodeNormalizedInt(X[W*3+1],Y),K[2]=a0.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(vR1(K,K,Q),Ao(K,K),$)X[W*3]=a0.decodeNormalizedInt(K[0],Y),X[W*3+1]=a0.decodeNormalizedInt(K[1],Y),X[W*3+2]=a0.decodeNormalizedInt(K[2],Y);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function co(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=HU();for(let K=0,W=J.getCount();K<W;K++){if($)Q[0]=a0.decodeNormalizedInt(X[K*4],Y),Q[1]=a0.decodeNormalizedInt(X[K*4+1],Y),Q[2]=a0.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],Ao(Q,Q),$)X[K*4]=a0.decodeNormalizedInt(Q[0],Y),X[K*4+1]=a0.decodeNormalizedInt(Q[1],Y),X[K*4+2]=a0.decodeNormalizedInt(Q[2],Y);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function uR1(Z){if(Z.getMode()!==B8.Mode.TRIANGLES)return;if(!Z.getIndices())qU(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 lR1(Z,J){for(let X of Z.listPrimitives()){let $=yR1(X,Z);if(X!==$)Z.removePrimitive(X).addPrimitive($)}for(let X of Z.listPrimitives())Kz(X),so(X,J)}function yR1(Z,J){if(Z.listParents().some(($)=>$ instanceof hG&&$!==J))Z=Z.clone();for(let $ of Z.listTargets())if($.listParents().some((Q)=>Q instanceof B8&&Q!==Z))Z.removeTarget($).addTarget($.clone());return Z}var Oo=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function oo(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!a0.eq(X,Oo))lR1(J,X);for(let $ of Z.listChildren()){let Y=$.getMatrix();bo(Y,Y,X),$.setMatrix(Y)}return Z.setMatrix(Oo)}var{LINES:pR1,LINE_STRIP:iR1,LINE_LOOP:gR1,TRIANGLES:dR1,TRIANGLE_STRIP:aR1,TRIANGLE_FAN:nR1}=B8.Mode;function sR1(Z){let J=Z.getGraph(),X=L6.fromGraph(J);if(!Z.getIndices())qU(Z);let $=Z.getIndices(),Y=$.getArray(),Q=fo(Z),W=new DJ[$.getComponentType()](Q*2),G=Z.getMode();if(G===iR1)for(let v=0;v<Q;v++)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else if(G===gR1)for(let v=0;v<Q;v++)if(v<Q-1)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else W[v*2]=Y[v],W[v*2+1]=Y[0];else throw new Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(pR1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(wZ(X,$).setArray(W));else $.setArray(W)}function ro(Z){let J=Z.getGraph(),X=L6.fromGraph(J);if(!Z.getIndices())qU(Z);let $=Z.getIndices(),Y=$.getArray(),Q=fo(Z),W=new DJ[$.getComponentType()](Q*3),G=Z.getMode();if(G===aR1)for(let v=0,V=Y.length;v<V-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===nR1)for(let v=0;v<Q;v++)W[v*3]=Y[0],W[v*3+1]=Y[v+1],W[v*3+2]=Y[v+2];else throw new Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(dR1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(wZ(X,$).setArray(W));else $.setArray(W)}var Mo="dequantize",GU={pattern:/^((?!JOINTS_).)*$/};function to(Z=GU){let J=F7(GU,Z);return AJ(Mo,(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes())for(let Q of Y.listPrimitives())oR1(Q,J);X.createExtension(Yz).dispose(),$.debug(`${Mo}: Complete.`)})}function oR1(Z,J=GU){let X=F7(GU,J);for(let $ of Z.listSemantics())if(X.pattern.test($))SD(Z.getAttribute($));for(let $ of Z.listTargets())for(let Y of $.listSemantics())if(X.pattern.test(Y))SD($.getAttribute(Y))}function SD(Z){let J=Z.getArray();if(!J)return;let X=zU(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function zU(Z,J,X){let $=new Float32Array(Z.length);for(let Y=0,Q=Z.length;Y<Q;Y++)if(X)$[Y]=a0.decodeNormalizedInt(Z[Y],J);else $[Y]=Z[Y];return $}var{TEXTURE_INFO:eo,ROOT:mP6}=n;function Zr(Z){let J=new L6().setLogger(Z.getLogger()),X=lD(J,Z);return rR1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function rR1(Z,J,X){X||(X=lD(Z,J));for(let $ of J.getRoot().listExtensionsUsed()){let Y=Z.createExtension($.constructor);if($.isRequired())Y.setRequired(!0)}return tR1(Z,J,eR1(J),X)}function tR1(Z,J,X,$){$||($=lD(Z,J));let Y=new Map;for(let Q of X)if(!Y.has(Q)&&Q.propertyType!==eo)Y.set(Q,$(Q));for(let[Q,K]of Y.entries())K.copy(Q,$);return Y}function lD(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return($)=>{if($.propertyType===eo)return $;let Y=X.get($);if(!Y)Y=new $.constructor(Z.getGraph()),X.set($,Y);return Y}}function eR1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}var TD="flatten",Ro={cleanup:!0};function Jr(Z=Ro){let J=F7(Ro,Z);return AJ(TD,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 V=v.getTargetNode();if(V&&v.getTargetPath()!=="weights")K.add(V)}let W=new Set,G=new Set;for(let z of $.listScenes())z.traverse((v)=>{let V=v.getParentNode();if(!V)return;if(Q.has(V)||W.has(V))W.add(v);if(K.has(V)||G.has(V))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;JR1(v)});if(K.size)Y.debug(`${TD}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(VU({propertyTypes:[n.NODE],keepLeaves:!1}));Y.debug(`${TD}: Complete.`)})}function Xr(Z){return hR(Z)}var ZN1={skipValidation:!1},No=4294967295,{LINE_STRIP:JN1,LINE_LOOP:XN1,TRIANGLE_STRIP:$N1,TRIANGLE_FAN:YN1}=B8.Mode;function QN1(Z,J={}){let X=F7(ZN1,J),$=Z[0],Y=L6.fromGraph($.getGraph());if(!X.skipValidation&&new Set(Z.map(So)).size>1)throw new Error("Requires >=2 Primitives, sharing the same Material and Mode, with compatible vertex attributes and indices.");for(let q of Z)switch(q.getMode()){case JN1:case XN1:sR1(q);break;case $N1:case YN1:ro(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],w=F.getIndices(),U=F.getAttribute("POSITION").getCount(),x=w?w.getArray():null,L=w?w.getCount():U,j=new Uint32Array(U).fill(No);for(let c=0;c<L;c++){let R=x?x[c]:c;if(j[R]===No)j[R]=W++,K[q]++}Q.push(j),G+=L}let z=Y.createPrimitive().setMode($.getMode()).setMaterial($.getMaterial());for(let q of $.listSemantics()){let F=$.getAttribute(q),w=DJ[F.getComponentType()],U=wZ(Y,F).setArray(new w(W*F.getElementSize()));z.setAttribute(q,U)}let v=$.getIndices(),V=v?wZ(Y,v).setArray(mD(G,W)):null;z.setIndices(V);let H=0;for(let q=0;q<Q.length;q++){let F=Z[q],w=F.getIndices(),U=w?w.getCount():-1,x=Q[q];if(w&&V)WN1(w,x,V,H),H+=U;for(let L of z.listSemantics()){let j=F.getAttribute(L),c=z.getAttribute(L);KN1(j,w,x,c)}}return z}function KN1(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,V=J?J.getCount():K;v<V;v++){let H=Q?Q[v]:v,q=X[H];if(z[q])continue;for(let F=0;F<Y;F++)G[q*Y+F]=W[H*Y+F];z[q]=1}}function WN1(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 hD="join",{ROOT:GN1,NODE:zN1,MESH:vN1,PRIMITIVE:HN1,ACCESSOR:VN1}=n,kD=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Do={keepMeshes:!1,keepNamed:!1,cleanup:!0};function $r(Z=Do){let J=F7(Do,Z);return AJ(hD,async(X)=>{let $=X.getRoot(),Y=X.getLogger();for(let Q of $.listScenes())Po(X,Q,J),Q.traverse((K)=>Po(X,K,J));if(J.cleanup)await X.transform(VU({propertyTypes:[zN1,vN1,HN1,VN1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));Y.debug(`${hD}: Complete.`)})}function Po(Z,J,X){let $=Z.getLogger(),Y={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let z=Q[G];if(z.listParents().some((H)=>H instanceof N$))continue;let V=z.getMesh();if(!V)continue;if(z.getExtension("EXT_mesh_gpu_instancing"))continue;if(z.getSkin())continue;for(let H of V.listPrimitives()){if(H.listTargets().length>0)continue;let q=H.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;Kz(H),FN1(H);let F=So(H),w=V.getName()||z.getName();if(X.keepMeshes||X.keepNamed&&w)F+=`|${G}`;if(!(F in Y))Y[F]={prims:[],primMeshes:[],primNodes:[],dstNode:z,dstMesh:void 0};let U=Y[F];U.prims.push(H),U.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((V)=>{return V.propertyType!==GN1&&G!==V}))G.setMesh(z.clone())}for(let G of K){let{dstNode:z,primNodes:v}=G;G.dstMesh=z.getMesh(),G.primMeshes=v.map((V)=>V.getMesh())}for(let G of K){let{prims:z,primNodes:v,primMeshes:V,dstNode:H,dstMesh:q}=G,F=H.getMatrix();for(let x=0;x<z.length;x++){let L=v[x],j=V[x],c=z[x];if(j.removePrimitive(c),rM1(c))c=z[x]=qN1(z[x]);if(L!==H)bo(kD,XR1(kD,F),L.getMatrix()),so(c,kD)}let w=QN1(z),U=w.listAttributes()[0].getCount();q.addPrimitive(w),$.debug(`${hD}: Joined Primitives (${z.length}) containing ${ED(U)} vertices under Node "${H.getName()}".`)}}function qN1(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 FN1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)SD(X)}}var{TRANSLATION:uP6,ROTATION:lP6,SCALE:yP6,WEIGHTS:pP6}=N$.TargetPath;var wN1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var iP6=hK({level:"high"},wN1);var UN1="unweld";function xN1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let $=Z.getGraph(),Y=L6.fromGraph($),Q=Y.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,Co(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,Co(Y,z,X,J)),z.listParents().length===1)z.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${UN1}: ${vU(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function Co(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,V=X.getCount();v<V;v++)for(let H=0;H<G;H++)K[v*G+H]=Y[W[v]*G+H];if(!$.has(J))$.set(J,new Map);let z=wZ(Z,J).setArray(K);return $.get(J).set(X,z),z}var To;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(To||(To={}));var BN1=0.000001;function LN1(Z,J,X,$=0.0001){let Y=J.length/Z.length,Q=new Array(Y).fill(0),K=new Array(Y).fill(0),W=new Array(Y).fill(0),G=new Array(Y).fill(0),z=Z.length-1,v=1;for(let V=1;V<z;++V){let H=Z[v-1],q=Z[V],F=Z[V+1],w=(q-H)/(F-H),U=!1;if(q!==F&&(V!==1||q!==Z[0])){if(Qz(J,v-1,G),Qz(J,V,K),Qz(J,V+1,W),X==="slerp"){let x=ON1(Q,G,W,w),L=Eo(G,K)+Eo(K,W);U=!KU(K,x,$)||L+Number.EPSILON>=Math.PI}else if(X==="lerp"){let x=cN1(Q,G,W,w);U=!KU(K,x,$)}else if(X==="step")U=!KU(K,G)||!KU(K,W)}if(U){if(V!==v)Z[v]=Z[V],ko(J,v,Qz(J,V,Q));v++}}if(z>0)Z[v]=Z[z],ko(J,v,Qz(J,z,Q)),v++;return v}function Qz(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)X[$]=Z[J*Y+$];return X}function ko(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)Z[J*Y+$]=X[$]}function KU(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 jN1(Z,J,X){return Z*(1-X)+J*X}function cN1(Z,J,X,$){for(let Y=0;Y<J.length;Y++)Z[Y]=jN1(J[Y],X[Y],$);return Z}function ON1(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],V=X[3],H,q,F,w,U;if(q=Y*G+Q*z+K*v+W*V,q<0)q=-q,G=-G,z=-z,v=-v,V=-V;if(1-q>BN1)H=Math.acos(q),F=Math.sin(H),w=Math.sin((1-$)*H)/F,U=Math.sin($*H)/F;else w=1-$,U=$;return Z[0]=w*Y+U*G,Z[1]=w*Q+U*z,Z[2]=w*K+U*v,Z[3]=w*W+U*V,Z}function Eo(Z,J){let X=MN1(Z,J);return Math.acos(2*X*X-1)}function MN1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var gP6=new Float32Array(0),dP6={ready:Promise.resolve(),resample:LN1,tolerance:0.0001,cleanup:!0};var n$="simplify",{POINTS:Yr,LINES:RN1,LINE_STRIP:NN1,LINE_LOOP:DN1,TRIANGLES:PN1,TRIANGLE_STRIP:Qr,TRIANGLE_FAN:Kr}=B8.Mode,Wr={ratio:0,error:0.0001,lockBorder:!1,cleanup:!0};function Gr(Z){let J=F7(Wr,Z),X=J.simplifier;if(!X)throw new Error(`${n$}: simplifier dependency required — install "meshoptimizer".`);return AJ(n$,async($)=>{let Y=$.getLogger();await X.ready,await $.transform(uD({overwrite:!1,cleanup:J.cleanup}));let Q=0;for(let K of $.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G===PN1||G===Qr||G===Kr){if(Io(W,J),bJ(W,Q6.RENDER)===0)W.dispose()}else if(W.getMode()===Yr&&!!X.simplifyPoints){if(Io(W,J),bJ(W,Q6.RENDER)===0)W.dispose()}else Q++}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)Y.warn(`${n$}: Skipping simplification of ${Q} primitives: Unsupported draw mode.`);if(J.cleanup)await $.transform(VU({propertyTypes:[n.ACCESSOR,n.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),mo({propertyTypes:[n.ACCESSOR]}));Y.debug(`${n$}: Complete.`)})}function Io(Z,J){let X=hK({},Wr,J),$=X.simplifier,Y=Z.getGraph(),Q=L6.fromGraph(Y),K=Q.getLogger();switch(Z.getMode()){case Yr:return CN1(Q,Z,X);case RN1:case NN1:case DN1:return K.warn(`${n$}: Skipping primitive simplification: Unsupported draw mode.`),Z;case Qr:case Kr:ro(Z);break}let W=bJ(Z,Q6.UPLOAD),G=bJ(Z,Q6.RENDER);if(G<W/2)Kz(Z);let z=Z.getAttribute("POSITION"),v=Z.getIndices(),V=z.getArray(),H=v.getArray();if(!(V instanceof Float32Array))V=zU(V,z.getComponentType(),z.getNormalized());if(!(H instanceof Uint32Array))H=new Uint32Array(H);let q=Math.floor(X.ratio*G/3)*3,F=X.lockBorder?["LockBorder"]:[],[w,U]=$.simplify(H,V,3,q,X.error,F);if(Z.setIndices(wZ(Q,v).setArray(w)),v.listParents().length===1)v.dispose();Kz(Z);let x=bJ(Z,Q6.UPLOAD);if(x<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${n$}: ${vU(W,x)} vertices, error: ${U.toFixed(4)}.`),Z}function CN1(Z,J,X){let $=X.simplifier,Y=Z.getLogger();if(J.getIndices())xN1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),z=K.getArray(),v=W?W.getArray():void 0,V=W?W.getComponentSize():void 0;if(!(z instanceof Float32Array))z=zU(z,K.getComponentType(),K.getNormalized());if(v&&!(v instanceof Float32Array))v=zU(v,K.getComponentType(),K.getNormalized());$.useExperimentalFeatures=!0;let H=Math.floor(X.ratio*G),q=$.simplifyPoints(z,3,H,v,V);$.useExperimentalFeatures=!1;let[F,w]=$.compactMesh(q);Y.debug(`${n$}: ${vU(K.getCount(),w)} vertices.`);for(let U of AD(J)){let x=wZ(Z,U);if(fD(U,null,F,x,w),nM1(J,U,x),U.listParents().length===1)U.dispose()}return J}var bD;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(bD||(bD={}));var aP6={resizeFilter:bD.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var wr=t(Fr(),1);var AK={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DIRECTORIES:[(()=>{try{return u5.dirname(p.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))}catch{return null}})(),u5.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 U5{static instance=new U5;optimize=!0;optimizeEveryStart=!1;_modelUriDocuments=new Map;_modelUriBoundingBoxes=new Map;_modelUriNodeNames=new Map;_modelUriTrimeshes=new Map;constructor(){}async preloadModels(){let Z=await this._getAbsoluteModelPaths();console.log(`ModelRegistry.preloadModels(): Preloading ${Z.length} models...`);for(let J of Z){if(this.optimize)await this._resolveOptimizedModelPath(J);await this._loadModelData(J)}console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models!`)}getAnimationNames(Z){let J=this._modelUriDocuments.get(Z);if(!J)y.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J.getRoot().listAnimations().map(($)=>$.getName())}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=u5.normalize(Z);for(let X of AK.DIRECTORIES){let $=u5.normalize(X);if(J.startsWith($))return u5.relative($,J).replace(/\\/g,"/")}return u5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of AK.DIRECTORIES){let X=u5.resolve(process.cwd(),J);if(!mJ.existsSync(X))continue;let $=await Zw("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let Y of $)Z.push(u5.join(X,Y))}return Z}async _loadModelData(Z){let J=await new yR().read(Z),X=Xr(J.getRoot().listScenes()[0]),$=J.getRoot().listNodes().map((Q)=>Q.getName()),Y=this._absoluteModelPathToModelUri(Z);this._modelUriDocuments.set(Y,J),this._modelUriBoundingBoxes.set(Y,{min:{x:X.min[0],y:X.min[1],z:X.min[2]},max:{x:X.max[0],y:X.max[1],z:X.max[2]}}),this._modelUriNodeNames.set(Y,$),this._modelUriTrimeshes.set(Y,await this._buildTrimesh(Y))}async _resolveOptimizedModelPath(Z){let J=this._buildOptimizedModelPath(Z);if(!this.optimizeEveryStart&&this._isOptimizedVersionValid(Z))return J;return await this._optimizeModel(Z,J)}_isOptimizedVersionValid(Z){let J=`${this._buildOptimizedModelPath(Z)}${AK.CHECKSUM_EXT}`;if(!mJ.existsSync(J))return!1;let X=this._calculateChecksum(Z),$=mJ.readFileSync(J,"utf8");return X===$}_calculateChecksum(Z){if(!mJ.existsSync(Z))return"";let J=mJ.readFileSync(Z);return fN1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=u5.basename(Z),X=J.replace(/\.[^/.]+$/,""),$=u5.dirname(Z),Y=u5.join($,AK.OPTIMIZED_DIR,X);return u5.join(Y,J)}async _buildTrimesh(Z,J=1,X=0.001){let $=this._modelUriDocuments.get(Z);if(!$)y.fatalError(`ModelRegistry._buildTrimesh(): Model ${Z} not found!`);let Y=Zr($);Y.setLogger(new q5(_G.WARN)),await Y.transform(ho({pivot:"center"}),Jr(),$r(),uD(),Gr({simplifier:wr.MeshoptSimplifier,ratio:J,error:X}),to());for(let z of Y.getRoot().listScenes())for(let v of z.listChildren())oo(v);let Q=Y.getRoot().listMeshes()[0];if(!Q){y.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root mesh!`);return}let K=Q.listPrimitives()[0];if(!K){y.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root primitive!`);return}let W=K.getAttribute("POSITION"),G=K.getIndices();if(!W||!G){y.error(`ModelRegistry._buildTrimesh(): Model ${Z} missing required geometry data!`);return}return{vertices:W.getArray(),indices:G.getArray()}}async _optimizeModel(Z,J){let X=u5.dirname(J);mJ.rmSync(X,{recursive:!0,force:!0}),mJ.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let $ of AK.OPTIMIZER_RUNS){let Y=J.replace(/(\.[^/.]+)$/,`${$.suffix}$1`),{stderr:Q}=await wg("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 mJ.writeFileSync(`${J}${AK.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var Hz;((Y)=>{Y.DYNAMIC="dynamic";Y.FIXED="fixed";Y.KINEMATIC_POSITION="kinematic_position";Y.KINEMATIC_VELOCITY="kinematic_velocity"})(Hz||={});var dD=0.001,Ur="dynamic";class s$ extends L0{_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??=Ur,this._rigidBodyDesc=this._createRigidBodyDesc(Z),this._rigidBodyType=Z.type,this._applyRigidBodyOptions(Z),this._autoAddToSimulation(Z)}get additionalMass(){if(!this._requireNotRemoved("additionalMass"))return 0;return this._additionalMass}get additionalSolverIterations(){if(!this._requireNotRemoved("additionalSolverIterations"))return 0;return this._rigidBody?this._rigidBody.additionalSolverIterations():this._rigidBodyDesc.additionalSolverIterations}get angularDamping(){if(!this._requireNotRemoved("angularDamping"))return 0;return this._rigidBody?this._rigidBody.angularDamping():this._rigidBodyDesc.angularDamping}get angularVelocity(){if(!this._requireNotRemoved("angularVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.angvel():this._rigidBodyDesc.angvel}get colliders(){return this._colliders}get dominanceGroup(){if(!this._requireNotRemoved("dominanceGroup"))return 0;return this._rigidBody?this._rigidBody.dominanceGroup():this._rigidBodyDesc.dominanceGroup}get directionFromRotation(){let{x:Z,y:J,z:X,w:$}=this.rotation;return{x:-2*(Z*X+$*J),y:-2*(J*X-$*Z),z:-(1-2*(Z*Z+J*J))}}get effectiveAngularInertia(){if(!this._requireNotRemoved("effectiveAngularInertia"))return;return this._rigidBody?this._rigidBody.effectiveAngularInertia():void 0}get effectiveInverseMass(){if(!this._requireNotRemoved("effectiveInverseMass"))return;return this._rigidBody?this._rigidBody.effectiveInvMass():void 0}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("effectiveWorldInversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.effectiveWorldInvInertiaSqrt():void 0}get enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get inversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("inversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.invPrincipalInertiaSqrt():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(Z){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(Z,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(Z)}setAdditionalMassProperties(Z){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:J,centerOfMass:X,principalAngularInertia:$,principalAngularInertiaLocalFrame:Y}=Z;this._rigidBody?this._rigidBody.setAdditionalMassProperties(J,X,$,Y,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMassProperties(J,X,$,Y)}setAdditionalSolverIterations(Z){if(!this._requireDynamic("setAdditionalSolverIterations"))return;if(!this._requireNotRemoved("setAdditionalSolverIterations"))return;this._rigidBody?this._rigidBody.setAdditionalSolverIterations(Z):this._rigidBodyDesc.setAdditionalSolverIterations(Z)}setAngularDamping(Z){if(!this._requireDynamic("setAngularDamping"))return;if(!this._requireNotRemoved("setAngularDamping"))return;this._rigidBody?this._rigidBody.setAngularDamping(Z):this._rigidBodyDesc.setAngularDamping(Z)}setAngularVelocity(Z){if(!this._requireNotKinematicPositionBased("setAngularVelocity"))return;if(!this._requireNotRemoved("setAngularVelocity"))return;this._rigidBody?this._rigidBody.setAngvel(Z,!this._explicitSleep):this._rigidBodyDesc.setAngvel(Z)}setCcdEnabled(Z){if(!this._requireDynamic("setCcdEnabled"))return;if(!this._requireNotRemoved("setCcdEnabled"))return;this._rigidBody?this._rigidBody.enableCcd(Z):this._rigidBodyDesc.setCcdEnabled(Z)}setDominanceGroup(Z){if(!this._requireDynamic("setDominanceGroup"))return;if(!this._requireNotRemoved("setDominanceGroup"))return;this._rigidBody?this._rigidBody.setDominanceGroup(Z):this._rigidBodyDesc.setDominanceGroup(Z)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._rigidBody?this._rigidBody.setEnabled(Z):this._rigidBodyDesc.setEnabled(Z)}setEnabledPositions(Z){if(!this._requireDynamic("setEnabledPositions"))return;if(!this._requireNotRemoved("setEnabledPositions"))return;this._rigidBody?this._rigidBody.setEnabledTranslations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledTranslations(Z.x,Z.y,Z.z),this._enabledPositions=Z}setEnabledRotations(Z){if(!this._requireDynamic("setEnabledRotations"))return;if(!this._requireNotRemoved("setEnabledRotations"))return;this._rigidBody?this._rigidBody.setEnabledRotations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledRotations(Z.x,Z.y,Z.z),this._enabledRotations=Z}setGravityScale(Z){if(!this._requireDynamic("setGravityScale"))return;if(!this._requireNotRemoved("setGravityScale"))return;this._rigidBody?this._rigidBody.setGravityScale(Z,!this._explicitSleep):this._rigidBodyDesc.setGravityScale(Z)}setLinearDamping(Z){if(!this._requireDynamic("setLinearDamping"))return;if(!this._requireNotRemoved("setLinearDamping"))return;this._rigidBody?this._rigidBody.setLinearDamping(Z):this._rigidBodyDesc.setLinearDamping(Z)}setLinearVelocity(Z){if(!this._requireNotKinematicPositionBased("setLinearVelocity"))return;if(!this._requireNotRemoved("setLinearVelocity"))return;this._rigidBody?this._rigidBody.setLinvel(Z,!this._explicitSleep):this._rigidBodyDesc.setLinvel(Z.x,Z.y,Z.z)}setNextKinematicRotation(Z){if(!this._requireKinematic("setNextKinematicRotation"))return;if(!this._requireNotRemoved("setNextKinematicRotation"))return;this._rigidBody?this._rigidBody.setNextKinematicRotation(Z):this._rigidBodyDesc.setRotation(Z)}setNextKinematicPosition(Z){if(!this._requireKinematic("setNextKinematicPosition"))return;if(!this._requireNotRemoved("setNextKinematicPosition"))return;this._rigidBody?this._rigidBody.setNextKinematicTranslation(Z):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setPosition(Z){if(!this._requireNotRemoved("setPosition"))return;this._rigidBody?this._rigidBody.setTranslation(Z,!this._explicitSleep):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setRotation(Z){if(!this._requireNotRemoved("setRotation"))return;this._rigidBody?this._rigidBody.setRotation(Z,!this._explicitSleep):this._rigidBodyDesc.setRotation(Z)}setSleeping(Z){if(!this._requireDynamic("setSleeping"))return;if(!this._requireNotRemoved("setSleeping"))return;this._rigidBody?Z?this._rigidBody.sleep():this._rigidBody.wakeUp():this._rigidBodyDesc.sleeping=Z,this._explicitSleep=Z}setSoftCcdPrediction(Z){if(!this._requireDynamic("setSoftCcdPrediction"))return;if(!this._requireNotRemoved("setSoftCcdPrediction"))return;this._rigidBody?this._rigidBody.setSoftCcdPrediction(Z):this._rigidBodyDesc.setSoftCcdPrediction(Z)}setCollisionGroupsForSolidColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSolidColliders"))return;this._colliders.forEach((J)=>{if(J.isSensor)return;J.setCollisionGroups(Z)})}setCollisionGroupsForSensorColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSensorColliders"))return;this._colliders.forEach((J)=>{if(!J.isSensor)return;J.setCollisionGroups(Z)})}setType(Z){if(!this._requireNotRemoved("setType"))return;let X={["dynamic"]:Q1.RigidBodyType.Dynamic,["fixed"]:Q1.RigidBodyType.Fixed,["kinematic_position"]:Q1.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:Q1.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 l5({...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 l5(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??Ur;return{["dynamic"]:()=>Q1.RigidBodyDesc.dynamic(),["fixed"]:()=>Q1.RigidBodyDesc.fixed(),["kinematic_position"]:()=>Q1.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>Q1.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)<dD&&Math.abs(Z.y)<dD&&Math.abs(Z.z)<dD}}var aD;((Y)=>{Y[Y.Average=0]="Average";Y[Y.Min=1]="Min";Y[Y.Multiply=2]="Multiply";Y[Y.Max=3]="Max"})(aD||={});var Vz;((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"})(Vz||={});class l5 extends L0{_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 $=U5.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,V=W*J/2,H=(L)=>Math.max(0.01,L),q=()=>({shape:"block",halfExtents:{x:H(Y*J/2),y:H(Q*J/2),z:H(K*J/2)}}),F=()=>({shape:"round-cylinder",radius:H(V),halfHeight:H(Q*J/2),borderRadius:H(V*0.1)}),w=()=>{let L=U5.instance.getTrimesh(Z,J);if(!L)return;return{shape:"trimesh",vertices:L.vertices,indices:L.indices}},U=()=>({shape:"wedge",extents:{x:Y*J,y:Q*J,z:K*J}}),x=()=>({shape:"capsule",radius:H(V),halfHeight:H(Q*J/2-V)});if(X)switch(X){case"block":return q();case"capsule":return x();case"round-cylinder":return F();case"trimesh":{let L=w();if(!L){y.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return L}case"wedge":return U();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?G9.decodeRawCollisionGroups(this._collider.collisionGroups()):G9.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=G9.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|Q1.ActiveEvents.COLLISION_EVENTS:J&~Q1.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|Q1.ActiveEvents.CONTACT_FORCE_EVENTS:J&~Q1.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 Q1.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)y.fatalError("Block collider must have halfExtents!");return Q1.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 Q1.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)y.fatalError("Cone collider must have radius and halfHeight!");return Q1.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)y.fatalError("Cylinder collider must have radius and halfHeight!");return Q1.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 Q1.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 Q1.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)y.fatalError("Voxels collider must have coordinates and size!");return Q1.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=Q1.ColliderDesc.convexHull($);if(!Y)throw y.fatalError("Failed to create convex hull for wedge collider!"),new 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(Q1.ActiveCollisionTypes.DYNAMIC_DYNAMIC|Q1.ActiveCollisionTypes.DYNAMIC_KINEMATIC|Q1.ActiveCollisionTypes.DYNAMIC_FIXED|Q1.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Q1.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 _N1={shape:"voxels"},nD;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(nD||={});class y5 extends L0{_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,..._N1}}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 l5({...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(G9.isDefaultCollisionGroups(J.collisionGroups))J.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return J}serialize(){return P0.serializeBlockType(this)}}var sD;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(sD||={});class qz extends L0{_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 y5{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 P0.serializeBlockTypeRegistry(this)}}var DC={};pQ(DC,{worldSchema:()=>NC,worldPacketDefinition:()=>z80,vectorSchema:()=>v1,vectorBooleanSchema:()=>If1,uiSchema:()=>MC,uiPacketDefinition:()=>W80,uiDatasSchema:()=>RC,uiDatasPacketDefinition:()=>G80,uiDataSendPacketDefinition:()=>d10,uiDataSchema:()=>bz,syncResponseSchema:()=>OC,syncResponsePacketDefinition:()=>K80,syncRequestSchema:()=>oP,syncRequestPacketDefinition:()=>g10,stateRequestSchema:()=>sP,stateRequestPacketDefinition:()=>i10,sceneUIsSchema:()=>cC,sceneUIsPacketDefinition:()=>Q80,sceneUISchema:()=>jC,rgbColorSchema:()=>R6,registeredPackets:()=>$x,quaternionSchema:()=>GC,playersSchema:()=>LC,playersPacketDefinition:()=>Y80,playerSchema:()=>BC,physicsDebugRenderSchema:()=>xC,physicsDebugRenderPacketDefinition:()=>X80,physicsDebugRaycastsSchema:()=>UC,physicsDebugRaycastsPacketDefinition:()=>$80,physicsDebugRaycastSchema:()=>wC,particleEmittersSchema:()=>FC,particleEmittersPacketDefinition:()=>J80,particleEmitterSchema:()=>qC,outboundPackets:()=>Xx,modelNodeOverrideSchema:()=>WC,lightsSchema:()=>VC,lightsPacketDefinition:()=>Z80,lightSchema:()=>HC,isValidPacket:()=>_f1,inputSchema:()=>nP,inputPacketDefinition:()=>p10,inboundPackets:()=>Jx,hexColorSchema:()=>dP,heartbeatSchema:()=>gP,heartbeatPacketDefinition:()=>u10,entitySchema:()=>zC,entitiesSchema:()=>vC,entitiesPacketDefinition:()=>e10,definePacket:()=>k0,debugConfigSchema:()=>aP,debugConfigPacketDefinition:()=>y10,createPacket:()=>Of1,connectionSchema:()=>iP,connectionPacketDefinition:()=>m10,chunksSchema:()=>KC,chunksPacketDefinition:()=>t10,chunkSchema:()=>QC,chatMessagesSchema:()=>YC,chatMessagesPacketDefinition:()=>r10,chatMessageSendPacketDefinition:()=>l10,chatMessageSchema:()=>hz,cameraSchema:()=>$C,cameraPacketDefinition:()=>o10,blocksSchema:()=>ZC,blocksPacketDefinition:()=>n10,blockTypesSchema:()=>XC,blockTypesPacketDefinition:()=>s10,blockTypeSchema:()=>JC,blockSchema:()=>eP,bidirectionalPackets:()=>Zx,audiosSchema:()=>tP,audiosPacketDefinition:()=>a10,audioSchema:()=>rP,PacketId:()=>P1});var Zx={};pQ(Zx,{heartbeatPacketDefinition:()=>u10,connectionPacketDefinition:()=>m10});var yP=t(b10(),1);class pP extends yP.default{static instance=new yP.default}var P1;((P)=>{P[P.SYNC_REQUEST=0]="SYNC_REQUEST";P[P.INPUT=1]="INPUT";P[P.STATE_REQUEST=2]="STATE_REQUEST";P[P.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";P[P.UI_DATA_SEND=4]="UI_DATA_SEND";P[P.SYNC_RESPONSE=32]="SYNC_RESPONSE";P[P.AUDIOS=33]="AUDIOS";P[P.BLOCKS=34]="BLOCKS";P[P.BLOCK_TYPES=35]="BLOCK_TYPES";P[P.CHAT_MESSAGES=36]="CHAT_MESSAGES";P[P.CHUNKS=37]="CHUNKS";P[P.ENTITIES=38]="ENTITIES";P[P.WORLD=39]="WORLD";P[P.CAMERA=40]="CAMERA";P[P.UI=41]="UI";P[P.UI_DATAS=42]="UI_DATAS";P[P.SCENE_UIS=43]="SCENE_UIS";P[P.LIGHTS=44]="LIGHTS";P[P.PLAYERS=45]="PLAYERS";P[P.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";P[P.CONNECTION=116]="CONNECTION";P[P.HEARTBEAT=117]="HEARTBEAT";P[P.DEBUG_CONFIG=128]="DEBUG_CONFIG";P[P.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";P[P.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(P1||={});function Of1(Z,J,X){if(!Z.validate(J))throw new Error(`Invalid payload for packet with id ${Z.id}. Error: ${pP.instance.errorsText(Z.validate.errors)}`);let $=[Z.id,J];if(typeof X==="number")$.push(X);return $}function k0(Z,J){return{id:Z,schema:J,validate:pP.instance.compile(J)}}var Mf1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},A10={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},Rf1={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},Nf1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},Df1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},Pf1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},Cf1={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},Tf1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:Nf1,ic:{type:"array",items:Rf1},d:A10,s:Pf1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},kf1={type:"object",properties:{i:{type:"string"},d:A10},required:["i","d"],additionalProperties:!1},Ef1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:Cf1},required:["l","s"],additionalProperties:!1},iP={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},c:{...kf1,nullable:!0},ca:{...Mf1,nullable:!0},d:{type:"array",items:{...Ef1},nullable:!0},pa:{...Df1,nullable:!0},t:{type:"array",items:{...Tf1},nullable:!0}},additionalProperties:!1};var m10=k0(116,iP);var gP={type:"null",nullable:!0};var u10=k0(117,gP);var Jx={};pQ(Jx,{uiDataSendPacketDefinition:()=>d10,syncRequestPacketDefinition:()=>g10,stateRequestPacketDefinition:()=>i10,inputPacketDefinition:()=>p10,debugConfigPacketDefinition:()=>y10,chatMessageSendPacketDefinition:()=>l10});var dP={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var hz={type:"object",properties:{m:{type:"string"},c:{...dP,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var l10=k0(3,hz);var aP={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var y10=k0(128,aP);var nP={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 p10=k0(1,nP);var sP={type:"object",properties:{},additionalProperties:!1};var i10=k0(2,sP);var oP={type:"null",nullable:!0};var g10=k0(0,oP);var bz={type:"object",properties:{},additionalProperties:!0};var d10=k0(4,bz);var Xx={};pQ(Xx,{worldPacketDefinition:()=>z80,uiPacketDefinition:()=>W80,uiDatasPacketDefinition:()=>G80,syncResponsePacketDefinition:()=>K80,sceneUIsPacketDefinition:()=>Q80,playersPacketDefinition:()=>Y80,physicsDebugRenderPacketDefinition:()=>X80,physicsDebugRaycastsPacketDefinition:()=>$80,particleEmittersPacketDefinition:()=>J80,lightsPacketDefinition:()=>Z80,entitiesPacketDefinition:()=>e10,chunksPacketDefinition:()=>t10,chatMessagesPacketDefinition:()=>r10,cameraPacketDefinition:()=>o10,blocksPacketDefinition:()=>n10,blockTypesPacketDefinition:()=>s10,audiosPacketDefinition:()=>a10});var v1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var rP={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:{...v1,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 tP={type:"array",items:{...rP}};var a10=k0(33,tP);var eP={type:"object",properties:{i:{type:"number"},c:v1},required:["i","c"],additionalProperties:!1};var ZC={type:"array",items:{...eP}};var n10=k0(34,ZC);var JC={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 XC={type:"array",items:{...JC}};var s10=k0(35,XC);var $C={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:{...v1,nullable:!0},p:{...v1,nullable:!0},pt:{...v1,nullable:!0},pl:{...v1,nullable:!0},s:{type:"array",items:{type:"string"},nullable:!0},sa:{type:"number",nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var YC={type:"array",items:{...hz}};var QC={type:"object",properties:{c:v1,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 KC={type:"array",items:{...QC}};var R6={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 WC={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:{...R6,nullable:!0}},required:["n"],additionalProperties:!1};var GC={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var zC={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:{...v1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...WC},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...v1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...GC,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...R6,nullable:!0}},required:["i"],additionalProperties:!1};var vC={type:"array",items:{...zC}};var HC={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...R6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...v1,nullable:!0},p:{...v1,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:{...v1,nullable:!0}},required:["i"],additionalProperties:!1};var VC={type:"array",items:{...HC}};var qC={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},b:{type:"number",nullable:!0},ce:{...R6,nullable:!0},cev:{...R6,nullable:!0},cs:{...R6,nullable:!0},csv:{...R6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...v1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...v1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...v1,nullable:!0},pa:{type:"boolean",nullable:!0},pv:{...v1,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:{...v1,nullable:!0},vv:{...v1,nullable:!0}},required:["i"],additionalProperties:!1};var FC={type:"array",items:{...qC}};var wC={type:"object",properties:{o:{...v1},d:{...v1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var UC={type:"array",items:{...wC}};var xC={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var BC={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 LC={type:"array",items:{...BC}};var jC={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...v1,nullable:!0},p:{...v1,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 cC={type:"array",items:{...jC}};var OC={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var MC={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var RC={type:"array",items:{...bz}};var If1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var NC={type:"object",properties:{i:{type:"number"},ac:{...R6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...R6,nullable:!0},di:{type:"number",nullable:!0},dp:{...v1,nullable:!0},fc:{...R6,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 o10=k0(40,$C);var r10=k0(36,YC);var t10=k0(37,KC);var e10=k0(38,vC);var Z80=k0(44,VC);var J80=k0(46,FC);var X80=k0(192,xC);var $80=k0(193,UC);var Y80=k0(45,LC);var Q80=k0(43,cC);var K80=k0(32,OC);var W80=k0(41,MC);var G80=k0(42,RC);var z80=k0(39,NC);var $x=new Map,ff1={...Zx,...Jx,...Xx};for(let Z of Object.values(ff1))if("id"in Z&&"schema"in Z){let J=Z;if($x.has(J.id))throw new Error(`Packet with id ${J.id} is already registered.`);$x.set(J.id,J)}function _f1(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=$x.get(Z[0]);return!!J&&J.validate(Z[1])}var $0=DC;var _80=t(I80(),1);import XY from"fs";import f80 from"path";var mz="./dev/persistence";class x7{static instance=new x7;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;constructor(){try{this._creativeGateway=new _80.CreativeGateway}catch{console.warn(["━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","\uD83D\uDEA8 HYTOPIA PLATFORM GATEWAY IS NOT INITIALIZED \uD83D\uDEA8","","\uD83D\uDD27 Local development is still possible, but these features will be disabled:"," • \uD83D\uDC64 Player Accounts"," • \uD83C\uDFAD Player Cosmetics"," • \uD83D\uDC1B Crash Analytics & Debug Logs","","\uD83D\uDCA1 These features will be enabled but modified:"," • \uD83D\uDCBE Player & Global Persisted Data - Data will be persisted"," locally in the ./dev/persistence directory of your project."," Player ids for data persistence will begin at 1 for the first "," player to join your local server, and increments for each"," additional player. This means that if you restart your"," server, the first player id will be 1 again. This is to ensure"," that data persistence across server restarts can be easily"," tested and debugged in local development.","","To enable the HYTOPIA Platform Gateway locally:"," 1. Set these environment variables:"," HYTOPIA_API_KEY, HYTOPIA_GAME_ID, HYTOPIA_LOBBY_ID"," 2. You can find these values at: https://create.hytopia.com","","Note: In production, these environment variables will be auto-populated ","& the HYTOPIA Platform Gateway will automatically be initialized \uD83D\uDE80","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",""].join(`
|
400
400
|
`))}}get isGatewayAvailable(){return!!this._creativeGateway}async getData(Z){if(!this._creativeGateway&&process.env.NODE_ENV==="production")return y.warning("PlatformGateway.getData(): You are running in production mode, but the Platform Gateway is not initialized! No data will be returned.");return this._creativeGateway?await this._creativeGateway.kv.get(Z):this._readDevDataLocally(Z)}async getPlayerLoadout(Z){if(!this._creativeGateway)return;return await this._creativeGateway.getLoadout(Z)}async getPlayerSession(Z){if(!this._creativeGateway)return;return await this._creativeGateway.getSession(Z)}async setData(Z,J){if(J.error)return y.warning("PlatformGateway.setData(): Cannot set data with an error property.");if(!this._creativeGateway&&process.env.NODE_ENV==="production")return y.warning("PlatformGateway.setData(): You are running in production mode, but the Platform Gateway is not initialized! No data will be set.");return this._creativeGateway?await this._creativeGateway.kv.set(Z,J):this._writeDevDataLocally(Z,J)}_readDevDataLocally(Z){try{if(!XY.existsSync(mz))return;let J=f80.join(mz,`${Z}.json`);return JSON.parse(XY.readFileSync(J,"utf8"))}catch(J){y.warning(`PlatformGateway._readDevDataLocally(): Failed to read data for key "${Z}": ${J}`)}}_writeDevDataLocally(Z,J){try{if(!XY.existsSync(mz))XY.mkdirSync(mz,{recursive:!0});let X=f80.join(mz,`${Z}.json`),$={};if(XY.existsSync(X))$=JSON.parse(XY.readFileSync(X,"utf8"));let Y={...$,...J};XY.writeFileSync(X,JSON.stringify(Y,null,2),"utf8")}catch(X){y.warning(`PlatformGateway._writeDevDataLocally(): Failed to write data for key "${Z}": ${X}`)}}}class $Y{static instance=new $Y;constructor(){}async getGlobalData(Z){let J=await x7.instance.getData(Z);if(!J||J.error){if(J?.error)y.warning(`PersistenceManager.getGlobalData(): ${J.error.message}`);return}return J}async getPlayerData(Z){let J=await x7.instance.getData(this._getPlayerKey(Z));if(!J||J.error){if(J?.error)y.warning(`PersistenceManager.getPlayerData(): ${J.error.message}`);return}return J}async setGlobalData(Z,J){let X=await x7.instance.setData(Z,J);if(!X||X.error){if(X?.error)y.warning(`PersistenceManager.setGlobalData(): ${X.error.message}`);return}return X}async setPlayerData(Z,J){let X=await x7.instance.setData(this._getPlayerKey(Z),J);if(!X||X.error){if(X?.error)y.warning(`PersistenceManager.setPlayerData(): ${X.error.message}`);return}return X}_getPlayerKey(Z){return`player-${Z.id}`}}var S80;(($)=>{$[$.FIRST_PERSON=0]="FIRST_PERSON";$[$.THIRD_PERSON=1]="THIRD_PERSON";$[$.SPECTATOR=2]="SPECTATOR"})(S80||={});var CC;((w)=>{w.LOOK_AT_ENTITY="PLAYER_CAMERA.LOOK_AT_ENTITY";w.LOOK_AT_POSITION="PLAYER_CAMERA.LOOK_AT_POSITION";w.SET_ATTACHED_TO_ENTITY="PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY";w.SET_ATTACHED_TO_POSITION="PLAYER_CAMERA.SET_ATTACHED_TO_POSITION";w.SET_FILM_OFFSET="PLAYER_CAMERA.SET_FILM_OFFSET";w.SET_FORWARD_OFFSET="PLAYER_CAMERA.SET_FORWARD_OFFSET";w.SET_FOV="PLAYER_CAMERA.SET_FOV";w.SET_MODEL_HIDDEN_NODES="PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES";w.SET_MODEL_SHOWN_NODES="PLAYER_CAMERA.SET_MODEL_SHOWN_NODES";w.SET_MODE="PLAYER_CAMERA.SET_MODE";w.SET_OFFSET="PLAYER_CAMERA.SET_OFFSET";w.SET_SHOULDER_ANGLE="PLAYER_CAMERA.SET_SHOULDER_ANGLE";w.SET_TRACKED_ENTITY="PLAYER_CAMERA.SET_TRACKED_ENTITY";w.SET_TRACKED_POSITION="PLAYER_CAMERA.SET_TRACKED_POSITION";w.SET_ZOOM="PLAYER_CAMERA.SET_ZOOM"})(CC||={});class uz extends L0{player;_attachedToEntity;_attachedToPosition;_filmOffset=0;_forwardOffset=0;_fov=75;_modelHiddenNodes=new Set;_modelShownNodes=new Set;_mode=1;_offset={x:0,y:0,z:0};_orientation={pitch:0,yaw:0};_shoulderAngle=0;_trackedEntity;_trackedPosition;_zoom=1;constructor(Z){super();this.player=Z}get attachedToEntity(){return this._attachedToEntity}get attachedToPosition(){return this._attachedToPosition}get facingDirection(){return{x:-Math.sin(this._orientation.yaw)*Math.cos(this._orientation.pitch),y:Math.sin(this._orientation.pitch),z:-Math.cos(this._orientation.yaw)*Math.cos(this._orientation.pitch)}}get facingQuaternion(){let Z=this._orientation.pitch*0.5,J=this._orientation.yaw*0.5,X=Math.cos(Z),$=Math.sin(Z),Y=Math.cos(J),Q=Math.sin(J);return{x:$*Y,y:X*Q,z:-$*Q,w:X*Y}}get filmOffset(){return this._filmOffset}get forwardOffset(){return this._forwardOffset}get fov(){return this._fov}get modelHiddenNodes(){return this._modelHiddenNodes}get modelShownNodes(){return this._modelShownNodes}get mode(){return this._mode}get offset(){return this._offset}get orientation(){return this._orientation}get shoulderAngle(){return this._shoulderAngle}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get zoom(){return this._zoom}lookAtEntity(Z){if(!this._requirePlayerWorld("lookAtEntity"))return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_ENTITY",{playerCamera:this,entity:Z})}lookAtPosition(Z){if(!this._requirePlayerWorld("lookAtPosition"))return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_POSITION",{playerCamera:this,position:Z})}reset(){this._attachedToEntity=void 0,this._attachedToPosition=void 0,this._orientation={pitch:0,yaw:0},this._trackedEntity=void 0,this._trackedPosition=void 0}setAttachedToEntity(Z){if(!this._requirePlayerWorld("setAttachedToEntity"))return;if(!Z.isSpawned)return y.error(`PlayerCamera.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);this._attachedToEntity=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",{playerCamera:this,entity:Z})}setAttachedToPosition(Z){if(!this._requirePlayerWorld("setAttachedToPosition"))return;this._attachedToPosition=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",{playerCamera:this,position:Z})}setFilmOffset(Z){if(!this._requirePlayerWorld("setFilmOffset"))return;this._filmOffset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FILM_OFFSET",{playerCamera:this,filmOffset:Z})}setForwardOffset(Z){if(!this._requirePlayerWorld("setForwardOffset"))return;this._forwardOffset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FORWARD_OFFSET",{playerCamera:this,forwardOffset:Z})}setFov(Z){if(!this._requirePlayerWorld("setFov"))return;this._fov=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FOV",{playerCamera:this,fov:Z})}setModelHiddenNodes(Z){if(!this._requirePlayerWorld("setModelHiddenNodes"))return;this._modelHiddenNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",{playerCamera:this,modelHiddenNodes:this._modelHiddenNodes})}setModelShownNodes(Z){if(!this._requirePlayerWorld("setModelShownNodes"))return;this._modelShownNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_SHOWN_NODES",{playerCamera:this,modelShownNodes:this._modelShownNodes})}setMode(Z){if(!this._requirePlayerWorld("setMode"))return;this._mode=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODE",{playerCamera:this,mode:Z})}setOffset(Z){if(!this._requirePlayerWorld("setOffset"))return;this._offset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_OFFSET",{playerCamera:this,offset:Z})}setOrientationPitch(Z){this._orientation.pitch=Z}setOrientationYaw(Z){this._orientation.yaw=Z}setShoulderAngle(Z){if(!this._requirePlayerWorld("setShoulderAngle"))return;this._shoulderAngle=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_SHOULDER_ANGLE",{playerCamera:this,shoulderAngle:Z})}setTrackedEntity(Z){if(!this._requirePlayerWorld("setTrackedEntity"))return;this._trackedEntity=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_ENTITY",{playerCamera:this,entity:Z})}setTrackedPosition(Z){if(!this._requirePlayerWorld("setTrackedPosition"))return;this._trackedPosition=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_POSITION",{playerCamera:this,position:Z})}setZoom(Z){if(!this._requirePlayerWorld("setZoom"))return;this._zoom=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ZOOM",{playerCamera:this,zoom:Z})}serialize(){return P0.serializePlayerCamera(this)}_requirePlayerWorld(Z){if(!this.player.world)y.error(`PlayerCamera._requirePlayerWorld(): Player ${this.player.id} is not in a world, invoked method: ${Z}()`);return!!this.player.world}}var Qx;((Y)=>{Y.DATA="PLAYER_UI.DATA";Y.LOAD="PLAYER_UI.LOAD";Y.LOCK_POINTER="PLAYER_UI.LOCK_POINTER";Y.SEND_DATA="PLAYER_UI.SEND_DATA"})(Qx||={});class lz extends L0{player;constructor(Z){super();this.player=Z}load(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOAD",{playerUI:this,htmlUri:Z})}lockPointer(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOCK_POINTER",{playerUI:this,lock:Z})}sendData(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.SEND_DATA",{playerUI:this,data:Z})}}var h80=["w","a","s","d","sp","sh","tb","ml","mr","q","e","r","f","z","x","c","v","u","i","o","j","k","l","n","m","1","2","3","4","5","6","7","8","9","0"],yz;((Q)=>{Q.CHAT_MESSAGE_SEND="PLAYER.CHAT_MESSAGE_SEND";Q.JOINED_WORLD="PLAYER.JOINED_WORLD";Q.LEFT_WORLD="PLAYER.LEFT_WORLD";Q.RECONNECTED_WORLD="PLAYER.RECONNECTED_WORLD";Q.REQUEST_SYNC="PLAYER.REQUEST_SYNC"})(yz||={});class sK extends L0{static _devNextPlayerId=1;id;username;profilePictureUrl;camera;connection;ui;_input={};_lastUnreliableInputSequenceNumber=0;_persistedData;_world;_worldSwitched=!1;constructor(Z,J){super();this.id=J?.user.id??`player-${sK._devNextPlayerId++}`,this.username=J?.user.username??this.id,this.profilePictureUrl=J?.user.profilePictureURL??void 0,this.camera=new uz(this),this.connection=Z,this.ui=new lz(this),Z.onPacket($0.PacketId.CHAT_MESSAGE_SEND,this._onChatMessageSendPacket),Z.onPacket($0.PacketId.DEBUG_CONFIG,this._onDebugConfigPacket),Z.onPacket($0.PacketId.INPUT,this._onInputPacket),Z.onPacket($0.PacketId.SYNC_REQUEST,this._onSyncRequestPacket),Z.onPacket($0.PacketId.UI_DATA_SEND,this._onUIDataSendPacket)}get input(){return this._input}get world(){return this._world}disconnect(){this._leaveWorld(),this.connection.disconnect()}getPersistedData(){return this._persistedData}joinWorld(Z){if(this._world===Z)return;if(!this._world)this._world=Z,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world});else{for(let J of this._world.entityManager.getPlayerEntitiesByPlayer(this))if(J.isSpawned)J.despawn();this.disconnect(),this._world=Z,this._worldSwitched=!0}}async loadInitialPersistedData(){if(this._persistedData)return;this._persistedData=await $Y.instance.getPlayerData(this)??void 0}reconnected(){if(!this._world)return;if(this._lastUnreliableInputSequenceNumber=0,!this._worldSwitched)this.emitWithWorld(this._world,"PLAYER.RECONNECTED_WORLD",{player:this,world:this._world});else this._worldSwitched=!1,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world})}resetInputs(){this._input={}}setPersistedData(Z){return this._persistedData={...this._persistedData,...Z},$Y.instance.setPlayerData(this,Z).catch((J)=>{}),this._persistedData}serialize(){return P0.serializePlayer(this)}_leaveWorld(){if(!this._world)return;this.emitWithWorld(this._world,"PLAYER.LEFT_WORLD",{player:this,world:this._world}),this._world=void 0}_onChatMessageSendPacket=(Z)=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.CHAT_MESSAGE_SEND",{player:this,message:Z[1].m})};_onDebugConfigPacket=(Z)=>{console.log(Z)};_onInputPacket=(Z)=>{let J=Z[1];if(J.sq!==void 0){if(J.sq<this._lastUnreliableInputSequenceNumber)return;this._lastUnreliableInputSequenceNumber=J.sq}if(h80.forEach((X)=>{let $=X;if(J[$]!==void 0)this._input[$]=Boolean(J[$])}),J.cp!==void 0)this.camera.setOrientationPitch(J.cp);if(J.cy!==void 0)this.camera.setOrientationYaw(J.cy)};_onSyncRequestPacket=()=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.REQUEST_SYNC",{player:this,receivedAt:Date.now(),receivedAtMs:performance.now()})};_onUIDataSendPacket=(Z)=>{this.ui.emit("PLAYER_UI.DATA",{playerUI:this.ui,data:Z[1]})}}var TC;((X)=>{X.BROADCAST_MESSAGE="CHAT.BROADCAST_MESSAGE";X.PLAYER_MESSAGE="CHAT.PLAYER_MESSAGE"})(TC||={});class pz extends L0{_commandCallbacks={};_world;constructor(Z){super();this._world=Z,this._subscribeToPlayerEvents()}registerCommand(Z,J){this._commandCallbacks[Z]=J}unregisterCommand(Z){delete this._commandCallbacks[Z]}sendBroadcastMessage(Z,J){this._sendBroadcastMessage(void 0,Z,J)}sendPlayerMessage(Z,J,X){this.emitWithWorld(this._world,"CHAT.PLAYER_MESSAGE",{player:Z,message:J,color:X})}_subscribeToPlayerEvents(){this._world.on("PLAYER.CHAT_MESSAGE_SEND",(Z)=>{let{player:J,message:X}=Z,[$,...Y]=X.split(" "),Q=this._commandCallbacks[$];if(Q){Q(J,Y,X);return}this._sendBroadcastMessage(J,X)})}_sendBroadcastMessage(Z,J,X){this.emitWithWorld(this._world,"CHAT.BROADCAST_MESSAGE",{player:Z,message:J,color:X})}}var p5=16,kC=p5-1,Q_1=p5**3;class i5{_blocks;_originCoordinate;constructor(Z){this._blocks=new Uint8Array(Q_1),this._originCoordinate=Z}get blocks(){return this._blocks}get originCoordinate(){return this._originCoordinate}static blockIndexToLocalCoordinate(Z){return{x:Z%p5,y:(Z/p5|0)%p5,z:Z/(p5*p5)|0}}static globalCoordinateToLocalCoordinate(Z){return{x:Z.x&p5-1,y:Z.y&p5-1,z:Z.z&p5-1}}static globalCoordinateToOriginCoordinate(Z){return{x:Z.x&~(p5-1),y:Z.y&~(p5-1),z:Z.z&~(p5-1)}}getBlockId(Z){return this._blocks[this._getIndex(Z)]}hasBlock(Z){return this._blocks[this._getIndex(Z)]!==0}setBlock(Z,J){if(!this._isValidLocalCoordinate(Z))return y.error("Chunk.setBlock(): Block local coordinate is out of bounds");let X=this._getIndex(Z);this._blocks[X]=J}serialize(){return P0.serializeChunk(this)}_getIndex(Z){return Z.x+(Z.y<<4)+(Z.z<<8)}_isValidLocalCoordinate(Z){return Z.x>=0&&Z.x<=kC&&Z.y>=0&&Z.y<=kC&&Z.z>=0&&Z.z<=kC}}var EC;(($)=>{$.ADD_CHUNK="CHUNK_LATTICE.ADD_CHUNK";$.REMOVE_CHUNK="CHUNK_LATTICE.REMOVE_CHUNK";$.SET_BLOCK="CHUNK_LATTICE.SET_BLOCK"})(EC||={});class iz extends L0{_blockTypeColliders=new Map;_blockTypeCounts=new Map;_chunks=new Map;_rigidBody;_world;constructor(Z){super();this._world=Z}get chunkCount(){return this._chunks.size}clear(){for(let Z of this._blockTypeColliders.values())this._world.simulation.colliderMap.removeColliderBlockType(Z),Z.removeFromSimulation();this._chunks.forEach((Z)=>{this.emitWithWorld(this._world,"CHUNK_LATTICE.REMOVE_CHUNK",{chunkLattice:this,chunk:Z})}),this._blockTypeColliders.clear(),this._blockTypeCounts.clear(),this._chunks.clear()}getBlockId(Z){let J=this.getChunk(i5.globalCoordinateToOriginCoordinate(Z));if(!J)return 0;return J.getBlockId(i5.globalCoordinateToLocalCoordinate(Z))}getBlockTypeCollider(Z){return this._blockTypeColliders.get(Z)}getBlockType(Z){let J=this.getBlockId(Z);return J?this._world.blockTypeRegistry.getBlockType(J):null}getBlockTypeCount(Z){return this._blockTypeCounts.get(Z)??0}getChunk(Z){return this._chunks.get(this._getChunkKey(i5.globalCoordinateToOriginCoordinate(Z)))}getOrCreateBlockTypeCollider(Z,J){let X=this._blockTypeColliders.get(Z);if(X)return X;let Y=this._world.blockTypeRegistry.getBlockType(Z).createCollider(J);return this._blockTypeColliders.set(Z,Y),Y}getOrCreateChunk(Z){let J=i5.globalCoordinateToOriginCoordinate(Z),X=this._chunks.get(this._getChunkKey(J));if(X)return X;return X=new i5(J),this._chunks.set(this._getChunkKey(J),X),this.emitWithWorld(this._world,"CHUNK_LATTICE.ADD_CHUNK",{chunkLattice:this,chunk:X}),X}getAllChunks(){return Array.from(this._chunks.values())}hasBlock(Z){let J=this.getChunk(i5.globalCoordinateToOriginCoordinate(Z));if(!J)return!1;return J.hasBlock(i5.globalCoordinateToLocalCoordinate(Z))}hasChunk(Z){let J=i5.globalCoordinateToOriginCoordinate(Z);return this._chunks.has(this._getChunkKey(J))}setBlock(Z,J){let X=i5.globalCoordinateToLocalCoordinate(Z),$=this.getOrCreateChunk(Z),Y=$.getBlockId(X);if(Y===J)return;if($.setBlock(X,J),!this._rigidBody)this._rigidBody=new s$({type:"fixed"}),this._rigidBody.addToSimulation(this._world.simulation);if(Y!==0){let Q=Math.max(0,(this._blockTypeCounts.get(Y)??0)-1),K=this.getBlockTypeCollider(Y);if(K)if(Q===0)this._world.simulation.colliderMap.removeColliderBlockType(K),K.removeFromSimulation(),this._blockTypeColliders.delete(Y);else K.setVoxel(Z,!1),this._propagateVoxelChange(K,Z);this._blockTypeCounts.set(Y,Q)}if(J!==0){let Q=(this._blockTypeCounts.get(J)??0)+1,K=this.getOrCreateBlockTypeCollider(J,[Z]);if(Q===1){let W=this._world.blockTypeRegistry.getBlockType(J);K.addToSimulation(this._world.simulation,this._rigidBody),this._world.simulation.colliderMap.setColliderBlockType(K,W),this._combineVoxelStates(K)}else K.setVoxel(Z,!0),this._propagateVoxelChange(K,Z);this._blockTypeCounts.set(J,Q)}this.emitWithWorld(this._world,"CHUNK_LATTICE.SET_BLOCK",{chunkLattice:this,chunk:$,globalCoordinate:Z,localCoordinate:X,blockTypeId:J})}_combineVoxelStates(Z){if(Z.isSensor)return;for(let J of this._blockTypeColliders.values()){if(J===Z||J.isSensor)continue;Z.combineVoxelStates(J)}}_getChunkKey(Z){return`${Z.x},${Z.y},${Z.z}`}_propagateVoxelChange(Z,J){if(Z.isSensor)return;for(let X of this._blockTypeColliders.values()){if(X===Z||X.isSensor)continue;Z.propagateVoxelChange(X,J)}}}class gz{_colliderHandleBlockTypeMap=new Map;_colliderHandleCollisionCallbackMap=new Map;_colliderHandleEntityMap=new Map;_cleanupBlockTypeColliderHandles=new Set;_pendingCleanupBlockTypeColliderHandles=new Set;_cleanupCollisionCallbackColliderHandles=new Set;_pendingCleanupCollisionCallbackColliderHandles=new Set;_cleanupEntityColliderHandles=new Set;_pendingCleanupEntityColliderHandles=new Set;getColliderBlockType(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleBlockTypeMap.get(Z.rawCollider.handle)}getColliderCollisionCallback(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleCollisionCallbackMap.get(Z.rawCollider.handle)}getColliderEntity(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleEntityMap.get(Z.rawCollider.handle)}getColliderHandleBlockType(Z){return this._colliderHandleBlockTypeMap.get(Z)}getColliderHandleCollisionCallback(Z){return this._colliderHandleCollisionCallbackMap.get(Z)}getColliderHandleEntity(Z){return this._colliderHandleEntityMap.get(Z)}removeColliderBlockType(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleBlockType(Z.rawCollider.handle)}removeColliderCollisionCallback(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleCollisionCallback(Z.rawCollider.handle)}removeColliderEntity(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleEntity(Z.rawCollider.handle)}removeColliderHandleBlockType(Z){this._colliderHandleBlockTypeMap.delete(Z)}removeColliderHandleCollisionCallback(Z){this._colliderHandleCollisionCallbackMap.delete(Z)}removeColliderHandleEntity(Z){this._colliderHandleEntityMap.delete(Z)}setColliderBlockType(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleBlockType(Z.rawCollider.handle,J)}setColliderCollisionCallback(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleCollisionCallback(Z.rawCollider.handle,J)}setColliderEntity(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleEntity(Z.rawCollider.handle,J)}setColliderHandleBlockType(Z,J){this._colliderHandleBlockTypeMap.set(Z,J),this._cleanupBlockTypeColliderHandles.delete(Z),this._pendingCleanupBlockTypeColliderHandles.delete(Z)}setColliderHandleCollisionCallback(Z,J){this._colliderHandleCollisionCallbackMap.set(Z,J),this._cleanupCollisionCallbackColliderHandles.delete(Z),this._pendingCleanupCollisionCallbackColliderHandles.delete(Z)}setColliderHandleEntity(Z,J){this._colliderHandleEntityMap.set(Z,J),this._cleanupEntityColliderHandles.delete(Z),this._pendingCleanupEntityColliderHandles.delete(Z)}queueColliderHandleForCleanup(Z){if(this._colliderHandleBlockTypeMap.has(Z))this._pendingCleanupBlockTypeColliderHandles.add(Z);if(this._colliderHandleCollisionCallbackMap.has(Z))this._pendingCleanupCollisionCallbackColliderHandles.add(Z);if(this._colliderHandleEntityMap.has(Z))this._pendingCleanupEntityColliderHandles.add(Z)}cleanup(){for(let Z of this._cleanupBlockTypeColliderHandles)this._colliderHandleBlockTypeMap.delete(Z);if(this._cleanupBlockTypeColliderHandles.size>0)this._cleanupBlockTypeColliderHandles.clear();for(let Z of this._cleanupCollisionCallbackColliderHandles)this._colliderHandleCollisionCallbackMap.delete(Z);if(this._cleanupCollisionCallbackColliderHandles.size>0)this._cleanupCollisionCallbackColliderHandles.clear();for(let Z of this._cleanupEntityColliderHandles)this._colliderHandleEntityMap.delete(Z);if(this._cleanupEntityColliderHandles.size>0)this._cleanupEntityColliderHandles.clear();for(let Z of this._pendingCleanupBlockTypeColliderHandles)this._cleanupBlockTypeColliderHandles.add(Z);if(this._pendingCleanupBlockTypeColliderHandles.size>0)this._pendingCleanupBlockTypeColliderHandles.clear();for(let Z of this._pendingCleanupCollisionCallbackColliderHandles)this._cleanupCollisionCallbackColliderHandles.add(Z);if(this._pendingCleanupCollisionCallbackColliderHandles.size>0)this._pendingCleanupCollisionCallbackColliderHandles.clear();for(let Z of this._pendingCleanupEntityColliderHandles)this._cleanupEntityColliderHandles.add(Z);if(this._pendingCleanupEntityColliderHandles.size>0)this._pendingCleanupEntityColliderHandles.clear()}_requireSimulatedCollider(Z){if(!Z.rawCollider)y.error("ColliderMap._requireSimulatedCollider(): Collider is not in the simulation.");return!!Z.rawCollider}}var b80={type:"dynamic",softCcdPrediction:1},A80=0.015625,m80=Math.cos(0.026),dz;((c)=>{c.BLOCK_COLLISION="ENTITY.BLOCK_COLLISION";c.BLOCK_CONTACT_FORCE="ENTITY.BLOCK_CONTACT_FORCE";c.DESPAWN="ENTITY.DESPAWN";c.ENTITY_COLLISION="ENTITY.ENTITY_COLLISION";c.ENTITY_CONTACT_FORCE="ENTITY.ENTITY_CONTACT_FORCE";c.SET_MODEL_ANIMATIONS_PLAYBACK_RATE="ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE";c.SET_MODEL_HIDDEN_NODES="ENTITY.SET_MODEL_HIDDEN_NODES";c.SET_MODEL_SCALE="ENTITY.SET_MODEL_SCALE";c.SET_MODEL_SHOWN_NODES="ENTITY.SET_MODEL_SHOWN_NODES";c.SET_MODEL_TEXTURE_URI="ENTITY.SET_MODEL_TEXTURE_URI";c.SET_OPACITY="ENTITY.SET_OPACITY";c.SET_PARENT="ENTITY.SET_PARENT";c.SET_TINT_COLOR="ENTITY.SET_TINT_COLOR";c.SPAWN="ENTITY.SPAWN";c.START_MODEL_LOOPED_ANIMATIONS="ENTITY.START_MODEL_LOOPED_ANIMATIONS";c.START_MODEL_ONESHOT_ANIMATIONS="ENTITY.START_MODEL_ONESHOT_ANIMATIONS";c.STOP_MODEL_ANIMATIONS="ENTITY.STOP_MODEL_ANIMATIONS";c.TICK="ENTITY.TICK";c.UPDATE_POSITION="ENTITY.UPDATE_POSITION";c.UPDATE_ROTATION="ENTITY.UPDATE_ROTATION"})(dz||={});class A8 extends s${_id;_blockHalfExtents;_blockTextureUri;_controller;_isEnvironmental=!1;_modelAnimationsPlaybackRate=1;_modelHiddenNodes=new Set;_modelLoopedAnimations=new Set;_modelOneshotAnimations=new Set;_modelPreferredShape;_modelScale=1;_modelShownNodes=new Set;_modelTextureUri;_modelUri;_name;_opacity;_parent;_parentNodeName;_tag;_tintColor;_lastUpdatedPosition={x:0,y:0,z:0};_lastUpdatedRotation={x:0,y:0,z:0,w:1};_lastParentlessType="dynamic";_world;_positionUpdateThresholdSq;_rotationUpdateThreshold;constructor(Z){let J="blockTextureUri"in Z,X="modelUri"in Z;if(!J===!X)y.fatalError("Entity.constructor(): Entity data must include a blockTextureUri or modelUri, but not both.");if(J&&!Z.blockHalfExtents)y.fatalError("Entity.constructor(): Block entity must have blockHalfExtents!");if(Z.parent&&!Z.parent.isSpawned)y.fatalError("Entity.constructor(): Parent entity must be spawned before child entity!");if(Z.parent?.modelUri&&Z.parentNodeName&&!U5.instance.modelHasNode(Z.parent.modelUri,Z.parentNodeName))y.fatalError(`Entity.constructor(): Parent node name ${Z.parentNodeName} not found in parent model ${Z.parent.modelUri}!`);super(Z.rigidBodyOptions??b80);if(J)this._blockHalfExtents=Z.blockHalfExtents,this._blockTextureUri=Z.blockTextureUri;if(X)this._modelAnimationsPlaybackRate=Z.modelAnimationsPlaybackRate??1,this._modelPreferredShape=Z.modelPreferredShape,this._modelScale=Z.modelScale??1,this._modelTextureUri=Z.modelTextureUri,this._modelUri=Z.modelUri,Z.modelHiddenNodes?.forEach(($)=>this._modelHiddenNodes.add($.toLowerCase())),Z.modelLoopedAnimations?.forEach(($)=>this._modelLoopedAnimations.add($)),Z.modelShownNodes?.forEach(($)=>this._modelShownNodes.add($.toLowerCase()));if(this._isEnvironmental=Z.isEnvironmental??!1,this._name=Z.name??"Nameless",this._opacity=Z.opacity??1,this._parent=Z.parent,this._parentNodeName=Z.parentNodeName,this._tag=Z.tag,this._tintColor=Z.tintColor,this._positionUpdateThresholdSq=A80,this._rotationUpdateThreshold=m80,Z.controller)this.setController(Z.controller)}get id(){return this._id}get blockHalfExtents(){return this._blockHalfExtents}get blockTextureUri(){return this._blockTextureUri}get controller(){return this._controller}get depth(){return this.isModelEntity?U5.instance.getDepth(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.z*2}get height(){return this.isModelEntity?U5.instance.getHeight(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.y*2}get modelAnimationsPlaybackRate(){return this._modelAnimationsPlaybackRate}get modelHiddenNodes(){return this._modelHiddenNodes}get modelLoopedAnimations(){return this._modelLoopedAnimations}get modelPreferredShape(){return this._modelPreferredShape}get modelScale(){return this._modelScale}get modelShownNodes(){return this._modelShownNodes}get modelTextureUri(){return this._modelTextureUri}get modelUri(){return this._modelUri}get name(){return this._name}get opacity(){return this._opacity}get parent(){return this._parent}get parentNodeName(){return this._parentNodeName}get tag(){return this._tag}get tintColor(){return this._tintColor}get isBlockEntity(){return!!this._blockTextureUri}get isEnvironmental(){return this._isEnvironmental}get isModelEntity(){return!!this._modelUri}get isSpawned(){return!!this._world}get width(){return this.isModelEntity?U5.instance.getWidth(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.x*2}get world(){return this._world}spawn(Z,J,X){if(this.isSpawned)return y.error(`Entity.spawn(): Entity ${this._name} is already spawned with id ${this._id}!`);if(!this.isSimulated)this.addToSimulation(Z.simulation);if(this._blockTextureUri&&this._blockHalfExtents&&this.numColliders===0)this.addChildColliderToSimulation(new l5(l5.optionsFromBlockHalfExtents(this._blockHalfExtents)));if(this._modelUri&&this.numColliders===0&&this._modelPreferredShape!=="none")this.addChildColliderToSimulation(new l5(l5.optionsFromModelUri(this._modelUri,this._modelScale,this._modelPreferredShape)));if(this.colliders.forEach(($)=>{if(this.hasListeners("ENTITY.BLOCK_COLLISION")||this.hasListeners("ENTITY.ENTITY_COLLISION"))$.enableCollisionEvents(!0);if(this.hasListeners("ENTITY.BLOCK_CONTACT_FORCE")||this.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))$.enableContactForceEvents(!0);if(G9.isDefaultCollisionGroups($.collisionGroups)){let Y=this.isEnvironmental?[8]:[$.isSensor?4:2],Q=this.isEnvironmental?[65535&~8&~1]:[65535];$.setCollisionGroups({belongsTo:Y,collidesWith:Q})}}),this.setPosition(J),X)this.setRotation(X);if(this._id=Z.entityManager.registerEntity(this),this._world=Z,this._controller)this._controller.spawn(this);if(this._parent)this.setParent(this._parent,this._parentNodeName,J,X);this.colliders.forEach(($)=>{Z.simulation.colliderMap.setColliderEntity($,this)}),this.emitWithWorld(Z,"ENTITY.SPAWN",{entity:this})}despawn(){if(!this._requireSpawned("despawn"))return;if(this._world.entityManager.getEntityChildren(this).forEach((Z)=>{Z.despawn()}),this._controller)this._controller.detach(this),this._controller.despawn(this);if(this.emitWithWorld(this._world,"ENTITY.DESPAWN",{entity:this}),this.isSimulated)this.removeFromSimulation();this._world.entityManager.unregisterEntity(this),this._world.audioManager.unregisterEntityAttachedAudios(this),this._world.lightManager.despawnEntityAttachedLights(this),this._world.particleEmitterManager.despawnEntityAttachedParticleEmitters(this),this._world.sceneUIManager.unloadEntityAttachedSceneUIs(this),this._id=void 0,this._world=void 0}setController(Z){if(this._controller===Z)return;if(this._controller)this._controller.detach(this);if(this._controller=Z,this._controller)this._controller.attach(this)}setModelAnimationsPlaybackRate(Z){if(!this._requireSpawned("setModelAnimationsPlaybackRate"))return;if(!this.isModelEntity||this._modelAnimationsPlaybackRate===Z)return;this._modelAnimationsPlaybackRate=Z,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",{entity:this,playbackRate:Z})}setModelHiddenNodes(Z){if(!this._requireSpawned("setModelHiddenNodes"))return;if(!this.isModelEntity)return;this._modelHiddenNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_HIDDEN_NODES",{entity:this,modelHiddenNodes:this._modelHiddenNodes})}setModelScale(Z){if(!this._requireSpawned("setModelScale"))return;if(!this.isModelEntity||this._modelScale===Z)return;let J=Z/this._modelScale;this._modelScale=Z,this.colliders.forEach((X)=>X.scale(J)),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_SCALE",{entity:this,modelScale:Z})}setModelShownNodes(Z){if(!this._requireSpawned("setModelShownNodes"))return;if(!this.isModelEntity)return;this._modelShownNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_SHOWN_NODES",{entity:this,modelShownNodes:this._modelShownNodes})}setModelTextureUri(Z){if(!this._requireSpawned("setModelTextureUri"))return;if(!this.isModelEntity||this._modelTextureUri===Z)return;this._modelTextureUri=Z,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_TEXTURE_URI",{entity:this,modelTextureUri:Z})}setOpacity(Z){if(!this._requireSpawned("setOpacity"))return;if(this._opacity===Z)return;this._opacity=Z,this.emitWithWorld(this._world,"ENTITY.SET_OPACITY",{entity:this,opacity:Z})}setParent(Z,J,X,$){if(!this._requireSpawned("setParent"))return;if(Z&&!Z.isSpawned)return y.error("Entity.setParent(): Parent entity is not spawned, cannot set parent!");if(!this._parent&&Z)this._lastParentlessType=this.type;if(this._parent=Z,this._parentNodeName=J,this.colliders.forEach((Y)=>Y.setEnabled(!Z)),this.setType(!Z?this._lastParentlessType:"kinematic_velocity"),this.setPosition(X??{x:0,y:0,z:0}),this.setRotation($??{x:0,y:0,z:0,w:1}),!this.isKinematicPositionBased)this.resetAngularVelocity(),this.resetForces(),this.resetLinearVelocity(),this.resetTorques();this.emitWithWorld(this._world,"ENTITY.SET_PARENT",{entity:this,parent:Z,parentNodeName:J})}setTintColor(Z){if(!this._requireSpawned("setTintColor"))return;if(!Z&&!this._tintColor||Z&&this._tintColor&&Z.r===this._tintColor.r&&Z.g===this._tintColor.g&&Z.b===this._tintColor.b)return;this._tintColor=Z,this.emitWithWorld(this._world,"ENTITY.SET_TINT_COLOR",{entity:this,tintColor:Z})}startModelLoopedAnimations(Z){if(!this._requireSpawned("startModelLoopedAnimations"))return;if(!this.isModelEntity||!Z.length)return;if(!Z.some((J)=>!this._modelLoopedAnimations.has(J)))return;Z.forEach((J)=>{this._modelLoopedAnimations.add(J)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_LOOPED_ANIMATIONS",{entity:this,animations:new Set(Z)})}startModelOneshotAnimations(Z){if(!this._requireSpawned("startModelOneshotAnimations"))return;if(!this.isModelEntity||!Z.length)return;Z.forEach((J)=>{this._modelOneshotAnimations.add(J)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_ONESHOT_ANIMATIONS",{entity:this,animations:new Set(Z)})}stopAllModelAnimations(Z=[]){if(!this._requireSpawned("stopAllModelAnimations"))return;this._stopAnimationsFromSets([this._modelLoopedAnimations,this._modelOneshotAnimations],Z)}stopAllModelLoopedAnimations(Z=[]){if(!this._requireSpawned("stopAllModelLoopedAnimations"))return;this._stopAnimationsFromSets([this._modelLoopedAnimations],Z)}stopAllModelOneshotAnimations(Z=[]){if(!this._requireSpawned("stopAllModelOneshotAnimations"))return;this._stopAnimationsFromSets([this._modelOneshotAnimations],Z)}stopModelAnimations(Z){if(!this._requireSpawned("stopModelAnimations"))return;if(!this.isModelEntity||!Z.length)return;if(!Z.some((J)=>this._modelLoopedAnimations.has(J))&&!Z.some((J)=>this._modelOneshotAnimations.has(J)))return;Z.forEach((J)=>{this._modelLoopedAnimations.delete(J),this._modelOneshotAnimations.delete(J)}),this.emitWithWorld(this._world,"ENTITY.STOP_MODEL_ANIMATIONS",{entity:this,animations:new Set(Z)})}serialize(){return P0.serializeEntity(this)}tick(Z){if(this.emit("ENTITY.TICK",{entity:this,tickDeltaMs:Z}),this._controller)this._controller.tick(this,Z)}checkAndEmitUpdates(){if(!this._requireSpawned("checkAndEmitUpdates"))return;let Z=this.position,J=this.rotation;if(this._rotationExceedsThreshold(J,this._lastUpdatedRotation))this._lastUpdatedRotation=J,this.emitWithWorld(this._world,"ENTITY.UPDATE_ROTATION",{entity:this,rotation:J});if(this._positionExceedsThreshold(Z,this._lastUpdatedPosition))this._lastUpdatedPosition=Z,this.emitWithWorld(this._world,"ENTITY.UPDATE_POSITION",{entity:this,position:Z})}_positionExceedsThreshold(Z,J){let X=Z.x-J.x,$=Z.y-J.y,Y=Z.z-J.z;return X*X+$*$+Y*Y>this._positionUpdateThresholdSq}_requireSpawned(Z){if(!this.isSpawned)y.error(`Entity._requireSpawned(): Entity ${this._name} is not spawned, cannot invoke ${Z}()!`);return this.isSpawned}_rotationExceedsThreshold(Z,J){return Math.abs(Z.x*J.x+Z.y*J.y+Z.z*J.z+Z.w*J.w)<this._rotationUpdateThreshold}_stopAnimationsFromSets(Z,J=[]){if(!this.isModelEntity)return;let X=new Set(J),$=[];for(let Y of Z)for(let Q of Y)if(!X.has(Q))$.push(Q);if($.length>0)this.stopModelAnimations($)}}class f1 extends z${static BASE_ENTITY_HEIGHT=1.5;static GROUND_SENSOR_HEIGHT_SCALE=0.125;static GROUND_SENSOR_RADIUS_SCALE=0.23;static JUMP_LAND_HEAVY_VELOCITY_THRESHOLD=-12;static WALL_COLLIDER_HEIGHT_SCALE=0.33;static WALL_COLLIDER_RADIUS_SCALE=0.4;static MOVEMENT_ROTATIONS={wa:Math.PI/4,wd:-Math.PI/4,sa:Math.PI-Math.PI/4,sd:Math.PI+Math.PI/4,s:Math.PI,asd:Math.PI,a:Math.PI/2,d:-Math.PI/2};static EXTERNAL_IMPULSE_DECAY_RATE=0.253;static SWIM_UPWARD_COOLDOWN_MS=600;static SWIMMING_DRAG_FACTOR=0.05;static WATER_ENTRY_SINKING_FACTOR=0.8;static WATER_ENTRY_SINKING_MS=250;applyDirectionalMovementRotations=!0;autoCancelMouseLeftClick=!0;canJump=()=>!0;canRun=()=>!0;canSwim=()=>!0;canWalk=()=>!0;faceForwardOnStop=!0;idleLoopedAnimations=["idle-upper","idle-lower"];interactOneshotAnimations=["simple-interact"];jumpLandHeavyOneshotAnimations=["jump-post-heavy"];jumpLandLightOneshotAnimations=["jump-post-light"];jumpOneshotAnimations=["jump-loop"];jumpVelocity=10;runLoopedAnimations=["run-upper","run-lower"];runVelocity=8;sticksToPlatforms=!0;swimFastVelocity=5;swimGravity=0;swimIdleLoopedAnimations=["swim-idle"];swimLoopedAnimations=["swim-forward"];swimMaxGravityVelocity=-1;swimSlowVelocity=3;swimUpwardVelocity=2;walkLoopedAnimations=["walk-upper","walk-lower"];walkVelocity=4;_externalVelocity={x:0,y:0,z:0};_magnitudeYTracker=0;_groundContactCount=0;_internalApplyImpulse=()=>{};_isActivelyMoving=!1;_isFullySubmerged=!1;_justSubmergedUntil=0;_liquidContactCount=0;_platform;_reusableImpulse={x:0,y:0,z:0};_reusablePlatformVelocity={x:0,y:0,z:0};_reusableTargetVelocities={x:0,y:0,z:0};_reusableVelocityClamp={x:0,y:0,z:0};_stepAudio;_swimUpwardCooldownAt=0;constructor(Z={}){super();this.applyDirectionalMovementRotations=Z.applyDirectionalMovementRotations??this.applyDirectionalMovementRotations,this.autoCancelMouseLeftClick=Z.autoCancelMouseLeftClick??this.autoCancelMouseLeftClick,this.faceForwardOnStop=Z.faceForwardOnStop??this.faceForwardOnStop,this.sticksToPlatforms=Z.sticksToPlatforms??this.sticksToPlatforms,this.canJump=Z.canJump??this.canJump,this.canRun=Z.canRun??this.canRun,this.canSwim=Z.canSwim??this.canSwim,this.canWalk=Z.canWalk??this.canWalk,this.jumpVelocity=Z.jumpVelocity??this.jumpVelocity,this.runVelocity=Z.runVelocity??this.runVelocity,this.walkVelocity=Z.walkVelocity??this.walkVelocity,this.swimFastVelocity=Z.swimFastVelocity??this.swimFastVelocity,this.swimSlowVelocity=Z.swimSlowVelocity??this.swimSlowVelocity,this.swimUpwardVelocity=Z.swimUpwardVelocity??this.swimUpwardVelocity,this.swimGravity=Z.swimGravity??this.swimGravity,this.swimMaxGravityVelocity=Z.swimMaxGravityVelocity??this.swimMaxGravityVelocity,this.idleLoopedAnimations=Z.idleLoopedAnimations??this.idleLoopedAnimations,this.interactOneshotAnimations=Z.interactOneshotAnimations??this.interactOneshotAnimations,this.jumpOneshotAnimations=Z.jumpOneshotAnimations??this.jumpOneshotAnimations,this.jumpLandHeavyOneshotAnimations=Z.jumpLandHeavyOneshotAnimations??this.jumpLandHeavyOneshotAnimations,this.jumpLandLightOneshotAnimations=Z.jumpLandLightOneshotAnimations??this.jumpLandLightOneshotAnimations,this.runLoopedAnimations=Z.runLoopedAnimations??this.runLoopedAnimations,this.swimLoopedAnimations=Z.swimLoopedAnimations??this.swimLoopedAnimations,this.swimIdleLoopedAnimations=Z.swimIdleLoopedAnimations??this.swimIdleLoopedAnimations,this.walkLoopedAnimations=Z.walkLoopedAnimations??this.walkLoopedAnimations}get isActivelyMoving(){return this._isActivelyMoving}get isGrounded(){return this._groundContactCount>0}get isOnPlatform(){return!!this._platform}get isSwimming(){return this._liquidContactCount>0}get platform(){return this._platform}attach(Z){super.attach(Z),this._internalApplyImpulse=Z.applyImpulse.bind(Z),Z.applyImpulse=(J)=>{let X=Z.mass||1;this._externalVelocity.x+=J.x/X,this._externalVelocity.y+=J.y/X,this._externalVelocity.z+=J.z/X},this._stepAudio=new hW({uri:"audio/sfx/step/stone/stone-step-04.mp3",loop:!0,volume:0.1,referenceDistance:2,cutoffDistance:15,attachedToEntity:Z}),Z.setCcdEnabled(!0),Z.lockAllRotations(),Z.on("ENTITY.BLOCK_COLLISION",({blockType:J,started:X})=>{if(!J.isLiquid||!this.canSwim(this))return;if(this._liquidContactCount<=0&&X){let $=Z.linearVelocity;Z.setLinearVelocity({x:$.x*this.swimGravity,y:$.y*this.swimGravity,z:$.z*this.swimGravity})}if(this._liquidContactCount+=X?1:-1,this._liquidContactCount>0)Z.setGravityScale(this.swimGravity),Z.stopAllModelLoopedAnimations(this.swimLoopedAnimations),this._swimUpwardCooldownAt=performance.now()+f1.SWIM_UPWARD_COOLDOWN_MS;else Z.setGravityScale(1),Z.stopModelAnimations(this.swimLoopedAnimations)})}spawn(Z){if(!Z.isSpawned)return y.error("DefaultPlayerEntityController.spawn(): Entity is not spawned!");Z.createAndAddChildCollider({shape:"cylinder",radius:f1.GROUND_SENSOR_RADIUS_SCALE*(Z.height/f1.BASE_ENTITY_HEIGHT),halfHeight:f1.GROUND_SENSOR_HEIGHT_SCALE*(Z.height/f1.BASE_ENTITY_HEIGHT),collisionGroups:{belongsTo:[4],collidesWith:[1,2,8]},isSensor:!0,relativePosition:{x:0,y:-Z.height/2,z:0},tag:"groundSensor",onCollision:(J,X)=>{if(!Z.isSpawned)return;if(!(J instanceof y5)||!J.isLiquid){if(X&&this._groundContactCount===0&&Z.linearVelocity.y<-1)if(Z.linearVelocity.y<f1.JUMP_LAND_HEAVY_VELOCITY_THRESHOLD)Z.startModelOneshotAnimations(this.jumpLandHeavyOneshotAnimations);else Z.startModelOneshotAnimations(this.jumpLandLightOneshotAnimations);this._groundContactCount+=X?1:-1}if(!this._groundContactCount&&!this.isSwimming)Z.startModelOneshotAnimations(this.jumpOneshotAnimations);else Z.stopModelAnimations(this.jumpOneshotAnimations);if(!(J instanceof A8))return;if(X&&this.sticksToPlatforms)this._platform=J;else if(J===this._platform&&!X)this._platform=void 0}}),Z.createAndAddChildCollider({shape:"capsule",halfHeight:f1.WALL_COLLIDER_HEIGHT_SCALE*(Z.height/f1.BASE_ENTITY_HEIGHT),radius:f1.WALL_COLLIDER_RADIUS_SCALE*(Z.height/f1.BASE_ENTITY_HEIGHT),collisionGroups:{belongsTo:[4],collidesWith:[1,2,8]},friction:0,frictionCombineRule:1,tag:"wallCollider"})}tickWithPlayerInput(Z,J,X,$){if(!Z.isSpawned||!Z.world)return;if(super.tickWithPlayerInput(Z,J,X,$),Z.parent)return;let{w:Y,a:Q,s:K,d:W,c:G,sp:z,sh:v,ml:V}=J,{yaw:H}=X,q=Z.linearVelocity;this._reusableTargetVelocities.x=0,this._reusableTargetVelocities.y=0,this._reusableTargetVelocities.z=0,this._isActivelyMoving=!!(Y||Q||K||W);let F=v,w=Q&&W&&!Y&&!K||Y&&K&&!Q&&!W,U=F&&this.canRun(this)||!F&&this.canWalk(this);if(this.isSwimming&&!this._isFullySubmerged)this._isFullySubmerged=!0,this._justSubmergedUntil=performance.now()+f1.WATER_ENTRY_SINKING_MS;else if(!this.isSwimming)this._isFullySubmerged=!1,this._justSubmergedUntil=0;if(this.isGrounded&&!this.isSwimming&&this._isActivelyMoving&&!w&&U){let M=F?this.runLoopedAnimations:this.walkLoopedAnimations;Z.stopAllModelLoopedAnimations(M),Z.startModelLoopedAnimations(M),this._stepAudio?.setPlaybackRate(F?0.75:0.51),this._stepAudio?.play(Z.world,!this._stepAudio?.isPlaying)}else if(this._isFullySubmerged&&this.canSwim(this))if(this._stepAudio?.pause(),this._isActivelyMoving)Z.stopAllModelLoopedAnimations(this.swimLoopedAnimations),Z.startModelLoopedAnimations(this.swimLoopedAnimations);else Z.stopAllModelLoopedAnimations(this.swimIdleLoopedAnimations),Z.startModelLoopedAnimations(this.swimIdleLoopedAnimations);else this._stepAudio?.pause(),Z.stopAllModelLoopedAnimations(this.idleLoopedAnimations),Z.startModelLoopedAnimations(this.idleLoopedAnimations);let x;if(this.applyDirectionalMovementRotations&&U){if(Y&&Q&&!W&&!K)x=f1.MOVEMENT_ROTATIONS.wa;else if(Y&&W&&!Q&&!K)x=f1.MOVEMENT_ROTATIONS.wd;else if(K&&Q&&!Y&&!W)x=f1.MOVEMENT_ROTATIONS.sa;else if(K&&W&&!Y&&!Q)x=f1.MOVEMENT_ROTATIONS.sd;else if(K&&!Y&&!Q&&!W||Q&&K&&W&&!Y)x=f1.MOVEMENT_ROTATIONS.s;else if(Q&&!Y&&!K&&!W)x=f1.MOVEMENT_ROTATIONS.a;else if(W&&!Y&&!Q&&!K)x=f1.MOVEMENT_ROTATIONS.d}if(V)Z.startModelOneshotAnimations(this.interactOneshotAnimations),J.ml=!this.autoCancelMouseLeftClick;if(U){let M=!this.isSwimming?F?this.runVelocity:this.walkVelocity:F?this.swimFastVelocity:this.swimSlowVelocity,N=Math.sin(H),D=Math.cos(H);if(Y)this._reusableTargetVelocities.x-=M*N,this._reusableTargetVelocities.z-=M*D;if(K)this._reusableTargetVelocities.x+=M*N,this._reusableTargetVelocities.z+=M*D;if(Q)this._reusableTargetVelocities.x-=M*D,this._reusableTargetVelocities.z+=M*N;if(W)this._reusableTargetVelocities.x+=M*D,this._reusableTargetVelocities.z-=M*N;let P=Math.sqrt(this._reusableTargetVelocities.x*this._reusableTargetVelocities.x+this._reusableTargetVelocities.z*this._reusableTargetVelocities.z);if(P>M){let f=M/P;this._reusableTargetVelocities.x*=f,this._reusableTargetVelocities.z*=f}}if(this.isSwimming){if(q.y<this.swimMaxGravityVelocity)this._reusableVelocityClamp.x=q.x,this._reusableVelocityClamp.y=this.swimMaxGravityVelocity,this._reusableVelocityClamp.z=q.z,Z.setLinearVelocity(this._reusableVelocityClamp);if(q.y>this.swimUpwardVelocity*2)this._reusableVelocityClamp.x=q.x,this._reusableVelocityClamp.y=this.swimUpwardVelocity*2,this._reusableVelocityClamp.z=q.z,Z.setLinearVelocity(this._reusableVelocityClamp);if(G)this._reusableTargetVelocities.y=-this.swimUpwardVelocity;else if(performance.now()<this._justSubmergedUntil)this._reusableTargetVelocities.y=-this.swimUpwardVelocity*f1.WATER_ENTRY_SINKING_FACTOR;else if(!z)this._reusableTargetVelocities.y=-q.y*f1.SWIMMING_DRAG_FACTOR}if(z&&this.canJump(this)){if(this.isGrounded&&!this.isSwimming&&q.y>-0.001&&q.y<=3)this._reusableTargetVelocities.y=this.jumpVelocity;else if(this.isSwimming&&performance.now()>this._swimUpwardCooldownAt)this._reusableTargetVelocities.y=this.swimUpwardVelocity}let L=this._platform?.linearVelocity??this._reusablePlatformVelocity;if(this._externalVelocity.y!==0)this._magnitudeYTracker+=this._externalVelocity.y;if(this._externalVelocity.x!==0||this._externalVelocity.y!==0||this._externalVelocity.z!==0){if(this.isGrounded){let M=Math.sqrt(this._externalVelocity.x*this._externalVelocity.x+this._magnitudeYTracker*this._magnitudeYTracker+this._externalVelocity.z*this._externalVelocity.z);if(M>0.01){let D=Math.max(0,M-f1.EXTERNAL_IMPULSE_DECAY_RATE)/M;this._externalVelocity.x*=D,this._magnitudeYTracker*=D,this._externalVelocity.z*=D}else this._externalVelocity.x=0,this._externalVelocity.y=0,this._magnitudeYTracker=0,this._externalVelocity.z=0}}let j=this._reusableTargetVelocities.x+this._externalVelocity.x-q.x+L.x,c=this._reusableTargetVelocities.y+this._externalVelocity.y+L.y,R=this._reusableTargetVelocities.z+this._externalVelocity.z-q.z+L.z;if(this._externalVelocity.y=0,j!==0||c!==0||R!==0){let M=Z.mass;this._reusableImpulse.x=j*M,this._reusableImpulse.y=c*M,this._reusableImpulse.z=R*M,this._internalApplyImpulse(this._reusableImpulse)}if(H!==void 0&&(this.faceForwardOnStop||this.isActivelyMoving)){let N=(x!==void 0?H+x:H)*0.5;Z.setRotation({x:0,y:Math.sin(N),z:0,w:Math.cos(N)})}}}var IC;((W)=>{W.LOAD="SCENE_UI.LOAD";W.SET_ATTACHED_TO_ENTITY="SCENE_UI.SET_ATTACHED_TO_ENTITY";W.SET_OFFSET="SCENE_UI.SET_OFFSET";W.SET_POSITION="SCENE_UI.SET_POSITION";W.SET_STATE="SCENE_UI.SET_STATE";W.SET_VIEW_DISTANCE="SCENE_UI.SET_VIEW_DISTANCE";W.UNLOAD="SCENE_UI.UNLOAD"})(IC||={});class az extends L0{_id;_attachedToEntity;_offset;_position;_state={};_templateId;_viewDistance;_world;constructor(Z){if(!!Z.attachedToEntity===!!Z.position)y.fatalError("Either attachedToEntity or position must be set, but not both");super();this._attachedToEntity=Z.attachedToEntity,this._offset=Z.offset,this._position=Z.position,this._state=Z.state??{},this._templateId=Z.templateId,this._viewDistance=Z.viewDistance}get id(){return this._id}get attachedToEntity(){return this._attachedToEntity}get isLoaded(){return this._id!==void 0}get offset(){return this._offset}get position(){return this._position}get state(){return this._state}get templateId(){return this._templateId}get viewDistance(){return this._viewDistance}get world(){return this._world}load(Z){if(this.isLoaded)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return y.error(`SceneUI.load(): Attached entity ${this._attachedToEntity.id} must be spawned before loading SceneUI!`);this._id=Z.sceneUIManager.registerSceneUI(this),this._world=Z,this.emitWithWorld(Z,"SCENE_UI.LOAD",{sceneUI:this})}setAttachedToEntity(Z){if(!Z.isSpawned)return y.error(`SceneUI.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);if(this._attachedToEntity===Z)return;if(this._attachedToEntity=Z,this._position=void 0,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_ATTACHED_TO_ENTITY",{sceneUI:this,entity:Z})}setOffset(Z){if(this._offset===Z)return;if(this._offset=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_OFFSET",{sceneUI:this,offset:Z})}setPosition(Z){if(this._position===Z)return;if(this._attachedToEntity=void 0,this._position=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_POSITION",{sceneUI:this,position:Z})}setState(Z){if(this._state={...this._state,...Z},this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_STATE",{sceneUI:this,state:this._state})}setViewDistance(Z){if(this._viewDistance=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_VIEW_DISTANCE",{sceneUI:this,viewDistance:Z})}unload(){if(!this.isLoaded||!this._world)return;this._world.sceneUIManager.unregisterSceneUI(this),this.emitWithWorld(this._world,"SCENE_UI.UNLOAD",{sceneUI:this}),this._id=void 0,this._world=void 0}serialize(){return P0.serializeSceneUI(this)}}var u80=0.010000000000000002,l80=Math.cos(0.026);class B7 extends A8{player;nametagSceneUI;constructor(Z){super(Z);this._positionUpdateThresholdSq=u80,this._rotationUpdateThreshold=l80,this.player=Z.player,this.nametagSceneUI=new az({templateId:"hytopia:nametag",attachedToEntity:this,offset:{x:0,y:1,z:0},viewDistance:15,state:{username:this.player.username,profilePictureUrl:this.player.profilePictureUrl}})}spawn(Z,J,X){super.spawn(Z,J,X),this.nametagSceneUI.load(Z),this.player.on("PLAYER.CHAT_MESSAGE_SEND",({message:$})=>{this.nametagSceneUI.setState({chat:$})})}tick(Z){if(!this.isSpawned||!this.world)return;if(!this.controller)return y.error(`PlayerEntity.tick(): PlayerEntity "${this.name}" must have a controller.`);let{input:J,camera:X}=this.player;this.controller.tickWithPlayerInput(this,J,X.orientation,Z),super.tick(Z)}}class fC extends B7{constructor(Z){super({modelUri:"models/players/player.gltf",modelLoopedAnimations:["idle_lower","idle_upper"],modelHiddenNodes:["hair-"],modelShownNodes:["hair-0003"],...Z});if(!Z.controller)this.setController(new f1)}}class nz{_activeEntities=new Set;_entities=new Map;_nextEntityId=1;_world;constructor(Z){this._world=Z}get entityCount(){return this._entities.size}get world(){return this._world}registerEntity(Z){if(Z.id!==void 0)y.fatalError(`EntityManager.registerEntity(): Entity ${Z.name} is already assigned the id ${Z.id}!`);let J=this._nextEntityId;if(this._entities.set(J,Z),this._nextEntityId++,!Z.isEnvironmental)this._activeEntities.add(Z);return J}unregisterEntity(Z){if(Z.id===void 0)return y.error(`EntityManager.unregisterEntity(): Entity ${Z.name} is not assigned an id!`);if(this._entities.delete(Z.id),!Z.isEnvironmental)this._activeEntities.delete(Z)}getAllEntities(){return Array.from(this._entities.values())}getAllPlayerEntities(){let Z=[];return this._entities.forEach((J)=>{if(J instanceof B7)Z.push(J)}),Z}getPlayerEntitiesByPlayer(Z){let J=[];return this._entities.forEach((X)=>{if(X instanceof B7&&X.player===Z)J.push(X)}),J}getEntity(Z){return this._entities.get(Z)}getEntitiesByTag(Z){let J=[];return this._entities.forEach((X)=>{if(X.tag===Z)J.push(X)}),J}getEntitiesByTagSubstring(Z){let J=[];return this._entities.forEach((X)=>{if(X.tag?.includes(Z))J.push(X)}),J}getEntityChildren(Z){let J=[];return this._entities.forEach((X)=>{if(X.parent===Z)J.push(X)}),J}tickEntities(Z){for(let J of this._activeEntities)J.tick(Z)}checkAndEmitUpdates(){for(let Z of this._activeEntities)Z.checkAndEmitUpdates()}}import{gzipSync as M$6}from"zlib";var MS1=t(h60(),1),RS1=t(mC(),1),NS1=t(lC(),1),$3=t(Ux(),1),nC=t(p60(),1);var n6=t(a50(),1),ah6=n6.default.v1,nh6=n6.default.v1ToV6,sh6=n6.default.v3,n50=n6.default.v4,oh6=n6.default.v5,rh6=n6.default.v6,th6=n6.default.v6ToV1,eh6=n6.default.v7,Zb6=n6.default.NIL,Jb6=n6.default.MAX,Xb6=n6.default.version,$b6=n6.default.validate,Yb6=n6.default.stringify,Qb6=n6.default.parse;var XT;try{XT=new TextDecoder}catch(Z){}var J0,a5,A=0;var KT=[],zY=KT,Qv=0,C1={},W1,NZ,d5=0,R4=0,m8,DZ,O5=[],X1,s50={useRecords:!1,mapsAsObjects:!0};class Nx{}var WT=new Nx;WT.name="MessagePack 0xC1";var oJ=!1,$40=2,$T,YT,QT;try{new Function("")}catch(Z){$40=1/0}class PZ{constructor(Z){if(Z){if(Z.useRecords===!1&&Z.mapsAsObjects===void 0)Z.mapsAsObjects=!0;if(Z.sequential&&Z.trusted!==!1){if(Z.trusted=!0,!Z.structures&&Z.useRecords!=!1){if(Z.structures=[],!Z.maxSharedStructures)Z.maxSharedStructures=0}}if(Z.structures)Z.structures.sharedLength=Z.structures.length;else if(Z.getStructures)(Z.structures=[]).uninitialized=!0,Z.structures.sharedLength=0;if(Z.int64AsNumber)Z.int64AsType="number"}Object.assign(this,Z)}unpack(Z,J){if(J0)return F40(()=>{return Rx(),this?this.unpack(Z,J):PZ.prototype.unpack.call(s50,Z,J)});if(!Z.buffer&&Z.constructor===ArrayBuffer)Z=typeof Buffer!=="undefined"?Buffer.from(Z):new Uint8Array(Z);if(typeof J==="object")a5=J.end||Z.length,A=J.start||0;else A=0,a5=J>-1?J:Z.length;Qv=0,R4=0,NZ=null,zY=KT,m8=null,J0=Z;try{X1=Z.dataView||(Z.dataView=new DataView(Z.buffer,Z.byteOffset,Z.byteLength))}catch(X){if(J0=null,Z instanceof Uint8Array)throw X;throw new Error("Source must be a Uint8Array or Buffer but was a "+(Z&&typeof Z=="object"?Z.constructor.name:typeof Z))}if(this instanceof PZ){if(C1=this,this.structures)return W1=this.structures,Ox(J);else if(!W1||W1.length>0)W1=[]}else if(C1=s50,!W1||W1.length>0)W1=[];return Ox(J)}unpackMultiple(Z,J){let X,$=0;try{oJ=!0;let Y=Z.length,Q=this?this.unpack(Z,Y):Dx.unpack(Z,Y);if(J){if(J(Q,$,A)===!1)return;while(A<Y)if($=A,J(Ox(),$,A)===!1)return}else{X=[Q];while(A<Y)$=A,X.push(Ox());return X}}catch(Y){throw Y.lastPosition=$,Y.values=X,Y}finally{oJ=!1,Rx()}}_mergeStructures(Z,J){if(YT)Z=YT.call(this,Z);if(Z=Z||[],Object.isFrozen(Z))Z=Z.map((X)=>X.slice(0));for(let X=0,$=Z.length;X<$;X++){let Y=Z[X];if(Y){if(Y.isShared=!0,X>=32)Y.highByte=X-32>>5}}Z.sharedLength=Z.length;for(let X in J||[])if(X>=0){let $=Z[X],Y=J[X];if(Y){if($)(Z.restoreStructures||(Z.restoreStructures=[]))[X]=$;Z[X]=Y}}return this.structures=Z}decode(Z,J){return this.unpack(Z,J)}}function Ox(Z){try{if(!C1.trusted&&!oJ){let X=W1.sharedLength||0;if(X<W1.length)W1.length=X}let J;if(C1.randomAccessStructure&&J0[A]<64&&J0[A]>=32&&$T){if(J=$T(J0,A,a5,C1),J0=null,!(Z&&Z.lazy)&&J)J=J.toJSON();A=a5}else J=O8();if(m8)A=m8.postBundlePosition,m8=null;if(oJ)W1.restoreStructures=null;if(A==a5){if(W1&&W1.restoreStructures)o50();if(W1=null,J0=null,DZ)DZ=null}else if(A>a5)throw new Error("Unexpected end of MessagePack data");else if(!oJ){let X;try{X=JSON.stringify(J,($,Y)=>typeof Y==="bigint"?`${Y}n`:Y).slice(0,100)}catch($){X="(JSON view not available "+$+")"}throw new Error("Data read, but end of buffer not reached "+X)}return J}catch(J){if(W1&&W1.restoreStructures)o50();if(Rx(),J instanceof RangeError||J.message.startsWith("Unexpected end of buffer")||A>a5)J.incomplete=!0;throw J}}function o50(){for(let Z in W1.restoreStructures)W1[Z]=W1.restoreStructures[Z];W1.restoreStructures=null}function O8(){let Z=J0[A++];if(Z<160)if(Z<128)if(Z<64)return Z;else{let J=W1[Z&63]||C1.getStructures&&Y40()[Z&63];if(J){if(!J.read)J.read=GT(J,Z&63);return J.read()}else return Z}else if(Z<144)if(Z-=128,C1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let $=V40();if($==="__proto__")$="__proto_";J[$]=O8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(O8(),O8());return J}else{Z-=144;let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=O8();if(C1.freezeData)return Object.freeze(J);return J}else if(Z<192){let J=Z-160;if(R4>=A)return NZ.slice(A-d5,(A+=J)-d5);if(R4==0&&a5<140){let X=J<16?zT(J):H40(J);if(X!=null)return X}return Mx(J)}else{let J;switch(Z){case 192:return null;case 193:if(m8)if(J=O8(),J>0)return m8[1].slice(m8.position1,m8.position1+=J);else return m8[0].slice(m8.position0,m8.position0-=J);return WT;case 194:return!1;case 195:return!0;case 196:if(J=J0[A++],J===void 0)throw new Error("Unexpected end of buffer");return JT(J);case 197:return J=X1.getUint16(A),A+=2,JT(J);case 198:return J=X1.getUint32(A),A+=4,JT(J);case 199:return GY(J0[A++]);case 200:return J=X1.getUint16(A),A+=2,GY(J);case 201:return J=X1.getUint32(A),A+=4,GY(J);case 202:if(J=X1.getFloat32(A),C1.useFloat32>2){let X=HY[(J0[A]&127)<<1|J0[A+1]>>7];return A+=4,(X*J+(J>0?0.5:-0.5)>>0)/X}return A+=4,J;case 203:return J=X1.getFloat64(A),A+=8,J;case 204:return J0[A++];case 205:return J=X1.getUint16(A),A+=2,J;case 206:return J=X1.getUint32(A),A+=4,J;case 207:if(C1.int64AsType==="number")J=X1.getUint32(A)*4294967296,J+=X1.getUint32(A+4);else if(C1.int64AsType==="string")J=X1.getBigUint64(A).toString();else if(C1.int64AsType==="auto"){if(J=X1.getBigUint64(A),J<=BigInt(2)<<BigInt(52))J=Number(J)}else J=X1.getBigUint64(A);return A+=8,J;case 208:return X1.getInt8(A++);case 209:return J=X1.getInt16(A),A+=2,J;case 210:return J=X1.getInt32(A),A+=4,J;case 211:if(C1.int64AsType==="number")J=X1.getInt32(A)*4294967296,J+=X1.getUint32(A+4);else if(C1.int64AsType==="string")J=X1.getBigInt64(A).toString();else if(C1.int64AsType==="auto"){if(J=X1.getBigInt64(A),J>=BigInt(-2)<<BigInt(52)&&J<=BigInt(2)<<BigInt(52))J=Number(J)}else J=X1.getBigInt64(A);return A+=8,J;case 212:if(J=J0[A++],J==114)return X40(J0[A++]&63);else{let X=O5[J];if(X)if(X.read)return A++,X.read(O8());else if(X.noBuffer)return A++,X();else return X(J0.subarray(A,++A));else throw new Error("Unknown extension "+J)}case 213:if(J=J0[A],J==114)return A++,X40(J0[A++]&63,J0[A++]);else return GY(2);case 214:return GY(4);case 215:return GY(8);case 216:return GY(16);case 217:if(J=J0[A++],R4>=A)return NZ.slice(A-d5,(A+=J)-d5);return Q40(J);case 218:if(J=X1.getUint16(A),A+=2,R4>=A)return NZ.slice(A-d5,(A+=J)-d5);return K40(J);case 219:if(J=X1.getUint32(A),A+=4,R4>=A)return NZ.slice(A-d5,(A+=J)-d5);return W40(J);case 220:return J=X1.getUint16(A),A+=2,t50(J);case 221:return J=X1.getUint32(A),A+=4,t50(J);case 222:return J=X1.getUint16(A),A+=2,e50(J);case 223:return J=X1.getUint32(A),A+=4,e50(J);default:if(Z>=224)return Z-256;if(Z===void 0){let X=new Error("Unexpected end of MessagePack data");throw X.incomplete=!0,X}throw new Error("Unknown MessagePack token "+Z)}}}var Zb1=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function GT(Z,J){function X(){if(X.count++>$40){let Y=Z.read=new Function("r","return function(){return "+(C1.freezeData?"Object.freeze":"")+"({"+Z.map((Q)=>Q==="__proto__"?"__proto_:r()":Zb1.test(Q)?Q+":r()":"["+JSON.stringify(Q)+"]:r()").join(",")+"})}")(O8);if(Z.highByte===0)Z.read=r50(J,Z.read);return Y()}let $={};for(let Y=0,Q=Z.length;Y<Q;Y++){let K=Z[Y];if(K==="__proto__")K="__proto_";$[K]=O8()}if(C1.freezeData)return Object.freeze($);return $}if(X.count=0,Z.highByte===0)return r50(J,X);return X}var r50=(Z,J)=>{return function(){let X=J0[A++];if(X===0)return J();let $=Z<32?-(Z+(X<<5)):Z+(X<<5),Y=W1[$]||Y40()[$];if(!Y)throw new Error("Record id is not defined for "+$);if(!Y.read)Y.read=GT(Y,Z);return Y.read()}};function Y40(){let Z=F40(()=>{return J0=null,C1.getStructures()});return W1=C1._mergeStructures(Z,W1)}var Mx=vY,Q40=vY,K40=vY,W40=vY,G40=!1;function z40(Z){G40=!0,Mx=J(1),Q40=J(2),K40=J(3),W40=J(5);function J(X){return function $(Y){let Q=zY[Qv++];if(Q==null){if(m8)return vY(Y);let W=J0.byteOffset,G=Z(A-X+W,a5+W,J0.buffer);if(typeof G=="string")Q=G,zY=KT;else if(zY=G,Qv=1,R4=1,Q=zY[0],Q===void 0)throw new Error("Unexpected end of buffer")}let K=Q.length;if(K<=Y)return A+=Y,Q;return NZ=Q,d5=A,R4=A+K,A+=Y,Q.slice(0,Y)}}}function vY(Z){let J;if(Z<16){if(J=zT(Z))return J}if(Z>64&&XT)return XT.decode(J0.subarray(A,A+=Z));let X=A+Z,$=[];J="";while(A<X){let Y=J0[A++];if((Y&128)===0)$.push(Y);else if((Y&224)===192){let Q=J0[A++]&63;$.push((Y&31)<<6|Q)}else if((Y&240)===224){let Q=J0[A++]&63,K=J0[A++]&63;$.push((Y&31)<<12|Q<<6|K)}else if((Y&248)===240){let Q=J0[A++]&63,K=J0[A++]&63,W=J0[A++]&63,G=(Y&7)<<18|Q<<12|K<<6|W;if(G>65535)G-=65536,$.push(G>>>10&1023|55296),G=56320|G&1023;$.push(G)}else $.push(Y);if($.length>=4096)J+=s8.apply(String,$),$.length=0}if($.length>0)J+=s8.apply(String,$);return J}function v40(Z,J,X){let $=J0;J0=Z,A=J;try{return vY(X)}finally{J0=$}}function t50(Z){let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=O8();if(C1.freezeData)return Object.freeze(J);return J}function e50(Z){if(C1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let $=V40();if($==="__proto__")$="__proto_";J[$]=O8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(O8(),O8());return J}}var s8=String.fromCharCode;function H40(Z){let J=A,X=new Array(Z);for(let $=0;$<Z;$++){let Y=J0[A++];if((Y&128)>0){A=J;return}X[$]=Y}return s8.apply(String,X)}function zT(Z){if(Z<4)if(Z<2)if(Z===0)return"";else{let J=J0[A++];if((J&128)>1){A-=1;return}return s8(J)}else{let J=J0[A++],X=J0[A++];if((J&128)>0||(X&128)>0){A-=2;return}if(Z<3)return s8(J,X);let $=J0[A++];if(($&128)>0){A-=3;return}return s8(J,X,$)}else{let J=J0[A++],X=J0[A++],$=J0[A++],Y=J0[A++];if((J&128)>0||(X&128)>0||($&128)>0||(Y&128)>0){A-=4;return}if(Z<6)if(Z===4)return s8(J,X,$,Y);else{let Q=J0[A++];if((Q&128)>0){A-=5;return}return s8(J,X,$,Y,Q)}else if(Z<8){let Q=J0[A++],K=J0[A++];if((Q&128)>0||(K&128)>0){A-=6;return}if(Z<7)return s8(J,X,$,Y,Q,K);let W=J0[A++];if((W&128)>0){A-=7;return}return s8(J,X,$,Y,Q,K,W)}else{let Q=J0[A++],K=J0[A++],W=J0[A++],G=J0[A++];if((Q&128)>0||(K&128)>0||(W&128)>0||(G&128)>0){A-=8;return}if(Z<10)if(Z===8)return s8(J,X,$,Y,Q,K,W,G);else{let z=J0[A++];if((z&128)>0){A-=9;return}return s8(J,X,$,Y,Q,K,W,G,z)}else if(Z<12){let z=J0[A++],v=J0[A++];if((z&128)>0||(v&128)>0){A-=10;return}if(Z<11)return s8(J,X,$,Y,Q,K,W,G,z,v);let V=J0[A++];if((V&128)>0){A-=11;return}return s8(J,X,$,Y,Q,K,W,G,z,v,V)}else{let z=J0[A++],v=J0[A++],V=J0[A++],H=J0[A++];if((z&128)>0||(v&128)>0||(V&128)>0||(H&128)>0){A-=12;return}if(Z<14)if(Z===12)return s8(J,X,$,Y,Q,K,W,G,z,v,V,H);else{let q=J0[A++];if((q&128)>0){A-=13;return}return s8(J,X,$,Y,Q,K,W,G,z,v,V,H,q)}else{let q=J0[A++],F=J0[A++];if((q&128)>0||(F&128)>0){A-=14;return}if(Z<15)return s8(J,X,$,Y,Q,K,W,G,z,v,V,H,q,F);let w=J0[A++];if((w&128)>0){A-=15;return}return s8(J,X,$,Y,Q,K,W,G,z,v,V,H,q,F,w)}}}}}function Z40(){let Z=J0[A++],J;if(Z<192)J=Z-160;else switch(Z){case 217:J=J0[A++];break;case 218:J=X1.getUint16(A),A+=2;break;case 219:J=X1.getUint32(A),A+=4;break;default:throw new Error("Expected string")}return vY(J)}function JT(Z){return C1.copyBuffers?Uint8Array.prototype.slice.call(J0,A,A+=Z):J0.subarray(A,A+=Z)}function GY(Z){let J=J0[A++];if(O5[J]){let X;return O5[J](J0.subarray(A,X=A+=Z),($)=>{A=$;try{return O8()}finally{A=X}})}else throw new Error("Unknown extension type "+J)}var J40=new Array(4096);function V40(){let Z=J0[A++];if(Z>=160&&Z<192){if(Z=Z-160,R4>=A)return NZ.slice(A-d5,(A+=Z)-d5);else if(!(R4==0&&a5<180))return Mx(Z)}else return A--,q40(O8());let J=(Z<<5^(Z>1?X1.getUint16(A):Z>0?J0[A]:0))&4095,X=J40[J],$=A,Y=A+Z-3,Q,K=0;if(X&&X.bytes==Z){while($<Y){if(Q=X1.getUint32($),Q!=X[K++]){$=1879048192;break}$+=4}Y+=3;while($<Y)if(Q=J0[$++],Q!=X[K++]){$=1879048192;break}if($===Y)return A=$,X.string;Y-=3,$=A}X=[],J40[J]=X,X.bytes=Z;while($<Y)Q=X1.getUint32($),X.push(Q),$+=4;Y+=3;while($<Y)Q=J0[$++],X.push(Q);let W=Z<16?zT(Z):H40(Z);if(W!=null)return X.string=W;return X.string=Mx(Z)}function q40(Z){if(typeof Z==="string")return Z;if(typeof Z==="number"||typeof Z==="boolean"||typeof Z==="bigint")return Z.toString();if(Z==null)return Z+"";if(C1.allowArraysInMapKeys&&Array.isArray(Z)&&Z.flat().every((J)=>["string","number","boolean","bigint"].includes(typeof J)))return Z.flat().toString();throw new Error(`Invalid property type for record: ${typeof Z}`)}var X40=(Z,J)=>{let X=O8().map(q40),$=Z;if(J!==void 0)Z=Z<32?-((J<<5)+Z):(J<<5)+Z,X.highByte=J;let Y=W1[Z];if(Y&&(Y.isShared||oJ))(W1.restoreStructures||(W1.restoreStructures=[]))[Z]=Y;return W1[Z]=X,X.read=GT(X,$),X.read()};O5[0]=()=>{};O5[0].noBuffer=!0;O5[66]=(Z)=>{let J=Z.length,X=BigInt(Z[0]&128?Z[0]-256:Z[0]);for(let $=1;$<J;$++)X<<=BigInt(8),X+=BigInt(Z[$]);return X};var Jb1={Error,TypeError,ReferenceError};O5[101]=()=>{let Z=O8();return(Jb1[Z[0]]||Error)(Z[1],{cause:Z[2]})};O5[105]=(Z)=>{if(C1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=X1.getUint32(A-4);if(!DZ)DZ=new Map;let X=J0[A],$;if(X>=144&&X<160||X==220||X==221)$=[];else if(X>=128&&X<144||X==222||X==223)$=new Map;else if((X>=199&&X<=201||X>=212&&X<=216)&&J0[A+1]===115)$=new Set;else $={};let Y={target:$};DZ.set(J,Y);let Q=O8();if(!Y.used)return Y.target=Q;else Object.assign($,Q);if($ instanceof Map)for(let[K,W]of Q.entries())$.set(K,W);if($ instanceof Set)for(let K of Array.from(Q))$.add(K);return $};O5[112]=(Z)=>{if(C1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=X1.getUint32(A-4),X=DZ.get(J);return X.used=!0,X.target};O5[115]=()=>new Set(O8());var vT=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((Z)=>Z+"Array"),Xb1=typeof globalThis==="object"?globalThis:window;O5[116]=(Z)=>{let J=Z[0],X=Uint8Array.prototype.slice.call(Z,1).buffer,$=vT[J];if(!$){if(J===16)return X;if(J===17)return new DataView(X);throw new Error("Could not find typed array for code "+J)}return new Xb1[$](X)};O5[120]=()=>{let Z=O8();return new RegExp(Z[0],Z[1])};var $b1=[];O5[98]=(Z)=>{let J=(Z[0]<<24)+(Z[1]<<16)+(Z[2]<<8)+Z[3],X=A;return A+=J-Z.length,m8=$b1,m8=[Z40(),Z40()],m8.position0=0,m8.position1=0,m8.postBundlePosition=A,A=X,O8()};O5[255]=(Z)=>{if(Z.length==4)return new Date((Z[0]*16777216+(Z[1]<<16)+(Z[2]<<8)+Z[3])*1000);else if(Z.length==8)return new Date(((Z[0]<<22)+(Z[1]<<14)+(Z[2]<<6)+(Z[3]>>2))/1e6+((Z[3]&3)*4294967296+Z[4]*16777216+(Z[5]<<16)+(Z[6]<<8)+Z[7])*1000);else if(Z.length==12)return new Date(((Z[0]<<24)+(Z[1]<<16)+(Z[2]<<8)+Z[3])/1e6+((Z[4]&128?-281474976710656:0)+Z[6]*1099511627776+Z[7]*4294967296+Z[8]*16777216+(Z[9]<<16)+(Z[10]<<8)+Z[11])*1000);else return new Date("invalid")};function F40(Z){if(QT)QT();let J=a5,X=A,$=Qv,Y=d5,Q=R4,K=NZ,W=zY,G=DZ,z=m8,v=new Uint8Array(J0.slice(0,a5)),V=W1,H=W1.slice(0,W1.length),q=C1,F=oJ,w=Z();return a5=J,A=X,Qv=$,d5=Y,R4=Q,NZ=K,zY=W,DZ=G,m8=z,J0=v,oJ=F,W1=V,W1.splice(0,W1.length,...H),C1=q,X1=new DataView(J0.buffer,J0.byteOffset,J0.byteLength),w}function Rx(){J0=null,DZ=null,W1=null}var HY=new Array(147);for(let Z=0;Z<256;Z++)HY[Z]=+("1e"+Math.floor(45.15-Z*0.30103));var Dx=new PZ({useRecords:!1}),Yb1=Dx.unpack,Qb1=Dx.unpackMultiple,Kb1=Dx.unpack,Kv={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Wb1=new Float32Array(1),Wb6=new Uint8Array(Wb1.buffer,0,4);function w40(Z,J,X){$T=Z,YT=J,QT=X}var Cx;try{Cx=new TextEncoder}catch(Z){}var qT,B40,Gv=typeof Buffer!=="undefined",Px=Gv?function(Z){return Buffer.allocUnsafeSlow(Z)}:Uint8Array,L40=Gv?Buffer:Uint8Array,U40=Gv?4294967296:2144337920,g,Wv,_1,l=0,s6,s1=null,j40,Gb1=21760,zb1=/[\u0080-\uFFFF]/,j7=Symbol("record-id");class VY extends PZ{constructor(Z){super(Z);this.offset=0;let J,X,$,Y,Q,K=L40.prototype.utf8Write?function(T,k){return g.utf8Write(T,k,g.byteLength-k)}:Cx&&Cx.encodeInto?function(T,k){return Cx.encodeInto(T,g.subarray(k)).written}:!1,W=this;if(!Z)Z={};let G=Z&&Z.sequential,z=Z.structures||Z.saveStructures,v=Z.maxSharedStructures;if(v==null)v=z?32:0;if(v>8160)throw new Error("Maximum maxSharedStructure is 8160");if(Z.structuredClone&&Z.moreTypes==null)this.moreTypes=!0;let V=Z.maxOwnStructures;if(V==null)V=z?32:64;if(!this.structures&&Z.useRecords!=!1)this.structures=[];let H=v>32||V+v>64,q=v+64,F=v+V+64;if(F>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let w=[],U=0,x=0;this.pack=this.encode=function(T,k){if(!g)g=new Px(8192),_1=g.dataView||(g.dataView=new DataView(g.buffer,0,8192)),l=0;if(s6=g.length-10,s6-l<2048)g=new Px(g.length),_1=g.dataView||(g.dataView=new DataView(g.buffer,0,g.length)),s6=g.length-10,l=0;else l=l+7&2147483640;if(X=l,k&Ub1)l+=k&255;if(Q=W.structuredClone?new Map:null,W.bundleStrings&&typeof T!=="string")s1=[],s1.size=1/0;else s1=null;if(Y=W.structures,Y){if(Y.uninitialized)Y=W._mergeStructures(W.getStructures());let u=Y.sharedLength||0;if(u>v)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+Y.sharedLength);if(!Y.transitions){Y.transitions=Object.create(null);for(let a=0;a<u;a++){let o=Y[a];if(!o)continue;let Q0,W0=Y.transitions;for(let E0=0,I0=o.length;E0<I0;E0++){let t0=o[E0];if(Q0=W0[t0],!Q0)Q0=W0[t0]=Object.create(null);W0=Q0}W0[j7]=a+64}this.lastNamedStructuresLength=u}if(!G)Y.nextId=u+64}if($)$=!1;let h;try{if(W.randomAccessStructure&&T&&T.constructor&&T.constructor===Object)_(T);else c(T);let u=s1;if(s1)x40(X,c,0);if(Q&&Q.idsToInsert){let a=Q.idsToInsert.sort((E0,I0)=>E0.offset>I0.offset?1:-1),o=a.length,Q0=-1;while(u&&o>0){let E0=a[--o].offset+X;if(E0<u.stringsPosition+X&&Q0===-1)Q0=0;if(E0>u.position+X){if(Q0>=0)Q0+=6}else{if(Q0>=0)_1.setUint32(u.position+X,_1.getUint32(u.position+X)+Q0),Q0=-1;u=u.previous,o++}}if(Q0>=0&&u)_1.setUint32(u.position+X,_1.getUint32(u.position+X)+Q0);if(l+=a.length*6,l>s6)P(l);W.offset=l;let W0=Hb1(g.subarray(X,l),a);return Q=null,W0}if(W.offset=l,k&Fb1)return g.start=X,g.end=l,g;return g.subarray(X,l)}catch(u){throw h=u,u}finally{if(Y){if(L(),$&&W.saveStructures){let u=Y.sharedLength||0,a=g.subarray(X,l),o=c40(Y,W);if(!h){if(W.saveStructures(o,o.isCompatible)===!1)return W.pack(T,k);if(W.lastNamedStructuresLength=u,g.length>1073741824)g=null;return a}}}if(g.length>1073741824)g=null;if(k&wb1)l=X}};let L=()=>{if(x<10)x++;let T=Y.sharedLength||0;if(Y.length>T&&!G)Y.length=T;if(U>1e4){if(Y.transitions=null,x=0,U=0,w.length>0)w=[]}else if(w.length>0&&!G){for(let k=0,h=w.length;k<h;k++)w[k][j7]=0;w=[]}},j=(T)=>{var k=T.length;if(k<16)g[l++]=144|k;else if(k<65536)g[l++]=220,g[l++]=k>>8,g[l++]=k&255;else g[l++]=221,_1.setUint32(l,k),l+=4;for(let h=0;h<k;h++)c(T[h])},c=(T)=>{if(l>s6)g=P(l);var k=typeof T,h;if(k==="string"){let u=T.length;if(s1&&u>=4&&u<4096){if((s1.size+=u)>Gb1){let W0,E0=(s1[0]?s1[0].length*3+s1[1].length:0)+10;if(l+E0>s6)g=P(l+E0);let I0;if(s1.position)I0=s1,g[l]=200,l+=3,g[l++]=98,W0=l-X,l+=4,x40(X,c,0),_1.setUint16(W0+X-3,l-X-W0);else g[l++]=214,g[l++]=98,W0=l-X,l+=4;s1=["",""],s1.previous=I0,s1.size=0,s1.position=W0}let Q0=zb1.test(T);s1[Q0?0:1]+=T,g[l++]=193,c(Q0?-u:u);return}let a;if(u<32)a=1;else if(u<256)a=2;else if(u<65536)a=3;else a=5;let o=u*3;if(l+o>s6)g=P(l+o);if(u<64||!K){let Q0,W0,E0,I0=l+a;for(Q0=0;Q0<u;Q0++)if(W0=T.charCodeAt(Q0),W0<128)g[I0++]=W0;else if(W0<2048)g[I0++]=W0>>6|192,g[I0++]=W0&63|128;else if((W0&64512)===55296&&((E0=T.charCodeAt(Q0+1))&64512)===56320)W0=65536+((W0&1023)<<10)+(E0&1023),Q0++,g[I0++]=W0>>18|240,g[I0++]=W0>>12&63|128,g[I0++]=W0>>6&63|128,g[I0++]=W0&63|128;else g[I0++]=W0>>12|224,g[I0++]=W0>>6&63|128,g[I0++]=W0&63|128;h=I0-l-a}else h=K(T,l+a);if(h<32)g[l++]=160|h;else if(h<256){if(a<2)g.copyWithin(l+2,l+1,l+1+h);g[l++]=217,g[l++]=h}else if(h<65536){if(a<3)g.copyWithin(l+3,l+2,l+2+h);g[l++]=218,g[l++]=h>>8,g[l++]=h&255}else{if(a<5)g.copyWithin(l+5,l+3,l+3+h);g[l++]=219,_1.setUint32(l,h),l+=4}l+=h}else if(k==="number")if(T>>>0===T)if(T<32||T<128&&this.useRecords===!1||T<64&&!this.randomAccessStructure)g[l++]=T;else if(T<256)g[l++]=204,g[l++]=T;else if(T<65536)g[l++]=205,g[l++]=T>>8,g[l++]=T&255;else g[l++]=206,_1.setUint32(l,T),l+=4;else if(T>>0===T)if(T>=-32)g[l++]=256+T;else if(T>=-128)g[l++]=208,g[l++]=T+256;else if(T>=-32768)g[l++]=209,_1.setInt16(l,T),l+=2;else g[l++]=210,_1.setInt32(l,T),l+=4;else{let u;if((u=this.useFloat32)>0&&T<4294967296&&T>=-2147483648){g[l++]=202,_1.setFloat32(l,T);let a;if(u<4||(a=T*HY[(g[l]&127)<<1|g[l+1]>>7])>>0===a){l+=4;return}else l--}g[l++]=203,_1.setFloat64(l,T),l+=8}else if(k==="object"||k==="function")if(!T)g[l++]=192;else{if(Q){let a=Q.get(T);if(a){if(!a.id){let o=Q.idsToInsert||(Q.idsToInsert=[]);a.id=o.push(a)}g[l++]=214,g[l++]=112,_1.setUint32(l,a.id),l+=4;return}else Q.set(T,{offset:l-X})}let u=T.constructor;if(u===Object)D(T);else if(u===Array)j(T);else if(u===Map)if(this.mapAsEmptyObject)g[l++]=128;else{if(h=T.size,h<16)g[l++]=128|h;else if(h<65536)g[l++]=222,g[l++]=h>>8,g[l++]=h&255;else g[l++]=223,_1.setUint32(l,h),l+=4;for(let[a,o]of T)c(a),c(o)}else{for(let a=0,o=qT.length;a<o;a++){let Q0=B40[a];if(T instanceof Q0){let W0=qT[a];if(W0.write){if(W0.type)g[l++]=212,g[l++]=W0.type,g[l++]=0;let g1=W0.write.call(this,T);if(g1===T)if(Array.isArray(T))j(T);else D(T);else c(g1);return}let E0=g,I0=_1,t0=l;g=null;let C8;try{C8=W0.pack.call(this,T,(g1)=>{if(g=E0,E0=null,l+=g1,l>s6)P(l);return{target:g,targetView:_1,position:l-g1}},c)}finally{if(E0)g=E0,_1=I0,l=t0,s6=g.length-10}if(C8){if(C8.length+l>s6)P(C8.length+l);l=vb1(C8,g,l,W0.type)}return}}if(Array.isArray(T))j(T);else{if(T.toJSON){let a=T.toJSON();if(a!==T)return c(a)}if(k==="function")return c(this.writeFunction&&this.writeFunction(T));D(T)}}}else if(k==="boolean")g[l++]=T?195:194;else if(k==="bigint"){if(T<9223372036854776000&&T>=-9223372036854776000)g[l++]=211,_1.setBigInt64(l,T);else if(T<18446744073709552000&&T>0)g[l++]=207,_1.setBigUint64(l,T);else if(this.largeBigIntToFloat)g[l++]=203,_1.setFloat64(l,Number(T));else if(this.largeBigIntToString)return c(T.toString());else if((this.useBigIntExtension||this.moreTypes)&&T<BigInt(2)**BigInt(1023)&&T>-(BigInt(2)**BigInt(1023))){g[l++]=199,l++,g[l++]=66;let u=[],a;do{let o=T&BigInt(255);a=(o&BigInt(128))===(T<BigInt(0)?BigInt(128):BigInt(0)),u.push(o),T>>=BigInt(8)}while(!((T===BigInt(0)||T===BigInt(-1))&&a));g[l-2]=u.length;for(let o=u.length;o>0;)g[l++]=Number(u[--o]);return}else throw new RangeError(T+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string");l+=8}else if(k==="undefined")if(this.encodeUndefinedAsNil)g[l++]=192;else g[l++]=212,g[l++]=0,g[l++]=0;else throw new Error("Unknown type: "+k)},R=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?(T)=>{let k;if(this.skipValues){k=[];for(let a in T)if((typeof T.hasOwnProperty!=="function"||T.hasOwnProperty(a))&&!this.skipValues.includes(T[a]))k.push(a)}else k=Object.keys(T);let h=k.length;if(h<16)g[l++]=128|h;else if(h<65536)g[l++]=222,g[l++]=h>>8,g[l++]=h&255;else g[l++]=223,_1.setUint32(l,h),l+=4;let u;if(this.coercibleKeyAsNumber)for(let a=0;a<h;a++){u=k[a];let o=Number(u);c(isNaN(o)?u:o),c(T[u])}else for(let a=0;a<h;a++)c(u=k[a]),c(T[u])}:(T)=>{g[l++]=222;let k=l-X;l+=2;let h=0;for(let u in T)if(typeof T.hasOwnProperty!=="function"||T.hasOwnProperty(u))c(u),c(T[u]),h++;if(h>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');g[k+++X]=h>>8,g[k+X]=h&255},M=this.useRecords===!1?R:Z.progressiveRecords&&!H?(T)=>{let k,h=Y.transitions||(Y.transitions=Object.create(null)),u=l++-X,a;for(let o in T)if(typeof T.hasOwnProperty!=="function"||T.hasOwnProperty(o)){if(k=h[o],k)h=k;else{let Q0=Object.keys(T),W0=h;h=Y.transitions;let E0=0;for(let I0=0,t0=Q0.length;I0<t0;I0++){let C8=Q0[I0];if(k=h[C8],!k)k=h[C8]=Object.create(null),E0++;h=k}if(u+X+1==l)l--,f(h,Q0,E0);else E(h,Q0,u,E0);a=!0,h=W0[o]}c(T[o])}if(!a){let o=h[j7];if(o)g[u+X]=o;else E(h,Object.keys(T),u,0)}}:(T)=>{let k,h=Y.transitions||(Y.transitions=Object.create(null)),u=0;for(let o in T)if(typeof T.hasOwnProperty!=="function"||T.hasOwnProperty(o)){if(k=h[o],!k)k=h[o]=Object.create(null),u++;h=k}let a=h[j7];if(a)if(a>=96&&H)g[l++]=((a-=96)&31)+96,g[l++]=a>>5;else g[l++]=a;else f(h,h.__keys__||Object.keys(T),u);for(let o in T)if(typeof T.hasOwnProperty!=="function"||T.hasOwnProperty(o))c(T[o])},N=typeof this.useRecords=="function"&&this.useRecords,D=N?(T)=>{N(T)?M(T):R(T)}:M,P=(T)=>{let k;if(T>16777216){if(T-X>U40)throw new Error("Packed buffer would be larger than maximum buffer size");k=Math.min(U40,Math.round(Math.max((T-X)*(T>67108864?1.25:2),4194304)/4096)*4096)}else k=(Math.max(T-X<<2,g.length-1)>>12)+1<<12;let h=new Px(k);if(_1=h.dataView||(h.dataView=new DataView(h.buffer,0,k)),T=Math.min(T,g.length),g.copy)g.copy(h,0,X,T);else h.set(g.slice(X,T));return l-=X,X=0,s6=h.length-10,g=h},f=(T,k,h)=>{let u=Y.nextId;if(!u)u=64;if(u<q&&this.shouldShareStructure&&!this.shouldShareStructure(k)){if(u=Y.nextOwnId,!(u<F))u=q;Y.nextOwnId=u+1}else{if(u>=F)u=q;Y.nextId=u+1}let a=k.highByte=u>=96&&H?u-96>>5:-1;if(T[j7]=u,T.__keys__=k,Y[u-64]=k,u<q)if(k.isShared=!0,Y.sharedLength=u-63,$=!0,a>=0)g[l++]=(u&31)+96,g[l++]=a;else g[l++]=u;else{if(a>=0)g[l++]=213,g[l++]=114,g[l++]=(u&31)+96,g[l++]=a;else g[l++]=212,g[l++]=114,g[l++]=u;if(h)U+=x*h;if(w.length>=V)w.shift()[j7]=0;w.push(T),c(k)}},E=(T,k,h,u)=>{let a=g,o=l,Q0=s6,W0=X;if(g=Wv,l=0,X=0,!g)Wv=g=new Px(8192);s6=g.length-10,f(T,k,u),Wv=g;let E0=l;if(g=a,l=o,s6=Q0,X=W0,E0>1){let I0=l+E0-1;if(I0>s6)P(I0);let t0=h+X;g.copyWithin(t0+E0,t0+1,l),g.set(Wv.slice(0,E0),t0),l=I0}else g[h+X]=Wv[0]},_=(T)=>{let k=j40(T,g,X,l,Y,P,(h,u,a)=>{if(a)return $=!0;l=u;let o=g;if(c(h),L(),o!==g)return{position:l,targetView:_1,target:g};return l},this);if(k===0)return D(T);l=k}}useBuffer(Z){g=Z,g.dataView||(g.dataView=new DataView(g.buffer,g.byteOffset,g.byteLength)),l=0}set position(Z){l=Z}get position(){return l}clearSharedData(){if(this.structures)this.structures=[];if(this.typedStructs)this.typedStructs=[]}}B40=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Nx];qT=[{pack(Z,J,X){let $=Z.getTime()/1000;if((this.useTimestamp32||Z.getMilliseconds()===0)&&$>=0&&$<4294967296){let{target:Y,targetView:Q,position:K}=J(6);Y[K++]=214,Y[K++]=255,Q.setUint32(K,$)}else if($>0&&$<4294967296){let{target:Y,targetView:Q,position:K}=J(10);Y[K++]=215,Y[K++]=255,Q.setUint32(K,Z.getMilliseconds()*4000000+($/1000/4294967296>>0)),Q.setUint32(K+4,$)}else if(isNaN($)){if(this.onInvalidDate)return J(0),X(this.onInvalidDate());let{target:Y,targetView:Q,position:K}=J(3);Y[K++]=212,Y[K++]=255,Y[K++]=255}else{let{target:Y,targetView:Q,position:K}=J(15);Y[K++]=199,Y[K++]=12,Y[K++]=255,Q.setUint32(K,Z.getMilliseconds()*1e6),Q.setBigInt64(K+4,BigInt(Math.floor($)))}}},{pack(Z,J,X){if(this.setAsEmptyObject)return J(0),X({});let $=Array.from(Z),{target:Y,position:Q}=J(this.moreTypes?3:0);if(this.moreTypes)Y[Q++]=212,Y[Q++]=115,Y[Q++]=0;X($)}},{pack(Z,J,X){let{target:$,position:Y}=J(this.moreTypes?3:0);if(this.moreTypes)$[Y++]=212,$[Y++]=101,$[Y++]=0;X([Z.name,Z.message,Z.cause])}},{pack(Z,J,X){let{target:$,position:Y}=J(this.moreTypes?3:0);if(this.moreTypes)$[Y++]=212,$[Y++]=120,$[Y++]=0;X([Z.source,Z.flags])}},{pack(Z,J){if(this.moreTypes)HT(Z,16,J);else VT(Gv?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let X=Z.constructor;if(X!==L40&&this.moreTypes)HT(Z,vT.indexOf(X.name),J);else VT(Z,J)}},{pack(Z,J){if(this.moreTypes)HT(Z,17,J);else VT(Gv?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let{target:X,position:$}=J(1);X[$]=193}}];function HT(Z,J,X,$){let Y=Z.byteLength;if(Y+1<256){var{target:Q,position:K}=X(4+Y);Q[K++]=199,Q[K++]=Y+1}else if(Y+1<65536){var{target:Q,position:K}=X(5+Y);Q[K++]=200,Q[K++]=Y+1>>8,Q[K++]=Y+1&255}else{var{target:Q,position:K,targetView:W}=X(7+Y);Q[K++]=201,W.setUint32(K,Y+1),K+=4}if(Q[K++]=116,Q[K++]=J,!Z.buffer)Z=new Uint8Array(Z);Q.set(new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength),K)}function VT(Z,J){let X=Z.byteLength;var $,Y;if(X<256){var{target:$,position:Y}=J(X+2);$[Y++]=196,$[Y++]=X}else if(X<65536){var{target:$,position:Y}=J(X+3);$[Y++]=197,$[Y++]=X>>8,$[Y++]=X&255}else{var{target:$,position:Y,targetView:Q}=J(X+5);$[Y++]=198,Q.setUint32(Y,X),Y+=4}$.set(Z,Y)}function vb1(Z,J,X,$){let Y=Z.length;switch(Y){case 1:J[X++]=212;break;case 2:J[X++]=213;break;case 4:J[X++]=214;break;case 8:J[X++]=215;break;case 16:J[X++]=216;break;default:if(Y<256)J[X++]=199,J[X++]=Y;else if(Y<65536)J[X++]=200,J[X++]=Y>>8,J[X++]=Y&255;else J[X++]=201,J[X++]=Y>>24,J[X++]=Y>>16&255,J[X++]=Y>>8&255,J[X++]=Y&255}return J[X++]=$,J.set(Z,X),X+=Y,X}function Hb1(Z,J){let X,$=J.length*6,Y=Z.length-$;while(X=J.pop()){let{offset:Q,id:K}=X;Z.copyWithin(Q+$,Q,Y),$-=6;let W=Q+$;Z[W++]=214,Z[W++]=105,Z[W++]=K>>24,Z[W++]=K>>16&255,Z[W++]=K>>8&255,Z[W++]=K&255,Y=Q}return Z}function x40(Z,J,X){if(s1.length>0){_1.setUint32(s1.position+Z,l+X-s1.position-Z),s1.stringsPosition=l-Z;let $=s1;s1=null,J($[0]),J($[1])}}function c40(Z,J){return Z.isCompatible=(X)=>{let $=!X||(J.lastNamedStructuresLength||0)===X.length;if(!$)J._mergeStructures(X);return $},Z}function O40(Z,J){j40=Z,c40=J}var M40=new VY({useRecords:!1}),Vb1=M40.pack,qb1=M40.pack;var Fb1=512,wb1=1024,Ub1=2048;var FT=3,Q3=0,zv=2,Tx=1,UT=16,N40=["num","object","string","ascii"];N40[UT]="date";var Bb1=[!1,!0,!0,!1,!1,!0,!0,!1],D40;try{new Function(""),D40=!0}catch(Z){}var qY,Lb1=typeof Buffer!=="undefined",kx,c7;try{kx=new TextEncoder}catch(Z){}var jb1=Lb1?function(Z,J,X){return Z.utf8Write(J,X,Z.byteLength-X)}:kx&&kx.encodeInto?function(Z,J,X){return kx.encodeInto(J,Z.subarray(X)).written}:!1,Ub6=Symbol("type"),xb6=Symbol("parent");O40(P40,Nb1);function P40(Z,J,X,$,Y,Q,K,W){let G=W.typedStructs||(W.typedStructs=[]),z=J.dataView,v=(G.lastStringStart||100)+$,V=J.length-10,H=$;if($>V)J=Q($),z=J.dataView,$-=X,H-=X,v-=X,X=0,V=J.length-10;let q,F=v,w=G.transitions||(G.transitions=Object.create(null)),U=G.nextId||G.length,x=U<15?1:U<240?2:U<61440?3:U<15728640?4:0;if(x===0)return 0;$+=x;let L=[],j,c=0;for(let M in Z){let N=Z[M],D=w[M];if(!D)w[M]=D={key:M,parent:w,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};if($>V)J=Q($),z=J.dataView,$-=X,H-=X,v-=X,F-=X,X=0,V=J.length-10;switch(typeof N){case"number":let P=N;if(U<200||!D.num64){if(P>>0===P&&P<536870912&&P>-520093696){if(P<246&&P>=0&&(D.num8&&!(U>200&&D.num32)||P<32&&!D.num32))w=D.num8||M5(D,Q3,1),J[$++]=P;else w=D.num32||M5(D,Q3,4),z.setUint32($,P,!0),$+=4;break}else if(P<4294967296&&P>=-2147483648){if(z.setFloat32($,P,!0),Bb1[J[$+3]>>>5]){let T;if((T=P*HY[(J[$+3]&127)<<1|J[$+2]>>7])>>0===T){w=D.num32||M5(D,Q3,4),$+=4;break}}}}w=D.num64||M5(D,Q3,8),z.setFloat64($,P,!0),$+=8;break;case"string":let f=N.length;if(q=F-v,(f<<2)+F>V)J=Q((f<<2)+F),z=J.dataView,$-=X,H-=X,v-=X,F-=X,X=0,V=J.length-10;if(f>65280+q>>2){L.push(M,N,$-H);break}let E,_=F;if(f<64){let T,k,h;for(T=0;T<f;T++)if(k=N.charCodeAt(T),k<128)J[F++]=k;else if(k<2048)E=!0,J[F++]=k>>6|192,J[F++]=k&63|128;else if((k&64512)===55296&&((h=N.charCodeAt(T+1))&64512)===56320)E=!0,k=65536+((k&1023)<<10)+(h&1023),T++,J[F++]=k>>18|240,J[F++]=k>>12&63|128,J[F++]=k>>6&63|128,J[F++]=k&63|128;else E=!0,J[F++]=k>>12|224,J[F++]=k>>6&63|128,J[F++]=k&63|128}else F+=jb1(J,N,F),E=F-_>f;if(q<160||q<246&&(D.ascii8||D.string8)){if(E){if(!(w=D.string8))if(G.length>10&&(w=D.ascii8))w.__type=zv,D.ascii8=null,D.string8=w,K(null,0,!0);else w=M5(D,zv,1)}else if(q===0&&!j){j=!0,w=D.ascii0||M5(D,FT,0);break}else if(!(w=D.ascii8)&&!(G.length>10&&(w=D.string8)))w=M5(D,FT,1);J[$++]=q}else w=D.string16||M5(D,zv,2),z.setUint16($,q,!0),$+=2;break;case"object":if(N){if(N.constructor===Date)w=D.date64||M5(D,UT,8),z.setFloat64($,N.getTime(),!0),$+=8;else L.push(M,N,c);break}else if(D=R40(D,$,z,-10),D)w=D,$=qY;else L.push(M,N,c);break;case"boolean":w=D.num8||D.ascii8||M5(D,Q3,1),J[$++]=N?249:248;break;case"undefined":if(D=R40(D,$,z,-9),D)w=D,$=qY;else L.push(M,N,c);break;default:L.push(M,N,c)}c++}for(let M=0,N=L.length;M<N;){let D=L[M++],P=L[M++],f=L[M++],E=w[D];if(!E)w[D]=E={key:D,parent:w,enumerationOffset:f-c,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null};let _;if(P){let T;if(q=F-v,q<65280)if(w=E.object16,w)T=2;else if(w=E.object32)T=4;else w=M5(E,Tx,2),T=2;else w=E.object32||M5(E,Tx,4),T=4;if(_=K(P,F),typeof _==="object")F=_.position,z=_.targetView,J=_.target,v-=X,$-=X,H-=X,X=0;else F=_;if(T===2)z.setUint16($,q,!0),$+=2;else z.setUint32($,q,!0),$+=4}else w=E.object16||M5(E,Tx,2),z.setInt16($,P===null?-10:-9,!0),$+=2;c++}let R=w[j7];if(R==null){R=W.typedStructs.length;let M=[],N=w,D,P;while((P=N.__type)!==void 0){let f=N.__size;N=N.__parent,D=N.key;let E=[P,f,D];if(N.enumerationOffset)E.push(N.enumerationOffset);M.push(E),N=N.parent}M.reverse(),w[j7]=R,W.typedStructs[R]=M,K(null,0,!0)}switch(x){case 1:if(R>=16)return 0;J[H]=R+32;break;case 2:if(R>=256)return 0;J[H]=56,J[H+1]=R;break;case 3:if(R>=65536)return 0;J[H]=57,z.setUint16(H+1,R,!0);break;case 4:if(R>=16777216)return 0;z.setUint32(H,(R<<8)+58,!0);break}if($<v){if(v===F)return $;J.copyWithin($,v,F),F+=$-v,G.lastStringStart=$-H}else if($>v){if(v===F)return $;return G.lastStringStart=$-H,P40(Z,J,X,H,Y,Q,K,W)}return F}function R40(Z,J,X,$){let Y;if(Y=Z.ascii8||Z.num8)return X.setInt8(J,$,!0),qY=J+1,Y;if(Y=Z.string16||Z.object16)return X.setInt16(J,$,!0),qY=J+2,Y;if(Y=Z.num32)return X.setUint32(J,3758096640+$,!0),qY=J+4,Y;if(Y=Z.num64)return X.setFloat64(J,NaN,!0),X.setInt8(J,$),qY=J+8,Y;qY=J;return}function M5(Z,J,X){let $=N40[J]+(X<<3),Y=Z[$]||(Z[$]=Object.create(null));return Y.__type=J,Y.__size=X,Y.__parent=Z,Y}function cb1(Z){if(!(Z instanceof Map))return Z;let J=Z.get("typed")||[];if(Object.isFrozen(J))J=J.map((Y)=>Y.slice(0));let X=Z.get("named"),$=Object.create(null);for(let Y=0,Q=J.length;Y<Q;Y++){let K=J[Y],W=$;for(let[G,z,v]of K){let V=W[v];if(!V)W[v]=V={key:v,parent:W,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};W=M5(V,G,z)}W[j7]=Y}return J.transitions=$,this.typedStructs=J,this.lastTypedStructuresLength=J.length,X}var wT=Symbol.for("source");function Ob1(Z,J,X,$){let Y=Z[J++]-32;if(Y>=24)switch(Y){case 24:Y=Z[J++];break;case 25:Y=Z[J++]+(Z[J++]<<8);break;case 26:Y=Z[J++]+(Z[J++]<<8)+(Z[J++]<<16);break;case 27:Y=Z[J++]+(Z[J++]<<8)+(Z[J++]<<16)+(Z[J++]<<24);break}let Q=$.typedStructs&&$.typedStructs[Y];if(!Q){if(Z=Uint8Array.prototype.slice.call(Z,J,X),X-=J,J=0,!$.getStructures)throw new Error(`Reference to shared structure ${Y} without getStructures method`);if($._mergeStructures($.getStructures()),!$.typedStructs)throw new Error("Could not find any shared typed structures");if($.lastTypedStructuresLength=$.typedStructs.length,Q=$.typedStructs[Y],!Q)throw new Error("Could not find typed structure "+Y)}var{construct:K,fullConstruct:W}=Q;if(!K){K=Q.construct=function q(){},W=Q.fullConstruct=function q(){},W.prototype=$.structPrototype??{};var G=K.prototype=$.structPrototype?Object.create($.structPrototype):{};let v=[],V=0,H;for(let q=0,F=Q.length;q<F;q++){let w=Q[q],[U,x,L,j]=w;if(L==="__proto__")L="__proto_";let c={key:L,offset:V};if(j)v.splice(q+j,0,c);else v.push(c);let R;switch(x){case 0:R=()=>0;break;case 1:R=(N,D)=>{let P=N.bytes[D+c.offset];return P>=246?Y3(P):P};break;case 2:R=(N,D)=>{let P=N.bytes,E=(P.dataView||(P.dataView=new DataView(P.buffer,P.byteOffset,P.byteLength))).getUint16(D+c.offset,!0);return E>=65280?Y3(E&255):E};break;case 4:R=(N,D)=>{let P=N.bytes,E=(P.dataView||(P.dataView=new DataView(P.buffer,P.byteOffset,P.byteLength))).getUint32(D+c.offset,!0);return E>=4294967040?Y3(E&255):E};break}c.getRef=R,V+=x;let M;switch(U){case FT:if(H&&!H.next)H.next=c;H=c,c.multiGetCount=0,M=function(N){let{bytes:D,position:P}=N,f=V+P,E=R(N,P);if(typeof E!=="number")return E;let _,T=c.next;while(T){if(_=T.getRef(N,P),typeof _==="number")break;else _=null;T=T.next}if(_==null)_=N.bytesEnd-f;if(N.srcString)return N.srcString.slice(E,_);return v40(D,E+f,_-E)};break;case zv:case Tx:if(H&&!H.next)H.next=c;H=c,M=function(N){let D=N.position,P=V+D,f=R(N,D);if(typeof f!=="number")return f;let E=N.bytes,_,T=c.next;while(T){if(_=T.getRef(N,D),typeof _==="number")break;else _=null;T=T.next}if(_==null)_=N.bytesEnd-P;if(U===zv)return E.toString("utf8",f+P,_+P);else{c7=N;try{return $.unpack(E,{start:f+P,end:_+P})}finally{c7=null}}};break;case Q3:switch(x){case 4:M=function(N){let D=N.bytes,P=D.dataView||(D.dataView=new DataView(D.buffer,D.byteOffset,D.byteLength)),f=N.position+c.offset,E=P.getInt32(f,!0);if(E<536870912){if(E>-520093696)return E;if(E>-536870912)return Y3(E&255)}let _=P.getFloat32(f,!0),T=HY[(D[f+3]&127)<<1|D[f+2]>>7];return(T*_+(_>0?0.5:-0.5)>>0)/T};break;case 8:M=function(N){let D=N.bytes,f=(D.dataView||(D.dataView=new DataView(D.buffer,D.byteOffset,D.byteLength))).getFloat64(N.position+c.offset,!0);if(isNaN(f)){let E=D[N.position+c.offset];if(E>=246)return Y3(E)}return f};break;case 1:M=function(N){let P=N.bytes[N.position+c.offset];return P<246?P:Y3(P)};break}break;case UT:M=function(N){let D=N.bytes,P=D.dataView||(D.dataView=new DataView(D.buffer,D.byteOffset,D.byteLength));return new Date(P.getFloat64(N.position+c.offset,!0))};break}c.get=M}if(D40){let q=[],F=[],w=0,U;for(let L of v){if($.alwaysLazyProperty&&$.alwaysLazyProperty(L.key)){U=!0;continue}Object.defineProperty(G,L.key,{get:Mb1(L.get),enumerable:!0});let j="v"+w++;F.push(j),q.push("o["+JSON.stringify(L.key)+"]="+j+"(s)")}if(U)q.push("__proto__:this");let x=new Function(...F,"var c=this;return function(s){var o=new c();"+q.join(";")+";return o;}").apply(W,v.map((L)=>L.get));Object.defineProperty(G,"toJSON",{value(L){return x.call(this,this[wT])}})}else Object.defineProperty(G,"toJSON",{value(q){let F={};for(let w=0,U=v.length;w<U;w++){let x=v[w].key;F[x]=this[x]}return F}})}var z=new K;return z[wT]={bytes:Z,position:J,srcString:"",bytesEnd:X},z}function Y3(Z){switch(Z){case 246:return null;case 247:return;case 248:return!1;case 249:return!0}throw new Error("Unknown constant")}function Mb1(Z){return function(){return Z(this[wT])}}function Rb1(){if(c7)c7.bytes=Uint8Array.prototype.slice.call(c7.bytes,c7.position,c7.bytesEnd),c7.position=0,c7.bytesEnd=c7.bytes.length}function Nb1(Z,J){if(J.typedStructs){let $=new Map;$.set("named",Z),$.set("typed",J.typedStructs),Z=$}let X=J.lastTypedStructuresLength||0;return Z.isCompatible=($)=>{let Y=!0;if($ instanceof Map){if(($.get("named")||[]).length!==(J.lastNamedStructuresLength||0))Y=!1;if(($.get("typed")||[]).length!==X)Y=!1}else if($ instanceof Array||Array.isArray($)){if($.length!==(J.lastNamedStructuresLength||0))Y=!1}if(!Y)J._mergeStructures($);return Y},J.lastTypedStructuresLength=J.typedStructs&&J.typedStructs.length,Z}w40(Ob1,cb1,Rb1);var Cb1=process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED!==void 0&&process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase()==="true";if(!Cb1){let Z;try{if(Z=p("msgpackr-extract"),Z)z40(Z.extractStrings)}catch(J){}}var k2=t(LQ0(),1);import on1 from"http";import rn1 from"https";import T2 from"fs";import tn1 from"path";import en1 from"url";var jQ0=`-----BEGIN CERTIFICATE-----
|
401
401
|
MIIDRjCCAi6gAwIBAgIFOTEzNTIwDQYJKoZIhvcNAQELBQAwWDEQMA4GA1UEAxMH
|
402
402
|
SFlUT1BJQTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNV
|
@@ -442,7 +442,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
|
|
442
442
|
xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
|
443
443
|
6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
|
444
444
|
0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
|
445
|
-
-----END RSA PRIVATE KEY-----`;var IE=process.env.PORT??8080,fE="0.10.0-prerelease-
|
445
|
+
-----END RSA PRIVATE KEY-----`;var IE=process.env.PORT??8080,fE="0.10.0-prerelease-11",_E;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(_E||={});class D3 extends L0{static instance=new D3;_webserver=k2.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:fE,runtime:"node"})}),this._webserver.use(k2.default.static("assets"));try{this._webserver.use(k2.default.static(tn1.dirname(p.resolve("@hytopia.com/assets"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?on1.createServer(this._webserver):rn1.createServer({key:T2.existsSync("assets/certs/localhost.key")?T2.readFileSync("assets/certs/localhost.key"):cQ0,cert:T2.existsSync("assets/certs/localhost.crt")?T2.readFileSync("assets/certs/localhost.crt"):jQ0},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(IE,this._onStarted),console.info(`WebServer.start(): Server running on port ${IE}.`)}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 $=en1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&C7.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await x7.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
|
446
446
|
Content-Type: text/plain\r
|
447
447
|
Content-Length: ${W.length}\r
|
448
448
|
Connection: close\r
|