hytopia 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/node-server.mjs CHANGED
@@ -411,7 +411,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
411
411
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
412
412
  if (condition) { yield value; }`)};import{Buffer as kL1}from"node:buffer";import{StringDecoder as IL1}from"node:string_decoder";var zB=(Z,J,X)=>{if(X)return;if(Z)return{transform:_L1.bind(void 0,new TextEncoder)};let Y=new IL1(J);return{transform:SL1.bind(void 0,Y),final:vL1.bind(void 0,Y)}},_L1=function*(Z,J){if(kL1.isBuffer(J))yield MZ(J);else if(typeof J==="string")yield Z.encode(J);else yield J},SL1=function*(Z,J){yield d8(J)?Z.write(J):J},vL1=function*(Z){let J=Z.end();if(J!=="")yield J};import{callbackify as Hp}from"node:util";var tD=Hp(async(Z,J,X,Y)=>{J.currentIterable=Z(...X);try{for await(let $ of J.currentIterable)Y.push($)}finally{delete J.currentIterable}}),FB=async function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:Y=xL1}=J[X];for await(let $ of Y(Z))yield*FB($,J,X+1)},Vp=async function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*AL1(X,Number(J),Z)},AL1=async function*(Z,J,X){if(Z===void 0)return;for await(let Y of Z())yield*FB(Y,X,J+1)},zp=Hp(async({currentIterable:Z},J)=>{if(Z!==void 0){await(J?Z.throw(J):Z.return());return}if(J)throw J}),xL1=function*(Z){yield Z};var eD=(Z,J,X,Y)=>{try{for(let $ of Z(...J))X.push($);Y()}catch($){Y($)}},Fp=(Z,J)=>[...J.flatMap((X)=>[...dY(X,Z,0)]),...LH(Z)],dY=function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:Y=fL1}=J[X];for(let $ of Y(Z))yield*dY($,J,X+1)},LH=function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*hL1(X,Number(J),Z)},hL1=function*(Z,J,X){if(Z===void 0)return;for(let Y of Z())yield*dY(Y,X,J+1)},fL1=function*(Z){yield Z};var ZC=({value:Z,value:{transform:J,final:X,writableObjectMode:Y,readableObjectMode:$},optionName:Q},{encoding:K})=>{let G={},W=Up(Z,K,Q),H=uY(J),V=uY(X),F=H?tD.bind(void 0,FB,G):eD.bind(void 0,dY),z=H||V?tD.bind(void 0,Vp,G):eD.bind(void 0,LH),q=H||V?zp.bind(void 0,G):void 0;return{stream:new yL1({writableObjectMode:Y,writableHighWaterMark:qp(Y),readableObjectMode:$,readableHighWaterMark:qp($),transform(B,L,w){F([B,W,0],this,w)},flush(B){z([W],this,B)},destroy:q})}},qB=(Z,J,X,Y)=>{let $=J.filter(({type:K})=>K==="generator"),Q=Y?$.reverse():$;for(let{value:K,optionName:G}of Q){let W=Up(K,X,G);Z=Fp(W,Z)}return Z},Up=({transform:Z,final:J,binary:X,writableObjectMode:Y,readableObjectMode:$,preserveNewlines:Q},K,G)=>{let W={};return[{transform:Kp(Y,G)},zB(X,K,Y),VB(X,Q,Y,W),{transform:Z,final:J},{transform:Gp($,G)},Qp({binary:X,preserveNewlines:Q,readableObjectMode:$,state:W})].filter(Boolean)};var Lp=(Z,J)=>{for(let X of bL1(Z))gL1(Z,X,J)},bL1=(Z)=>new Set(Object.entries(Z).filter(([,{direction:J}])=>J==="input").map(([J])=>Number(J))),gL1=(Z,J,X)=>{let{stdioItems:Y}=Z[J],$=Y.filter(({contents:G})=>G!==void 0);if($.length===0)return;if(J!==0){let[{type:G,optionName:W}]=$;throw new TypeError(`Only the \`stdin\` option, not \`${W}\`, can be ${mJ[G]} with synchronous methods.`)}let K=$.map(({contents:G})=>G).map((G)=>mL1(G,Y));X.input=GH(K)},mL1=(Z,J)=>{let X=qB(Z,J,"utf8",!0);return uL1(X),GH(X)},uL1=(Z)=>{let J=Z.find((X)=>typeof X!=="string"&&!d8(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 pL1,appendFileSync as iL1}from"node:fs";var UB=({stdioItems:Z,encoding:J,verboseInfo:X,fdNumber:Y})=>Y!=="all"&&TK(X,Y)&&!r5.has(J)&&dL1(Y)&&(Z.some(({type:$,value:Q})=>$==="native"&&cL1.has(Q))||Z.every(({type:$})=>S9.has($))),dL1=(Z)=>Z===1||Z===2,cL1=new Set(["pipe","overlapped"]),Bp=async(Z,J,X,Y)=>{for await(let $ of Z)if(!lL1(J))jp($,X,Y)},wp=(Z,J,X)=>{for(let Y of Z)jp(Y,J,X)},lL1=(Z)=>Z._readableState.pipes.length>0,jp=(Z,J,X)=>{let Y=CL(Z);B7({type:"output",verboseMessage:Y,fdNumber:J,verboseInfo:X})};var Op=({fileDescriptors:Z,syncResult:{output:J},options:X,isMaxBuffer:Y,verboseInfo:$})=>{if(J===null)return{output:Array.from({length:3})};let Q={},K=new Set([]);return{output:J.map((W,H)=>nL1({result:W,fileDescriptors:Z,fdNumber:H,state:Q,outputFiles:K,isMaxBuffer:Y,verboseInfo:$},X)),...Q}},nL1=({result:Z,fileDescriptors:J,fdNumber:X,state:Y,outputFiles:$,isMaxBuffer:Q,verboseInfo:K},{buffer:G,encoding:W,lines:H,stripFinalNewline:V,maxBuffer:F})=>{if(Z===null)return;let z=Ml(Z,Q,F),q=MZ(z),{stdioItems:U,objectMode:B}=J[X],L=aL1([q],U,W,Y),{serializedResult:w,finalResult:O=w}=sL1({chunks:L,objectMode:B,encoding:W,lines:H,stripFinalNewline:V,fdNumber:X});oL1({serializedResult:w,fdNumber:X,state:Y,verboseInfo:K,encoding:W,stdioItems:U,objectMode:B});let M=G[X]?O:void 0;try{if(Y.error===void 0)rL1(w,U,$);return M}catch(R){return Y.error=R,M}},aL1=(Z,J,X,Y)=>{try{return qB(Z,J,X,!1)}catch($){return Y.error=$,Z}},sL1=({chunks:Z,objectMode:J,encoding:X,lines:Y,stripFinalNewline:$,fdNumber:Q})=>{if(J)return{serializedResult:Z};if(X==="buffer")return{serializedResult:GH(Z)};let K=xu(Z,X);if(Y[Q])return{serializedResult:K,finalResult:rD(K,!$[Q],J)};return{serializedResult:K}},oL1=({serializedResult:Z,fdNumber:J,state:X,verboseInfo:Y,encoding:$,stdioItems:Q,objectMode:K})=>{if(!UB({stdioItems:Q,encoding:$,verboseInfo:Y,fdNumber:J}))return;let G=rD(Z,!1,K);try{wp(G,J,Y)}catch(W){X.error??=W}},rL1=(Z,J,X)=>{for(let{path:Y,append:$}of J.filter(({type:Q})=>WB.has(Q))){let Q=typeof Y==="string"?Y:Y.toString();if($||X.has(Q))iL1(Y,Z);else X.add(Q),pL1(Y,Z)}};var Mp=([,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,DZ(J,X,"all")];if(Array.isArray(J))return[DZ(Z,X,"all"),...J];if(d8(Z)&&d8(J))return KD([Z,J]);return`${Z}${J}`};import{once as JC}from"node:events";var Rp=async(Z,J)=>{let[X,Y]=await tL1(Z);return J.isForcefullyTerminated??=!1,[X,Y]},tL1=async(Z)=>{let[J,X]=await Promise.allSettled([JC(Z,"spawn"),JC(Z,"exit")]);if(J.status==="rejected")return[];return X.status==="rejected"?Np(Z):X.value},Np=async(Z)=>{try{return await JC(Z,"exit")}catch{return Np(Z)}},Pp=async(Z)=>{let[J,X]=await Z;if(!eL1(J,X)&&XC(J,X))throw new w7;return[J,X]},eL1=(Z,J)=>Z===void 0&&J===void 0,XC=(Z,J)=>Z!==0||J!==null;var Dp=({error:Z,status:J,signal:X,output:Y},{maxBuffer:$})=>{let Q=ZB1(Z,J,X),K=Q?.code==="ETIMEDOUT",G=Ol(Q,Y,$);return{resultError:Q,exitCode:J,signal:X,timedOut:K,isMaxBuffer:G}},ZB1=(Z,J,X)=>{if(Z!==void 0)return Z;return XC(J,X)?new w7:void 0};var Cp=(Z,J,X)=>{let{file:Y,commandArguments:$,command:Q,escapedCommand:K,startTime:G,verboseInfo:W,options:H,fileDescriptors:V}=XB1(Z,J,X),F=QB1({file:Y,commandArguments:$,options:H,command:Q,escapedCommand:K,verboseInfo:W,fileDescriptors:V,startTime:G});return hK(F,W,H)},XB1=(Z,J,X)=>{let{command:Y,escapedCommand:$,startTime:Q,verboseInfo:K}=EL(Z,J,X),G=YB1(X),{file:W,commandArguments:H,options:V}=oL(Z,J,G);$B1(V);let F=Jp(V,K);return{file:W,commandArguments:H,command:Y,escapedCommand:$,startTime:Q,verboseInfo:K,options:V,fileDescriptors:F}},YB1=(Z)=>Z.node&&!Z.ipc?{...Z,ipc:!1}:Z,$B1=({ipc:Z,ipcInput:J,detached:X,cancelSignal:Y})=>{if(J)LB("ipcInput");if(Z)LB("ipc: true");if(X)LB("detached: true");if(Y)LB("cancelSignal")},LB=(Z)=>{throw new TypeError(`The "${Z}" option cannot be used with synchronous methods.`)},QB1=({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,verboseInfo:Q,fileDescriptors:K,startTime:G})=>{let W=KB1({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,fileDescriptors:K,startTime:G});if(W.failed)return W;let{resultError:H,exitCode:V,signal:F,timedOut:z,isMaxBuffer:q}=Dp(W,X),{output:U,error:B=H}=Op({fileDescriptors:K,syncResult:W,options:X,isMaxBuffer:q,verboseInfo:Q}),L=U.map((O,M)=>DZ(O,X,M)),w=DZ(Mp(U,X),X,"all");return WB1({error:B,exitCode:V,signal:F,timedOut:z,isMaxBuffer:q,stdio:L,all:w,options:X,command:Y,escapedCommand:$,startTime:G})},KB1=({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,fileDescriptors:Q,startTime:K})=>{try{Lp(Q,X);let G=GB1(X);return JB1(Z,J,G)}catch(G){return xK({error:G,command:Y,escapedCommand:$,fileDescriptors:Q,options:X,startTime:K,isSync:!0})}},GB1=({encoding:Z,maxBuffer:J,...X})=>({...X,encoding:"buffer",maxBuffer:$B(J)}),WB1=({error:Z,exitCode:J,signal:X,timedOut:Y,isMaxBuffer:$,stdio:Q,all:K,options:G,command:W,escapedCommand:H,startTime:V})=>Z===void 0?QB({command:W,escapedCommand:H,stdio:Q,all:K,ipcOutput:[],options:G,startTime:V}):UH({error:Z,command:W,escapedCommand:H,timedOut:Y,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:$,isForcefullyTerminated:!1,exitCode:J,signal:X,stdio:Q,all:K,ipcOutput:[],options:G,startTime:V,isSync:!0});import{setMaxListeners as s21}from"node:events";import{spawn as o21}from"node:child_process";import _p from"node:process";import{once as YC,on as HB1}from"node:events";var Tp=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y},{reference:$=!0,filter:Q}={})=>{return IK({methodName:"getOneMessage",isSubprocess:X,ipc:Y,isConnected:lL(Z)}),VB1({anyProcess:Z,channel:J,isSubprocess:X,filter:Q,reference:$})},VB1=async({anyProcess:Z,channel:J,isSubprocess:X,filter:Y,reference:$})=>{mL(J,$);let Q=gJ(Z,J,X),K=new AbortController;try{return await Promise.race([zB1(Q,Y,K),FB1(Q,X,K),qB1(Q,X,K)])}catch(G){throw _K(Z),G}finally{K.abort(),uL(J,$)}},zB1=async(Z,J,{signal:X})=>{if(J===void 0){let[Y]=await YC(Z,"message",{signal:X});return Y}for await(let[Y]of HB1(Z,"message",{signal:X}))if(J(Y))return Y},FB1=async(Z,J,{signal:X})=>{await YC(Z,"disconnect",{signal:X}),zc(J)},qB1=async(Z,J,{signal:X})=>{let[Y]=await YC(Z,"strict:error",{signal:X});throw yL(Y,J)};import{once as kp,on as UB1}from"node:events";var Ip=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y},{reference:$=!0}={})=>$C({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y,shouldAwait:!X,reference:$}),$C=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y,shouldAwait:$,reference:Q})=>{IK({methodName:"getEachMessage",isSubprocess:X,ipc:Y,isConnected:lL(Z)}),mL(J,Q);let K=gJ(Z,J,X),G=new AbortController,W={};return LB1(Z,K,G),BB1({ipcEmitter:K,isSubprocess:X,controller:G,state:W}),wB1({anyProcess:Z,channel:J,ipcEmitter:K,isSubprocess:X,shouldAwait:$,controller:G,state:W,reference:Q})},LB1=async(Z,J,X)=>{try{await kp(J,"disconnect",{signal:X.signal}),X.abort()}catch{}},BB1=async({ipcEmitter:Z,isSubprocess:J,controller:X,state:Y})=>{try{let[$]=await kp(Z,"strict:error",{signal:X.signal});Y.error=yL($,J),X.abort()}catch{}},wB1=async function*({anyProcess:Z,channel:J,ipcEmitter:X,isSubprocess:Y,shouldAwait:$,controller:Q,state:K,reference:G}){try{for await(let[W]of UB1(X,"message",{signal:Q.signal}))Ep(K),yield W}catch{Ep(K)}finally{if(Q.abort(),uL(J,G),!Y)_K(Z);if($)await Z}},Ep=({error:Z})=>{if(Z)throw Z};var Sp=(Z,{ipc:J})=>{Object.assign(Z,Ap(Z,!1,J))},vp=()=>{let Z=_p,J=!0,X=_p.channel!==void 0;return{...Ap(Z,!0,X),getCancelSignal:bc.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:!0,ipc:X})}},Ap=(Z,J,X)=>({sendMessage:aL.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getOneMessage:Tp.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getEachMessage:Ip.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X})});import{ChildProcess as jB1}from"node:child_process";import{PassThrough as OB1,Readable as MB1,Writable as RB1,Duplex as NB1}from"node:stream";var xp=({error:Z,command:J,escapedCommand:X,fileDescriptors:Y,options:$,startTime:Q,verboseInfo:K})=>{aD(Y);let G=new jB1;PB1(G,Y),Object.assign(G,{readable:DB1,writable:CB1,duplex:TB1});let W=xK({error:Z,command:J,escapedCommand:X,fileDescriptors:Y,options:$,startTime:Q,isSync:!1}),H=EB1(W,K,$);return{subprocess:G,promise:H}},PB1=(Z,J)=>{let X=BH(),Y=BH(),$=BH(),Q=Array.from({length:J.length-3},BH),K=BH(),G=[X,Y,$,...Q];Object.assign(Z,{stdin:X,stdout:Y,stderr:$,all:K,stdio:G})},BH=()=>{let Z=new OB1;return Z.end(),Z},DB1=()=>new MB1({read(){}}),CB1=()=>new RB1({write(){}}),TB1=()=>new NB1({read(){},write(){}}),EB1=async(Z,J,X)=>hK(Z,J,X);import{createReadStream as hp,createWriteStream as fp}from"node:fs";import{Buffer as kB1}from"node:buffer";import{Readable as wH,Writable as IB1,Duplex as _B1}from"node:stream";var bp=(Z,J)=>HB(SB1,Z,J,!1),jH=({type:Z,optionName:J})=>{throw new TypeError(`The \`${J}\` option cannot be ${mJ[Z]}.`)},yp={fileNumber:jH,generator:ZC,asyncGenerator:ZC,nodeStream:({value:Z})=>({stream:Z}),webTransform({value:{transform:Z,writableObjectMode:J,readableObjectMode:X}}){let Y=J||X;return{stream:_B1.fromWeb(Z,{objectMode:Y})}},duplex:({value:{transform:Z}})=>({stream:Z}),native(){}},SB1={input:{...yp,fileUrl:({value:Z})=>({stream:hp(Z)}),filePath:({value:{file:Z}})=>({stream:hp(Z)}),webStream:({value:Z})=>({stream:wH.fromWeb(Z)}),iterable:({value:Z})=>({stream:wH.from(Z)}),asyncIterable:({value:Z})=>({stream:wH.from(Z)}),string:({value:Z})=>({stream:wH.from(Z)}),uint8Array:({value:Z})=>({stream:wH.from(kB1.from(Z))})},output:{...yp,fileUrl:({value:Z})=>({stream:fp(Z)}),filePath:({value:{file:Z,append:J}})=>({stream:fp(Z,J?{flags:"a"}:{})}),webStream:({value:Z})=>({stream:IB1.fromWeb(Z)}),iterable:jH,asyncIterable:jH,string:jH,uint8Array:jH}};import{on as vB1,once as gp}from"node:events";import{PassThrough as AB1,getDefaultHighWaterMark as xB1}from"node:stream";import{finished as dp}from"node:stream/promises";function cY(Z){if(!Array.isArray(Z))throw new TypeError(`Expected an array, got \`${typeof Z}\`.`);for(let $ of Z)QC($);let J=Z.some(({readableObjectMode:$})=>$),X=hB1(Z,J),Y=new cp({objectMode:J,writableHighWaterMark:X,readableHighWaterMark:X});for(let $ of Z)Y.add($);return Y}var hB1=(Z,J)=>{if(Z.length===0)return xB1(J);let X=Z.filter(({readableObjectMode:Y})=>Y===J).map(({readableHighWaterMark:Y})=>Y);return Math.max(...X)};class cp extends AB1{#Z=new Set([]);#J=new Set([]);#Y=new Set([]);#X;#$=Symbol("unpipe");#V=new WeakMap;add(Z){if(QC(Z),this.#Z.has(Z))return;this.#Z.add(Z),this.#X??=fB1(this,this.#Z,this.#$);let J=gB1({passThroughStream:this,stream:Z,streams:this.#Z,ended:this.#J,aborted:this.#Y,onFinished:this.#X,unpipeEvent:this.#$});this.#V.set(Z,J),Z.pipe(this,{end:!1})}async remove(Z){if(QC(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 fB1=async(Z,J,X)=>{BB(Z,mp);let Y=new AbortController;try{await Promise.race([yB1(Z,Y),bB1(Z,J,X,Y)])}finally{Y.abort(),BB(Z,-mp)}},yB1=async(Z,{signal:J})=>{try{await dp(Z,{signal:J,cleanup:!0})}catch(X){throw lp(Z,X),X}},bB1=async(Z,J,X,{signal:Y})=>{for await(let[$]of vB1(Z,"unpipe",{signal:Y}))if(J.has($))$.emit(X)},QC=(Z)=>{if(typeof Z?.pipe!=="function")throw new TypeError(`Expected a readable stream, got: \`${typeof Z}\`.`)},gB1=async({passThroughStream:Z,stream:J,streams:X,ended:Y,aborted:$,onFinished:Q,unpipeEvent:K})=>{BB(Z,up);let G=new AbortController;try{await Promise.race([mB1(Q,J,G),uB1({passThroughStream:Z,stream:J,streams:X,ended:Y,aborted:$,controller:G}),dB1({stream:J,streams:X,ended:Y,aborted:$,unpipeEvent:K,controller:G})])}finally{G.abort(),BB(Z,-up)}if(X.size>0&&X.size===Y.size+$.size)if(Y.size===0&&$.size>0)KC(Z);else cB1(Z)},mB1=async(Z,J,{signal:X})=>{try{if(await Z,!X.aborted)KC(J)}catch(Y){if(!X.aborted)lp(J,Y)}},uB1=async({passThroughStream:Z,stream:J,streams:X,ended:Y,aborted:$,controller:{signal:Q}})=>{try{if(await dp(J,{signal:Q,cleanup:!0,readable:!0,writable:!1}),X.has(J))Y.add(J)}catch(K){if(Q.aborted||!X.has(J))return;if(pp(K))$.add(J);else ip(Z,K)}},dB1=async({stream:Z,streams:J,ended:X,aborted:Y,unpipeEvent:$,controller:{signal:Q}})=>{if(await gp(Z,$,{signal:Q}),!Z.readable)return gp(Q,"abort",{signal:Q});J.delete(Z),X.delete(Z),Y.delete(Z)},cB1=(Z)=>{if(Z.writable)Z.end()},lp=(Z,J)=>{if(pp(J))KC(Z);else ip(Z,J)},pp=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",KC=(Z)=>{if(Z.readable||Z.writable)Z.destroy()},ip=(Z,J)=>{if(!Z.destroyed)Z.once("error",lB1),Z.destroy(J)},lB1=()=>{},BB=(Z,J)=>{let X=Z.getMaxListeners();if(X!==0&&X!==Number.POSITIVE_INFINITY)Z.setMaxListeners(X+J)},mp=2,up=1;import{finished as np}from"node:stream/promises";var yK=(Z,J)=>{Z.pipe(J),pB1(Z,J),iB1(Z,J)},pB1=async(Z,J)=>{if(E4(Z)||E4(J))return;try{await np(Z,{cleanup:!0,readable:!0,writable:!1})}catch{}GC(J)},GC=(Z)=>{if(Z.writable)Z.end()},iB1=async(Z,J)=>{if(E4(Z)||E4(J))return;try{await np(J,{cleanup:!0,readable:!1,writable:!0})}catch{}WC(Z)},WC=(Z)=>{if(Z.readable)Z.destroy()};var ap=(Z,J,X)=>{let Y=new Map;for(let[$,{stdioItems:Q,direction:K}]of Object.entries(J)){for(let{stream:G}of Q.filter(({type:W})=>S9.has(W)))nB1(Z,G,K,$);for(let{stream:G}of Q.filter(({type:W})=>!S9.has(W)))sB1({subprocess:Z,stream:G,direction:K,fdNumber:$,pipeGroups:Y,controller:X})}for(let[$,Q]of Y.entries()){let K=Q.length===1?Q[0]:cY(Q);yK(K,$)}},nB1=(Z,J,X,Y)=>{if(X==="output")yK(Z.stdio[Y],J);else yK(J,Z.stdio[Y]);let $=aB1[Y];if($!==void 0)Z[$]=J;Z.stdio[Y]=J},aB1=["stdin","stdout","stderr"],sB1=({subprocess:Z,stream:J,direction:X,fdNumber:Y,pipeGroups:$,controller:Q})=>{if(J===void 0)return;oB1(J,Q);let[K,G]=X==="output"?[J,Z.stdio[Y]]:[Z.stdio[Y],J],W=$.get(K)??[];$.set(K,[...W,G])},oB1=(Z,{signal:J})=>{if(E4(Z))gY(Z,rB1,J)},rB1=2;import{addAbortListener as Z21}from"node:events";var lY=[];lY.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")lY.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")lY.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var wB=(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",HC=Symbol.for("signal-exit emitter"),VC=globalThis,tB1=Object.defineProperty.bind(Object);class sp{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(VC[HC])return VC[HC];tB1(VC,HC,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Z,J){this.listeners[Z].push(J)}removeListener(Z,J){let X=this.listeners[Z],Y=X.indexOf(J);if(Y===-1)return;if(Y===0&&X.length===1)X.length=0;else X.splice(Y,1)}emit(Z,J,X){if(this.emitted[Z])return!1;this.emitted[Z]=!0;let Y=!1;for(let $ of this.listeners[Z])Y=$(J,X)===!0||Y;if(Z==="exit")Y=this.emit("afterExit",J,X)||Y;return Y}}class FC{}var eB1=(Z)=>{return{onExit(J,X){return Z.onExit(J,X)},load(){return Z.load()},unload(){return Z.unload()}}};class op extends FC{onExit(){return()=>{}}load(){}unload(){}}class rp extends FC{#Z=zC.platform==="win32"?"SIGINT":"SIGHUP";#J=new sp;#Y;#X;#$;#V={};#F=!1;constructor(Z){super();this.#Y=Z,this.#V={};for(let J of lY)this.#V[J]=()=>{let X=this.#Y.listeners(J),{count:Y}=this.#J,$=Z;if(typeof $.__signal_exit_emitter__==="object"&&typeof $.__signal_exit_emitter__.count==="number")Y+=$.__signal_exit_emitter__.count;if(X.length===Y){this.unload();let Q=this.#J.emit("exit",null,J),K=J==="SIGHUP"?this.#Z:J;if(!Q)Z.kill(Z.pid,K)}};this.#$=Z.reallyExit,this.#X=Z.emit}onExit(Z,J){if(!wB(this.#Y))return()=>{};if(this.#F===!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.#F)return;this.#F=!0,this.#J.count+=1;for(let Z of lY)try{let J=this.#V[Z];if(J)this.#Y.on(Z,J)}catch(J){}this.#Y.emit=(Z,...J)=>{return this.#W(Z,...J)},this.#Y.reallyExit=(Z)=>{return this.#G(Z)}}unload(){if(!this.#F)return;this.#F=!1,lY.forEach((Z)=>{let J=this.#V[Z];if(!J)throw new Error("Listener not defined for signal: "+Z);try{this.#Y.removeListener(Z,J)}catch(X){}}),this.#Y.emit=this.#X,this.#Y.reallyExit=this.#$,this.#J.count-=1}#G(Z){if(!wB(this.#Y))return 0;return this.#Y.exitCode=Z||0,this.#J.emit("exit",this.#Y.exitCode,null),this.#$.call(this.#Y,this.#Y.exitCode)}#W(Z,...J){let X=this.#X;if(Z==="exit"&&wB(this.#Y)){if(typeof J[0]==="number")this.#Y.exitCode=J[0];let Y=X.call(this.#Y,Z,...J);return this.#J.emit("exit",this.#Y.exitCode,null),Y}else return X.call(this.#Y,Z,...J)}}var zC=globalThis.process,{onExit:tp,load:zT6,unload:FT6}=eB1(wB(zC)?new rp(zC):new op);var ep=(Z,{cleanup:J,detached:X},{signal:Y})=>{if(!J||X)return;let $=tp(()=>{Z.kill()});Z21(Y,()=>{$()})};var Ji=({source:Z,sourcePromise:J,boundOptions:X,createNested:Y},...$)=>{let Q=TL(),{destination:K,destinationStream:G,destinationError:W,from:H,unpipeSignal:V}=J21(X,Y,$),{sourceStream:F,sourceError:z}=Y21(Z,H),{options:q,fileDescriptors:U}=O7.get(Z);return{sourcePromise:J,sourceStream:F,sourceOptions:q,sourceError:z,destination:K,destinationStream:G,destinationError:W,unpipeSignal:V,fileDescriptors:U,startTime:Q}},J21=(Z,J,X)=>{try{let{destination:Y,pipeOptions:{from:$,to:Q,unpipeSignal:K}={}}=X21(Z,J,...X),G=gL(Y,Q);return{destination:Y,destinationStream:G,from:$,unpipeSignal:K}}catch(Y){return{destinationError:Y}}},X21=(Z,J,X,...Y)=>{if(Array.isArray(X))return{destination:J(Zi,Z)(X,...Y),pipeOptions:Z};if(typeof X==="string"||X instanceof URL||$D(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[$,Q,K]=BL(X,...Y);return{destination:J(Zi)($,Q,K),pipeOptions:K}}if(O7.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:Y[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${X}`)},Zi=({options:Z})=>({options:{...Z,stdin:"pipe",piped:!0}}),Y21=(Z,J)=>{try{return{sourceStream:SK(Z,J)}}catch(X){return{sourceError:X}}};var Yi=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y,fileDescriptors:$,sourceOptions:Q,startTime:K})=>{let G=$21({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y});if(G!==void 0)throw qC({error:G,fileDescriptors:$,sourceOptions:Q,startTime:K})},$21=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y})=>{if(J!==void 0&&Y!==void 0)return Y;if(Y!==void 0)return WC(Z),Y;if(J!==void 0)return GC(X),J},qC=({error:Z,fileDescriptors:J,sourceOptions:X,startTime:Y})=>xK({error:Z,command:Xi,escapedCommand:Xi,fileDescriptors:J,options:X,startTime:Y,isSync:!1}),Xi="source.pipe(destination)";var $i=async(Z)=>{let[{status:J,reason:X,value:Y=X},{status:$,reason:Q,value:K=Q}]=await Z;if(!K.pipedFrom.includes(Y))K.pipedFrom.push(Y);if($==="rejected")throw K;if(J==="rejected")throw Y;return K};import{finished as Q21}from"node:stream/promises";var Qi=(Z,J,X)=>{let Y=jB.has(J)?G21(Z,J):K21(Z,J);return gY(Z,H21,X.signal),gY(J,V21,X.signal),W21(J),Y},K21=(Z,J)=>{let X=cY([Z]);return yK(X,J),jB.set(J,X),X},G21=(Z,J)=>{let X=jB.get(J);return X.add(Z),X},W21=async(Z)=>{try{await Q21(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}jB.delete(Z)},jB=new WeakMap,H21=2,V21=1;import{aborted as z21}from"node:util";var Ki=(Z,J)=>Z===void 0?[]:[F21(Z,J)],F21=async(Z,{sourceStream:J,mergedStream:X,fileDescriptors:Y,sourceOptions:$,startTime:Q})=>{await z21(Z,J),await X.remove(J);let K=new Error("Pipe canceled by `unpipeSignal` option.");throw qC({error:K,fileDescriptors:Y,sourceOptions:$,startTime:Q})};var OB=(Z,...J)=>{if(P8(J[0]))return OB.bind(void 0,{...Z,boundOptions:{...Z.boundOptions,...J[0]}});let{destination:X,...Y}=Ji(Z,...J),$=q21({...Y,destination:X});return $.pipe=OB.bind(void 0,{...Z,source:X,sourcePromise:$,boundOptions:{}}),$},q21=async({sourcePromise:Z,sourceStream:J,sourceOptions:X,sourceError:Y,destination:$,destinationStream:Q,destinationError:K,unpipeSignal:G,fileDescriptors:W,startTime:H})=>{let V=U21(Z,$);Yi({sourceStream:J,sourceError:Y,destinationStream:Q,destinationError:K,fileDescriptors:W,sourceOptions:X,startTime:H});let F=new AbortController;try{let z=Qi(J,Q,F);return await Promise.race([$i(V),...Ki(G,{sourceStream:J,mergedStream:z,sourceOptions:X,fileDescriptors:W,startTime:H})])}finally{F.abort()}},U21=(Z,J)=>Promise.allSettled([Z,J]);import{setImmediate as R21}from"node:timers/promises";import{on as L21}from"node:events";import{getDefaultHighWaterMark as B21}from"node:stream";var MB=({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:Y,encoding:$,preserveNewlines:Q})=>{let K=new AbortController;return w21(J,K),Wi({stream:Z,controller:K,binary:X,shouldEncode:!Z.readableObjectMode&&Y,encoding:$,shouldSplit:!Z.readableObjectMode,preserveNewlines:Q})},w21=async(Z,J)=>{try{await Z}catch{}finally{J.abort()}},UC=({stream:Z,onStreamEnd:J,lines:X,encoding:Y,stripFinalNewline:$,allMixed:Q})=>{let K=new AbortController;j21(J,K,Z);let G=Z.readableObjectMode&&!Q;return Wi({stream:Z,controller:K,binary:Y==="buffer",shouldEncode:!G,encoding:Y,shouldSplit:!G&&X,preserveNewlines:!$})},j21=async(Z,J,X)=>{try{await Z}catch{X.destroy()}finally{J.abort()}},Wi=({stream:Z,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K})=>{let G=L21(Z,"data",{signal:J.signal,highWaterMark:Gi,highWatermark:Gi});return O21({onStdoutChunk:G,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K})},LC=B21(!0),Gi=LC,O21=async function*({onStdoutChunk:Z,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K}){let G=M21({binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K});try{for await(let[W]of Z)yield*dY(W,G,0)}catch(W){if(!J.signal.aborted)throw W}finally{yield*LH(G)}},M21=({binary:Z,shouldEncode:J,encoding:X,shouldSplit:Y,preserveNewlines:$})=>[zB(Z,X,!J),VB(Z,$,!Y,{})].filter(Boolean);var Hi=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,buffer:$,maxBuffer:Q,lines:K,allMixed:G,stripFinalNewline:W,verboseInfo:H,streamInfo:V})=>{let F=N21({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,allMixed:G,verboseInfo:H,streamInfo:V});if(!$){await Promise.all([P21(Z),F]);return}let z=sD(W,X),q=UC({stream:Z,onStreamEnd:J,lines:K,encoding:Y,stripFinalNewline:z,allMixed:G}),[U]=await Promise.all([D21({stream:Z,iterable:q,fdNumber:X,encoding:Y,maxBuffer:Q,lines:K}),F]);return U},N21=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,allMixed:$,verboseInfo:Q,streamInfo:{fileDescriptors:K}})=>{if(!UB({stdioItems:K[X]?.stdioItems,encoding:Y,verboseInfo:Q,fdNumber:X}))return;let G=UC({stream:Z,onStreamEnd:J,lines:!0,encoding:Y,stripFinalNewline:!0,allMixed:$});await Bp(G,Z,X,Q)},P21=async(Z)=>{if(await R21(),Z.readableFlowing===null)Z.resume()},D21=async({stream:Z,stream:{readableObjectMode:J},iterable:X,fdNumber:Y,encoding:$,maxBuffer:Q,lines:K})=>{try{if(J||K)return await ZB(X,{maxBuffer:Q});if($==="buffer")return new Uint8Array(await JB(X,{maxBuffer:Q}));return await YB(X,{maxBuffer:Q})}catch(G){return Vi(Bl({error:G,stream:Z,readableObjectMode:J,lines:K,encoding:$,fdNumber:Y}))}},BC=async(Z)=>{try{return await Z}catch(J){return Vi(J)}},Vi=({bufferedData:Z})=>vu(Z)?new Uint8Array(Z):Z;import{finished as C21}from"node:stream/promises";var OH=async(Z,J,X,{isSameDirection:Y,stopOnExit:$=!1}={})=>{let Q=T21(Z,X),K=new AbortController;try{await Promise.race([...$?[X.exitPromise]:[],C21(Z,{cleanup:!0,signal:K.signal})])}catch(G){if(!Q.stdinCleanedUp)I21(G,J,X,Y)}finally{K.abort()}},T21=(Z,{originalStreams:[J],subprocess:X})=>{let Y={stdinCleanedUp:!1};if(Z===J)E21(Z,X,Y);return Y},E21=(Z,J,X)=>{let{_destroy:Y}=Z;Z._destroy=(...$)=>{k21(J,X),Y.call(Z,...$)}},k21=({exitCode:Z,signalCode:J},X)=>{if(Z!==null||J!==null)X.stdinCleanedUp=!0},I21=(Z,J,X,Y)=>{if(!_21(Z,J,X,Y))throw Z},_21=(Z,J,X,Y=!0)=>{if(X.propagating)return zi(Z)||RB(Z);return X.propagating=!0,wC(X,J)===Y?zi(Z):RB(Z)},wC=({fileDescriptors:Z},J)=>J!=="all"&&Z[J].direction==="input",RB=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",zi=(Z)=>Z?.code==="EPIPE";var Fi=({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:Q,verboseInfo:K,streamInfo:G})=>Z.stdio.map((W,H)=>jC({stream:W,fdNumber:H,encoding:J,buffer:X[H],maxBuffer:Y[H],lines:$[H],allMixed:!1,stripFinalNewline:Q,verboseInfo:K,streamInfo:G})),jC=async({stream:Z,fdNumber:J,encoding:X,buffer:Y,maxBuffer:$,lines:Q,allMixed:K,stripFinalNewline:G,verboseInfo:W,streamInfo:H})=>{if(!Z)return;let V=OH(Z,J,H);if(wC(H,J)){await V;return}let[F]=await Promise.all([Hi({stream:Z,onStreamEnd:V,fdNumber:J,encoding:X,buffer:Y,maxBuffer:$,lines:Q,allMixed:K,stripFinalNewline:G,verboseInfo:W,streamInfo:H}),V]);return F};var qi=({stdout:Z,stderr:J},{all:X})=>X&&(Z||J)?cY([Z,J].filter(Boolean)):void 0,Ui=({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:Q,verboseInfo:K,streamInfo:G})=>jC({...S21(Z,X),fdNumber:"all",encoding:J,maxBuffer:Y[1]+Y[2],lines:$[1]||$[2],allMixed:v21(Z),stripFinalNewline:Q,verboseInfo:K,streamInfo:G}),S21=({stdout:Z,stderr:J,all:X},[,Y,$])=>{let Q=Y||$;if(!Q)return{stream:X,buffer:Q};if(!Y)return{stream:J,buffer:Q};if(!$)return{stream:Z,buffer:Q};return{stream:X,buffer:Q}},v21=({all:Z,stdout:J,stderr:X})=>Z&&J&&X&&J.readableObjectMode!==X.readableObjectMode;import{once as A21}from"node:events";var Li=(Z)=>TK(Z,"ipc"),Bi=(Z,J)=>{let X=CL(Z);B7({type:"ipc",verboseMessage:X,fdNumber:"ipc",verboseInfo:J})};var wi=async({subprocess:Z,buffer:J,maxBuffer:X,ipc:Y,ipcOutput:$,verboseInfo:Q})=>{if(!Y)return $;let K=Li(Q),G=RZ(J,"ipc"),W=RZ(X,"ipc");for await(let H of $C({anyProcess:Z,channel:Z.channel,isSubprocess:!1,ipc:Y,shouldAwait:!1,reference:!0})){if(G)wl(Z,$,W),$.push(H);if(K)Bi(H,Q)}return $},ji=async(Z,J)=>{return await Promise.allSettled([Z]),J};var Oi=async({subprocess:Z,options:{encoding:J,buffer:X,maxBuffer:Y,lines:$,timeoutDuration:Q,cancelSignal:K,gracefulCancel:G,forceKillAfterDelay:W,stripFinalNewline:H,ipc:V,ipcInput:F},context:z,verboseInfo:q,fileDescriptors:U,originalStreams:B,onInternalError:L,controller:w})=>{let O=Rp(Z,z),M={originalStreams:B,fileDescriptors:U,subprocess:Z,exitPromise:O,propagating:!1},R=Fi({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:H,verboseInfo:q,streamInfo:M}),D=Ui({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:H,verboseInfo:q,streamInfo:M}),N=[],C=wi({subprocess:Z,buffer:X,maxBuffer:Y,ipc:V,ipcOutput:N,verboseInfo:q}),T=x21(B,Z,M),E=h21(U,M);try{return await Promise.race([Promise.all([{},Pp(O),Promise.all(R),D,C,ac(Z,F),...T,...E]),L,f21(Z,w),...cc(Z,Q,z,w),...Vc({subprocess:Z,cancelSignal:K,gracefulCancel:G,context:z,controller:w}),...uc({subprocess:Z,cancelSignal:K,gracefulCancel:G,forceKillAfterDelay:W,context:z,controller:w})])}catch(A){return z.terminationReason??="other",Promise.all([{error:A},O,Promise.all(R.map((S)=>BC(S))),BC(D),ji(C,N),Promise.allSettled(T),Promise.allSettled(E)])}},x21=(Z,J,X)=>Z.map((Y,$)=>Y===J.stdio[$]?void 0:OH(Y,$,X)),h21=(Z,J)=>Z.flatMap(({stdioItems:X},Y)=>X.filter(({value:$,stream:Q=$})=>I4(Q,{checkOpen:!1})&&!E4(Q)).map(({type:$,value:Q,stream:K=Q})=>OH(K,Y,J,{isSameDirection:S9.has($),stopOnExit:$==="native"}))),f21=async(Z,{signal:J})=>{let[X]=await A21(Z,"error",{signal:J});throw X};var Mi=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),MH=(Z,J,X)=>{let Y=Z[X];if(!Y.has(J))Y.set(J,[]);let $=Y.get(J),Q=j7();return $.push(Q),{resolve:Q.resolve.bind(Q),promises:$}},bK=async({resolve:Z,promises:J},X)=>{Z();let[Y]=await Promise.race([Promise.allSettled([!0,X]),Promise.all([!1,...J])]);return!Y};import{Readable as y21}from"node:stream";import{callbackify as b21}from"node:util";import{finished as Ri}from"node:stream/promises";var OC=async(Z)=>{if(Z===void 0)return;try{await MC(Z)}catch{}},Ni=async(Z)=>{if(Z===void 0)return;try{await RC(Z)}catch{}},MC=async(Z)=>{await Ri(Z,{cleanup:!0,readable:!1,writable:!0})},RC=async(Z)=>{await Ri(Z,{cleanup:!0,readable:!0,writable:!1})},NB=async(Z,J)=>{if(await Z,J)throw J},PB=(Z,J,X)=>{if(X&&!RB(X))Z.destroy(X);else if(J)Z.destroy()};var Pi=({subprocess:Z,concurrentStreams:J,encoding:X},{from:Y,binary:$=!0,preserveNewlines:Q=!0}={})=>{let K=$||r5.has(X),{subprocessStdout:G,waitReadableDestroy:W}=NC(Z,Y,J),{readableEncoding:H,readableObjectMode:V,readableHighWaterMark:F}=PC(G,K),{read:z,onStdoutDataDone:q}=DC({subprocessStdout:G,subprocess:Z,binary:K,encoding:X,preserveNewlines:Q}),U=new y21({read:z,destroy:b21(TC.bind(void 0,{subprocessStdout:G,subprocess:Z,waitReadableDestroy:W})),highWaterMark:F,objectMode:V,encoding:H});return CC({subprocessStdout:G,onStdoutDataDone:q,readable:U,subprocess:Z}),U},NC=(Z,J,X)=>{let Y=SK(Z,J),$=MH(X,Y,"readableDestroy");return{subprocessStdout:Y,waitReadableDestroy:$}},PC=({readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X},Y)=>Y?{readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X}:{readableEncoding:Z,readableObjectMode:!0,readableHighWaterMark:LC},DC=({subprocessStdout:Z,subprocess:J,binary:X,encoding:Y,preserveNewlines:$})=>{let Q=j7(),K=MB({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:!X,encoding:Y,preserveNewlines:$});return{read(){g21(this,K,Q)},onStdoutDataDone:Q}},g21=async(Z,J,X)=>{try{let{value:Y,done:$}=await J.next();if($)X.resolve();else Z.push(Y)}catch{}},CC=async({subprocessStdout:Z,onStdoutDataDone:J,readable:X,subprocess:Y,subprocessStdin:$})=>{try{if(await RC(Z),await Y,await OC($),await J,X.readable)X.push(null)}catch(Q){await OC($),Di(X,Q)}},TC=async({subprocessStdout:Z,subprocess:J,waitReadableDestroy:X},Y)=>{if(await bK(X,J))Di(Z,Y),await NB(J,Y)},Di=(Z,J)=>{PB(Z,Z.readable,J)};import{Writable as m21}from"node:stream";import{callbackify as Ci}from"node:util";var Ti=({subprocess:Z,concurrentStreams:J},{to:X}={})=>{let{subprocessStdin:Y,waitWritableFinal:$,waitWritableDestroy:Q}=EC(Z,X,J),K=new m21({...kC(Y,Z,$),destroy:Ci(_C.bind(void 0,{subprocessStdin:Y,subprocess:Z,waitWritableFinal:$,waitWritableDestroy:Q})),highWaterMark:Y.writableHighWaterMark,objectMode:Y.writableObjectMode});return IC(Y,K),K},EC=(Z,J,X)=>{let Y=gL(Z,J),$=MH(X,Y,"writableFinal"),Q=MH(X,Y,"writableDestroy");return{subprocessStdin:Y,waitWritableFinal:$,waitWritableDestroy:Q}},kC=(Z,J,X)=>({write:u21.bind(void 0,Z),final:Ci(d21.bind(void 0,Z,J,X))}),u21=(Z,J,X,Y)=>{if(Z.write(J,X))Y();else Z.once("drain",Y)},d21=async(Z,J,X)=>{if(await bK(X,J)){if(Z.writable)Z.end();await J}},IC=async(Z,J,X)=>{try{if(await MC(Z),J.writable)J.end()}catch(Y){await Ni(X),Ei(J,Y)}},_C=async({subprocessStdin:Z,subprocess:J,waitWritableFinal:X,waitWritableDestroy:Y},$)=>{if(await bK(X,J),await bK(Y,J))Ei(Z,$),await NB(J,$)},Ei=(Z,J)=>{PB(Z,Z.writable,J)};import{Duplex as c21}from"node:stream";import{callbackify as l21}from"node:util";var ki=({subprocess:Z,concurrentStreams:J,encoding:X},{from:Y,to:$,binary:Q=!0,preserveNewlines:K=!0}={})=>{let G=Q||r5.has(X),{subprocessStdout:W,waitReadableDestroy:H}=NC(Z,Y,J),{subprocessStdin:V,waitWritableFinal:F,waitWritableDestroy:z}=EC(Z,$,J),{readableEncoding:q,readableObjectMode:U,readableHighWaterMark:B}=PC(W,G),{read:L,onStdoutDataDone:w}=DC({subprocessStdout:W,subprocess:Z,binary:G,encoding:X,preserveNewlines:K}),O=new c21({read:L,...kC(V,Z,F),destroy:l21(p21.bind(void 0,{subprocessStdout:W,subprocessStdin:V,subprocess:Z,waitReadableDestroy:H,waitWritableFinal:F,waitWritableDestroy:z})),readableHighWaterMark:B,writableHighWaterMark:V.writableHighWaterMark,readableObjectMode:U,writableObjectMode:V.writableObjectMode,encoding:q});return CC({subprocessStdout:W,onStdoutDataDone:w,readable:O,subprocess:Z,subprocessStdin:V}),IC(V,O,W),O},p21=async({subprocessStdout:Z,subprocessStdin:J,subprocess:X,waitReadableDestroy:Y,waitWritableFinal:$,waitWritableDestroy:Q},K)=>{await Promise.all([TC({subprocessStdout:Z,subprocess:X,waitReadableDestroy:Y},K),_C({subprocessStdin:J,subprocess:X,waitWritableFinal:$,waitWritableDestroy:Q},K)])};var SC=(Z,J,{from:X,binary:Y=!1,preserveNewlines:$=!1}={})=>{let Q=Y||r5.has(J),K=SK(Z,X),G=MB({subprocessStdout:K,subprocess:Z,binary:Q,shouldEncode:!0,encoding:J,preserveNewlines:$});return i21(G,K,Z)},i21=async function*(Z,J,X){try{yield*Z}finally{if(J.readable)J.destroy();await X}};var Ii=(Z,{encoding:J})=>{let X=Mi();Z.readable=Pi.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.writable=Ti.bind(void 0,{subprocess:Z,concurrentStreams:X}),Z.duplex=ki.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.iterable=SC.bind(void 0,Z,J),Z[Symbol.asyncIterator]=SC.bind(void 0,Z,J,{})};var _i=(Z,J)=>{for(let[X,Y]of a21){let $=Y.value.bind(J);Reflect.defineProperty(Z,X,{...Y,value:$})}},n21=(async()=>{})().constructor.prototype,a21=["then","catch","finally"].map((Z)=>[Z,Reflect.getOwnPropertyDescriptor(n21,Z)]);var Si=(Z,J,X,Y)=>{let{file:$,commandArguments:Q,command:K,escapedCommand:G,startTime:W,verboseInfo:H,options:V,fileDescriptors:F}=r21(Z,J,X),{subprocess:z,promise:q}=e21({file:$,commandArguments:Q,options:V,startTime:W,verboseInfo:H,command:K,escapedCommand:G,fileDescriptors:F});return z.pipe=OB.bind(void 0,{source:z,sourcePromise:q,boundOptions:{},createNested:Y}),_i(z,q),O7.set(z,{options:V,fileDescriptors:F}),z},r21=(Z,J,X)=>{let{command:Y,escapedCommand:$,startTime:Q,verboseInfo:K}=EL(Z,J,X),{file:G,commandArguments:W,options:H}=oL(Z,J,X),V=t21(H),F=bp(V,K);return{file:G,commandArguments:W,command:Y,escapedCommand:$,startTime:Q,verboseInfo:K,options:V,fileDescriptors:F}},t21=({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}},e21=({file:Z,commandArguments:J,options:X,startTime:Y,verboseInfo:$,command:Q,escapedCommand:K,fileDescriptors:G})=>{let W;try{W=o21(Z,J,X)}catch(U){return xp({error:U,command:Q,escapedCommand:K,fileDescriptors:G,options:X,startTime:Y,verboseInfo:$})}let H=new AbortController;s21(Number.POSITIVE_INFINITY,H.signal);let V=[...W.stdio];ap(W,G,H),ep(W,X,H);let F={},z=j7();W.kill=Wc.bind(void 0,{kill:W.kill.bind(W),options:X,onInternalError:z,context:F,controller:H}),W.all=qi(W,X),Ii(W,X),Sp(W,X);let q=Zw1({subprocess:W,options:X,startTime:Y,verboseInfo:$,fileDescriptors:G,originalStreams:V,command:Q,escapedCommand:K,context:F,onInternalError:z,controller:H});return{subprocess:W,promise:q}},Zw1=async({subprocess:Z,options:J,startTime:X,verboseInfo:Y,fileDescriptors:$,originalStreams:Q,command:K,escapedCommand:G,context:W,onInternalError:H,controller:V})=>{let[F,[z,q],U,B,L]=await Oi({subprocess:Z,options:J,context:W,verboseInfo:Y,fileDescriptors:$,originalStreams:Q,onInternalError:H,controller:V});V.abort(),H.resolve();let w=U.map((R,D)=>DZ(R,J,D)),O=DZ(B,J,"all"),M=Jw1({errorInfo:F,exitCode:z,signal:q,stdio:w,all:O,ipcOutput:L,context:W,options:J,command:K,escapedCommand:G,startTime:X});return hK(M,Y,J)},Jw1=({errorInfo:Z,exitCode:J,signal:X,stdio:Y,all:$,ipcOutput:Q,context:K,options:G,command:W,escapedCommand:H,startTime:V})=>("error"in Z)?UH({error:Z.error,command:W,escapedCommand:H,timedOut:K.terminationReason==="timeout",isCanceled:K.terminationReason==="cancel"||K.terminationReason==="gracefulCancel",isGracefullyCanceled:K.terminationReason==="gracefulCancel",isMaxBuffer:Z.error instanceof NZ,isForcefullyTerminated:K.isForcefullyTerminated,exitCode:J,signal:X,stdio:Y,all:$,ipcOutput:Q,options:G,startTime:V,isSync:!1}):QB({command:W,escapedCommand:H,stdio:Y,all:$,ipcOutput:Q,options:G,startTime:V});var DB=(Z,J)=>{let X=Object.fromEntries(Object.entries(J).map(([Y,$])=>[Y,Xw1(Y,Z[Y],$)]));return{...Z,...X}},Xw1=(Z,J,X)=>{if(Yw1.has(Z)&&P8(J)&&P8(X))return{...J,...X};return X},Yw1=new Set(["env",...VD]);var uJ=(Z,J,X,Y)=>{let $=(K,G,W)=>uJ(K,G,X,W),Q=(...K)=>$w1({mapArguments:Z,deepOptions:X,boundOptions:J,setBoundExeca:Y,createNested:$},...K);if(Y!==void 0)Y(Q,$,J);return Q},$w1=({mapArguments:Z,deepOptions:J={},boundOptions:X={},setBoundExeca:Y,createNested:$},Q,...K)=>{if(P8(Q))return $(Z,DB(X,Q),Y);let{file:G,commandArguments:W,options:H,isSync:V}=Qw1({mapArguments:Z,firstArgument:Q,nextArguments:K,deepOptions:J,boundOptions:X});return V?Cp(G,W,H):Si(G,W,H,$)},Qw1=({mapArguments:Z,firstArgument:J,nextArguments:X,deepOptions:Y,boundOptions:$})=>{let Q=bu(J)?gu(J,X):[J,...X],[K,G,W]=BL(...Q),H=DB(DB(Y,$),W),{file:V=K,commandArguments:F=G,options:z=H,isSync:q=!1}=Z({file:K,commandArguments:G,options:H});return{file:V,commandArguments:F,options:z,isSync:q}};var vi=({file:Z,commandArguments:J})=>xi(Z,J),Ai=({file:Z,commandArguments:J})=>({...xi(Z,J),isSync:!0}),xi=(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,...Y]=Kw1(Z);return{file:X,commandArguments:Y}},Kw1=(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 Y of J.split(Gw1)){let $=X.at(-1);if($&&$.endsWith("\\"))X[X.length-1]=`${$.slice(0,-1)} ${Y}`;else X.push(Y)}return X},Gw1=/ +/g;var hi=(Z,J,X)=>{Z.sync=J(Ww1,X),Z.s=Z.sync},fi=({options:Z})=>yi(Z),Ww1=({options:Z})=>({...yi(Z),isSync:!0}),yi=(Z)=>({options:{...Hw1(Z),...Z}}),Hw1=({input:Z,inputFile:J,stdio:X})=>Z===void 0&&J===void 0&&X===void 0?{stdin:"inherit"}:{},bi={preferLocal:!0};var gi=uJ(()=>({})),ZI6=uJ(()=>({isSync:!0})),JI6=uJ(vi),XI6=uJ(Ai),YI6=uJ(pc),$I6=uJ(fi,{},bi,hi),{sendMessage:QI6,getOneMessage:KI6,getEachMessage:GI6,getCancelSignal:WI6}=vp();var Qn=r(ri(),1);var NH=(Z)=>{if(typeof Z!=="string")throw new TypeError("invalid pattern");if(Z.length>65536)throw new TypeError("pattern is too long")};var ww1={"[: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]},PH=(Z)=>Z.replace(/[[\]\\-]/g,"\\$&"),jw1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ti=(Z)=>Z.join(""),ei=(Z,J)=>{let X=J;if(Z.charAt(X)!=="[")throw new Error("not in a brace expression");let Y=[],$=[],Q=X+1,K=!1,G=!1,W=!1,H=!1,V=X,F="";Z:while(Q<Z.length){let B=Z.charAt(Q);if((B==="!"||B==="^")&&Q===X+1){H=!0,Q++;continue}if(B==="]"&&K&&!W){V=Q+1;break}if(K=!0,B==="\\"){if(!W){W=!0,Q++;continue}}if(B==="["&&!W){for(let[L,[w,O,M]]of Object.entries(ww1))if(Z.startsWith(L,Q)){if(F)return["$.",!1,Z.length-X,!0];if(Q+=L.length,M)$.push(w);else Y.push(w);G=G||O;continue Z}}if(W=!1,F){if(B>F)Y.push(PH(F)+"-"+PH(B));else if(B===F)Y.push(PH(B));F="",Q++;continue}if(Z.startsWith("-]",Q+1)){Y.push(PH(B+"-")),Q+=2;continue}if(Z.startsWith("-",Q+1)){F=B,Q+=2;continue}Y.push(PH(B)),Q++}if(V<Q)return["",!1,0,!1];if(!Y.length&&!$.length)return["$.",!1,Z.length-X,!0];if($.length===0&&Y.length===1&&/^\\?.$/.test(Y[0])&&!H){let B=Y[0].length===2?Y[0].slice(-1):Y[0];return[jw1(B),!1,V-X,!1]}let z="["+(H?"^":"")+ti(Y)+"]",q="["+(H?"":"^")+ti($)+"]";return[Y.length&&$.length?"("+z+"|"+q+")":Y.length?z:q,G,V-X,!0]};var _4=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/\[([^\/\\])\]/g,"$1"):Z.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var Ow1=new Set(["!","?","+","*","@"]),Zn=(Z)=>Ow1.has(Z),Mw1="(?!(?:^|/)\\.\\.?(?:$|/))",CB="(?!\\.)",Rw1=new Set(["[","."]),Nw1=new Set(["..","."]),Pw1=new Set("().*{}+?[]^$\\!"),Dw1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),hC="[^/]",Jn=hC+"*?",Xn=hC+"+?";class L6{type;#Z;#J;#Y=!1;#X=[];#$;#V;#F;#G=!1;#W;#H;#z=!1;constructor(Z,J,X={}){if(this.type=Z,Z)this.#J=!0;if(this.#$=J,this.#Z=this.#$?this.#$.#Z:this,this.#W=this.#Z===this?X:this.#Z.#W,this.#F=this.#Z===this?[]:this.#Z.#F,Z==="!"&&!this.#Z.#G)this.#F.push(this);this.#V=this.#$?this.#$.#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.#H!==void 0)return this.#H;if(!this.type)return this.#H=this.#X.map((Z)=>String(Z)).join("");else return this.#H=this.type+"("+this.#X.map((Z)=>String(Z)).join("|")+")"}#Q(){if(this!==this.#Z)throw new Error("should only call on root");if(this.#G)return this;this.toString(),this.#G=!0;let Z;while(Z=this.#F.pop()){if(Z.type!=="!")continue;let J=Z,X=J.#$;while(X){for(let Y=J.#V+1;!X.type&&Y<X.#X.length;Y++)for(let $ of Z.#X){if(typeof $==="string")throw new Error("string part in extglob AST??");$.copyIn(X.#X[Y])}J=X,X=J.#$}}return this}push(...Z){for(let J of Z){if(J==="")continue;if(typeof J!=="string"&&!(J instanceof L6&&J.#$===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.#G&&this.#$?.type==="!"))Z.push({});return Z}isStart(){if(this.#Z===this)return!0;if(!this.#$?.isStart())return!1;if(this.#V===0)return!0;let Z=this.#$;for(let J=0;J<this.#V;J++){let X=Z.#X[J];if(!(X instanceof L6&&X.type==="!"))return!1}return!0}isEnd(){if(this.#Z===this)return!0;if(this.#$?.type==="!")return!0;if(!this.#$?.isEnd())return!1;if(!this.type)return this.#$?.isEnd();let Z=this.#$?this.#$.#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 L6(this.type,Z);for(let X of this.#X)J.copyIn(X);return J}static#U(Z,J,X,Y){let $=!1,Q=!1,K=-1,G=!1;if(J.type===null){let z=X,q="";while(z<Z.length){let U=Z.charAt(z++);if($||U==="\\"){$=!$,q+=U;continue}if(Q){if(z===K+1){if(U==="^"||U==="!")G=!0}else if(U==="]"&&!(z===K+2&&G))Q=!1;q+=U;continue}else if(U==="["){Q=!0,K=z,G=!1,q+=U;continue}if(!Y.noext&&Zn(U)&&Z.charAt(z)==="("){J.push(q),q="";let B=new L6(U,J);z=L6.#U(Z,B,z,Y),J.push(B);continue}q+=U}return J.push(q),z}let W=X+1,H=new L6(null,J),V=[],F="";while(W<Z.length){let z=Z.charAt(W++);if($||z==="\\"){$=!$,F+=z;continue}if(Q){if(W===K+1){if(z==="^"||z==="!")G=!0}else if(z==="]"&&!(W===K+2&&G))Q=!1;F+=z;continue}else if(z==="["){Q=!0,K=W,G=!1,F+=z;continue}if(Zn(z)&&Z.charAt(W)==="("){H.push(F),F="";let q=new L6(z,H);H.push(q),W=L6.#U(Z,q,W,Y);continue}if(z==="|"){H.push(F),F="",V.push(H),H=new L6(null,J);continue}if(z===")"){if(F===""&&J.#X.length===0)J.#z=!0;return H.push(F),F="",J.push(...V,H),W}F+=z}return J.type=null,J.#J=void 0,J.#X=[Z.substring(X-1)],W}static fromGlob(Z,J={}){let X=new L6(null,void 0,J);return L6.#U(Z,X,0,J),X}toMMPattern(){if(this!==this.#Z)return this.#Z.toMMPattern();let Z=this.toString(),[J,X,Y,$]=this.toRegExpSource();if(!(Y||this.#J||this.#W.nocase&&!this.#W.nocaseMagicOnly&&Z.toUpperCase()!==Z.toLowerCase()))return X;let K=(this.#W.nocase?"i":"")+($?"u":"");return Object.assign(new RegExp(`^${J}$`,K),{_src:J,_glob:Z})}get options(){return this.#W}toRegExpSource(Z){let J=Z??!!this.#W.dot;if(this.#Z===this)this.#Q();if(!this.type){let G=this.isStart()&&this.isEnd(),W=this.#X.map((z)=>{let[q,U,B,L]=typeof z==="string"?L6.#L(z,this.#J,G):z.toRegExpSource(Z);return this.#J=this.#J||B,this.#Y=this.#Y||L,q}).join(""),H="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&Nw1.has(this.#X[0]))){let q=Rw1,U=J&&q.has(W.charAt(0))||W.startsWith("\\.")&&q.has(W.charAt(2))||W.startsWith("\\.\\.")&&q.has(W.charAt(4)),B=!J&&!Z&&q.has(W.charAt(0));H=U?Mw1:B?CB:""}}}let V="";if(this.isEnd()&&this.#Z.#G&&this.#$?.type==="!")V="(?:$|\\/)";return[H+W+V,_4(W),this.#J=!!this.#J,this.#Y]}let X=this.type==="*"||this.type==="+",Y=this.type==="!"?"(?:(?!(?:":"(?:",$=this.#B(J);if(this.isStart()&&this.isEnd()&&!$&&this.type!=="!"){let G=this.toString();return this.#X=[G],this.type=null,this.#J=void 0,[G,_4(this.toString()),!1,!1]}let Q=!X||Z||J||!CB?"":this.#B(!0);if(Q===$)Q="";if(Q)$=`(?:${$})(?:${Q})*?`;let K="";if(this.type==="!"&&this.#z)K=(this.isStart()&&!J?CB:"")+Xn;else{let G=this.type==="!"?"))"+(this.isStart()&&!J&&!Z?CB:"")+Jn+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&Q?")":this.type==="*"&&Q?")?":`)${this.type}`;K=Y+$+G}return[K,_4($),this.#J=!!this.#J,this.#Y]}#B(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.#Y=this.#Y||Q,X}).filter((J)=>!(this.isStart()&&this.isEnd())||!!J).join("|")}static#L(Z,J,X=!1){let Y=!1,$="",Q=!1;for(let K=0;K<Z.length;K++){let G=Z.charAt(K);if(Y){Y=!1,$+=(Pw1.has(G)?"\\":"")+G;continue}if(G==="\\"){if(K===Z.length-1)$+="\\\\";else Y=!0;continue}if(G==="["){let[W,H,V,F]=ei(Z,K);if(V){$+=W,Q=Q||H,K+=V-1,J=J||F;continue}}if(G==="*"){if(X&&Z==="*")$+=Xn;else $+=Jn;J=!0;continue}if(G==="?"){$+=hC,J=!0;continue}$+=Dw1(G)}return[$,_4(Z),!!J,Q]}}var gK=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/[?*()[\]]/g,"[$&]"):Z.replace(/[?*()[\]\\]/g,"\\$&")};var a6=(Z,J,X={})=>{if(NH(J),!X.nocomment&&J.charAt(0)==="#")return!1;return new A9(J,X).match(Z)},Cw1=/^\*+([^+@!?\*\[\(]*)$/,Tw1=(Z)=>(J)=>!J.startsWith(".")&&J.endsWith(Z),Ew1=(Z)=>(J)=>J.endsWith(Z),kw1=(Z)=>{return Z=Z.toLowerCase(),(J)=>!J.startsWith(".")&&J.toLowerCase().endsWith(Z)},Iw1=(Z)=>{return Z=Z.toLowerCase(),(J)=>J.toLowerCase().endsWith(Z)},_w1=/^\*+\.\*+$/,Sw1=(Z)=>!Z.startsWith(".")&&Z.includes("."),vw1=(Z)=>Z!=="."&&Z!==".."&&Z.includes("."),Aw1=/^\.\*+$/,xw1=(Z)=>Z!=="."&&Z!==".."&&Z.startsWith("."),hw1=/^\*+$/,fw1=(Z)=>Z.length!==0&&!Z.startsWith("."),yw1=(Z)=>Z.length!==0&&Z!=="."&&Z!=="..",bw1=/^\?+([^+@!?\*\[\(]*)?$/,gw1=([Z,J=""])=>{let X=Kn([Z]);if(!J)return X;return J=J.toLowerCase(),(Y)=>X(Y)&&Y.toLowerCase().endsWith(J)},mw1=([Z,J=""])=>{let X=Gn([Z]);if(!J)return X;return J=J.toLowerCase(),(Y)=>X(Y)&&Y.toLowerCase().endsWith(J)},uw1=([Z,J=""])=>{let X=Gn([Z]);return!J?X:(Y)=>X(Y)&&Y.endsWith(J)},dw1=([Z,J=""])=>{let X=Kn([Z]);return!J?X:(Y)=>X(Y)&&Y.endsWith(J)},Kn=([Z])=>{let J=Z.length;return(X)=>X.length===J&&!X.startsWith(".")},Gn=([Z])=>{let J=Z.length;return(X)=>X.length===J&&X!=="."&&X!==".."},Wn=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Yn={win32:{sep:"\\"},posix:{sep:"/"}},cw1=Wn==="win32"?Yn.win32.sep:Yn.posix.sep;a6.sep=cw1;var B6=Symbol("globstar **");a6.GLOBSTAR=B6;var lw1="[^/]",pw1=lw1+"*?",iw1="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",nw1="(?:(?!(?:\\/|^)\\.).)*?",aw1=(Z,J={})=>(X)=>a6(X,Z,J);a6.filter=aw1;var v9=(Z,J={})=>Object.assign({},Z,J),sw1=(Z)=>{if(!Z||typeof Z!=="object"||!Object.keys(Z).length)return a6;let J=a6;return Object.assign((Y,$,Q={})=>J(Y,$,v9(Z,Q)),{Minimatch:class Y extends J.Minimatch{constructor($,Q={}){super($,v9(Z,Q))}static defaults($){return J.defaults(v9(Z,$)).Minimatch}},AST:class Y extends J.AST{constructor($,Q,K={}){super($,Q,v9(Z,K))}static fromGlob($,Q={}){return J.AST.fromGlob($,v9(Z,Q))}},unescape:(Y,$={})=>J.unescape(Y,v9(Z,$)),escape:(Y,$={})=>J.escape(Y,v9(Z,$)),filter:(Y,$={})=>J.filter(Y,v9(Z,$)),defaults:(Y)=>J.defaults(v9(Z,Y)),makeRe:(Y,$={})=>J.makeRe(Y,v9(Z,$)),braceExpand:(Y,$={})=>J.braceExpand(Y,v9(Z,$)),match:(Y,$,Q={})=>J.match(Y,$,v9(Z,Q)),sep:J.sep,GLOBSTAR:B6})};a6.defaults=sw1;var Hn=(Z,J={})=>{if(NH(Z),J.nobrace||!/\{(?:(?!\{).)*\}/.test(Z))return[Z];return Qn.default(Z)};a6.braceExpand=Hn;var ow1=(Z,J={})=>new A9(Z,J).makeRe();a6.makeRe=ow1;var rw1=(Z,J,X={})=>{let Y=new A9(J,X);if(Z=Z.filter(($)=>Y.match($)),Y.options.nonull&&!Z.length)Z.push(J);return Z};a6.match=rw1;var $n=/[?*]|[+@!]\(.*?\)|\[|\]/,tw1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class A9{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Z,J={}){if(NH(Z),J=J||{},this.options=J,this.pattern=Z,this.platform=J.platform||Wn,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=(...$)=>console.error(...$);this.debug(this.pattern,this.globSet);let X=this.globSet.map(($)=>this.slashSplit($));this.globParts=this.preprocess(X),this.debug(this.pattern,this.globParts);let Y=this.globParts.map(($,Q,K)=>{if(this.isWindows&&this.windowsNoMagicRoot){let G=$[0]===""&&$[1]===""&&($[2]==="?"||!$n.test($[2]))&&!$n.test($[3]),W=/^[a-z]:/i.test($[0]);if(G)return[...$.slice(0,4),...$.slice(4).map((H)=>this.parse(H))];else if(W)return[$[0],...$.slice(1).map((H)=>this.parse(H))]}return $.map((G)=>this.parse(G))});if(this.debug(this.pattern,Y),this.set=Y.filter(($)=>$.indexOf(!1)===-1),this.isWindows)for(let $=0;$<this.set.length;$++){let Q=this.set[$];if(Q[0]===""&&Q[1]===""&&this.globParts[$][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 Y=0;Y<Z[X].length;Y++)if(Z[X][Y]==="**")Z[X][Y]="*"}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 Y=X;while(J[Y+1]==="**")Y++;if(Y!==X)J.splice(X,Y-X)}return J})}levelOneOptimize(Z){return Z.map((J)=>{return J=J.reduce((X,Y)=>{let $=X[X.length-1];if(Y==="**"&&$==="**")return X;if(Y===".."){if($&&$!==".."&&$!=="."&&$!=="**")return X.pop(),X}return X.push(Y),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 Y=1;Y<Z.length-1;Y++){let $=Z[Y];if(Y===1&&$===""&&Z[0]==="")continue;if($==="."||$==="")J=!0,Z.splice(Y,1),Y--}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 Y=Z[X-1];if(Y&&Y!=="."&&Y!==".."&&Y!=="**")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 Y=-1;while((Y=X.indexOf("**",Y+1))!==-1){let Q=Y;while(X[Q+1]==="**")Q++;if(Q>Y)X.splice(Y+1,Q-Y);let K=X[Y+1],G=X[Y+2],W=X[Y+3];if(K!=="..")continue;if(!G||G==="."||G===".."||!W||W==="."||W==="..")continue;J=!0,X.splice(Y,1);let H=X.slice(0);H[Y]="**",Z.push(H),Y--}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 $=0;while(($=X.indexOf("..",$+1))!==-1){let Q=X[$-1];if(Q&&Q!=="."&&Q!==".."&&Q!=="**"){J=!0;let G=$===1&&X[$+1]==="**"?["."]:[];if(X.splice($-1,2,...G),X.length===0)X.push("");$-=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 Y=this.partsMatch(Z[J],Z[X],!this.preserveMultipleSlashes);if(Y){Z[J]=[],Z[X]=Y;break}}return Z.filter((J)=>J.length)}partsMatch(Z,J,X=!1){let Y=0,$=0,Q=[],K="";while(Y<Z.length&&$<J.length)if(Z[Y]===J[$])Q.push(K==="b"?J[$]:Z[Y]),Y++,$++;else if(X&&Z[Y]==="**"&&J[$]===Z[Y+1])Q.push(Z[Y]),Y++;else if(X&&J[$]==="**"&&Z[Y]===J[$+1])Q.push(J[$]),$++;else if(Z[Y]==="*"&&J[$]&&(this.options.dot||!J[$].startsWith("."))&&J[$]!=="**"){if(K==="b")return!1;K="a",Q.push(Z[Y]),Y++,$++}else if(J[$]==="*"&&Z[Y]&&(this.options.dot||!Z[Y].startsWith("."))&&Z[Y]!=="**"){if(K==="a")return!1;K="b",Q.push(J[$]),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 Y=0;Y<Z.length&&Z.charAt(Y)==="!";Y++)J=!J,X++;if(X)this.pattern=Z.slice(X);this.negate=J}matchOne(Z,J,X=!1){let Y=this.options;if(this.isWindows){let U=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),B=!U&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&/^[a-z]:$/i.test(Z[3]),L=typeof J[0]==="string"&&/^[a-z]:$/i.test(J[0]),w=!L&&J[0]===""&&J[1]===""&&J[2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]),O=B?3:U?0:void 0,M=w?3:L?0:void 0;if(typeof O==="number"&&typeof M==="number"){let[R,D]=[Z[O],J[M]];if(R.toLowerCase()===D.toLowerCase()){if(J[M]=R,M>O)J=J.slice(M);else if(O>M)Z=Z.slice(O)}}}let{optimizationLevel:$=1}=this.options;if($>=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,G=Z.length,W=J.length;Q<G&&K<W;Q++,K++){this.debug("matchOne loop");var H=J[K],V=Z[Q];if(this.debug(J,H,V),H===!1)return!1;if(H===B6){this.debug("GLOBSTAR",[J,H,V]);var F=Q,z=K+1;if(z===W){this.debug("** at the end");for(;Q<G;Q++)if(Z[Q]==="."||Z[Q]===".."||!Y.dot&&Z[Q].charAt(0)===".")return!1;return!0}while(F<G){var q=Z[F];if(this.debug(`
413
413
  globstar while`,Z,F,J,z,q),this.matchOne(Z.slice(F),J.slice(z),X))return this.debug("globstar found match!",F,G,q),!0;else{if(q==="."||q===".."||!Y.dot&&q.charAt(0)==="."){this.debug("dot detected!",Z,F,J,z);break}this.debug("globstar swallow a segment, and continue"),F++}}if(X){if(this.debug(`
414
- >>> no match, partial?`,Z,F,J,z),F===G)return!0}return!1}let U;if(typeof H==="string")U=V===H,this.debug("string match",H,V,U);else U=H.test(V),this.debug("pattern match",H,V,U);if(!U)return!1}if(Q===G&&K===W)return!0;else if(Q===G)return X;else if(K===W)return Q===G-1&&Z[Q]==="";else throw new Error("wtf?")}braceExpand(){return Hn(this.pattern,this.options)}parse(Z){NH(Z);let J=this.options;if(Z==="**")return B6;if(Z==="")return"";let X,Y=null;if(X=Z.match(hw1))Y=J.dot?yw1:fw1;else if(X=Z.match(Cw1))Y=(J.nocase?J.dot?Iw1:kw1:J.dot?Ew1:Tw1)(X[1]);else if(X=Z.match(bw1))Y=(J.nocase?J.dot?mw1:gw1:J.dot?uw1:dw1)(X);else if(X=Z.match(_w1))Y=J.dot?vw1:Sw1;else if(X=Z.match(Aw1))Y=xw1;let $=L6.fromGlob(Z,this.options).toMMPattern();if(Y&&typeof $==="object")Reflect.defineProperty($,"test",{value:Y});return $}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?pw1:J.dot?iw1:nw1,Y=new Set(J.nocase?["i"]:[]),$=Z.map((G)=>{let W=G.map((H)=>{if(H instanceof RegExp)for(let V of H.flags.split(""))Y.add(V);return typeof H==="string"?tw1(H):H===B6?B6:H._src});return W.forEach((H,V)=>{let F=W[V+1],z=W[V-1];if(H!==B6||z===B6)return;if(z===void 0)if(F!==void 0&&F!==B6)W[V+1]="(?:\\/|"+X+"\\/)?"+F;else W[V]=X;else if(F===void 0)W[V-1]=z+"(?:\\/|"+X+")?";else if(F!==B6)W[V-1]=z+"(?:\\/|\\/"+X+"\\/)"+F,W[V+1]=B6}),W.filter((H)=>H!==B6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if($="^"+Q+$+K+"$",this.negate)$="^(?!"+$+").+$";try{this.regexp=new RegExp($,[...Y].join(""))}catch(G){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 Y=this.slashSplit(Z);this.debug(this.pattern,"split",Y);let $=this.set;this.debug(this.pattern,"set",$);let Q=Y[Y.length-1];if(!Q)for(let K=Y.length-2;!Q&&K>=0;K--)Q=Y[K];for(let K=0;K<$.length;K++){let G=$[K],W=Y;if(X.matchBase&&G.length===1)W=[Q];if(this.matchOne(W,G,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return a6.defaults(Z).Minimatch}}a6.AST=L6;a6.Minimatch=A9;a6.escape=gK;a6.unescape=_4;import{fileURLToPath as _j1}from"node:url";var mK=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,zn=new Set,fC=typeof process==="object"&&!!process?process:{},Fn=(Z,J,X,Y)=>{typeof fC.emitWarning==="function"?fC.emitWarning(Z,J,X,Y):console.error(`[${X}] ${J}: ${Z}`)},TB=globalThis.AbortController,Vn=globalThis.AbortSignal;if(typeof TB==="undefined"){Vn=class X{onabort;_onabort=[];reason;aborted=!1;addEventListener(Y,$){this._onabort.push($)}},TB=class X{constructor(){J()}signal=new Vn;abort(Y){if(this.signal.aborted)return;this.signal.reason=Y,this.signal.aborted=!0;for(let $ of this.signal._onabort)$(Y);this.signal.onabort?.(Y)}};let Z=fC.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,Fn("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 ew1=(Z)=>!zn.has(Z),EI6=Symbol("type"),dJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),qn=(Z)=>!dJ(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?DH:null;class DH extends Array{constructor(Z){super(Z);this.fill(0)}}class uK{heap;length;static#Z=!1;static create(Z){let J=qn(Z);if(!J)return[];uK.#Z=!0;let X=new uK(Z,J);return uK.#Z=!1,X}constructor(Z,J){if(!uK.#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 CH{#Z;#J;#Y;#X;#$;#V;#F;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#G;#W;#H;#z;#Q;#U;#B;#L;#j;#E;#O;#k;#N;#R;#M;#C;#w;#_;static unsafeExposeInternals(Z){return{starts:Z.#N,ttls:Z.#R,sizes:Z.#k,keyMap:Z.#H,keyList:Z.#z,valList:Z.#Q,next:Z.#U,prev:Z.#B,get head(){return Z.#L},get tail(){return Z.#j},free:Z.#E,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,Y,$)=>Z.#h(J,X,Y,$),moveToTail:(J)=>Z.#b(J),indexes:(J)=>Z.#T(J),rindexes:(J)=>Z.#I(J),isStale:(J)=>Z.#D(J)}}get max(){return this.#Z}get maxSize(){return this.#J}get calculatedSize(){return this.#W}get size(){return this.#G}get fetchMethod(){return this.#V}get memoMethod(){return this.#F}get dispose(){return this.#Y}get onInsert(){return this.#X}get disposeAfter(){return this.#$}constructor(Z){let{max:J=0,ttl:X,ttlResolution:Y=1,ttlAutopurge:$,updateAgeOnGet:Q,updateAgeOnHas:K,allowStale:G,dispose:W,onInsert:H,disposeAfter:V,noDisposeOnSet:F,noUpdateTTL:z,maxSize:q=0,maxEntrySize:U=0,sizeCalculation:B,fetchMethod:L,memoMethod:w,noDeleteOnFetchRejection:O,noDeleteOnStaleGet:M,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:D,ignoreFetchAbort:N}=Z;if(J!==0&&!dJ(J))throw new TypeError("max option must be a nonnegative integer");let C=J?qn(J):Array;if(!C)throw new Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=U||this.#J,this.sizeCalculation=B,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw new TypeError("sizeCalculation set to non-function")}if(w!==void 0&&typeof w!=="function")throw new TypeError("memoMethod must be a function if defined");if(this.#F=w,L!==void 0&&typeof L!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#V=L,this.#C=!!L,this.#H=new Map,this.#z=new Array(J).fill(void 0),this.#Q=new Array(J).fill(void 0),this.#U=new C(J),this.#B=new C(J),this.#L=0,this.#j=0,this.#E=uK.create(J),this.#G=0,this.#W=0,typeof W==="function")this.#Y=W;if(typeof H==="function")this.#X=H;if(typeof V==="function")this.#$=V,this.#O=[];else this.#$=void 0,this.#O=void 0;if(this.#M=!!this.#Y,this.#_=!!this.#X,this.#w=!!this.#$,this.noDisposeOnSet=!!F,this.noUpdateTTL=!!z,this.noDeleteOnFetchRejection=!!O,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!N,this.maxEntrySize!==0){if(this.#J!==0){if(!dJ(this.#J))throw new TypeError("maxSize must be a positive integer if specified")}if(!dJ(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#m()}if(this.allowStale=!!G,this.noDeleteOnStaleGet=!!M,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=dJ(Y)||Y===0?Y:1,this.ttlAutopurge=!!$,this.ttl=X||0,this.ttl){if(!dJ(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(ew1("LRU_CACHE_UNBOUNDED"))zn.add("LRU_CACHE_UNBOUNDED"),Fn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",CH)}}getRemainingTTL(Z){return this.#H.has(Z)?1/0:0}#K(){let Z=new DH(this.#Z),J=new DH(this.#Z);this.#R=Z,this.#N=J,this.#S=($,Q,K=mK.now())=>{if(J[$]=Q!==0?K:0,Z[$]=Q,Q!==0&&this.ttlAutopurge){let G=setTimeout(()=>{if(this.#D($))this.#v(this.#z[$],"expire")},Q+1);if(G.unref)G.unref()}},this.#A=($)=>{J[$]=Z[$]!==0?mK.now():0},this.#P=($,Q)=>{if(Z[Q]){let K=Z[Q],G=J[Q];if(!K||!G)return;$.ttl=K,$.start=G,$.now=X||Y();let W=$.now-G;$.remainingTTL=K-W}};let X=0,Y=()=>{let $=mK.now();if(this.ttlResolution>0){X=$;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return $};this.getRemainingTTL=($)=>{let Q=this.#H.get($);if(Q===void 0)return 0;let K=Z[Q],G=J[Q];if(!K||!G)return 1/0;let W=(X||Y())-G;return K-W},this.#D=($)=>{let Q=J[$],K=Z[$];return!!K&&!!Q&&(X||Y())-Q>K}}#A=()=>{};#P=()=>{};#S=()=>{};#D=()=>!1;#m(){let Z=new DH(this.#Z);this.#W=0,this.#k=Z,this.#x=(J)=>{this.#W-=Z[J],Z[J]=0},this.#u=(J,X,Y,$)=>{if(this.#q(X))return 0;if(!dJ(Y))if($){if(typeof $!=="function")throw new TypeError("sizeCalculation must be a function");if(Y=$(X,J),!dJ(Y))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 Y},this.#f=(J,X,Y)=>{if(Z[J]=X,this.#J){let $=this.#J-Z[J];while(this.#W>$)this.#y(!0)}if(this.#W+=Z[J],Y)Y.entrySize=X,Y.totalCalculatedSize=this.#W}}#x=(Z)=>{};#f=(Z,J,X)=>{};#u=(Z,J,X,Y)=>{if(X||Y)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:Z=this.allowStale}={}){if(this.#G)for(let J=this.#j;;){if(!this.#d(J))break;if(Z||!this.#D(J))yield J;if(J===this.#L)break;else J=this.#B[J]}}*#I({allowStale:Z=this.allowStale}={}){if(this.#G)for(let J=this.#L;;){if(!this.#d(J))break;if(Z||!this.#D(J))yield J;if(J===this.#j)break;else J=this.#U[J]}}#d(Z){return Z!==void 0&&this.#H.get(this.#z[Z])===Z}*entries(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&this.#z[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#z[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#I())if(this.#Q[Z]!==void 0&&this.#z[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#z[Z],this.#Q[Z]]}*keys(){for(let Z of this.#T()){let J=this.#z[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#I()){let J=this.#z[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#I())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.#T()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;if(Z($,this.#z[X],this))return this.get(this.#z[X],J)}}forEach(Z,J=this){for(let X of this.#T()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#z[X],this)}}rforEach(Z,J=this){for(let X of this.#I()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#z[X],this)}}purgeStale(){let Z=!1;for(let J of this.#I({allowStale:!0}))if(this.#D(J))this.#v(this.#z[J],"expire"),Z=!0;return Z}info(Z){let J=this.#H.get(Z);if(J===void 0)return;let X=this.#Q[J],Y=this.#q(X)?X.__staleWhileFetching:X;if(Y===void 0)return;let $={value:Y};if(this.#R&&this.#N){let Q=this.#R[J],K=this.#N[J];if(Q&&K){let G=Q-(mK.now()-K);$.ttl=G,$.start=Date.now()}}if(this.#k)$.size=this.#k[J];return $}dump(){let Z=[];for(let J of this.#T({allowStale:!0})){let X=this.#z[J],Y=this.#Q[J],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0||X===void 0)continue;let Q={value:$};if(this.#R&&this.#N){Q.ttl=this.#R[J];let K=mK.now()-this.#N[J];Q.start=Math.floor(Date.now()-K)}if(this.#k)Q.size=this.#k[J];Z.unshift([X,Q])}return Z}load(Z){this.clear();for(let[J,X]of Z){if(X.start){let Y=Date.now()-X.start;X.start=mK.now()-Y}this.set(J,X.value,X)}}set(Z,J,X={}){if(J===void 0)return this.delete(Z),this;let{ttl:Y=this.ttl,start:$,noDisposeOnSet:Q=this.noDisposeOnSet,sizeCalculation:K=this.sizeCalculation,status:G}=X,{noUpdateTTL:W=this.noUpdateTTL}=X,H=this.#u(Z,J,X.size||0,K);if(this.maxEntrySize&&H>this.maxEntrySize){if(G)G.set="miss",G.maxEntrySizeExceeded=!0;return this.#v(Z,"set"),this}let V=this.#G===0?void 0:this.#H.get(Z);if(V===void 0){if(V=this.#G===0?this.#j:this.#E.length!==0?this.#E.pop():this.#G===this.#Z?this.#y(!1):this.#G,this.#z[V]=Z,this.#Q[V]=J,this.#H.set(Z,V),this.#U[this.#j]=V,this.#B[V]=this.#j,this.#j=V,this.#G++,this.#f(V,H,G),G)G.set="add";if(W=!1,this.#_)this.#X?.(J,Z,"add")}else{this.#b(V);let F=this.#Q[V];if(J!==F){if(this.#C&&this.#q(F)){F.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:z}=F;if(z!==void 0&&!Q){if(this.#M)this.#Y?.(z,Z,"set");if(this.#w)this.#O?.push([z,Z,"set"])}}else if(!Q){if(this.#M)this.#Y?.(F,Z,"set");if(this.#w)this.#O?.push([F,Z,"set"])}if(this.#x(V),this.#f(V,H,G),this.#Q[V]=J,G){G.set="replace";let z=F&&this.#q(F)?F.__staleWhileFetching:F;if(z!==void 0)G.oldValue=z}}else if(G)G.set="update";if(this.#_)this.onInsert?.(J,Z,J===F?"update":"replace")}if(Y!==0&&!this.#R)this.#K();if(this.#R){if(!W)this.#S(V,Y,$);if(G)this.#P(G,V)}if(!Q&&this.#w&&this.#O){let F=this.#O,z;while(z=F?.shift())this.#$?.(...z)}return this}pop(){try{while(this.#G){let Z=this.#Q[this.#L];if(this.#y(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#w&&this.#O){let Z=this.#O,J;while(J=Z?.shift())this.#$?.(...J)}}}#y(Z){let J=this.#L,X=this.#z[J],Y=this.#Q[J];if(this.#C&&this.#q(Y))Y.__abortController.abort(new Error("evicted"));else if(this.#M||this.#w){if(this.#M)this.#Y?.(Y,X,"evict");if(this.#w)this.#O?.push([Y,X,"evict"])}if(this.#x(J),Z)this.#z[J]=void 0,this.#Q[J]=void 0,this.#E.push(J);if(this.#G===1)this.#L=this.#j=0,this.#E.length=0;else this.#L=this.#U[J];return this.#H.delete(X),this.#G--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:Y}=J,$=this.#H.get(Z);if($!==void 0){let Q=this.#Q[$];if(this.#q(Q)&&Q.__staleWhileFetching===void 0)return!1;if(!this.#D($)){if(X)this.#A($);if(Y)Y.has="hit",this.#P(Y,$);return!0}else if(Y)Y.has="stale",this.#P(Y,$)}else if(Y)Y.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,Y=this.#H.get(Z);if(Y===void 0||!X&&this.#D(Y))return;let $=this.#Q[Y];return this.#q($)?$.__staleWhileFetching:$}#h(Z,J,X,Y){let $=J===void 0?void 0:this.#Q[J];if(this.#q($))return $;let Q=new TB,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let G={signal:Q.signal,options:X,context:Y},W=(U,B=!1)=>{let{aborted:L}=Q.signal,w=X.ignoreFetchAbort&&U!==void 0;if(X.status)if(L&&!B){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,w)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(L&&!w&&!B)return V(Q.signal.reason);let O=z;if(this.#Q[J]===z)if(U===void 0)if(O.__staleWhileFetching)this.#Q[J]=O.__staleWhileFetching;else this.#v(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,U,G.options)}return U},H=(U)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=U;return V(U)},V=(U)=>{let{aborted:B}=Q.signal,L=B&&X.allowStaleOnFetchAbort,w=L||X.allowStaleOnFetchRejection,O=w||X.noDeleteOnFetchRejection,M=z;if(this.#Q[J]===z){if(!O||M.__staleWhileFetching===void 0)this.#v(Z,"fetch");else if(!L)this.#Q[J]=M.__staleWhileFetching}if(w){if(X.status&&M.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return M.__staleWhileFetching}else if(M.__returned===M)throw U},F=(U,B)=>{let L=this.#V?.(Z,$,G);if(L&&L instanceof Promise)L.then((w)=>U(w===void 0?void 0:w),B);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(U(void 0),X.allowStaleOnFetchAbort)U=(w)=>W(w,!0)}})};if(X.status)X.status.fetchDispatched=!0;let z=new Promise(F).then(W,H),q=Object.assign(z,{__abortController:Q,__staleWhileFetching:$,__returned:void 0});if(J===void 0)this.set(Z,q,{...G.options,status:void 0}),J=this.#H.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#C)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof TB}async fetch(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:Y=this.updateAgeOnGet,noDeleteOnStaleGet:$=this.noDeleteOnStaleGet,ttl:Q=this.ttl,noDisposeOnSet:K=this.noDisposeOnSet,size:G=0,sizeCalculation:W=this.sizeCalculation,noUpdateTTL:H=this.noUpdateTTL,noDeleteOnFetchRejection:V=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:F=this.allowStaleOnFetchRejection,ignoreFetchAbort:z=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:U,forceRefresh:B=!1,status:L,signal:w}=J;if(!this.#C){if(L)L.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,status:L})}let O={allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,ttl:Q,noDisposeOnSet:K,size:G,sizeCalculation:W,noUpdateTTL:H,noDeleteOnFetchRejection:V,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:q,ignoreFetchAbort:z,status:L,signal:w},M=this.#H.get(Z);if(M===void 0){if(L)L.fetch="miss";let R=this.#h(Z,M,O,U);return R.__returned=R}else{let R=this.#Q[M];if(this.#q(R)){let E=X&&R.__staleWhileFetching!==void 0;if(L){if(L.fetch="inflight",E)L.returnedStale=!0}return E?R.__staleWhileFetching:R.__returned=R}let D=this.#D(M);if(!B&&!D){if(L)L.fetch="hit";if(this.#b(M),Y)this.#A(M);if(L)this.#P(L,M);return R}let N=this.#h(Z,M,O,U),T=N.__staleWhileFetching!==void 0&&X;if(L){if(L.fetch=D?"stale":"refresh",T&&D)L.returnedStale=!0}return T?N.__staleWhileFetching:N.__returned=N}}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.#F;if(!X)throw new Error("no memoMethod provided to constructor");let{context:Y,forceRefresh:$,...Q}=J,K=this.get(Z,Q);if(!$&&K!==void 0)return K;let G=X(Z,K,{options:Q,context:Y});return this.set(Z,G,Q),G}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:Y=this.updateAgeOnGet,noDeleteOnStaleGet:$=this.noDeleteOnStaleGet,status:Q}=J,K=this.#H.get(Z);if(K!==void 0){let G=this.#Q[K],W=this.#q(G);if(Q)this.#P(Q,K);if(this.#D(K)){if(Q)Q.get="stale";if(!W){if(!$)this.#v(Z,"expire");if(Q&&X)Q.returnedStale=!0;return X?G:void 0}else{if(Q&&X&&G.__staleWhileFetching!==void 0)Q.returnedStale=!0;return X?G.__staleWhileFetching:void 0}}else{if(Q)Q.get="hit";if(W)return G.__staleWhileFetching;if(this.#b(K),Y)this.#A(K);return G}}else if(Q)Q.get="miss"}#c(Z,J){this.#B[J]=Z,this.#U[Z]=J}#b(Z){if(Z!==this.#j){if(Z===this.#L)this.#L=this.#U[Z];else this.#c(this.#B[Z],this.#U[Z]);this.#c(this.#j,Z),this.#j=Z}}delete(Z){return this.#v(Z,"delete")}#v(Z,J){let X=!1;if(this.#G!==0){let Y=this.#H.get(Z);if(Y!==void 0)if(X=!0,this.#G===1)this.#g(J);else{this.#x(Y);let $=this.#Q[Y];if(this.#q($))$.__abortController.abort(new Error("deleted"));else if(this.#M||this.#w){if(this.#M)this.#Y?.($,Z,J);if(this.#w)this.#O?.push([$,Z,J])}if(this.#H.delete(Z),this.#z[Y]=void 0,this.#Q[Y]=void 0,Y===this.#j)this.#j=this.#B[Y];else if(Y===this.#L)this.#L=this.#U[Y];else{let Q=this.#B[Y];this.#U[Q]=this.#U[Y];let K=this.#U[Y];this.#B[K]=this.#B[Y]}this.#G--,this.#E.push(Y)}}if(this.#w&&this.#O?.length){let Y=this.#O,$;while($=Y?.shift())this.#$?.(...$)}return X}clear(){return this.#g("delete")}#g(Z){for(let J of this.#I({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(new Error("deleted"));else{let Y=this.#z[J];if(this.#M)this.#Y?.(X,Y,Z);if(this.#w)this.#O?.push([X,Y,Z])}}if(this.#H.clear(),this.#Q.fill(void 0),this.#z.fill(void 0),this.#R&&this.#N)this.#R.fill(0),this.#N.fill(0);if(this.#k)this.#k.fill(0);if(this.#L=0,this.#j=0,this.#E.length=0,this.#W=0,this.#G=0,this.#w&&this.#O){let J=this.#O,X;while(X=J?.shift())this.#$?.(...X)}}}import{posix as Vj1,win32 as iC}from"node:path";import{fileURLToPath as zj1}from"node:url";import{lstatSync as Fj1,readdir as qj1,readdirSync as Uj1,readlinkSync as Lj1,realpathSync as Bj1}from"fs";import*as wj1 from"node:fs";import{lstat as Oj1,readdir as Mj1,readlink as Rj1,realpath as Nj1}from"node:fs/promises";import{EventEmitter as dC}from"node:events";import jn from"node:stream";import{StringDecoder as Zj1}from"node:string_decoder";var Un=typeof process==="object"&&process?process:{stdout:null,stderr:null},Jj1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof iY||Z instanceof jn||Xj1(Z)||Yj1(Z)),Xj1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof dC&&typeof Z.pipe==="function"&&Z.pipe!==jn.Writable.prototype.pipe,Yj1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof dC&&typeof Z.write==="function"&&typeof Z.end==="function",CZ=Symbol("EOF"),TZ=Symbol("maybeEmitEnd"),cJ=Symbol("emittedEnd"),EB=Symbol("emittingEnd"),TH=Symbol("emittedError"),kB=Symbol("closed"),Ln=Symbol("read"),IB=Symbol("flush"),Bn=Symbol("flushChunk"),S4=Symbol("encoding"),dK=Symbol("decoder"),t8=Symbol("flowing"),EH=Symbol("paused"),cK=Symbol("resume"),e8=Symbol("buffer"),s6=Symbol("pipes"),Z6=Symbol("bufferLength"),yC=Symbol("bufferPush"),_B=Symbol("bufferShift"),k6=Symbol("objectMode"),D8=Symbol("destroyed"),bC=Symbol("error"),gC=Symbol("emitData"),wn=Symbol("emitEnd"),mC=Symbol("emitEnd2"),R7=Symbol("async"),uC=Symbol("abort"),SB=Symbol("aborted"),kH=Symbol("signal"),pY=Symbol("dataListeners"),t5=Symbol("discarded"),IH=(Z)=>Promise.resolve().then(Z),$j1=(Z)=>Z(),Qj1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",Kj1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,Gj1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class cC{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[cK](),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 On extends cC{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Z,J,X){super(Z,J,X);this.proxyErrors=(Y)=>J.emit("error",Y),Z.on("error",this.proxyErrors)}}var Wj1=(Z)=>!!Z.objectMode,Hj1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class iY extends dC{[t8]=!1;[EH]=!1;[s6]=[];[e8]=[];[k6];[S4];[R7];[dK];[CZ]=!1;[cJ]=!1;[EB]=!1;[kB]=!1;[TH]=null;[Z6]=0;[D8]=!1;[kH];[SB]=!1;[pY]=0;[t5]=!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(Wj1(J))this[k6]=!0,this[S4]=null;else if(Hj1(J))this[S4]=J.encoding,this[k6]=!1;else this[k6]=!1,this[S4]=null;if(this[R7]=!!J.async,this[dK]=this[S4]?new Zj1(this[S4]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[e8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[s6]});let{signal:X}=J;if(X)if(this[kH]=X,X.aborted)this[uC]();else X.addEventListener("abort",()=>this[uC]())}get bufferLength(){return this[Z6]}get encoding(){return this[S4]}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[k6]}set objectMode(Z){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[R7]}set["async"](Z){this[R7]=this[R7]||!!Z}[uC](){this[SB]=!0,this.emit("abort",this[kH]?.reason),this.destroy(this[kH]?.reason)}get aborted(){return this[SB]}set aborted(Z){}write(Z,J,X){if(this[SB])return!1;if(this[CZ])throw new Error("write after end");if(this[D8])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 Y=this[R7]?IH:$j1;if(!this[k6]&&!Buffer.isBuffer(Z)){if(Gj1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(Kj1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[k6]){if(this[t8]&&this[Z6]!==0)this[IB](!0);if(this[t8])this.emit("data",Z);else this[yC](Z);if(this[Z6]!==0)this.emit("readable");if(X)Y(X);return this[t8]}if(!Z.length){if(this[Z6]!==0)this.emit("readable");if(X)Y(X);return this[t8]}if(typeof Z==="string"&&!(J===this[S4]&&!this[dK]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[S4])Z=this[dK].write(Z);if(this[t8]&&this[Z6]!==0)this[IB](!0);if(this[t8])this.emit("data",Z);else this[yC](Z);if(this[Z6]!==0)this.emit("readable");if(X)Y(X);return this[t8]}read(Z){if(this[D8])return null;if(this[t5]=!1,this[Z6]===0||Z===0||Z&&Z>this[Z6])return this[TZ](),null;if(this[k6])Z=null;if(this[e8].length>1&&!this[k6])this[e8]=[this[S4]?this[e8].join(""):Buffer.concat(this[e8],this[Z6])];let J=this[Ln](Z||null,this[e8][0]);return this[TZ](),J}[Ln](Z,J){if(this[k6])this[_B]();else{let X=J;if(Z===X.length||Z===null)this[_B]();else if(typeof X==="string")this[e8][0]=X.slice(Z),J=X.slice(0,Z),this[Z6]-=Z;else this[e8][0]=X.subarray(Z),J=X.subarray(0,Z),this[Z6]-=Z}if(this.emit("data",J),!this[e8].length&&!this[CZ])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[CZ]=!0,this.writable=!1,this[t8]||!this[EH])this[TZ]();return this}[cK](){if(this[D8])return;if(!this[pY]&&!this[s6].length)this[t5]=!0;if(this[EH]=!1,this[t8]=!0,this.emit("resume"),this[e8].length)this[IB]();else if(this[CZ])this[TZ]();else this.emit("drain")}resume(){return this[cK]()}pause(){this[t8]=!1,this[EH]=!0,this[t5]=!1}get destroyed(){return this[D8]}get flowing(){return this[t8]}get paused(){return this[EH]}[yC](Z){if(this[k6])this[Z6]+=1;else this[Z6]+=Z.length;this[e8].push(Z)}[_B](){if(this[k6])this[Z6]-=1;else this[Z6]-=this[e8][0].length;return this[e8].shift()}[IB](Z=!1){do;while(this[Bn](this[_B]())&&this[e8].length);if(!Z&&!this[e8].length&&!this[CZ])this.emit("drain")}[Bn](Z){return this.emit("data",Z),this[t8]}pipe(Z,J){if(this[D8])return Z;this[t5]=!1;let X=this[cJ];if(J=J||{},Z===Un.stdout||Z===Un.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[s6].push(!J.proxyErrors?new cC(this,Z,J):new On(this,Z,J)),this[R7])IH(()=>this[cK]());else this[cK]();return Z}unpipe(Z){let J=this[s6].find((X)=>X.dest===Z);if(J){if(this[s6].length===1){if(this[t8]&&this[pY]===0)this[t8]=!1;this[s6]=[]}else this[s6].splice(this[s6].indexOf(J),1);J.unpipe()}}addListener(Z,J){return this.on(Z,J)}on(Z,J){let X=super.on(Z,J);if(Z==="data"){if(this[t5]=!1,this[pY]++,!this[s6].length&&!this[t8])this[cK]()}else if(Z==="readable"&&this[Z6]!==0)super.emit("readable");else if(Qj1(Z)&&this[cJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[TH]){let Y=J;if(this[R7])IH(()=>Y.call(this,this[TH]));else Y.call(this,this[TH])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[pY]=this.listeners("data").length,this[pY]===0&&!this[t5]&&!this[s6].length)this[t8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[pY]=0,!this[t5]&&!this[s6].length)this[t8]=!1}return J}get emittedEnd(){return this[cJ]}[TZ](){if(!this[EB]&&!this[cJ]&&!this[D8]&&this[e8].length===0&&this[CZ]){if(this[EB]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[kB])this.emit("close");this[EB]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==D8&&this[D8])return!1;else if(Z==="data")return!this[k6]&&!X?!1:this[R7]?(IH(()=>this[gC](X)),!0):this[gC](X);else if(Z==="end")return this[wn]();else if(Z==="close"){if(this[kB]=!0,!this[cJ]&&!this[D8])return!1;let $=super.emit("close");return this.removeAllListeners("close"),$}else if(Z==="error"){this[TH]=X,super.emit(bC,X);let $=!this[kH]||this.listeners("error").length?super.emit("error",X):!1;return this[TZ](),$}else if(Z==="resume"){let $=super.emit("resume");return this[TZ](),$}else if(Z==="finish"||Z==="prefinish"){let $=super.emit(Z);return this.removeAllListeners(Z),$}let Y=super.emit(Z,...J);return this[TZ](),Y}[gC](Z){for(let X of this[s6])if(X.dest.write(Z)===!1)this.pause();let J=this[t5]?!1:super.emit("data",Z);return this[TZ](),J}[wn](){if(this[cJ])return!1;return this[cJ]=!0,this.readable=!1,this[R7]?(IH(()=>this[mC]()),!0):this[mC]()}[mC](){if(this[dK]){let J=this[dK].end();if(J){for(let X of this[s6])X.dest.write(J);if(!this[t5])super.emit("data",J)}}for(let J of this[s6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[k6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[k6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[k6])throw new Error("cannot concat in objectMode");let Z=await this.collect();return this[S4]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(D8,()=>J(new Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[t5]=!1;let Z=!1,J=async()=>{return this.pause(),Z=!0,{value:void 0,done:!0}};return{next:()=>{if(Z)return J();let Y=this.read();if(Y!==null)return Promise.resolve({done:!1,value:Y});if(this[CZ])return J();let $,Q,K=(V)=>{this.off("data",G),this.off("end",W),this.off(D8,H),J(),Q(V)},G=(V)=>{this.off("error",K),this.off("end",W),this.off(D8,H),this.pause(),$({value:V,done:!!this[CZ]})},W=()=>{this.off("error",K),this.off("data",G),this.off(D8,H),J(),$({done:!0,value:void 0})},H=()=>K(new Error("stream destroyed"));return new Promise((V,F)=>{Q=F,$=V,this.once(D8,H),this.once("error",K),this.once("end",W),this.once("data",G)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[t5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(bC,J),this.off(D8,J),this.off("end",J),Z=!0,{done:!0,value:void 0}},X=()=>{if(Z)return J();let Y=this.read();return Y===null?J():{done:!1,value:Y}};return this.once("end",J),this.once(bC,J),this.once(D8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[D8]){if(Z)this.emit("error",Z);else this.emit(D8);return this}this[D8]=!0,this[t5]=!0,this[e8].length=0,this[Z6]=0;let J=this;if(typeof J.close==="function"&&!this[kB])J.close();if(Z)this.emit("error",Z);else this.emit(D8);return this}static get isStream(){return Jj1}}var jj1=Bj1.native,SH={lstatSync:Fj1,readdir:qj1,readdirSync:Uj1,readlinkSync:Lj1,realpathSync:jj1,promises:{lstat:Oj1,readdir:Mj1,readlink:Rj1,realpath:Nj1}},Dn=(Z)=>!Z||Z===SH||Z===wj1?SH:{...SH,...Z,promises:{...SH.promises,...Z.promises||{}}},Cn=/^\\\\\?\\([a-z]:)\\?$/i,Pj1=(Z)=>Z.replace(/\//g,"\\").replace(Cn,"$1\\"),Dj1=/[\\\/]/,h9=0,Tn=1,En=2,N7=4,kn=6,In=8,nY=10,_n=12,x9=15,_H=~x9,lC=16,Mn=32,vH=64,v4=128,vB=256,xB=512,Rn=vH|v4|xB,Cj1=1023,pC=(Z)=>Z.isFile()?In:Z.isDirectory()?N7:Z.isSymbolicLink()?nY:Z.isCharacterDevice()?En:Z.isBlockDevice()?kn:Z.isSocket()?_n:Z.isFIFO()?Tn:h9,Nn=new Map,AH=(Z)=>{let J=Nn.get(Z);if(J)return J;let X=Z.normalize("NFKD");return Nn.set(Z,X),X},Pn=new Map,AB=(Z)=>{let J=Pn.get(Z);if(J)return J;let X=AH(Z.toLowerCase());return Pn.set(Z,X),X};class nC extends CH{constructor(){super({max:256})}}class Sn extends CH{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var vn=Symbol("PathScurry setAsCwd");class o6{name;root;roots;parent;nocase;isCWD=!1;#Z;#J;get dev(){return this.#J}#Y;get mode(){return this.#Y}#X;get nlink(){return this.#X}#$;get uid(){return this.#$}#V;get gid(){return this.#V}#F;get rdev(){return this.#F}#G;get blksize(){return this.#G}#W;get ino(){return this.#W}#H;get size(){return this.#H}#z;get blocks(){return this.#z}#Q;get atimeMs(){return this.#Q}#U;get mtimeMs(){return this.#U}#B;get ctimeMs(){return this.#B}#L;get birthtimeMs(){return this.#L}#j;get atime(){return this.#j}#E;get mtime(){return this.#E}#O;get ctime(){return this.#O}#k;get birthtime(){return this.#k}#N;#R;#M;#C;#w;#_;#K;#A;#P;#S;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=h9,X,Y,$,Q,K){if(this.name=Z,this.#N=$?AB(Z):AH(Z),this.#K=J&Cj1,this.nocase=$,this.roots=Y,this.root=X||this,this.#A=Q,this.#M=K.fullpath,this.#w=K.relative,this.#_=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=Dn(K.fs)}depth(){if(this.#R!==void 0)return this.#R;if(!this.parent)return this.#R=0;return this.#R=this.parent.depth()+1}childrenCache(){return this.#A}resolve(Z){if(!Z)return this;let J=this.getRootString(Z),Y=Z.substring(J.length).split(this.splitSep);return J?this.getRoot(J).#D(Y):this.#D(Y)}#D(Z){let J=this;for(let X of Z)J=J.child(X);return J}children(){let Z=this.#A.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#A.set(this,J),this.#K&=~lC,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),Y=this.nocase?AB(Z):AH(Z);for(let G of X)if(G.#N===Y)return G;let $=this.parent?this.sep:"",Q=this.#M?this.#M+$+Z:void 0,K=this.newChild(Z,h9,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=v4;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#w!==void 0)return this.#w;let Z=this.name,J=this.parent;if(!J)return this.#w=this.name;let X=J.relative();return X+(!X||!J.parent?"":this.sep)+Z}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#_!==void 0)return this.#_;let Z=this.name,J=this.parent;if(!J)return this.#_=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#M!==void 0)return this.#M;let Z=this.name,J=this.parent;if(!J)return this.#M=this.name;let Y=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#M=Y}fullpathPosix(){if(this.#C!==void 0)return this.#C;if(this.sep==="/")return this.#C=this.fullpath();if(!this.parent){let Y=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(Y))return this.#C=`//?/${Y}`;else return this.#C=Y}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#C=X}isUnknown(){return(this.#K&x9)===h9}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&x9)===In}isDirectory(){return(this.#K&x9)===N7}isCharacterDevice(){return(this.#K&x9)===En}isBlockDevice(){return(this.#K&x9)===kn}isFIFO(){return(this.#K&x9)===Tn}isSocket(){return(this.#K&x9)===_n}isSymbolicLink(){return(this.#K&nY)===nY}lstatCached(){return this.#K&Mn?this:void 0}readlinkCached(){return this.#P}realpathCached(){return this.#S}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#P)return!0;if(!this.parent)return!1;let Z=this.#K&x9;return!(Z!==h9&&Z!==nY||this.#K&vB||this.#K&v4)}calledReaddir(){return!!(this.#K&lC)}isENOENT(){return!!(this.#K&v4)}isNamed(Z){return!this.nocase?this.#N===AH(Z):this.#N===AB(Z)}async readlink(){let Z=this.#P;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.#P=X}catch(J){this.#y(J.code);return}}readlinkSync(){let Z=this.#P;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.#P=X}catch(J){this.#y(J.code);return}}#m(Z){this.#K|=lC;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#x()}}#x(){if(this.#K&v4)return;this.#K=(this.#K|v4)&_H,this.#f()}#f(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#x()}#u(){this.#K|=xB,this.#T()}#T(){if(this.#K&vH)return;let Z=this.#K;if((Z&x9)===N7)Z&=_H;this.#K=Z|vH,this.#f()}#I(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#T();else if(Z==="ENOENT")this.#x();else this.children().provisional=0}#d(Z=""){if(Z==="ENOTDIR")this.parent.#T();else if(Z==="ENOENT")this.#x()}#y(Z=""){let J=this.#K;if(J|=vB,Z==="ENOENT")J|=v4;if(Z==="EINVAL"||Z==="UNKNOWN")J&=_H;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#T()}#h(Z,J){return this.#c(Z,J)||this.#q(Z,J)}#q(Z,J){let X=pC(Z),Y=this.newChild(Z.name,X,{parent:this}),$=Y.#K&x9;if($!==N7&&$!==nY&&$!==h9)Y.#K|=vH;return J.unshift(Y),J.provisional++,Y}#c(Z,J){for(let X=J.provisional;X<J.length;X++){let Y=J[X];if((this.nocase?AB(Z.name):AH(Z.name))!==Y.#N)continue;return this.#b(Z,Y,X,J)}}#b(Z,J,X,Y){let $=J.name;if(J.#K=J.#K&_H|pC(Z),$!==Z.name)J.name=Z.name;if(X!==Y.provisional){if(X===Y.length-1)Y.pop();else Y.splice(X,1);Y.unshift(J)}return Y.provisional++,J}async lstat(){if((this.#K&v4)===0)try{return this.#v(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#d(Z.code)}}lstatSync(){if((this.#K&v4)===0)try{return this.#v(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#d(Z.code)}}#v(Z){let{atime:J,atimeMs:X,birthtime:Y,birthtimeMs:$,blksize:Q,blocks:K,ctime:G,ctimeMs:W,dev:H,gid:V,ino:F,mode:z,mtime:q,mtimeMs:U,nlink:B,rdev:L,size:w,uid:O}=Z;this.#j=J,this.#Q=X,this.#k=Y,this.#L=$,this.#G=Q,this.#z=K,this.#O=G,this.#B=W,this.#J=H,this.#V=V,this.#W=F,this.#Y=z,this.#E=q,this.#U=U,this.#X=B,this.#F=L,this.#H=w,this.#$=O;let M=pC(Z);if(this.#K=this.#K&_H|M|Mn,M!==h9&&M!==N7&&M!==nY)this.#K|=vH}#g=[];#p=!1;#i(Z){this.#p=!1;let J=this.#g.slice();this.#g.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 $=X.slice(0,X.provisional);if(J)Z(null,$);else queueMicrotask(()=>Z(null,$));return}if(this.#g.push(Z),this.#p)return;this.#p=!0;let Y=this.fullpath();this.#Z.readdir(Y,{withFileTypes:!0},($,Q)=>{if($)this.#I($.code),X.provisional=0;else{for(let K of Q)this.#h(K,X);this.#m(X)}this.#i(X.slice(0,X.provisional));return})}#l;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.#l)await this.#l;else{let X=()=>{};this.#l=new Promise((Y)=>X=Y);try{for(let Y of await this.#Z.promises.readdir(J,{withFileTypes:!0}))this.#h(Y,Z);this.#m(Z)}catch(Y){this.#I(Y.code),Z.provisional=0}this.#l=void 0,X()}return Z.slice(0,Z.provisional)}readdirSync(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();try{for(let X of this.#Z.readdirSync(J,{withFileTypes:!0}))this.#h(X,Z);this.#m(Z)}catch(X){this.#I(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&Rn)return!1;let Z=x9&this.#K;if(!(Z===h9||Z===N7||Z===nY))return!1;return!0}shouldWalk(Z,J){return(this.#K&N7)===N7&&!(this.#K&Rn)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#S)return this.#S;if((xB|vB|v4)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#S=this.resolve(Z)}catch(Z){this.#u()}}realpathSync(){if(this.#S)return this.#S;if((xB|vB|v4)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#S=this.resolve(Z)}catch(Z){this.#u()}}[vn](Z){if(Z===this)return;Z.isCWD=!1,this.isCWD=!0;let J=new Set([]),X=[],Y=this;while(Y&&Y.parent)J.add(Y),Y.#w=X.join(this.sep),Y.#_=X.join("/"),Y=Y.parent,X.push("..");Y=Z;while(Y&&Y.parent&&!J.has(Y))Y.#w=void 0,Y.#_=void 0,Y=Y.parent}}class hB extends o6{sep="\\";splitSep=Dj1;constructor(Z,J=h9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}newChild(Z,J=h9,X={}){return new hB(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return iC.parse(Z).root}getRoot(Z){if(Z=Pj1(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 xH(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(Cn,"$1\\"),Z===J}}class fB extends o6{splitSep="/";sep="/";constructor(Z,J=h9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=h9,X={}){return new fB(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class aC{root;rootPath;roots;cwd;#Z;#J;#Y;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:Y,childrenCacheSize:$=16384,fs:Q=SH}={}){if(this.#X=Dn(Q),Z instanceof URL||Z.startsWith("file://"))Z=zj1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new nC,this.#J=new nC,this.#Y=new Sn($);let G=K.substring(this.rootPath.length).split(X);if(G.length===1&&!G[0])G.pop();if(Y===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=Y,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let W=this.root,H=G.length-1,V=J.sep,F=this.rootPath,z=!1;for(let q of G){let U=H--;W=W.child(q,{relative:new Array(U).fill("..").join(V),relativePosix:new Array(U).fill("..").join("/"),fullpath:F+=(z?"":V)+q}),z=!0}this.cwd=W}depth(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.depth()}childrenCache(){return this.#Y}resolve(...Z){let J="";for(let $=Z.length-1;$>=0;$--){let Q=Z[$];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 Y=this.cwd.resolve(J).fullpath();return this.#Z.set(J,Y),Y}resolvePosix(...Z){let J="";for(let $=Z.length-1;$>=0;$--){let Q=Z[$];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 Y=this.cwd.resolve(J).fullpathPosix();return this.#J.set(J,Y),Y}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 o6))J=Z,Z=this.cwd;let{withFileTypes:X}=J;if(!Z.canReaddir())return[];else{let Y=await Z.readdir();return X?Y:Y.map(($)=>$.name)}}readdirSync(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof o6))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((Y)=>Y.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 o6))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 o6))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 o6))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 o6))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 o6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let G=new Set,W=(V,F)=>{G.add(V),V.readdirCB((z,q)=>{if(z)return F(z);let U=q.length;if(!U)return F();let B=()=>{if(--U===0)F()};for(let L of q){if(!$||$(L))K.push(X?L:L.fullpath());if(Y&&L.isSymbolicLink())L.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(G,Q)?W(w,B):B());else if(L.shouldWalk(G,Q))W(L,B);else B()}},!0)},H=Z;return new Promise((V,F)=>{W(H,(z)=>{if(z)return F(z);V(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof o6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let G=new Set([Z]);for(let W of G){let H=W.readdirSync();for(let V of H){if(!$||$(V))K.push(X?V:V.fullpath());let F=V;if(V.isSymbolicLink()){if(!(Y&&(F=V.realpathSync())))continue;if(F.isUnknown())F.lstatSync()}if(F.shouldWalk(G,Q))G.add(F)}}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 o6))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 o6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J;if(!$||$(Z))yield X?Z:Z.fullpath();let K=new Set([Z]);for(let G of K){let W=G.readdirSync();for(let H of W){if(!$||$(H))yield X?H:H.fullpath();let V=H;if(H.isSymbolicLink()){if(!(Y&&(V=H.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 o6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new iY({objectMode:!0});if(!$||$(Z))K.write(X?Z:Z.fullpath());let G=new Set,W=[Z],H=0,V=()=>{let F=!1;while(!F){let z=W.shift();if(!z){if(H===0)K.end();return}H++,G.add(z);let q=(B,L,w=!1)=>{if(B)return K.emit("error",B);if(Y&&!w){let O=[];for(let M of L)if(M.isSymbolicLink())O.push(M.realpath().then((R)=>R?.isUnknown()?R.lstat():R));if(O.length){Promise.all(O).then(()=>q(null,L,!0));return}}for(let O of L)if(O&&(!$||$(O))){if(!K.write(X?O:O.fullpath()))F=!0}H--;for(let O of L){let M=O.realpathCached()||O;if(M.shouldWalk(G,Q))W.push(M)}if(F&&!K.flowing)K.once("drain",V);else if(!U)V()},U=!0;z.readdirCB(q,!0),U=!1}};return V(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof o6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new iY({objectMode:!0}),G=new Set;if(!$||$(Z))K.write(X?Z:Z.fullpath());let W=[Z],H=0,V=()=>{let F=!1;while(!F){let z=W.shift();if(!z){if(H===0)K.end();return}H++,G.add(z);let q=z.readdirSync();for(let U of q)if(!$||$(U)){if(!K.write(X?U:U.fullpath()))F=!0}H--;for(let U of q){let B=U;if(U.isSymbolicLink()){if(!(Y&&(B=U.realpathSync())))continue;if(B.isUnknown())B.lstatSync()}if(B.shouldWalk(G,Q))W.push(B)}}if(F&&!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[vn](J)}}class xH extends aC{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,iC,"\\",{...J,nocase:X});this.nocase=X;for(let Y=this.cwd;Y;Y=Y.parent)Y.nocase=this.nocase}parseRootPath(Z){return iC.parse(Z).root.toUpperCase()}newRoot(Z){return new hB(this.rootPath,N7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class hH extends aC{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,Vj1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new fB(this.rootPath,N7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class yB extends hH{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var gI6=process.platform==="win32"?hB:fB,An=process.platform==="win32"?xH:process.platform==="darwin"?yB:hH;var Tj1=(Z)=>Z.length>=1,Ej1=(Z)=>Z.length>=1;class lK{#Z;#J;#Y;length;#X;#$;#V;#F;#G;#W;#H=!0;constructor(Z,J,X,Y){if(!Tj1(Z))throw new TypeError("empty pattern list");if(!Ej1(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.#Y=X,this.#X=Y,this.#Y===0){if(this.isUNC()){let[$,Q,K,G,...W]=this.#Z,[H,V,F,z,...q]=this.#J;if(W[0]==="")W.shift(),q.shift();let U=[$,Q,K,G,""].join("/"),B=[H,V,F,z,""].join("/");this.#Z=[U,...W],this.#J=[B,...q],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[$,...Q]=this.#Z,[K,...G]=this.#J;if(Q[0]==="")Q.shift(),G.shift();let W=$+"/",H=K+"/";this.#Z=[W,...Q],this.#J=[H,...G],this.length=this.#Z.length}}}pattern(){return this.#Z[this.#Y]}isString(){return typeof this.#Z[this.#Y]==="string"}isGlobstar(){return this.#Z[this.#Y]===B6}isRegExp(){return this.#Z[this.#Y]instanceof RegExp}globString(){return this.#V=this.#V||(this.#Y===0?this.isAbsolute()?this.#J[0]+this.#J.slice(1).join("/"):this.#J.join("/"):this.#J.slice(this.#Y).join("/"))}hasMore(){return this.length>this.#Y+1}rest(){if(this.#$!==void 0)return this.#$;if(!this.hasMore())return this.#$=null;return this.#$=new lK(this.#Z,this.#J,this.#Y+1,this.#X),this.#$.#W=this.#W,this.#$.#G=this.#G,this.#$.#F=this.#F,this.#$}isUNC(){let Z=this.#Z;return this.#G!==void 0?this.#G:this.#G=this.#X==="win32"&&this.#Y===0&&Z[0]===""&&Z[1]===""&&typeof Z[2]==="string"&&!!Z[2]&&typeof Z[3]==="string"&&!!Z[3]}isDrive(){let Z=this.#Z;return this.#F!==void 0?this.#F:this.#F=this.#X==="win32"&&this.#Y===0&&this.length>1&&typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0])}isAbsolute(){let Z=this.#Z;return this.#W!==void 0?this.#W:this.#W=Z[0]===""&&Z.length>1||this.isDrive()||this.isUNC()}root(){let Z=this.#Z[0];return typeof Z==="string"&&this.isAbsolute()&&this.#Y===0?Z:""}checkFollowGlobstar(){return!(this.#Y===0||!this.isGlobstar()||!this.#H)}markFollowGlobstar(){if(this.#Y===0||!this.isGlobstar()||!this.#H)return!1;return this.#H=!1,!0}}var kj1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class fH{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:Y,noglobstar:$,platform:Q=kj1}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=Q,this.mmopts={dot:!0,nobrace:J,nocase:X,noext:Y,noglobstar:$,optimizationLevel:2,platform:Q,nocomment:!0,nonegate:!0};for(let K of Z)this.add(K)}add(Z){let J=new A9(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let Y=J.set[X],$=J.globParts[X];if(!Y||!$)throw new Error("invalid pattern object");while(Y[0]==="."&&$[0]===".")Y.shift(),$.shift();let Q=new lK(Y,$,0,this.platform),K=new A9(Q.globString(),this.mmopts),G=$[$.length-1]==="**",W=Q.isAbsolute();if(W)this.absolute.push(K);else this.relative.push(K);if(G)if(W)this.absoluteChildren.push(K);else this.relativeChildren.push(K)}}ignored(Z){let J=Z.fullpath(),X=`${J}/`,Y=Z.relative()||".",$=`${Y}/`;for(let Q of this.relative)if(Q.match(Y)||Q.match($))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 Y of this.relativeChildren)if(Y.match(X))return!0;for(let Y of this.absoluteChildren)if(Y.match(J))return!0;return!1}}class sC{store;constructor(Z=new Map){this.store=Z}copy(){return new sC(new Map(this.store))}hasWalked(Z,J){return this.store.get(Z.fullpath())?.has(J.globString())}storeWalked(Z,J){let X=Z.fullpath(),Y=this.store.get(X);if(Y)Y.add(J.globString());else this.store.set(X,new Set([J.globString()]))}}class xn{store=new Map;add(Z,J,X){let Y=(J?2:0)|(X?1:0),$=this.store.get(Z);this.store.set(Z,$===void 0?Y:Y&$)}entries(){return[...this.store.entries()].map(([Z,J])=>[Z,!!(J&2),!!(J&1)])}}class hn{store=new Map;add(Z,J){if(!Z.canReaddir())return;let X=this.store.get(Z);if(X){if(!X.find((Y)=>Y.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 yH{hasWalkedCache;matches=new xn;subwalks=new hn;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new sC}processPatterns(Z,J){this.patterns=J;let X=J.map((Y)=>[Z,Y]);for(let[Y,$]of X){this.hasWalkedCache.storeWalked(Y,$);let Q=$.root(),K=$.isAbsolute()&&this.opts.absolute!==!1;if(Q){Y=Y.resolve(Q==="/"&&this.opts.root!==void 0?this.opts.root:Q);let V=$.rest();if(!V){this.matches.add(Y,!0,!1);continue}else $=V}if(Y.isENOENT())continue;let G,W,H=!1;while(typeof(G=$.pattern())==="string"&&(W=$.rest()))Y=Y.resolve(G),$=W,H=!0;if(G=$.pattern(),W=$.rest(),H){if(this.hasWalkedCache.hasWalked(Y,$))continue;this.hasWalkedCache.storeWalked(Y,$)}if(typeof G==="string"){let V=G===".."||G===""||G===".";this.matches.add(Y.resolve(G),K,V);continue}else if(G===B6){if(!Y.isSymbolicLink()||this.follow||$.checkFollowGlobstar())this.subwalks.add(Y,$);let V=W?.pattern(),F=W?.rest();if(!W||(V===""||V===".")&&!F)this.matches.add(Y,K,V===""||V===".");else if(V===".."){let z=Y.parent||Y;if(!F)this.matches.add(z,K,!0);else if(!this.hasWalkedCache.hasWalked(z,F))this.subwalks.add(z,F)}}else if(G instanceof RegExp)this.subwalks.add(Y,$)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new yH(this.opts,this.hasWalkedCache)}filterEntries(Z,J){let X=this.subwalks.get(Z),Y=this.child();for(let $ of J)for(let Q of X){let K=Q.isAbsolute(),G=Q.pattern(),W=Q.rest();if(G===B6)Y.testGlobstar($,Q,W,K);else if(G instanceof RegExp)Y.testRegExp($,G,W,K);else Y.testString($,G,W,K)}return Y}testGlobstar(Z,J,X,Y){if(this.dot||!Z.name.startsWith(".")){if(!J.hasMore())this.matches.add(Z,Y,!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 $=X.pattern();if(typeof $==="string"&&$!==".."&&$!==""&&$!==".")this.testString(Z,$,X.rest(),Y);else if($===".."){let Q=Z.parent||Z;this.subwalks.add(Q,X)}else if($ instanceof RegExp)this.testRegExp(Z,$,X.rest(),Y)}}testRegExp(Z,J,X,Y){if(!J.test(Z.name))return;if(!X)this.matches.add(Z,Y,!1);else this.subwalks.add(Z,X)}testString(Z,J,X,Y){if(!Z.isNamed(J))return;if(!X)this.matches.add(Z,Y,!1);else this.subwalks.add(Z,X)}}var Ij1=(Z,J)=>typeof Z==="string"?new fH([Z],J):Array.isArray(Z)?new fH(Z,J):Z;class oC{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#J;#Y;signal;maxDepth;includeChildMatches;constructor(Z,J,X){if(this.patterns=Z,this.path=J,this.opts=X,this.#Y=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#J=Ij1(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)}#$(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 $=Z.isUnknown()||this.opts.stat?await Z.lstat():Z;if(this.opts.follow&&this.opts.nodir&&$?.isSymbolicLink()){let Q=await $.realpath();if(Q&&(Q.isUnknown()||this.opts.stat))await Q.lstat()}return this.matchCheckTest($,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 $=Z.isUnknown()||this.opts.stat?Z.lstatSync():Z;if(this.opts.follow&&this.opts.nodir&&$?.isSymbolicLink()){let Q=$.realpathSync();if(Q&&(Q?.isUnknown()||this.opts.stat))Q.lstatSync()}return this.matchCheckTest($,J)}matchFinish(Z,J){if(this.#X(Z))return;if(!this.includeChildMatches&&this.#J?.add){let $=`${Z.relativePosix()}/**`;this.#J.add($)}let X=this.opts.absolute===void 0?J:this.opts.absolute;this.seen.add(Z);let Y=this.opts.mark&&Z.isDirectory()?this.#Y:"";if(this.opts.withFileTypes)this.matchEmit(Z);else if(X){let $=this.opts.posix?Z.fullpathPosix():Z.fullpath();this.matchEmit($+Y)}else{let $=this.opts.posix?Z.relativePosix():Z.relative(),Q=this.opts.dotRelative&&!$.startsWith(".."+this.#Y)?"."+this.#Y:"";this.matchEmit(!$?"."+Y:Q+$+Y)}}async match(Z,J,X){let Y=await this.matchCheck(Z,X);if(Y)this.matchFinish(Y,J)}matchSync(Z,J,X){let Y=this.matchCheckSync(Z,X);if(Y)this.matchFinish(Y,J)}walkCB(Z,J,X){if(this.signal?.aborted)X();this.walkCB2(Z,J,new yH(this.opts),X)}walkCB2(Z,J,X,Y){if(this.#$(Z))return Y();if(this.signal?.aborted)Y();if(this.paused){this.onResume(()=>this.walkCB2(Z,J,X,Y));return}X.processPatterns(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,G,W]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,G,W).then(()=>Q())}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let G=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,G,X,Q);else K.readdirCB((W,H)=>this.walkCB3(K,H,X,Q),!0)}Q()}walkCB3(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,G,W]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,G,W).then(()=>Q())}for(let[K,G]of X.subwalks.entries())$++,this.walkCB2(K,G,X.child(),Q);Q()}walkCBSync(Z,J,X){if(this.signal?.aborted)X();this.walkCB2Sync(Z,J,new yH(this.opts),X)}walkCB2Sync(Z,J,X,Y){if(this.#$(Z))return Y();if(this.signal?.aborted)Y();if(this.paused){this.onResume(()=>this.walkCB2Sync(Z,J,X,Y));return}X.processPatterns(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,G,W]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,G,W)}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let G=K.readdirSync();this.walkCB3Sync(K,G,X,Q)}Q()}walkCB3Sync(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,G,W]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,G,W)}for(let[K,G]of X.subwalks.entries())$++,this.walkCB2Sync(K,G,X.child(),Q);Q()}}class bB extends oC{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 gB extends oC{results;constructor(Z,J,X){super(Z,J,X);this.results=new iY({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 Sj1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class P7{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=_j1(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((G)=>G.replace(/\\/g,"/"));if(this.matchBase){if(J.noglobstar)throw new TypeError("base matching requires globstar");Z=Z.map((G)=>G.includes("/")?G:`./**/${G}`)}if(this.pattern=Z,this.platform=J.platform||Sj1,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 G=J.platform==="win32"?xH:J.platform==="darwin"?yB:J.platform?hH:An;this.scurry=new G(this.cwd,{nocase:J.nocase,fs:J.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",Y={...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},$=this.pattern.map((G)=>new A9(G,Y)),[Q,K]=$.reduce((G,W)=>{return G[0].push(...W.set),G[1].push(...W.globParts),G},[[],[]]);this.patterns=Q.map((G,W)=>{let H=K[W];if(!H)throw new Error("invalid pattern object");return new lK(G,H,0,this.platform)})}async walk(){return[...await new bB(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 bB(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 gB(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 gB(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 rC=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new A9(X,J).hasMagic())return!0;return!1};function uB(Z,J={}){return new P7(Z,J).streamSync()}function yn(Z,J={}){return new P7(Z,J).stream()}function bn(Z,J={}){return new P7(Z,J).walkSync()}async function fn(Z,J={}){return new P7(Z,J).walk()}function dB(Z,J={}){return new P7(Z,J).iterateSync()}function gn(Z,J={}){return new P7(Z,J).iterate()}var vj1=uB,Aj1=Object.assign(yn,{sync:uB}),xj1=dB,hj1=Object.assign(gn,{sync:dB}),fj1=Object.assign(bn,{stream:uB,iterate:dB}),mB=Object.assign(fn,{glob:fn,globSync:bn,sync:fj1,globStream:yn,stream:Aj1,globStreamSync:uB,streamSync:vj1,globIterate:gn,iterate:hj1,globIterateSync:dB,iterateSync:xj1,Glob:P7,hasMagic:rC,escape:gK,unescape:_4});mB.glob=mB;class tC{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 Y=this._listeners[Z];if(Y!==void 0){let $=Y.indexOf(J);if($!==-1)Y.splice($,1)}return this}dispatchEvent(Z){let X=this._listeners[Z.type];if(X!==void 0){let Y=X.slice(0);for(let $=0,Q=Y.length;$<Q;$++)Y[$].call(this,Z)}return this}dispose(){for(let Z in this._listeners)delete this._listeners[Z]}}class T5{constructor(Z,J,X,Y={}){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=Y,!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 pK extends tC{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,Y){let $=new T5(Z,J,X,Y);this._edges.add($);let Q=$.getParent();if(!this._parentEdges.has(Q))this._parentEdges.set(Q,new Set);this._parentEdges.get(Q).add($);let K=$.getChild();if(!this._childEdges.has(K))this._childEdges.set(K,new Set);return this._childEdges.get(K).add($),$}_destroyEdge(Z){return this._edges.delete(Z),this._parentEdges.get(Z.getParent()).delete(Z),this._childEdges.get(Z.getChild()).delete(Z),this}}function bH(){return bH=Object.assign||function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)if(Object.prototype.hasOwnProperty.call(X,Y))Z[Y]=X[Y]}return Z},bH.apply(this,arguments)}class I6{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 E0{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 e1{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 y0=Symbol("attributes"),A4=Symbol("immutableKeys");class iK extends tC{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[y0]=void 0,this[A4]=void 0,this.graph=Z,this[A4]=new Set,this[y0]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let Y=Z[X];if(Y instanceof iK){let $=this.graph._createEdge(X,this,Y);this[A4].add(X),J[X]=$}else J[X]=Y}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[y0]){let Y=this[y0][X];if(Y instanceof T5){let $=Y;if($.getChild()===Z)this.setRef(X,J,$.getAttributes())}else if(Y instanceof I6)for(let $ of Y.listRefsByChild(Z)){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if(Y instanceof E0){let $=Y.getRefByChild(Z);if($){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if(Y instanceof e1)for(let $ of Y.keys()){let Q=Y.get($);if(Q.getChild()===Z)this.setRefMap(X,$,J,Q.getAttributes())}}return this}get(Z){return this[y0][Z]}set(Z,J){return this[y0][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[y0][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[A4].has(Z))throw new Error(`Cannot overwrite immutable attribute, "${Z}".`);let Y=this[y0][Z];if(Y)Y.dispose();if(!J)return this;let $=this.graph._createEdge(Z,this,J,X);return this[y0][Z]=$,this.dispatchEvent({type:"change",attribute:Z})}listRefs(Z){return this.assertRefList(Z).values().map((X)=>X.getChild())}addRef(Z,J,X){let Y=this.graph._createEdge(Z,this,J,X);return this.assertRefList(Z).add(Y),this.dispatchEvent({type:"change",attribute:Z})}removeRef(Z,J){let X=this.assertRefList(Z);if(X instanceof I6)for(let Y of X.listRefsByChild(J))Y.dispose();else{let Y=X.getRefByChild(J);if(Y)Y.dispose()}return this}assertRefList(Z){let J=this[y0][Z];if(J instanceof I6||J instanceof E0)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 Y=this.assertRefMap(Z).get(J);return Y?Y.getChild():null}setRefMap(Z,J,X,Y){let $=this.assertRefMap(Z),Q=$.get(J);if(Q)Q.dispose();if(!X)return this;Y=Object.assign(Y||{},{key:J});let K=this.graph._createEdge(Z,this,X,bH({},Y,{key:J}));return $.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[y0][Z];if(J instanceof e1)return J;throw new Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(bH({},Z,{target:this})),this.graph.dispatchEvent(bH({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[y0][J]===Z){if(this[y0][J]=null,this[A4].has(J))Z.getChild().dispose()}else if(this[y0][J]instanceof I6)this[y0][J].remove(Z);else if(this[y0][J]instanceof E0)this[y0][J].remove(Z);else if(this[y0][J]instanceof e1){let X=this[y0][J];for(let Y of X.keys())if(X.get(Y)===Z)X.delete(Y)}else return;this.graph._destroyEdge(Z),this.dispatchEvent({type:"change",attribute:J})}}var nn="v4.1.1",aB="@glb.bin",a;(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"})(a||(a={}));var sB;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(sB||(sB={}));var e5;(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"})(e5||(e5={}));var oB;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(oB||(oB={}));var EZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(EZ||(EZ={}));var iJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array},ZT=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 yj1(){var Z=new ZT(3);if(ZT!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function eC(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function bj1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}(function(){var Z=yj1();return function(J,X,Y,$,Q,K){var G,W;if(!X)X=3;if(!Y)Y=0;if($)W=Math.min($*X+Y,J.length);else W=J.length;for(G=Y;G<W;G+=X)Z[0]=J[G],Z[1]=J[G+1],Z[2]=J[G+2],Q(Z,Z,K),J[G]=Z[0],J[G+1]=Z[1],J[G+2]=Z[2];return J}})();function $T(Z){let J=an(),X=Z.propertyType===a.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=gj1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))JT(K.min,J),JT(K.max,J)});return J}function gj1(Z,J){let X=an();for(let Y of Z.listPrimitives()){let $=Y.getAttribute("POSITION"),Q=Y.getIndices();if(!$)continue;let K=[0,0,0],G=[0,0,0];for(let W=0,H=Q?Q.getCount():$.getCount();W<H;W++){let V=Q?Q.getScalar(W):W;K=$.getElement(V,K),G=bj1(G,K,J),JT(G,X)}}return X}function JT(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 an(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class o0{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let Y=0;Y<J.length;Y++)X[Y]=J.charCodeAt(Y);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 $ of Z)J+=$.byteLength;let X=new Uint8Array(J),Y=0;for(let $ 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 Y=new Uint8Array(X);if(Y.set(Z),J!==0)for(let $=Z.byteLength;$<X;$++)Y[$]=J;return Y}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 QT{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^Y*255<<8^$*255<<0}static convertSRGBToLinear(Z,J){let X=Z,Y=J;for(let $=0;$<3;$++)Y[$]=X[$]<0.04045?X[$]*0.0773993808:Math.pow(X[$]*0.9478672986+0.0521327014,2.4);return J}static convertLinearToSRGB(Z,J){let X=Z,Y=J;for(let $=0;$<3;$++)Y[$]=X[$]<0.0031308?X[$]*12.92:1.055*Math.pow(X[$],0.41666)-0.055;return J}}class sn{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,Y;while(J.byteLength){if(X=J.getUint16(0,!1),mj1(J,X),Y=J.getUint8(X+1),Y===192||Y===193||Y===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 eB{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(o0.decodeText(Z.slice(12,16))===eB.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}}eB.PNG_FRIED_CHUNK_NAME="CgBI";class kZ{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,Y=4,$=this.getSize(Z,J);if(!$)return null;while($[0]>1||$[1]>1)X+=$[0]*$[1]*Y,$[0]=Math.max(Math.floor($[0]/2),1),$[1]=Math.max(Math.floor($[1]/2),1);return X+=1*Y,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}`}}kZ.impls={"image/jpeg":new sn,"image/png":new eB};function mj1(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 IZ{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 kZ.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 mn(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function aY(Z){if(mn(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(mn(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var XT,gH;(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"})(gH||(gH={}));class k5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=k5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=k5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=k5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=k5.Verbosity.ERROR)console.error(Z)}}XT=k5;k5.Verbosity=gH;k5.DEFAULT_INSTANCE=new XT(XT.Verbosity.INFO);function uj1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],G=Z[6],W=Z[7],H=Z[8],V=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,O=J*G-Y*Q,M=J*W-$*Q,R=X*G-Y*K,D=X*W-$*K,N=Y*W-$*G,C=H*U-V*q,T=H*B-F*q,E=H*L-z*q,A=V*B-F*U,S=V*L-z*U,x=F*L-z*B;return w*x-O*S+M*A+R*E-D*T+N*C}function dj1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],G=J[4],W=J[5],H=J[6],V=J[7],F=J[8],z=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],O=J[15],M=X[0],R=X[1],D=X[2],N=X[3];return Z[0]=M*Y+R*G+D*F+N*B,Z[1]=M*$+R*W+D*z+N*L,Z[2]=M*Q+R*H+D*q+N*w,Z[3]=M*K+R*V+D*U+N*O,M=X[4],R=X[5],D=X[6],N=X[7],Z[4]=M*Y+R*G+D*F+N*B,Z[5]=M*$+R*W+D*z+N*L,Z[6]=M*Q+R*H+D*q+N*w,Z[7]=M*K+R*V+D*U+N*O,M=X[8],R=X[9],D=X[10],N=X[11],Z[8]=M*Y+R*G+D*F+N*B,Z[9]=M*$+R*W+D*z+N*L,Z[10]=M*Q+R*H+D*q+N*w,Z[11]=M*K+R*V+D*U+N*O,M=X[12],R=X[13],D=X[14],N=X[15],Z[12]=M*Y+R*G+D*F+N*B,Z[13]=M*$+R*W+D*z+N*L,Z[14]=M*Q+R*H+D*q+N*w,Z[15]=M*K+R*V+D*U+N*O,Z}function cj1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],G=J[6],W=J[8],H=J[9],V=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,G),Z[2]=Math.hypot(W,H,V),Z}function lj1(Z,J){var X=new ZT(3);cj1(X,J);var Y=1/X[0],$=1/X[1],Q=1/X[2],K=J[0]*Y,G=J[1]*$,W=J[2]*Q,H=J[4]*Y,V=J[5]*$,F=J[6]*Q,z=J[8]*Y,q=J[9]*$,U=J[10]*Q,B=K+V+U,L=0;if(B>0)L=Math.sqrt(B+1)*2,Z[3]=0.25*L,Z[0]=(F-q)/L,Z[1]=(z-W)/L,Z[2]=(G-H)/L;else if(K>V&&K>U)L=Math.sqrt(1+K-V-U)*2,Z[3]=(F-q)/L,Z[0]=0.25*L,Z[1]=(G+H)/L,Z[2]=(z+W)/L;else if(V>U)L=Math.sqrt(1+V-K-U)*2,Z[3]=(z-W)/L,Z[0]=(G+H)/L,Z[1]=0.25*L,Z[2]=(F+q)/L;else L=Math.sqrt(1+U-K-V)*2,Z[3]=(G-H)/L,Z[0]=(z+W)/L,Z[1]=(F+q)/L,Z[2]=0.25*L;return Z}class i0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(i0.clamp(Z,0,1)*65535);case 5121:return Math.round(i0.clamp(Z,0,1)*255);case 5122:return Math.round(i0.clamp(Z,-1,1)*32767);case 5120:return Math.round(i0.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=eC([Z[0],Z[1],Z[2]]),Q=eC([Z[4],Z[5],Z[6]]),K=eC([Z[8],Z[9],Z[10]]);if(uj1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let W=Z.slice(),H=1/$,V=1/Q,F=1/K;W[0]*=H,W[1]*=H,W[2]*=H,W[4]*=V,W[5]*=V,W[6]*=V,W[8]*=F,W[9]*=F,W[10]*=F,lj1(X,W),Y[0]=$,Y[1]=Q,Y[2]=K}static compose(Z,J,X,Y){let $=Y,Q=J[0],K=J[1],G=J[2],W=J[3],H=Q+Q,V=K+K,F=G+G,z=Q*H,q=Q*V,U=Q*F,B=K*V,L=K*F,w=G*F,O=W*H,M=W*V,R=W*F,D=X[0],N=X[1],C=X[2];return $[0]=(1-(B+w))*D,$[1]=(q+R)*D,$[2]=(U-M)*D,$[3]=0,$[4]=(q-R)*N,$[5]=(1-(z+w))*N,$[6]=(L+O)*N,$[7]=0,$[8]=(U+M)*C,$[9]=(L-O)*C,$[10]=(1-(z+B))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function pj1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function ij1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),Y=J.values();if(X.length!==Y.length)return!1;for(let $=0;$<X.length;$++){let Q=X[$],K=Y[$];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function nj1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),Y=J.keys();if(X.length!==Y.length)return!1;for(let $ of X){let Q=Z.get($),K=J.get($);if(!!Q!==!!K)return!1;let G=Q.getChild(),W=K.getChild();if(G===W)continue;if(!G.equals(W))return!1}return!0}function on(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 rn(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!aY(Z)||!aY(J))return Z===J;let X=Z,Y=J,$=0,Q=0,K;for(K in X)$++;for(K in Y)Q++;if($!==Q)return!1;for(K in X){let G=X[K],W=Y[K];if(rB(G)&&rB(W)){if(!on(G,W))return!1}else if(aY(G)&&aY(W)){if(!rn(G,W))return!1}else if(G!==W)return!1}return!0}function rB(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var un="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",aj1=999,sj1=6,dn=new Set,oj1=function Z(){let J="";for(let X=0;X<sj1;X++)J+=un.charAt(Math.floor(Math.random()*un.length));return J},tn=function Z(){for(let J=0;J<aj1;J++){let X=oj1();if(!dn.has(X))return dn.add(X),X}return""},cn="https://null.example";class f9{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return IZ.basename(new URL(Z,cn).pathname)}static extension(Z){return IZ.extension(new URL(Z,cn).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),Y=J.split("/");X.pop();for(let $=0;$<Y.length;$++){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)}}f9.DEFAULT_INIT={};f9.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var pJ=(Z)=>Z,rj1=new Set;class Z2 extends iK{constructor(Z,J=""){super(Z);this[y0].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,pJ)}copy(Z,J=pJ){for(let X in this[y0]){let Y=this[y0][X];if(Y instanceof T5){if(!this[A4].has(X))Y.dispose()}else if(Y instanceof I6||Y instanceof E0)for(let $ of Y.values())$.dispose();else if(Y instanceof e1)for(let $ of Y.values())$.dispose()}for(let X in Z[y0]){let Y=this[y0][X],$=Z[y0][X];if($ instanceof T5)if(this[A4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof E0||$ instanceof I6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof e1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(aY($))this[y0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[y0][X]=$.slice();else this[y0][X]=$}return this}equals(Z,J=rj1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[y0]){if(J.has(X))continue;let Y=this[y0][X],$=Z[y0][X];if(Y instanceof T5||$ instanceof T5){if(!pj1(Y,$))return!1}else if(Y instanceof E0||$ instanceof E0||Y instanceof I6||$ instanceof I6){if(!ij1(Y,$))return!1}else if(Y instanceof e1||$ instanceof e1){if(!nj1(Y,$))return!1}else if(aY(Y)||aY($)){if(!rn(Y,$))return!1}else if(rB(Y)||rB($)){if(!on(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 S6 extends Z2{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new e1})}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 x0 extends S6{init(){this.propertyType=a.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:x0.Type.SCALAR,componentType:x0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case x0.Type.SCALAR:return 1;case x0.Type.VEC2:return 2;case x0.Type.VEC3:return 3;case x0.Type.VEC4:return 4;case x0.Type.MAT2:return 4;case x0.Type.MAT3:return 9;case x0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case x0.ComponentType.BYTE:return 1;case x0.ComponentType.UNSIGNED_BYTE:return 1;case x0.ComponentType.SHORT:return 2;case x0.ComponentType.UNSIGNED_SHORT:return 2;case x0.ComponentType.UNSIGNED_INT:return 4;case x0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMin(Z),J)for(let $=0;$<X;$++)Z[$]=i0.decodeNormalizedInt(Z[$],Y);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMax(Z),J)for(let $=0;$<X;$++)Z[$]=i0.decodeNormalizedInt(Z[$],Y);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=-1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+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 x0.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(),Y=this.getArray();if(this.getNormalized())return i0.decodeNormalizedInt(Y[Z*J],X);return Y[Z*J]}setScalar(Z,J){let X=this.getElementSize(),Y=this.getComponentType(),$=this.getArray();if(this.getNormalized())$[Z*X]=i0.encodeNormalizedInt(J,Y);else $[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)J[K]=i0.decodeNormalizedInt(Q[Z*Y+K],$);else J[K]=Q[Z*Y+K];return J}setElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)Q[Z*Y+K]=i0.encodeNormalizedInt(J[K],$);else Q[Z*Y+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?tj1(Z):x0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}x0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};x0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function tj1(Z){switch(Z.constructor){case Float32Array:return x0.ComponentType.FLOAT;case Uint32Array:return x0.ComponentType.UNSIGNED_INT;case Uint16Array:return x0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return x0.ComponentType.UNSIGNED_BYTE;case Int16Array:return x0.ComponentType.SHORT;case Int8Array:return x0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class KT extends S6{init(){this.propertyType=a.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new E0,samplers:new E0})}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 sY extends S6{init(){this.propertyType=a.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)}}sY.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class nK extends S6{init(){this.propertyType=a.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:nK.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:e5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:e5.OTHER})}}nK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class GT extends S6{init(){this.propertyType=a.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class oY extends S6{init(){this.propertyType=a.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:oY.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)}}oY.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class aK extends Z2{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}aK.EXTENSION_NAME=void 0;class E5 extends S6{init(){this.propertyType=a.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:E5.WrapMode.REPEAT,wrapT:E5.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)}}E5.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};E5.MagFilter={NEAREST:9728,LINEAR:9729};E5.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:cB,G:lB,B:pB,A:ej1}=oB;class D7 extends S6{init(){this.propertyType=a.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:D7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new E5(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new E5(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new E5(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new E5(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new E5(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:cB|lB|pB|ej1,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:cB|lB|pB,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:cB|lB|pB})}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:cB})}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:lB|pB})}}D7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class uH extends S6{init(){this.propertyType=a.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new E0})}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 J2 extends S6{init(){this.propertyType=a.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 E0})}copy(Z,J=pJ){if(J===pJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return i0.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),Y=this.get("scale").slice();return i0.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return i0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return i0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return i0.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let Y=this;Y!=null;Y=Y.getParentNode())Z.push(Y);let J,X=Z.pop().getMatrix();while(J=Z.pop())dj1(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===a.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===a.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 C8 extends S6{init(){this.propertyType=a.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:C8.Mode.TRIANGLES,material:null,indices:null,attributes:new e1,targets:new E0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:e5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:e5.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)}}C8.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class WT extends Z2{init(){this.propertyType=a.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new e1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:e5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function r6(){return r6=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},r6.apply(null,arguments)}class sK extends S6{init(){this.propertyType=a.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new E0})}copy(Z,J=pJ){if(J===pJ)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 HT extends S6{init(){this.propertyType=a.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new E0})}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:e5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class rY extends S6{init(){this.propertyType=a.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||kZ.extensionToMimeType(IZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=kZ.extensionToMimeType(IZ.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",o0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return kZ.getSize(Z,this.getMimeType())}}class tY extends S6{init(){this.propertyType=a.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${nn}`,version:"2.0"},defaultScene:null,accessors:new E0,animations:new E0,buffers:new E0,cameras:new E0,materials:new E0,meshes:new E0,nodes:new E0,scenes:new E0,skins:new E0,textures:new E0})}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=pJ){if(J===pJ)throw new Error("Root cannot be copied.");this.set("asset",r6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(r6({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let Y=Z.getExtension(X);this.setExtension(X,J(Y))}return this}_addChildOfRoot(Z){if(Z instanceof sK)this.addRef("scenes",Z);else if(Z instanceof J2)this.addRef("nodes",Z);else if(Z instanceof oY)this.addRef("cameras",Z);else if(Z instanceof HT)this.addRef("skins",Z);else if(Z instanceof uH)this.addRef("meshes",Z);else if(Z instanceof D7)this.addRef("materials",Z);else if(Z instanceof rY)this.addRef("textures",Z);else if(Z instanceof KT)this.addRef("animations",Z);else if(Z instanceof x0)this.addRef("accessors",Z);else if(Z instanceof GT)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 _6{static fromGraph(Z){return _6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new pK,this._root=new tY(this._graph),this._logger=k5.DEFAULT_INSTANCE,_6._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((Y)=>Y.extensionName===J)||new Z(this)}createScene(Z=""){return new sK(this._graph,Z)}createNode(Z=""){return new J2(this._graph,Z)}createCamera(Z=""){return new oY(this._graph,Z)}createSkin(Z=""){return new HT(this._graph,Z)}createMesh(Z=""){return new uH(this._graph,Z)}createPrimitive(){return new C8(this._graph)}createPrimitiveTarget(Z=""){return new WT(this._graph,Z)}createMaterial(Z=""){return new D7(this._graph,Z)}createTexture(Z=""){return new rY(this._graph,Z)}createAnimation(Z=""){return new KT(this._graph,Z)}createAnimationChannel(Z=""){return new sY(this._graph,Z)}createAnimationSampler(Z=""){return new nK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new x0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new GT(this._graph,Z)}}_6._GRAPH_DOCUMENTS=new WeakMap;class en{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 Y=X,$=Y.target;if($ instanceof aK&&$.extensionName===this.extensionName){if(Y.type==="node:create")this._addExtensionProperty($);if(Y.type==="node:dispose")this._removeExtensionProperty($)}};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}}en.EXTENSION_NAME=void 0;class Za{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 Y=this.jsonDoc.json.samplers[X.sampler];if(Y.magFilter!==void 0)Z.setMagFilter(Y.magFilter);if(Y.minFilter!==void 0)Z.setMinFilter(Y.minFilter);if(Y.wrapS!==void 0)Z.setWrapS(Y.wrapS);if(Y.wrapT!==void 0)Z.setWrapT(Y.wrapT)}}var ln={logger:k5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},ZO1=new Set([a.BUFFER,a.TEXTURE,a.MATERIAL,a.MESH,a.PRIMITIVE,a.NODE,a.SCENE]);class Ja{static read(Z,J=ln){let X=r6({},ln,J),{json:Y}=Z,$=new _6().setLogger(X.logger);this.validate(Z,X);let Q=new Za(Z),K=Y.asset,G=$.getRoot().getAsset();if(K.copyright)G.copyright=K.copyright;if(K.extras)G.extras=K.extras;if(Y.extras!==void 0)$.getRoot().setExtras(r6({},Y.extras));let W=Y.extensionsUsed||[],H=Y.extensionsRequired||[];X.extensions.sort((N,C)=>N.EXTENSION_NAME>C.EXTENSION_NAME?1:-1);for(let N of X.extensions)if(W.includes(N.EXTENSION_NAME)){let C=$.createExtension(N).setRequired(H.includes(N.EXTENSION_NAME)),T=C.prereadTypes.filter((E)=>!ZO1.has(E));if(T.length)X.logger.warn(`Preread hooks for some types (${T.join()}), requested by extension ${C.extensionName}, are unsupported. Please file an issue or a PR.`);for(let E of C.readDependencies)C.install(E,X.dependencies[E])}let V=Y.buffers||[];$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.BUFFER)).forEach((N)=>N.preread(Q,a.BUFFER)),Q.buffers=V.map((N)=>{let C=$.createBuffer(N.name);if(N.extras)C.setExtras(N.extras);if(N.uri&&N.uri.indexOf("__")!==0)C.setURI(N.uri);return C});let F=Y.bufferViews||[];Q.bufferViewBuffers=F.map((N,C)=>{if(!Q.bufferViews[C]){let T=Z.json.buffers[N.buffer],E=T.uri?Z.resources[T.uri]:Z.resources[aB],A=N.byteOffset||0;Q.bufferViews[C]=o0.toView(E,A,N.byteLength)}return Q.buffers[N.buffer]});let z=Y.accessors||[];Q.accessors=z.map((N)=>{let C=Q.bufferViewBuffers[N.bufferView],T=$.createAccessor(N.name,C).setType(N.type);if(N.extras)T.setExtras(N.extras);if(N.normalized!==void 0)T.setNormalized(N.normalized);if(N.bufferView===void 0)return T;return T.setArray(nB(N,Q)),T});let q=Y.images||[],U=Y.textures||[];$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.TEXTURE)).forEach((N)=>N.preread(Q,a.TEXTURE)),Q.textures=q.map((N)=>{let C=$.createTexture(N.name);if(N.extras)C.setExtras(N.extras);if(N.bufferView!==void 0){let T=Y.bufferViews[N.bufferView],E=Z.json.buffers[T.buffer],A=E.uri?Z.resources[E.uri]:Z.resources[aB],S=T.byteOffset||0,x=T.byteLength,I=A.slice(S,S+x);C.setImage(I)}else if(N.uri!==void 0){if(C.setImage(Z.resources[N.uri]),N.uri.indexOf("__")!==0)C.setURI(N.uri)}if(N.mimeType!==void 0)C.setMimeType(N.mimeType);else if(N.uri){let T=IZ.extension(N.uri);C.setMimeType(kZ.extensionToMimeType(T))}return C}),$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.MATERIAL)).forEach((N)=>N.preread(Q,a.MATERIAL));let B=Y.materials||[];Q.materials=B.map((N)=>{let C=$.createMaterial(N.name);if(N.extras)C.setExtras(N.extras);if(N.alphaMode!==void 0)C.setAlphaMode(N.alphaMode);if(N.alphaCutoff!==void 0)C.setAlphaCutoff(N.alphaCutoff);if(N.doubleSided!==void 0)C.setDoubleSided(N.doubleSided);let T=N.pbrMetallicRoughness||{};if(T.baseColorFactor!==void 0)C.setBaseColorFactor(T.baseColorFactor);if(N.emissiveFactor!==void 0)C.setEmissiveFactor(N.emissiveFactor);if(T.metallicFactor!==void 0)C.setMetallicFactor(T.metallicFactor);if(T.roughnessFactor!==void 0)C.setRoughnessFactor(T.roughnessFactor);if(T.baseColorTexture!==void 0){let E=T.baseColorTexture,A=Q.textures[U[E.index].source];C.setBaseColorTexture(A),Q.setTextureInfo(C.getBaseColorTextureInfo(),E)}if(N.emissiveTexture!==void 0){let E=N.emissiveTexture,A=Q.textures[U[E.index].source];C.setEmissiveTexture(A),Q.setTextureInfo(C.getEmissiveTextureInfo(),E)}if(N.normalTexture!==void 0){let E=N.normalTexture,A=Q.textures[U[E.index].source];if(C.setNormalTexture(A),Q.setTextureInfo(C.getNormalTextureInfo(),E),N.normalTexture.scale!==void 0)C.setNormalScale(N.normalTexture.scale)}if(N.occlusionTexture!==void 0){let E=N.occlusionTexture,A=Q.textures[U[E.index].source];if(C.setOcclusionTexture(A),Q.setTextureInfo(C.getOcclusionTextureInfo(),E),N.occlusionTexture.strength!==void 0)C.setOcclusionStrength(N.occlusionTexture.strength)}if(T.metallicRoughnessTexture!==void 0){let E=T.metallicRoughnessTexture,A=Q.textures[U[E.index].source];C.setMetallicRoughnessTexture(A),Q.setTextureInfo(C.getMetallicRoughnessTextureInfo(),E)}return C}),$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.MESH)).forEach((N)=>N.preread(Q,a.MESH));let L=Y.meshes||[];$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.PRIMITIVE)).forEach((N)=>N.preread(Q,a.PRIMITIVE)),Q.meshes=L.map((N)=>{let C=$.createMesh(N.name);if(N.extras)C.setExtras(N.extras);if(N.weights!==void 0)C.setWeights(N.weights);return(N.primitives||[]).forEach((E)=>{let A=$.createPrimitive();if(E.extras)A.setExtras(E.extras);if(E.material!==void 0)A.setMaterial(Q.materials[E.material]);if(E.mode!==void 0)A.setMode(E.mode);for(let[I,_]of Object.entries(E.attributes||{}))A.setAttribute(I,Q.accessors[_]);if(E.indices!==void 0)A.setIndices(Q.accessors[E.indices]);let S=N.extras&&N.extras.targetNames||[];(E.targets||[]).forEach((I,_)=>{let y=S[_]||_.toString(),u=$.createPrimitiveTarget(y);for(let[n,o]of Object.entries(I))u.setAttribute(n,Q.accessors[o]);A.addTarget(u)}),C.addPrimitive(A)}),C});let w=Y.cameras||[];Q.cameras=w.map((N)=>{let C=$.createCamera(N.name).setType(N.type);if(N.extras)C.setExtras(N.extras);if(N.type===oY.Type.PERSPECTIVE){let T=N.perspective;if(C.setYFov(T.yfov),C.setZNear(T.znear),T.zfar!==void 0)C.setZFar(T.zfar);if(T.aspectRatio!==void 0)C.setAspectRatio(T.aspectRatio)}else{let T=N.orthographic;C.setZNear(T.znear).setZFar(T.zfar).setXMag(T.xmag).setYMag(T.ymag)}return C});let O=Y.nodes||[];$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.NODE)).forEach((N)=>N.preread(Q,a.NODE)),Q.nodes=O.map((N)=>{let C=$.createNode(N.name);if(N.extras)C.setExtras(N.extras);if(N.translation!==void 0)C.setTranslation(N.translation);if(N.rotation!==void 0)C.setRotation(N.rotation);if(N.scale!==void 0)C.setScale(N.scale);if(N.matrix!==void 0){let T=[0,0,0],E=[0,0,0,1],A=[1,1,1];i0.decompose(N.matrix,T,E,A),C.setTranslation(T),C.setRotation(E),C.setScale(A)}if(N.weights!==void 0)C.setWeights(N.weights);return C});let M=Y.skins||[];Q.skins=M.map((N)=>{let C=$.createSkin(N.name);if(N.extras)C.setExtras(N.extras);if(N.inverseBindMatrices!==void 0)C.setInverseBindMatrices(Q.accessors[N.inverseBindMatrices]);if(N.skeleton!==void 0)C.setSkeleton(Q.nodes[N.skeleton]);for(let T of N.joints)C.addJoint(Q.nodes[T]);return C}),O.map((N,C)=>{let T=Q.nodes[C];if((N.children||[]).forEach((A)=>T.addChild(Q.nodes[A])),N.mesh!==void 0)T.setMesh(Q.meshes[N.mesh]);if(N.camera!==void 0)T.setCamera(Q.cameras[N.camera]);if(N.skin!==void 0)T.setSkin(Q.skins[N.skin])});let R=Y.animations||[];Q.animations=R.map((N)=>{let C=$.createAnimation(N.name);if(N.extras)C.setExtras(N.extras);let E=(N.samplers||[]).map((S)=>{let x=$.createAnimationSampler().setInput(Q.accessors[S.input]).setOutput(Q.accessors[S.output]).setInterpolation(S.interpolation||nK.Interpolation.LINEAR);if(S.extras)x.setExtras(S.extras);return C.addSampler(x),x});return(N.channels||[]).forEach((S)=>{let x=$.createAnimationChannel().setSampler(E[S.sampler]).setTargetPath(S.target.path);if(S.target.node!==void 0)x.setTargetNode(Q.nodes[S.target.node]);if(S.extras)x.setExtras(S.extras);C.addChannel(x)}),C});let D=Y.scenes||[];if($.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.SCENE)).forEach((N)=>N.preread(Q,a.SCENE)),Q.scenes=D.map((N)=>{let C=$.createScene(N.name);if(N.extras)C.setExtras(N.extras);return(N.nodes||[]).map((E)=>Q.nodes[E]).forEach((E)=>C.addChild(E)),C}),Y.scene!==void 0)$.getRoot().setDefaultScene(Q.scenes[Y.scene]);return $.getRoot().listExtensionsUsed().forEach((N)=>N.read(Q)),z.forEach((N,C)=>{let T=Q.accessors[C],E=!!N.sparse,A=!N.bufferView&&!T.getArray();if(E||A)T.setSparse(!0).setArray(XO1(N,Q))}),$}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 Y of X.extensionsRequired)if(!J.extensions.find(($)=>$.EXTENSION_NAME===Y))throw new Error(`Missing required extension, "${Y}".`)}if(X.extensionsUsed){for(let Y of X.extensionsUsed)if(!J.extensions.find(($)=>$.EXTENSION_NAME===Y))J.logger.warn(`Missing optional extension, "${Y}".`)}}}function JO1(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=iJ[Z.componentType],K=x0.getElementSize(Z.type),G=Q.BYTES_PER_ELEMENT,W=Z.byteOffset||0,H=new Q(Z.count*K),V=new DataView(Y.buffer,Y.byteOffset,Y.byteLength),F=$.byteStride;for(let z=0;z<Z.count;z++)for(let q=0;q<K;q++){let U=W+z*F+q*G,B;switch(Z.componentType){case x0.ComponentType.FLOAT:B=V.getFloat32(U,!0);break;case x0.ComponentType.UNSIGNED_INT:B=V.getUint32(U,!0);break;case x0.ComponentType.UNSIGNED_SHORT:B=V.getUint16(U,!0);break;case x0.ComponentType.UNSIGNED_BYTE:B=V.getUint8(U);break;case x0.ComponentType.SHORT:B=V.getInt16(U,!0);break;case x0.ComponentType.BYTE:B=V.getInt8(U);break;default:throw new Error(`Unexpected componentType "${Z.componentType}".`)}H[z*K+q]=B}return H}function nB(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=iJ[Z.componentType],K=x0.getElementSize(Z.type),G=Q.BYTES_PER_ELEMENT,W=K*G;if($.byteStride!==void 0&&$.byteStride!==W)return JO1(Z,J);let H=Y.byteOffset+(Z.byteOffset||0),V=Z.count*K*G;return new Q(Y.buffer.slice(H,H+V))}function XO1(Z,J){let X=iJ[Z.componentType],Y=x0.getElementSize(Z.type),$;if(Z.bufferView!==void 0)$=nB(Z,J);else $=new X(Z.count*Y);let Q=Z.sparse;if(!Q)return $;let K=Q.count,G=r6({},Z,Q.indices,{count:K,type:"SCALAR"}),W=r6({},Z,Q.values,{count:K}),H=nB(G,J),V=nB(W,J);for(let F=0;F<G.count;F++)for(let z=0;z<Y;z++)$[H[F]*Y+z]=V[F*Y+z];return $}var mH;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(mH||(mH={}));class lJ{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 Y=Z.getRoot(),$=Y.listBuffers().length,Q=Y.listTextures().length;this.bufferURIGenerator=new YT($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new YT(Q>1,(K)=>YO1(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()},Y=JSON.stringify(X);if(!this.samplerDefIndexMap.has(Y))this.samplerDefIndexMap.set(Y,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let $={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get(Y)},Q=JSON.stringify($);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push($);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((Y)=>Y.getName()==="attributes"&&Y.getAttributes().key==="POSITION"||Y.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===EZ.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 Y=kZ.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,Y),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let Y=this.jsonDoc.resources;if(!(Z in Y)){Y[Z]=J;return}if(J===Y[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let $=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn($);return}throw new Error($)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return e5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:Y}=X.getAttributes();if(Y)return Y;if(X.getParent().propertyType!==a.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return e5.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}}lJ.BufferViewTarget=mH;lJ.BufferViewUsage=e5;lJ.USAGE_TO_TARGET={[e5.ARRAY_BUFFER]:mH.ARRAY_BUFFER,[e5.ELEMENT_ARRAY_BUFFER]:mH.ELEMENT_ARRAY_BUFFER};class YT{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 YO1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:iB}=lJ,{UNSIGNED_INT:$O1,UNSIGNED_SHORT:QO1,UNSIGNED_BYTE:KO1}=x0.ComponentType,GO1=new Set([a.ACCESSOR,a.BUFFER,a.MATERIAL,a.MESH]);class Xa{static write(Z,J){let X=Z.getGraph(),Y=Z.getRoot(),$={asset:r6({generator:`glTF-Transform ${nn}`},Y.getAsset()),extras:r6({},Y.getExtras())},Q={json:$,resources:{}},K=new lJ(Z,Q,J),G=J.logger||k5.DEFAULT_INSTANCE,W=new Set(J.extensions.map((L)=>L.EXTENSION_NAME)),H=Z.getRoot().listExtensionsUsed().filter((L)=>W.has(L.extensionName)).sort((L,w)=>L.extensionName>w.extensionName?1:-1),V=Z.getRoot().listExtensionsRequired().filter((L)=>W.has(L.extensionName)).sort((L,w)=>L.extensionName>w.extensionName?1:-1);if(H.length<Z.getRoot().listExtensionsUsed().length)G.warn("Some extensions were not registered for I/O, and will not be written.");for(let L of H){let w=L.prewriteTypes.filter((O)=>!GO1.has(O));if(w.length)G.warn(`Prewrite hooks for some types (${w.join()}), requested by extension ${L.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of L.writeDependencies)L.install(O,J.dependencies[O])}function F(L,w,O,M){let R=[],D=0;for(let T of L){let E=K.createAccessorDef(T);E.bufferView=$.bufferViews.length;let A=T.getArray(),S=o0.pad(o0.toView(A));E.byteOffset=D,D+=S.byteLength,R.push(S),K.accessorIndexMap.set(T,$.accessors.length),$.accessors.push(E)}let N=o0.concat(R),C={buffer:w,byteOffset:O,byteLength:N.byteLength};if(M)C.target=M;return $.bufferViews.push(C),{buffers:R,byteLength:D}}function z(L,w,O){let M=L[0].getCount(),R=0;for(let E of L){let A=K.createAccessorDef(E);A.bufferView=$.bufferViews.length,A.byteOffset=R;let S=E.getElementSize(),x=E.getComponentSize();R+=o0.padNumber(S*x),K.accessorIndexMap.set(E,$.accessors.length),$.accessors.push(A)}let D=M*R,N=new ArrayBuffer(D),C=new DataView(N);for(let E=0;E<M;E++){let A=0;for(let S of L){let x=S.getElementSize(),I=S.getComponentSize(),_=S.getComponentType(),y=S.getArray();for(let u=0;u<x;u++){let n=E*R+A+u*I,o=y[E*x+u];switch(_){case x0.ComponentType.FLOAT:C.setFloat32(n,o,!0);break;case x0.ComponentType.BYTE:C.setInt8(n,o);break;case x0.ComponentType.SHORT:C.setInt16(n,o,!0);break;case x0.ComponentType.UNSIGNED_BYTE:C.setUint8(n,o);break;case x0.ComponentType.UNSIGNED_SHORT:C.setUint16(n,o,!0);break;case x0.ComponentType.UNSIGNED_INT:C.setUint32(n,o,!0);break;default:throw new Error("Unexpected component type: "+_)}}A+=o0.padNumber(x*I)}}let T={buffer:w,byteOffset:O,byteLength:D,byteStride:R,target:lJ.BufferViewTarget.ARRAY_BUFFER};return $.bufferViews.push(T),{byteLength:D,buffers:[new Uint8Array(N)]}}function q(L,w,O){let M=[],R=0,D=new Map,N=-1/0,C=!1;for(let _ of L){let y=K.createAccessorDef(_);$.accessors.push(y),K.accessorIndexMap.set(_,$.accessors.length-1);let u=[],n=[],o=[],Q0=new Array(_.getElementSize()).fill(0);for(let r0=0,A8=_.getCount();r0<A8;r0++){if(_.getElement(r0,o),i0.eq(o,Q0,0))continue;N=Math.max(r0,N),u.push(r0);for(let r1=0;r1<o.length;r1++)n.push(o[r1])}let G0=u.length,S0={accessorDef:y,count:G0};if(D.set(_,S0),G0===0)continue;if(G0>_.getCount()/2)C=!0;let v0=iJ[_.getComponentType()];S0.indices=u,S0.values=new v0(n)}if(!Number.isFinite(N))return{buffers:M,byteLength:R};if(C)G.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let T=N<255?Uint8Array:N<65535?Uint16Array:Uint32Array,E=N<255?KO1:N<65535?QO1:$O1,A={buffer:w,byteOffset:O+R,byteLength:0};for(let _ of L){let y=D.get(_);if(y.count===0)continue;y.indicesByteOffset=A.byteLength;let u=o0.pad(o0.toView(new T(y.indices)));M.push(u),R+=u.byteLength,A.byteLength+=u.byteLength}$.bufferViews.push(A);let S=$.bufferViews.length-1,x={buffer:w,byteOffset:O+R,byteLength:0};for(let _ of L){let y=D.get(_);if(y.count===0)continue;y.valuesByteOffset=x.byteLength;let u=o0.pad(o0.toView(y.values));M.push(u),R+=u.byteLength,x.byteLength+=u.byteLength}$.bufferViews.push(x);let I=$.bufferViews.length-1;for(let _ of L){let y=D.get(_);if(y.count===0)continue;y.accessorDef.sparse={count:y.count,indices:{bufferView:S,byteOffset:y.indicesByteOffset,componentType:E},values:{bufferView:I,byteOffset:y.valuesByteOffset}}}return{buffers:M,byteLength:R}}if($.accessors=[],$.bufferViews=[],$.samplers=[],$.textures=[],$.images=Y.listTextures().map((L,w)=>{let O=K.createPropertyDef(L);if(L.getMimeType())O.mimeType=L.getMimeType();let M=L.getImage();if(M)K.createImageData(O,M,L);return K.imageIndexMap.set(L,w),O}),H.filter((L)=>L.prewriteTypes.includes(a.ACCESSOR)).forEach((L)=>L.prewrite(K,a.ACCESSOR)),Y.listAccessors().forEach((L)=>{let{accessorUsageGroupedByParent:w,accessorParents:O}=K;if(K.accessorIndexMap.has(L))return;let M=K.getAccessorUsage(L);if(K.addAccessorToUsageGroup(L,M),w.has(M)){let R=X.listParents(L).find((D)=>D.propertyType!==a.ROOT);O.set(L,R)}}),H.filter((L)=>L.prewriteTypes.includes(a.BUFFER)).forEach((L)=>L.prewrite(K,a.BUFFER)),(Y.listAccessors().length>0||K.otherBufferViews.size>0||Y.listTextures().length>0&&J.format===EZ.GLB)&&Y.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");if($.buffers=[],Y.listBuffers().forEach((L,w)=>{let O=K.createPropertyDef(L),M=K.accessorUsageGroupedByParent,R=L.listParents().filter((x)=>x instanceof x0),D=new Set(R.map((x)=>K.accessorParents.get(x))),N=new Map(Array.from(D).map((x,I)=>[x,I])),C={};for(let x of R){var T;if(K.accessorIndexMap.has(x))continue;let I=K.getAccessorUsage(x),_=I;if(M.has(I)){let y=K.accessorParents.get(x);_+=`:${N.get(y)}`}C[T=_]||(C[T]={usage:I,accessors:[]}),C[_].accessors.push(x)}let E=[],A=$.buffers.length,S=0;for(let{usage:x,accessors:I}of Object.values(C))if(x===iB.ARRAY_BUFFER&&J.vertexLayout===sB.INTERLEAVED){let _=z(I,A,S);S+=_.byteLength;for(let y of _.buffers)E.push(y)}else if(x===iB.ARRAY_BUFFER)for(let _ of I){let y=z([_],A,S);S+=y.byteLength;for(let u of y.buffers)E.push(u)}else if(x===iB.SPARSE){let _=q(I,A,S);S+=_.byteLength;for(let y of _.buffers)E.push(y)}else if(x===iB.ELEMENT_ARRAY_BUFFER){let _=lJ.BufferViewTarget.ELEMENT_ARRAY_BUFFER,y=F(I,A,S,_);S+=y.byteLength;for(let u of y.buffers)E.push(u)}else{let _=F(I,A,S);S+=_.byteLength;for(let y of _.buffers)E.push(y)}if(K.imageBufferViews.length&&w===0){for(let x=0;x<K.imageBufferViews.length;x++)if($.bufferViews[$.images[x].bufferView].byteOffset=S,S+=K.imageBufferViews[x].byteLength,E.push(K.imageBufferViews[x]),S%8){let I=8-S%8;S+=I,E.push(new Uint8Array(I))}}if(K.otherBufferViews.has(L))for(let x of K.otherBufferViews.get(L))$.bufferViews.push({buffer:A,byteOffset:S,byteLength:x.byteLength}),K.otherBufferViewsIndexMap.set(x,$.bufferViews.length-1),S+=x.byteLength,E.push(x);if(S){let x;if(J.format===EZ.GLB)x=aB;else x=K.bufferURIGenerator.createURI(L,"bin"),O.uri=x;O.byteLength=S,K.assignResourceURI(x,o0.concat(E),!0)}$.buffers.push(O),K.bufferIndexMap.set(L,w)}),Y.listAccessors().find((L)=>!L.getBuffer()))G.warn("Skipped writing one or more Accessors: no Buffer assigned.");H.filter((L)=>L.prewriteTypes.includes(a.MATERIAL)).forEach((L)=>L.prewrite(K,a.MATERIAL)),$.materials=Y.listMaterials().map((L,w)=>{let O=K.createPropertyDef(L);if(L.getAlphaMode()!==D7.AlphaMode.OPAQUE)O.alphaMode=L.getAlphaMode();if(L.getAlphaMode()===D7.AlphaMode.MASK)O.alphaCutoff=L.getAlphaCutoff();if(L.getDoubleSided())O.doubleSided=!0;if(O.pbrMetallicRoughness={},!i0.eq(L.getBaseColorFactor(),[1,1,1,1]))O.pbrMetallicRoughness.baseColorFactor=L.getBaseColorFactor();if(!i0.eq(L.getEmissiveFactor(),[0,0,0]))O.emissiveFactor=L.getEmissiveFactor();if(L.getRoughnessFactor()!==1)O.pbrMetallicRoughness.roughnessFactor=L.getRoughnessFactor();if(L.getMetallicFactor()!==1)O.pbrMetallicRoughness.metallicFactor=L.getMetallicFactor();if(L.getBaseColorTexture()){let M=L.getBaseColorTexture(),R=L.getBaseColorTextureInfo();O.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(M,R)}if(L.getEmissiveTexture()){let M=L.getEmissiveTexture(),R=L.getEmissiveTextureInfo();O.emissiveTexture=K.createTextureInfoDef(M,R)}if(L.getNormalTexture()){let M=L.getNormalTexture(),R=L.getNormalTextureInfo(),D=K.createTextureInfoDef(M,R);if(L.getNormalScale()!==1)D.scale=L.getNormalScale();O.normalTexture=D}if(L.getOcclusionTexture()){let M=L.getOcclusionTexture(),R=L.getOcclusionTextureInfo(),D=K.createTextureInfoDef(M,R);if(L.getOcclusionStrength()!==1)D.strength=L.getOcclusionStrength();O.occlusionTexture=D}if(L.getMetallicRoughnessTexture()){let M=L.getMetallicRoughnessTexture(),R=L.getMetallicRoughnessTextureInfo();O.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(M,R)}return K.materialIndexMap.set(L,w),O}),H.filter((L)=>L.prewriteTypes.includes(a.MESH)).forEach((L)=>L.prewrite(K,a.MESH)),$.meshes=Y.listMeshes().map((L,w)=>{let O=K.createPropertyDef(L),M=null;if(O.primitives=L.listPrimitives().map((R)=>{let D={attributes:{}};D.mode=R.getMode();let N=R.getMaterial();if(N)D.material=K.materialIndexMap.get(N);if(Object.keys(R.getExtras()).length)D.extras=R.getExtras();let C=R.getIndices();if(C)D.indices=K.accessorIndexMap.get(C);for(let T of R.listSemantics())D.attributes[T]=K.accessorIndexMap.get(R.getAttribute(T));for(let T of R.listTargets()){let E={};for(let A of T.listSemantics())E[A]=K.accessorIndexMap.get(T.getAttribute(A));D.targets=D.targets||[],D.targets.push(E)}if(R.listTargets().length&&!M)M=R.listTargets().map((T)=>T.getName());return D}),L.getWeights().length)O.weights=L.getWeights();if(M)O.extras=O.extras||{},O.extras.targetNames=M;return K.meshIndexMap.set(L,w),O}),$.cameras=Y.listCameras().map((L,w)=>{let O=K.createPropertyDef(L);if(O.type=L.getType(),O.type===oY.Type.PERSPECTIVE){O.perspective={znear:L.getZNear(),zfar:L.getZFar(),yfov:L.getYFov()};let M=L.getAspectRatio();if(M!==null)O.perspective.aspectRatio=M}else O.orthographic={znear:L.getZNear(),zfar:L.getZFar(),xmag:L.getXMag(),ymag:L.getYMag()};return K.cameraIndexMap.set(L,w),O}),$.nodes=Y.listNodes().map((L,w)=>{let O=K.createPropertyDef(L);if(!i0.eq(L.getTranslation(),[0,0,0]))O.translation=L.getTranslation();if(!i0.eq(L.getRotation(),[0,0,0,1]))O.rotation=L.getRotation();if(!i0.eq(L.getScale(),[1,1,1]))O.scale=L.getScale();if(L.getWeights().length)O.weights=L.getWeights();return K.nodeIndexMap.set(L,w),O}),$.skins=Y.listSkins().map((L,w)=>{let O=K.createPropertyDef(L),M=L.getInverseBindMatrices();if(M)O.inverseBindMatrices=K.accessorIndexMap.get(M);let R=L.getSkeleton();if(R)O.skeleton=K.nodeIndexMap.get(R);return O.joints=L.listJoints().map((D)=>K.nodeIndexMap.get(D)),K.skinIndexMap.set(L,w),O}),Y.listNodes().forEach((L,w)=>{let O=$.nodes[w],M=L.getMesh();if(M)O.mesh=K.meshIndexMap.get(M);let R=L.getCamera();if(R)O.camera=K.cameraIndexMap.get(R);let D=L.getSkin();if(D)O.skin=K.skinIndexMap.get(D);if(L.listChildren().length>0)O.children=L.listChildren().map((N)=>K.nodeIndexMap.get(N))}),$.animations=Y.listAnimations().map((L,w)=>{let O=K.createPropertyDef(L),M=new Map;return O.samplers=L.listSamplers().map((R,D)=>{let N=K.createPropertyDef(R);return N.input=K.accessorIndexMap.get(R.getInput()),N.output=K.accessorIndexMap.get(R.getOutput()),N.interpolation=R.getInterpolation(),M.set(R,D),N}),O.channels=L.listChannels().map((R)=>{let D=K.createPropertyDef(R);return D.sampler=M.get(R.getSampler()),D.target={node:K.nodeIndexMap.get(R.getTargetNode()),path:R.getTargetPath()},D}),K.animationIndexMap.set(L,w),O}),$.scenes=Y.listScenes().map((L,w)=>{let O=K.createPropertyDef(L);return O.nodes=L.listChildren().map((M)=>K.nodeIndexMap.get(M)),K.sceneIndexMap.set(L,w),O});let B=Y.getDefaultScene();if(B)$.scene=Y.listScenes().indexOf(B);return $.extensionsUsed=H.map((L)=>L.extensionName),$.extensionsRequired=V.map((L)=>L.extensionName),H.forEach((L)=>L.write(K)),WO1($),Q}}function WO1(Z){let J=[];for(let X in Z){let Y=Z[X];if(Array.isArray(Y)&&Y.length===0)J.push(X);else if(Y===null||Y==="")J.push(X);else if(Y&&typeof Y==="object"&&Object.keys(Y).length===0)J.push(X)}for(let X of J)delete Z[X]}var tB;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(tB||(tB={}));class Ya{constructor(){this._logger=k5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=sB.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=pn(J)?this._binaryToJSON(J):{json:JSON.parse(o0.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),Ja.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(o0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some((Y)=>HO1(J,Y)))throw new Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some((Y)=>VO1(J,Y)))throw new Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(o0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===EZ.GLB&&Z.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Xa.write(Z,{format:J.format||EZ.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:r6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:EZ.GLB}),Y=new Uint32Array([1179937895,2,12]),$=JSON.stringify(J),Q=o0.pad(o0.encodeText($),32),K=o0.toView(new Uint32Array([Q.byteLength,1313821514])),G=o0.concat([K,Q]);Y[Y.length-1]+=G.byteLength;let W=Object.values(X)[0];if(!W||!W.byteLength)return o0.concat([o0.toView(Y),G]);let H=o0.pad(W,0),V=o0.toView(new Uint32Array([H.byteLength,5130562])),F=o0.concat([V,H]);return Y[Y.length-1]+=F.byteLength,o0.concat([o0.toView(Y),G,F])}async _readResourcesExternal(Z,J){var X=this;let Y=Z.json.images||[],$=Z.json.buffers||[],Q=[...Y,...$].map(async function(K){let G=K.uri;if(!G||G.match(/data:/))return Promise.resolve();Z.resources[G]=await X.readURI(X.resolve(J,G),"view"),X.lastReadBytes+=Z.resources[G].byteLength});await Promise.all(Q)}_readResourcesInternal(Z){function J($){if(!$.uri)return;if($.uri in Z.resources){o0.assertView(Z.resources[$.uri]);return}if($.uri.match(/data:/)){let Q=`__${tn()}.${IZ.extension($.uri)}`;Z.resources[Q]=o0.createBufferFromDataURI($.uri),$.uri=Q}}(Z.json.images||[]).forEach(($)=>{if($.bufferView===void 0&&$.uri===void 0)throw new Error("Missing resource URI or buffer view.");J($)}),(Z.json.buffers||[]).forEach(J)}_copyJSON(Z){let{images:J,buffers:X}=Z.json;if(Z={json:r6({},Z.json),resources:r6({},Z.resources)},J)Z.json.images=J.map((Y)=>r6({},Y));if(X)Z.json.buffers=X.map((Y)=>r6({},Y));return Z}_binaryToJSON(Z){if(!pn(Z))throw new Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==tB.JSON)throw new Error("Missing required GLB JSON chunk.");let X=20,Y=J[0],$=o0.decodeText(o0.toView(Z,X,Y)),Q=JSON.parse($),K=X+Y;if(Z.byteLength<=K)return{json:Q,resources:{}};let G=new Uint32Array(Z.buffer,Z.byteOffset+K,2);if(G[1]!==tB.BIN)return{json:Q,resources:{}};let W=G[0],H=o0.toView(Z,K+8,W);return{json:Q,resources:{[aB]:H}}}}function HO1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function VO1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function pn(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 VT extends Ya{constructor(Z=null,J=f9.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(),f9.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(f9.isAbsoluteURL(Z)||f9.isAbsoluteURL(J))return f9.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(f9.isAbsoluteURL(Z))return f9.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:Y,resources:$}=await this.writeJSON(J,{format:EZ.GLTF,basename:IZ.basename(Z)}),{_fs:Q,_path:K}=this,G=K.dirname(Z),W=JSON.stringify(Y,null,2);await Q.writeFile(Z,W),this.lastWriteBytes+=W.length;for(let H of zO1(Object.keys($),10))await Promise.all(H.map(async function(V){if(f9.isAbsoluteURL(V)){if(f9.extension(V)==="bin")throw new Error(`Cannot write buffer to path "${V}".`);return}let F=K.join(G,decodeURIComponent(V));await Q.mkdir(K.dirname(F),{recursive:!0}),await Q.writeFile(F,$[V]),X.lastWriteBytes+=$[V].byteLength}))}async _writeGLB(Z,J){let X=await this.writeBinary(J);await this._fs.writeFile(Z,X),this.lastWriteBytes=X.byteLength}}function zO1(Z,J){let X=[];for(let Y=0,$=Z.length;Y<$;Y+=J){let Q=[];for(let K=0;K<J&&Y+K<$;K++)Q.push(Z[Y+K]);X.push(Q)}return X}var Zr=r(zT(),1),Jr=r(fo(),1),XD1=r(eo(),1);async function YD1(Z,J){if(!(Z instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:Y}=await Jr.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return Zr.default(new Uint8Array(X),[Y.width,Y.height,4],[4,4*Y.width|0,1],0)}async function Xr(Z,J){return YD1(Z)}var $D1="v4.1.3",cT="@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 Yr;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(Yr||(Yr={}));var X9;(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"})(X9||(X9={}));var Y9;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(Y9||(Y9={}));var yT;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(yT||(yT={}));var bT=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 QD1(){var Z=new bT(3);if(bT!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function fT(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function KD1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}(function(){var Z=QD1();return function(J,X,Y,$,Q,K){var G,W;if(!X)X=3;if(!Y)Y=0;if($)W=Math.min($*X+Y,J.length);else W=J.length;for(G=Y;G<W;G+=X)Z[0]=J[G],Z[1]=J[G+1],Z[2]=J[G+2],Q(Z,Z,K),J[G]=Z[0],J[G+1]=Z[1],J[G+2]=Z[2];return J}})();function Gr(Z){let J=Wr(),X=Z.propertyType===s.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=GD1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))gT(K.min,J),gT(K.max,J)});return J}function GD1(Z,J){let X=Wr();for(let Y of Z.listPrimitives()){let $=Y.getAttribute("POSITION"),Q=Y.getIndices();if(!$)continue;let K=[0,0,0],G=[0,0,0];for(let W=0,H=Q?Q.getCount():$.getCount();W<H;W++){let V=Q?Q.getScalar(W):W;K=$.getElement(V,K),G=KD1(G,K,J),gT(G,X)}}return X}function gT(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 Wr(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class v6{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let Y=0;Y<J.length;Y++)X[Y]=J.charCodeAt(Y);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 $ of Z)J+=$.byteLength;let X=new Uint8Array(J),Y=0;for(let $ 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 Y=new Uint8Array(X);if(Y.set(Z),J!==0)for(let $=Z.byteLength;$<X;$++)Y[$]=J;return Y}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 Hr{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,Y;while(J.byteLength){if(X=J.getUint16(0,!1),WD1(J,X),Y=J.getUint8(X+1),Y===192||Y===193||Y===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 _2{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(v6.decodeText(Z.slice(12,16))===_2.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}}_2.PNG_FRIED_CHUNK_NAME="CgBI";class h4{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,Y=4,$=this.getSize(Z,J);if(!$)return null;while($[0]>1||$[1]>1)X+=$[0]*$[1]*Y,$[0]=Math.max(Math.floor($[0]/2),1),$[1]=Math.max(Math.floor($[1]/2),1);return X+=1*Y,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}`}}h4.impls={"image/jpeg":new Hr,"image/png":new _2};function WD1(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 rH{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 h4.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 $r(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function X$(Z){if($r(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if($r(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var mT,uT;(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"})(uT||(uT={}));class _7{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=_7.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=_7.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=_7.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=_7.Verbosity.ERROR)console.error(Z)}}mT=_7;_7.Verbosity=uT;_7.DEFAULT_INSTANCE=new mT(mT.Verbosity.INFO);function HD1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],G=Z[6],W=Z[7],H=Z[8],V=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,O=J*G-Y*Q,M=J*W-$*Q,R=X*G-Y*K,D=X*W-$*K,N=Y*W-$*G,C=H*U-V*q,T=H*B-F*q,E=H*L-z*q,A=V*B-F*U,S=V*L-z*U,x=F*L-z*B;return w*x-O*S+M*A+R*E-D*T+N*C}function VD1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],G=J[4],W=J[5],H=J[6],V=J[7],F=J[8],z=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],O=J[15],M=X[0],R=X[1],D=X[2],N=X[3];return Z[0]=M*Y+R*G+D*F+N*B,Z[1]=M*$+R*W+D*z+N*L,Z[2]=M*Q+R*H+D*q+N*w,Z[3]=M*K+R*V+D*U+N*O,M=X[4],R=X[5],D=X[6],N=X[7],Z[4]=M*Y+R*G+D*F+N*B,Z[5]=M*$+R*W+D*z+N*L,Z[6]=M*Q+R*H+D*q+N*w,Z[7]=M*K+R*V+D*U+N*O,M=X[8],R=X[9],D=X[10],N=X[11],Z[8]=M*Y+R*G+D*F+N*B,Z[9]=M*$+R*W+D*z+N*L,Z[10]=M*Q+R*H+D*q+N*w,Z[11]=M*K+R*V+D*U+N*O,M=X[12],R=X[13],D=X[14],N=X[15],Z[12]=M*Y+R*G+D*F+N*B,Z[13]=M*$+R*W+D*z+N*L,Z[14]=M*Q+R*H+D*q+N*w,Z[15]=M*K+R*V+D*U+N*O,Z}function zD1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],G=J[6],W=J[8],H=J[9],V=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,G),Z[2]=Math.hypot(W,H,V),Z}function FD1(Z,J){var X=new bT(3);zD1(X,J);var Y=1/X[0],$=1/X[1],Q=1/X[2],K=J[0]*Y,G=J[1]*$,W=J[2]*Q,H=J[4]*Y,V=J[5]*$,F=J[6]*Q,z=J[8]*Y,q=J[9]*$,U=J[10]*Q,B=K+V+U,L=0;if(B>0)L=Math.sqrt(B+1)*2,Z[3]=0.25*L,Z[0]=(F-q)/L,Z[1]=(z-W)/L,Z[2]=(G-H)/L;else if(K>V&&K>U)L=Math.sqrt(1+K-V-U)*2,Z[3]=(F-q)/L,Z[0]=0.25*L,Z[1]=(G+H)/L,Z[2]=(z+W)/L;else if(V>U)L=Math.sqrt(1+V-K-U)*2,Z[3]=(z-W)/L,Z[0]=(G+H)/L,Z[1]=0.25*L,Z[2]=(F+q)/L;else L=Math.sqrt(1+U-K-V)*2,Z[3]=(G-H)/L,Z[0]=(z+W)/L,Z[1]=(F+q)/L,Z[2]=0.25*L;return Z}class z8{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>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(z8.clamp(Z,0,1)*65535);case 5121:return Math.round(z8.clamp(Z,0,1)*255);case 5122:return Math.round(z8.clamp(Z,-1,1)*32767);case 5120:return Math.round(z8.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=fT([Z[0],Z[1],Z[2]]),Q=fT([Z[4],Z[5],Z[6]]),K=fT([Z[8],Z[9],Z[10]]);if(HD1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let W=Z.slice(),H=1/$,V=1/Q,F=1/K;W[0]*=H,W[1]*=H,W[2]*=H,W[4]*=V,W[5]*=V,W[6]*=V,W[8]*=F,W[9]*=F,W[10]*=F,FD1(X,W),Y[0]=$,Y[1]=Q,Y[2]=K}static compose(Z,J,X,Y){let $=Y,Q=J[0],K=J[1],G=J[2],W=J[3],H=Q+Q,V=K+K,F=G+G,z=Q*H,q=Q*V,U=Q*F,B=K*V,L=K*F,w=G*F,O=W*H,M=W*V,R=W*F,D=X[0],N=X[1],C=X[2];return $[0]=(1-(B+w))*D,$[1]=(q+R)*D,$[2]=(U-M)*D,$[3]=0,$[4]=(q-R)*N,$[5]=(1-(z+w))*N,$[6]=(L+O)*N,$[7]=0,$[8]=(U+M)*C,$[9]=(L-O)*C,$[10]=(1-(z+B))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function qD1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function UD1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),Y=J.values();if(X.length!==Y.length)return!1;for(let $=0;$<X.length;$++){let Q=X[$],K=Y[$];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function LD1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),Y=J.keys();if(X.length!==Y.length)return!1;for(let $ of X){let Q=Z.get($),K=J.get($);if(!!Q!==!!K)return!1;let G=Q.getChild(),W=K.getChild();if(G===W)continue;if(!G.equals(W))return!1}return!0}function Vr(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 zr(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!X$(Z)||!X$(J))return Z===J;let X=Z,Y=J,$=0,Q=0,K;for(K in X)$++;for(K in Y)Q++;if($!==Q)return!1;for(K in X){let G=X[K],W=Y[K];if(E2(G)&&E2(W)){if(!Vr(G,W))return!1}else if(X$(G)&&X$(W)){if(!zr(G,W))return!1}else if(G!==W)return!1}return!0}function E2(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Qr="https://null.example";class lT{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return rH.basename(new URL(Z,Qr).pathname)}static extension(Z){return rH.extension(new URL(Z,Qr).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),Y=J.split("/");X.pop();for(let $=0;$<Y.length;$++){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)}}lT.DEFAULT_INIT={};lT.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var tJ=(Z)=>Z,BD1=new Set;class S2 extends iK{constructor(Z,J=""){super(Z);this[y0].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,tJ)}copy(Z,J=tJ){for(let X in this[y0]){let Y=this[y0][X];if(Y instanceof T5){if(!this[A4].has(X))Y.dispose()}else if(Y instanceof I6||Y instanceof E0)for(let $ of Y.values())$.dispose();else if(Y instanceof e1)for(let $ of Y.values())$.dispose()}for(let X in Z[y0]){let Y=this[y0][X],$=Z[y0][X];if($ instanceof T5)if(this[A4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof E0||$ instanceof I6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof e1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(X$($))this[y0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[y0][X]=$.slice();else this[y0][X]=$}return this}equals(Z,J=BD1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[y0]){if(J.has(X))continue;let Y=this[y0][X],$=Z[y0][X];if(Y instanceof T5||$ instanceof T5){if(!qD1(Y,$))return!1}else if(Y instanceof E0||$ instanceof E0||Y instanceof I6||$ instanceof I6){if(!UD1(Y,$))return!1}else if(Y instanceof e1||$ instanceof e1){if(!LD1(Y,$))return!1}else if(X$(Y)||X$($)){if(!zr(Y,$))return!1}else if(E2(Y)||E2($)){if(!Vr(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 A6 extends S2{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new e1})}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 T0 extends A6{init(){this.propertyType=s.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:T0.Type.SCALAR,componentType:T0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case T0.Type.SCALAR:return 1;case T0.Type.VEC2:return 2;case T0.Type.VEC3:return 3;case T0.Type.VEC4:return 4;case T0.Type.MAT2:return 4;case T0.Type.MAT3:return 9;case T0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case T0.ComponentType.BYTE:return 1;case T0.ComponentType.UNSIGNED_BYTE:return 1;case T0.ComponentType.SHORT:return 2;case T0.ComponentType.UNSIGNED_SHORT:return 2;case T0.ComponentType.UNSIGNED_INT:return 4;case T0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMin(Z),J)for(let $=0;$<X;$++)Z[$]=z8.decodeNormalizedInt(Z[$],Y);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMax(Z),J)for(let $=0;$<X;$++)Z[$]=z8.decodeNormalizedInt(Z[$],Y);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=-1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+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 T0.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(),Y=this.getArray();if(this.getNormalized())return z8.decodeNormalizedInt(Y[Z*J],X);return Y[Z*J]}setScalar(Z,J){let X=this.getElementSize(),Y=this.getComponentType(),$=this.getArray();if(this.getNormalized())$[Z*X]=z8.encodeNormalizedInt(J,Y);else $[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)J[K]=z8.decodeNormalizedInt(Q[Z*Y+K],$);else J[K]=Q[Z*Y+K];return J}setElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)Q[Z*Y+K]=z8.encodeNormalizedInt(J[K],$);else Q[Z*Y+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?wD1(Z):T0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}T0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};T0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function wD1(Z){switch(Z.constructor){case Float32Array:return T0.ComponentType.FLOAT;case Uint32Array:return T0.ComponentType.UNSIGNED_INT;case Uint16Array:return T0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return T0.ComponentType.UNSIGNED_BYTE;case Int16Array:return T0.ComponentType.SHORT;case Int8Array:return T0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class pT extends A6{init(){this.propertyType=s.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new E0,samplers:new E0})}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 eH extends A6{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)}}eH.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class QG extends A6{init(){this.propertyType=s.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:QG.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:X9.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:X9.OTHER})}}QG.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class iT extends A6{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 ZV extends A6{init(){this.propertyType=s.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:ZV.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)}}ZV.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class s1 extends S2{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}s1.EXTENSION_NAME=void 0;class T1 extends A6{init(){this.propertyType=s.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:T1.WrapMode.REPEAT,wrapT:T1.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)}}T1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};T1.MagFilter={NEAREST:9728,LINEAR:9729};T1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:D2,G:C2,B:T2,A:jD1}=Y9;class JV extends A6{init(){this.propertyType=s.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:JV.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new T1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new T1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new T1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new T1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new T1(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:D2|C2|T2|jD1,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:D2|C2|T2,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:D2|C2|T2})}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:D2})}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:C2|T2})}}JV.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class nT extends A6{init(){this.propertyType=s.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new E0})}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 aT extends A6{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 E0})}copy(Z,J=tJ){if(J===tJ)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 z8.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),Y=this.get("scale").slice();return z8.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return z8.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return z8.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return z8.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let Y=this;Y!=null;Y=Y.getParentNode())Z.push(Y);let J,X=Z.pop().getMatrix();while(J=Z.pop())VD1(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 eJ extends A6{init(){this.propertyType=s.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:eJ.Mode.TRIANGLES,material:null,indices:null,attributes:new e1,targets:new E0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:X9.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:X9.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)}}eJ.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class Fr extends S2{init(){this.propertyType=s.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new e1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:X9.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function k2(){return k2=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},k2.apply(null,arguments)}class sT extends A6{init(){this.propertyType=s.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new E0})}copy(Z,J=tJ){if(J===tJ)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 oT extends A6{init(){this.propertyType=s.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new E0})}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:X9.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class rT extends A6{init(){this.propertyType=s.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||h4.extensionToMimeType(rH.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=h4.extensionToMimeType(rH.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",v6.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return h4.getSize(Z,this.getMimeType())}}class v2 extends A6{init(){this.propertyType=s.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${$D1}`,version:"2.0"},defaultScene:null,accessors:new E0,animations:new E0,buffers:new E0,cameras:new E0,materials:new E0,meshes:new E0,nodes:new E0,scenes:new E0,skins:new E0,textures:new E0})}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=tJ){if(J===tJ)throw new Error("Root cannot be copied.");this.set("asset",k2({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(k2({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let Y=Z.getExtension(X);this.setExtension(X,J(Y))}return this}_addChildOfRoot(Z){if(Z instanceof sT)this.addRef("scenes",Z);else if(Z instanceof aT)this.addRef("nodes",Z);else if(Z instanceof ZV)this.addRef("cameras",Z);else if(Z instanceof oT)this.addRef("skins",Z);else if(Z instanceof nT)this.addRef("meshes",Z);else if(Z instanceof JV)this.addRef("materials",Z);else if(Z instanceof rT)this.addRef("textures",Z);else if(Z instanceof pT)this.addRef("animations",Z);else if(Z instanceof T0)this.addRef("accessors",Z);else if(Z instanceof iT)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 I2{static fromGraph(Z){return I2._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new pK,this._root=new v2(this._graph),this._logger=_7.DEFAULT_INSTANCE,I2._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((Y)=>Y.extensionName===J)||new Z(this)}createScene(Z=""){return new sT(this._graph,Z)}createNode(Z=""){return new aT(this._graph,Z)}createCamera(Z=""){return new ZV(this._graph,Z)}createSkin(Z=""){return new oT(this._graph,Z)}createMesh(Z=""){return new nT(this._graph,Z)}createPrimitive(){return new eJ(this._graph)}createPrimitiveTarget(Z=""){return new Fr(this._graph,Z)}createMaterial(Z=""){return new JV(this._graph,Z)}createTexture(Z=""){return new rT(this._graph,Z)}createAnimation(Z=""){return new pT(this._graph,Z)}createAnimationChannel(Z=""){return new eH(this._graph,Z)}createAnimationSampler(Z=""){return new QG(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new T0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new iT(this._graph,Z)}}I2._GRAPH_DOCUMENTS=new WeakMap;class I1{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 Y=X,$=Y.target;if($ instanceof s1&&$.extensionName===this.extensionName){if(Y.type==="node:create")this._addExtensionProperty($);if(Y.type==="node:dispose")this._removeExtensionProperty($)}};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}}I1.EXTENSION_NAME=void 0;var MS6={logger:_7.DEFAULT_INSTANCE,extensions:[],dependencies:{}},RS6=new Set([s.BUFFER,s.TEXTURE,s.MATERIAL,s.MESH,s.PRIMITIVE,s.NODE,s.SCENE]);var tH;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(tH||(tH={}));class ZX{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 Y=Z.getRoot(),$=Y.listBuffers().length,Q=Y.listTextures().length;this.bufferURIGenerator=new dT($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new dT(Q>1,(K)=>OD1(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()},Y=JSON.stringify(X);if(!this.samplerDefIndexMap.has(Y))this.samplerDefIndexMap.set(Y,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let $={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get(Y)},Q=JSON.stringify($);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push($);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((Y)=>Y.getName()==="attributes"&&Y.getAttributes().key==="POSITION"||Y.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===yT.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 Y=h4.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,Y),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let Y=this.jsonDoc.resources;if(!(Z in Y)){Y[Z]=J;return}if(J===Y[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let $=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn($);return}throw new Error($)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return X9.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:Y}=X.getAttributes();if(Y)return Y;if(X.getParent().propertyType!==s.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return X9.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}}ZX.BufferViewTarget=tH;ZX.BufferViewUsage=X9;ZX.USAGE_TO_TARGET={[X9.ARRAY_BUFFER]:tH.ARRAY_BUFFER,[X9.ELEMENT_ARRAY_BUFFER]:tH.ELEMENT_ARRAY_BUFFER};class dT{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 OD1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{UNSIGNED_INT:NS6,UNSIGNED_SHORT:PS6,UNSIGNED_BYTE:DS6}=T0.ComponentType,CS6=new Set([s.ACCESSOR,s.BUFFER,s.MATERIAL,s.MESH]);var Kr;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(Kr||(Kr={}));var Ur=163,Lr=166;function MD1(){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 KG{constructor(Z,J,X,Y){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(Z.buffer,Z.byteOffset+J,X),this._littleEndian=Y,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,Y=0;while(this._dataView.getUint8(this._offset)!==J&&Y<Z)Y++,this._offset++;if(Y<Z)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+X,Y)}}var kS6=new Uint8Array([0]),J5=[171,75,84,88,32,50,48,187,13,10,26,10];function qr(Z){return new TextDecoder().decode(Z)}function A2(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,J5.length);if(J[0]!==J5[0]||J[1]!==J5[1]||J[2]!==J5[2]||J[3]!==J5[3]||J[4]!==J5[4]||J[5]!==J5[5]||J[6]!==J5[6]||J[7]!==J5[7]||J[8]!==J5[8]||J[9]!==J5[9]||J[10]!==J5[10]||J[11]!==J5[11])throw new Error("Missing KTX 2.0 identifier.");let X=MD1(),Y=17*Uint32Array.BYTES_PER_ELEMENT,$=new KG(Z,J5.length,Y,!0);X.vkFormat=$._nextUint32(),X.typeSize=$._nextUint32(),X.pixelWidth=$._nextUint32(),X.pixelHeight=$._nextUint32(),X.pixelDepth=$._nextUint32(),X.layerCount=$._nextUint32(),X.faceCount=$._nextUint32();let Q=$._nextUint32();X.supercompressionScheme=$._nextUint32();let K=$._nextUint32(),G=$._nextUint32(),W=$._nextUint32(),H=$._nextUint32(),V=$._nextUint64(),F=$._nextUint64(),z=Q*3*8,q=new KG(Z,J5.length+Y,z,!0);for(let q6=0;q6<Q;q6++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+q._nextUint64(),q._nextUint64()),uncompressedByteLength:q._nextUint64()});let U=new KG(Z,K,G,!0);U._skip(4);let B=U._nextUint16(),L=U._nextUint16(),w=U._nextUint16(),O=U._nextUint16(),M=U._nextUint8(),R=U._nextUint8(),D=U._nextUint8(),N=U._nextUint8(),C=[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],T=[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],A={vendorId:B,descriptorType:L,versionNumber:w,colorModel:M,colorPrimaries:R,transferFunction:D,flags:N,texelBlockDimension:C,bytesPlane:T,samples:[]},S=6,x=4,I=(O/4-S)/x;for(let q6=0;q6<I;q6++){let LZ={bitOffset:U._nextUint16(),bitLength:U._nextUint8(),channelType:U._nextUint8(),samplePosition:[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(LZ.channelType&64)LZ.sampleLower=U._nextInt32(),LZ.sampleUpper=U._nextInt32();else LZ.sampleLower=U._nextUint32(),LZ.sampleUpper=U._nextUint32();A.samples[q6]=LZ}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(A);let _=new KG(Z,W,H,!0);while(_._offset<H){let q6=_._nextUint32(),LZ=_._scan(q6),MU=qr(LZ);if(X.keyValue[MU]=_._nextUint8Array(q6-LZ.byteLength-1),MU.match(/^ktx/i)){let hm=qr(X.keyValue[MU]);X.keyValue[MU]=hm.substring(0,hm.lastIndexOf("\x00"))}let DV1=q6%4?4-q6%4:0;_._skip(DV1)}if(F<=0)return X;let y=new KG(Z,V,F,!0),u=y._nextUint16(),n=y._nextUint16(),o=y._nextUint32(),Q0=y._nextUint32(),G0=y._nextUint32(),S0=y._nextUint32(),v0=[];for(let q6=0;q6<Q;q6++)v0.push({imageFlags:y._nextUint32(),rgbSliceByteOffset:y._nextUint32(),rgbSliceByteLength:y._nextUint32(),alphaSliceByteOffset:y._nextUint32(),alphaSliceByteLength:y._nextUint32()});let r0=V+y._offset,A8=r0+o,r1=A8+Q0,U7=r1+G0,N4=new Uint8Array(Z.buffer,Z.byteOffset+r0,o),HK=new Uint8Array(Z.buffer,Z.byteOffset+A8,Q0),VK=new Uint8Array(Z.buffer,Z.byteOffset+r1,G0),IY=new Uint8Array(Z.buffer,Z.byteOffset+U7,S0);return X.globalData={endpointCount:u,selectorCount:n,imageDescs:v0,endpointsData:N4,selectorsData:HK,tablesData:VK,extendedData:IY},X}var XE="EXT_mesh_gpu_instancing",eT="EXT_meshopt_compression",RD1="EXT_texture_webp",ND1="EXT_texture_avif",Ir="KHR_draco_mesh_compression",YE="KHR_lights_punctual",$E="KHR_materials_anisotropy",QE="KHR_materials_clearcoat",KE="KHR_materials_diffuse_transmission",GE="KHR_materials_dispersion",WE="KHR_materials_emissive_strength",HE="KHR_materials_ior",VE="KHR_materials_iridescence",zE="KHR_materials_pbrSpecularGlossiness",FE="KHR_materials_sheen",qE="KHR_materials_specular",UE="KHR_materials_transmission",LE="KHR_materials_unlit",BE="KHR_materials_volume",w$="KHR_materials_variants",PD1="KHR_mesh_quantization",DD1="KHR_texture_basisu",wE="KHR_texture_transform",x2="KHR_xmp_json_ld",ZE="INSTANCE_ATTRIBUTE";class jE extends s1{init(){this.extensionName=XE,this.propertyType="InstancedMesh",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new e1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:ZE})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}jE.EXTENSION_NAME=XE;var Y$=XE;class y2 extends I1{constructor(...Z){super(...Z);this.extensionName=Y$,this.provideTypes=[s.NODE],this.prewriteTypes=[s.ACCESSOR]}createInstancedMesh(){return new jE(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[Y$])return;let Q=Y.extensions[Y$],K=this.createInstancedMesh();for(let G in Q.attributes)K.setAttribute(G,Z.accessors[Q.attributes[G]]);Z.nodes[$].setExtension(Y$,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(ZE);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,ZE);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let Y=X.getExtension(Y$);if(Y){let $=Z.nodeIndexMap.get(X),Q=J.json.nodes[$],K={attributes:{}};Y.listSemantics().forEach((G)=>{let W=Y.getAttribute(G);K.attributes[G]=Z.accessorIndexMap.get(W)}),Q.extensions=Q.extensions||{},Q.extensions[Y$]=K}}),this}}y2.EXTENSION_NAME=Y$;function AZ(){return AZ=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},AZ.apply(null,arguments)}var QV;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(QV||(QV={}));var WG;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(WG||(WG={}));var F8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})(F8||(F8={}));var{BYTE:CD1,SHORT:Br,FLOAT:TD1}=T0.ComponentType,{encodeNormalizedInt:wr,decodeNormalizedInt:JE}=z8;function ED1(Z,J,X,Y){let{filter:$,bits:Q}=Y,K={array:Z.getArray(),byteStride:Z.getElementSize()*Z.getComponentSize(),componentType:Z.getComponentType(),normalized:Z.getNormalized()};if(X!==WG.ATTRIBUTES)return K;if($!==F8.NONE){let G=Z.getNormalized()?kD1(Z):new Float32Array(K.array);switch($){case F8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=TD1,K.normalized=!1,K.array=J.encodeFilterExp(G,Z.getCount(),K.byteStride,Q);break;case F8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?Br:CD1,K.normalized=!0,G=Z.getElementSize()===3?_D1(G):G,K.array=J.encodeFilterOct(G,Z.getCount(),K.byteStride,Q);break;case F8.QUATERNION:K.byteStride=8,K.componentType=Br,K.normalized=!0,K.array=J.encodeFilterQuat(G,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((W)=>JE(W,Z.getComponentType())),K.max=K.max.map((W)=>JE(W,Z.getComponentType()));if(K.normalized)K.min=K.min.map((W)=>wr(W,K.componentType)),K.max=K.max.map((W)=>wr(W,K.componentType))}else if(K.byteStride%4)K.array=ID1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function kD1(Z){let J=Z.getComponentType(),X=Z.getArray(),Y=new Float32Array(X.length);for(let $=0;$<X.length;$++)Y[$]=JE(X[$],J);return Y}function ID1(Z,J){let Y=v6.padNumber(Z.BYTES_PER_ELEMENT*J)/Z.BYTES_PER_ELEMENT,$=Z.length/J,Q=new Z.constructor($*Y);for(let K=0;K*J<Z.length;K++)for(let G=0;G<J;G++)Q[K*Y+G]=Z[K*J+G];return Q}function _D1(Z){let J=new Float32Array(Z.length*4/3);for(let X=0,Y=Z.length/3;X<Y;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 SD1(Z,J){if(J===ZX.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some((Y)=>{return Y instanceof eJ&&Y.getMode()===eJ.Mode.TRIANGLES})?WG.TRIANGLES:WG.INDICES;return WG.ATTRIBUTES}function vD1(Z,J){let X=J.getGraph().listParentEdges(Z).filter((Y)=>!(Y.getParent()instanceof v2));for(let Y of X){let $=Y.getName(),Q=Y.getAttributes().key||"",K=Y.getParent().propertyType===s.PRIMITIVE_TARGET;if($==="indices")return{filter:F8.NONE};if($==="attributes"){if(Q==="POSITION")return{filter:F8.NONE};if(Q==="TEXCOORD_0")return{filter:F8.NONE};if(Q.startsWith("JOINTS_"))return{filter:F8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:F8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:F8.NONE}:{filter:F8.OCTAHEDRAL,bits:8}}if($==="output"){let G=_r(Z);if(G==="rotation")return{filter:F8.QUATERNION,bits:16};if(G==="translation")return{filter:F8.EXPONENTIAL,bits:12};if(G==="scale")return{filter:F8.EXPONENTIAL,bits:12};return{filter:F8.NONE}}if($==="input")return{filter:F8.NONE};if($==="inverseBindMatrices")return{filter:F8.NONE}}return{filter:F8.NONE}}function _r(Z){for(let J of Z.listParents()){if(!(J instanceof QG))continue;for(let X of J.listParents()){if(!(X instanceof eH))continue;return X.getTargetPath()}}return null}function AD1(Z){if(!Z.extensions||!Z.extensions[eT])return!1;return!!Z.extensions[eT].fallback}var X5=eT,jr={method:QV.QUANTIZE};class GV extends I1{constructor(...Z){super(...Z);this.extensionName=X5,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=jr,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=AZ({},jr,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${X5}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${X5}]: 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(!Y.extensions||!Y.extensions[X5])return;let Q=Y.extensions[X5],K=Q.byteOffset||0,G=Q.byteLength||0,W=Q.count,H=Q.byteStride,V=new Uint8Array(W*H),F=J.json.buffers[Q.buffer],z=F.uri?J.resources[F.uri]:J.resources[cT],q=v6.toView(z,K,G);this._decoder.decodeGltfBuffer(V,W,H,q,Q.mode,Q.filter),Z.bufferViews[$]=V})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y)=>{if(!Y.extensions||!Y.extensions[X5])return;let $=Y.extensions[X5],Q=Z.buffers[$.buffer],K=Z.buffers[Y.buffer],G=J.json.buffers[Y.buffer];if(AD1(G))this._decoderFallbackBufferMap.set(K,Q)})}read(Z){if(!this.isRequired())return this;for(let[J,X]of this._decoderFallbackBufferMap){for(let Y of J.listParents())if(Y instanceof T0)Y.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,Y=this._encoderOptions,$=this.document.getGraph(),Q=this.document.createBuffer(),K=this.document.getRoot().listBuffers().indexOf(Q),G=1,W=new Map,H=(V)=>{for(let F of $.listParents(V)){if(F.propertyType===s.ROOT)continue;let z=W.get(V);if(z===void 0)W.set(V,z=G++);return z}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let V of this.document.getRoot().listAccessors()){if(_r(V)==="weights")continue;if(V.getSparse())continue;let F=Z.getAccessorUsage(V),z=Z.accessorUsageGroupedByParent.has(F)?H(V):null,q=SD1(V,F),U=Y.method===QV.FILTER?vD1(V,this.document):{filter:F8.NONE},B=ED1(V,X,q,U),{array:L,byteStride:w}=B,O=V.getBuffer();if(!O)throw new Error(`${X5}: Missing buffer for accessor.`);let M=this.document.getRoot().listBuffers().indexOf(O),R=[F,z,q,U.filter,w,M].join(":"),D=this._encoderBufferViews[R],N=this._encoderBufferViewData[R],C=this._encoderBufferViewAccessors[R];if(!D||!N)C=this._encoderBufferViewAccessors[R]=[],N=this._encoderBufferViewData[R]=[],D=this._encoderBufferViews[R]={buffer:K,target:ZX.USAGE_TO_TARGET[F],byteOffset:0,byteLength:0,byteStride:F===ZX.BufferViewUsage.ARRAY_BUFFER?w:void 0,extensions:{[X5]:{buffer:M,byteOffset:0,byteLength:0,mode:q,filter:U.filter!==F8.NONE?U.filter:void 0,byteStride:w,count:0}}};let T=Z.createAccessorDef(V);if(T.componentType=B.componentType,T.normalized=B.normalized,T.byteOffset=D.byteLength,T.min&&B.min)T.min=B.min;if(T.max&&B.max)T.max=B.max;Z.accessorIndexMap.set(V,J.accessors.length),J.accessors.push(T),C.push(T),N.push(new Uint8Array(L.buffer,L.byteOffset,L.byteLength)),D.byteLength+=L.byteLength,D.extensions.EXT_meshopt_compression.count+=V.getCount()}}_prewriteBuffers(Z){let J=this._encoder;for(let X in this._encoderBufferViews){let Y=this._encoderBufferViews[X],$=this._encoderBufferViewData[X],Q=this.document.getRoot().listBuffers()[Y.extensions[X5].buffer],K=Z.otherBufferViews.get(Q)||[],{count:G,byteStride:W,mode:H}=Y.extensions[X5],V=v6.concat($),F=J.encodeGltfBuffer(V,G,W,H),z=v6.pad(F);Y.extensions[X5].byteLength=F.byteLength,$.length=0,$.push(z),K.push(z),Z.otherBufferViews.set(Q,K)}}write(Z){let J=0;for(let Q in this._encoderBufferViews){let K=this._encoderBufferViews[Q],G=this._encoderBufferViewData[Q][0],W=Z.otherBufferViewsIndexMap.get(G),H=this._encoderBufferViewAccessors[Q];for(let q of H)q.bufferView=W;let V=Z.jsonDoc.json.bufferViews[W],F=V.byteOffset||0;Object.assign(V,K),V.byteOffset=J;let z=V.extensions[X5];z.byteOffset=F,J+=v6.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,Y=Z.bufferIndexMap.get(X),$=Z.jsonDoc.json.buffers[Y];return $.byteLength=J,$.extensions={[X5]:{fallback:!0}},X.dispose(),this}}GV.EXTENSION_NAME=X5;GV.EncoderMethod=QV;var XV=ND1;class Sr{match(Z){return Z.length>=12&&v6.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=Or(J,0);if(!X)return null;let Y=X.end;while(X=Or(J,Y))if(X.type==="meta")Y=X.start+4;else if(X.type==="iprp"||X.type==="ipco")Y=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 Y=X.end;return null}getChannels(Z){return 4}}class b2 extends I1{constructor(...Z){super(...Z);this.extensionName=XV,this.prereadTypes=[s.TEXTURE]}static register(){h4.registerFormat("image/avif",new Sr)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[XV])X.source=X.extensions[XV].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 Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[XV]={source:Q.source},delete Q.source})}}),this}}b2.EXTENSION_NAME=XV;function Or(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:v6.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}var YV=RD1;class vr{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=v6.decodeText(Z.slice(0,4)),X=v6.decodeText(Z.slice(8,12));if(J!=="RIFF"||X!=="WEBP")return null;let Y=new DataView(Z.buffer,Z.byteOffset),$=12;while($<Y.byteLength){let Q=v6.decodeText(new Uint8Array([Y.getUint8($),Y.getUint8($+1),Y.getUint8($+2),Y.getUint8($+3)])),K=Y.getUint32($+4,!0);if(Q==="VP8 "){let G=Y.getInt16($+14,!0)&16383,W=Y.getInt16($+16,!0)&16383;return[G,W]}else if(Q==="VP8L"){let G=Y.getUint8($+9),W=Y.getUint8($+10),H=Y.getUint8($+11),V=Y.getUint8($+12),F=1+((W&63)<<8|G),z=1+((V&15)<<10|H<<2|(W&192)>>6);return[F,z]}$+=8+K+K%2}return null}getChannels(Z){return 4}}class g2 extends I1{constructor(...Z){super(...Z);this.extensionName=YV,this.prereadTypes=[s.TEXTURE]}static register(){h4.registerFormat("image/webp",new vr)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[YV])X.source=X.extensions[YV].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 Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[YV]={source:Q.source},delete Q.source})}}),this}}g2.EXTENSION_NAME=YV;var Mr=Ir,l8,Ar,xr;function xD1(Z,J){let X=new l8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==l8.TRIANGULAR_MESH)throw new Error(`[${Mr}] Unknown geometry type.`);let $=new l8.Mesh;if(!Z.DecodeBufferToMesh(X,$).ok()||$.ptr===0)throw new Error(`[${Mr}] Decoding failure.`);return $}finally{l8.destroy(X)}}function hD1(Z,J){let Y=J.num_faces()*3,$,Q;if(J.num_points()<=65534){let K=Y*Uint16Array.BYTES_PER_ELEMENT;$=l8._malloc(K),Z.GetTrianglesUInt16Array(J,K,$),Q=new Uint16Array(l8.HEAPU16.buffer,$,Y).slice()}else{let K=Y*Uint32Array.BYTES_PER_ELEMENT;$=l8._malloc(K),Z.GetTrianglesUInt32Array(J,K,$),Q=new Uint32Array(l8.HEAPU32.buffer,$,Y).slice()}return l8._free($),Q}function fD1(Z,J,X,Y){let $=xr[Y.componentType],Q=Ar[Y.componentType],K=X.num_components(),W=J.num_points()*K,H=W*Q.BYTES_PER_ELEMENT,V=l8._malloc(H);Z.GetAttributeDataArrayForAllPoints(J,X,$,H,V);let F=new Q(l8.HEAPF32.buffer,V,W).slice();return l8._free(V),F}function yD1(Z){l8=Z,Ar={[T0.ComponentType.FLOAT]:Float32Array,[T0.ComponentType.UNSIGNED_INT]:Uint32Array,[T0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[T0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[T0.ComponentType.SHORT]:Int16Array,[T0.ComponentType.BYTE]:Int8Array},xr={[T0.ComponentType.FLOAT]:l8.DT_FLOAT32,[T0.ComponentType.UNSIGNED_INT]:l8.DT_UINT32,[T0.ComponentType.UNSIGNED_SHORT]:l8.DT_UINT16,[T0.ComponentType.UNSIGNED_BYTE]:l8.DT_UINT8,[T0.ComponentType.SHORT]:l8.DT_INT16,[T0.ComponentType.BYTE]:l8.DT_INT8}}var b9,KV;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(KV||(KV={}));var g9;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(g9||(g9={}));var hr={[g9.POSITION]:14,[g9.NORMAL]:10,[g9.COLOR]:8,[g9.TEX_COORD]:12,[g9.GENERIC]:12},Rr={decodeSpeed:5,encodeSpeed:5,method:KV.EDGEBREAKER,quantizationBits:hr,quantizationVolume:"mesh"};function bD1(Z){b9=Z}function gD1(Z,J=Rr){let X=AZ({},Rr,J);X.quantizationBits=AZ({},hr,J.quantizationBits);let Y=new b9.MeshBuilder,$=new b9.Mesh,Q=new b9.ExpertEncoder($),K={},G=new b9.DracoInt8Array,W=Z.listTargets().length>0,H=!1;for(let B of Z.listSemantics()){let L=Z.getAttribute(B);if(L.getSparse()){H=!0;continue}let w=mD1(B),O=uD1(Y,L.getComponentType(),$,b9[w],L.getCount(),L.getElementSize(),L.getArray());if(O===-1)throw new Error(`Error compressing "${B}" attribute.`);if(K[B]=O,X.quantizationVolume==="mesh"||B!=="POSITION")Q.SetAttributeQuantization(O,X.quantizationBits[w]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:M}=X,R=Math.max(M.max[0]-M.min[0],M.max[1]-M.min[1],M.max[2]-M.min[2]);Q.SetAttributeExplicitQuantization(O,X.quantizationBits[w],L.getElementSize(),M.min,R)}else throw new Error("Invalid quantization volume state.")}let V=Z.getIndices();if(!V)throw new h2("Primitive must have indices.");if(Y.AddFacesToMesh($,V.getCount()/3,V.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===KV.SEQUENTIAL||W||H)Q.SetEncodingMethod(b9.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(b9.MESH_EDGEBREAKER_ENCODING);let F=Q.EncodeToDracoBuffer(!(W||H),G);if(F<=0)throw new h2("Error applying Draco compression.");let z=new Uint8Array(F);for(let B=0;B<F;++B)z[B]=G.GetValue(B);let q=Q.GetNumberOfEncodedPoints(),U=Q.GetNumberOfEncodedFaces()*3;return b9.destroy(G),b9.destroy($),b9.destroy(Y),b9.destroy(Q),{numVertices:q,numIndices:U,data:z,attributeIDs:K}}function mD1(Z){if(Z==="POSITION")return g9.POSITION;else if(Z==="NORMAL")return g9.NORMAL;else if(Z.startsWith("COLOR_"))return g9.COLOR;else if(Z.startsWith("TEXCOORD_"))return g9.TEX_COORD;return g9.GENERIC}function uD1(Z,J,X,Y,$,Q,K){switch(J){case T0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,Y,$,Q,K);case T0.ComponentType.BYTE:return Z.AddInt8Attribute(X,Y,$,Q,K);case T0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,Y,$,Q,K);case T0.ComponentType.SHORT:return Z.AddInt16Attribute(X,Y,$,Q,K);case T0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,Y,$,Q,K);case T0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,Y,$,Q,K);default:throw new Error(`Unexpected component type, "${J}".`)}}class h2 extends Error{}var E8=Ir;class WV extends I1{constructor(...Z){super(...Z);this.extensionName=E8,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,yD1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,bD1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw new Error(`[${E8}] Please install extension dependency, "draco3d.decoder".`);let J=this.document.getLogger(),X=Z.jsonDoc,Y=new Map;try{let $=X.json.meshes||[];for(let Q of $)for(let K of Q.primitives){if(!K.extensions||!K.extensions[E8])continue;let G=K.extensions[E8],[W,H]=Y.get(G.bufferView)||[];if(!H||!W){let V=X.json.bufferViews[G.bufferView],F=X.json.buffers[V.buffer],z=F.uri?X.resources[F.uri]:X.resources[cT],q=V.byteOffset||0,U=V.byteLength,B=v6.toView(z,q,U);W=new this._decoderModule.Decoder,H=xD1(W,B),Y.set(G.bufferView,[W,H]),J.debug(`[${E8}] Decompressed ${B.byteLength} bytes.`)}for(let V in G.attributes){let F=Z.jsonDoc.json.accessors[K.attributes[V]],z=W.GetAttributeByUniqueId(H,G.attributes[V]),q=fD1(W,H,z,F);Z.accessors[K.attributes[V]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(hD1(W,H))}}finally{for(let[$,Q]of Array.from(Y.values()))this._decoderModule.destroy($),this._decoderModule.destroy(Q)}return this}read(Z){return this}prewrite(Z,J){if(!this._encoderModule)throw new Error(`[${E8}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${E8}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let Y=dD1(this.document),$=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${E8}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=Gr(this.document.getRoot().listScenes().pop());for(let K of Array.from(Y.keys())){let G=Y.get(K);if(!G)throw new Error("Unexpected primitive.");if($.has(G)){$.set(G,$.get(G));continue}let W=K.getIndices(),H=Z.jsonDoc.json.accessors,V;try{V=gD1(K,AZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof h2){X.warn(`[${E8}]: ${q.message} Skipping primitive compression.`);continue}throw q}$.set(G,V);let F=Z.createAccessorDef(W);if(F.count=V.numIndices,Z.accessorIndexMap.set(W,H.length),H.push(F),V.numVertices>65534&&T0.getComponentSize(F.componentType)<=2)F.componentType=T0.ComponentType.UNSIGNED_INT;else if(V.numVertices>254&&T0.getComponentSize(F.componentType)<=1)F.componentType=T0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let U=K.getAttribute(q);if(V.attributeIDs[q]===void 0)continue;let B=Z.createAccessorDef(U);B.count=V.numVertices,Z.accessorIndexMap.set(U,H.length),H.push(B)}let z=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(z))Z.otherBufferViews.set(z,[]);Z.otherBufferViews.get(z).push(V.data)}return X.debug(`[${E8}] Compressed ${Y.size} primitives.`),Z.extensionData[E8]={primitiveHashMap:Y,primitiveEncodingMap:$},this}write(Z){let J=Z.extensionData[E8];for(let X of this.document.getRoot().listMeshes()){let Y=Z.jsonDoc.json.meshes[Z.meshIndexMap.get(X)];for(let $=0;$<X.listPrimitives().length;$++){let Q=X.listPrimitives()[$],K=Y.primitives[$],G=J.primitiveHashMap.get(Q);if(!G)continue;let W=J.primitiveEncodingMap.get(G);if(!W)continue;K.extensions=K.extensions||{},K.extensions[E8]={bufferView:Z.otherBufferViewsIndexMap.get(W.data),attributes:W.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter((Y)=>Y!==E8),X.extensionsRequired=(X.extensionsRequired||[]).filter((Y)=>Y!==E8)}return this}}WV.EXTENSION_NAME=E8;WV.EncoderMethod=KV;function dD1(Z){let J=Z.getLogger(),X=new Set,Y=new Set,$=0,Q=0;for(let F of Z.getRoot().listMeshes())for(let z of F.listPrimitives())if(!z.getIndices())Y.add(z),$++;else if(z.getMode()!==eJ.Mode.TRIANGLES)Y.add(z),Q++;else X.add(z);if($>0)J.warn(`[${E8}] Skipping Draco compression of ${$} non-indexed primitives.`);if(Q>0)J.warn(`[${E8}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),G=new Map;for(let F=0;F<K.length;F++)G.set(K[F],F);let W=new Map,H=new Set,V=new Map;for(let F of Array.from(X)){let z=Nr(F,G);if(H.has(z)){V.set(F,z);continue}if(W.has(F.getIndices())){let q=F.getIndices(),U=q.clone();G.set(U,Z.getRoot().listAccessors().length-1),F.swap(q,U)}for(let q of F.listAttributes())if(W.has(q)){let U=q.clone();G.set(U,Z.getRoot().listAccessors().length-1),F.swap(q,U)}z=Nr(F,G),H.add(z),V.set(F,z),W.set(F.getIndices(),z);for(let q of F.listAttributes())W.set(q,z)}for(let F of Array.from(W.keys())){let z=new Set(F.listParents().map((q)=>q.propertyType));if(z.size!==2||!z.has(s.PRIMITIVE)||!z.has(s.ROOT))throw new Error(`[${E8}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let F of Array.from(X)){let z=V.get(F),q=F.getIndices();if(W.get(q)!==z||F.listAttributes().some((U)=>W.get(U)!==z))throw new Error(`[${E8}] Draco primitives must share all, or no, accessors.`)}for(let F of Array.from(Y)){let z=F.getIndices();if(W.has(z)||F.listAttributes().some((q)=>W.has(q)))throw new Error(`[${E8}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return V}function Nr(Z,J){let X=[],Y=Z.getIndices();X.push(J.get(Y));for(let $ of Z.listAttributes())X.push(J.get($));return X.sort().join("|")}class HG extends s1{init(){this.extensionName=YE,this.propertyType="Light",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:HG.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)}}HG.EXTENSION_NAME=YE;HG.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};var S7=YE;class OE extends I1{constructor(...Z){super(...Z);this.extensionName=S7}createLight(Z=""){return new HG(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[S7])return this;let $=(J.json.extensions[S7].lights||[]).map((Q)=>{var K,G;let W=this.createLight().setName(Q.name||"").setType(Q.type);if(Q.color!==void 0)W.setColor(Q.color);if(Q.intensity!==void 0)W.setIntensity(Q.intensity);if(Q.range!==void 0)W.setRange(Q.range);if(((K=Q.spot)==null?void 0:K.innerConeAngle)!==void 0)W.setInnerConeAngle(Q.spot.innerConeAngle);if(((G=Q.spot)==null?void 0:G.outerConeAngle)!==void 0)W.setOuterConeAngle(Q.spot.outerConeAngle);return W});return J.json.nodes.forEach((Q,K)=>{if(!Q.extensions||!Q.extensions[S7])return;let G=Q.extensions[S7];Z.nodes[K].setExtension(S7,$[G.light])}),this}write(Z){let J=Z.jsonDoc;if(this.properties.size===0)return this;let X=[],Y=new Map;for(let $ of this.properties){let Q=$,K={type:Q.getType()};if(!z8.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()===HG.Type.SPOT)K.spot={innerConeAngle:Q.getInnerConeAngle(),outerConeAngle:Q.getOuterConeAngle()};X.push(K),Y.set(Q,X.length-1)}return this.document.getRoot().listNodes().forEach(($)=>{let Q=$.getExtension(S7);if(Q){let K=Z.nodeIndexMap.get($),G=J.json.nodes[K];G.extensions=G.extensions||{},G.extensions[S7]={light:Y.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[S7]={lights:X},this}}OE.EXTENSION_NAME=S7;var{R:cD1,G:lD1,B:pD1}=Y9;class ME extends s1{init(){this.extensionName=$E,this.propertyType="Anisotropy",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new T1(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:cD1|lD1|pD1})}}ME.EXTENSION_NAME=$E;var $$=$E;class RE extends I1{constructor(...Z){super(...Z);this.extensionName=$$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createAnisotropy(){return new ME(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[$$]){let K=this.createAnisotropy();Z.materials[Q].setExtension($$,K);let G=$.extensions[$$];if(G.anisotropyStrength!==void 0)K.setAnisotropyStrength(G.anisotropyStrength);if(G.anisotropyRotation!==void 0)K.setAnisotropyRotation(G.anisotropyRotation);if(G.anisotropyTexture!==void 0){let W=G.anisotropyTexture,H=Z.textures[Y[W.index].source];K.setAnisotropyTexture(H),Z.setTextureInfo(K.getAnisotropyTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension($$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[$$]={};if(Y.getAnisotropyStrength()>0)K.anisotropyStrength=Y.getAnisotropyStrength();if(Y.getAnisotropyRotation()!==0)K.anisotropyRotation=Y.getAnisotropyRotation();if(Y.getAnisotropyTexture()){let G=Y.getAnisotropyTexture(),W=Y.getAnisotropyTextureInfo();K.anisotropyTexture=Z.createTextureInfoDef(G,W)}}}),this}}RE.EXTENSION_NAME=$$;var{R:Pr,G:Dr,B:iD1}=Y9;class NE extends s1{init(){this.extensionName=QE,this.propertyType="Clearcoat",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new T1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new T1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new T1(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:Pr})}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:Dr})}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:Pr|Dr|iD1})}}NE.EXTENSION_NAME=QE;var Q$=QE;class PE extends I1{constructor(...Z){super(...Z);this.extensionName=Q$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createClearcoat(){return new NE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[Q$]){let K=this.createClearcoat();Z.materials[Q].setExtension(Q$,K);let G=$.extensions[Q$];if(G.clearcoatFactor!==void 0)K.setClearcoatFactor(G.clearcoatFactor);if(G.clearcoatRoughnessFactor!==void 0)K.setClearcoatRoughnessFactor(G.clearcoatRoughnessFactor);if(G.clearcoatTexture!==void 0){let W=G.clearcoatTexture,H=Z.textures[Y[W.index].source];K.setClearcoatTexture(H),Z.setTextureInfo(K.getClearcoatTextureInfo(),W)}if(G.clearcoatRoughnessTexture!==void 0){let W=G.clearcoatRoughnessTexture,H=Z.textures[Y[W.index].source];K.setClearcoatRoughnessTexture(H),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),W)}if(G.clearcoatNormalTexture!==void 0){let W=G.clearcoatNormalTexture,H=Z.textures[Y[W.index].source];if(K.setClearcoatNormalTexture(H),Z.setTextureInfo(K.getClearcoatNormalTextureInfo(),W),W.scale!==void 0)K.setClearcoatNormalScale(W.scale)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(Q$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[Q$]={clearcoatFactor:Y.getClearcoatFactor(),clearcoatRoughnessFactor:Y.getClearcoatRoughnessFactor()};if(Y.getClearcoatTexture()){let G=Y.getClearcoatTexture(),W=Y.getClearcoatTextureInfo();K.clearcoatTexture=Z.createTextureInfoDef(G,W)}if(Y.getClearcoatRoughnessTexture()){let G=Y.getClearcoatRoughnessTexture(),W=Y.getClearcoatRoughnessTextureInfo();K.clearcoatRoughnessTexture=Z.createTextureInfoDef(G,W)}if(Y.getClearcoatNormalTexture()){let G=Y.getClearcoatNormalTexture(),W=Y.getClearcoatNormalTextureInfo();if(K.clearcoatNormalTexture=Z.createTextureInfoDef(G,W),Y.getClearcoatNormalScale()!==1)K.clearcoatNormalTexture.scale=Y.getClearcoatNormalScale()}}}),this}}PE.EXTENSION_NAME=Q$;var{R:nD1,G:aD1,B:sD1,A:oD1}=Y9;class DE extends s1{init(){this.extensionName=KE,this.propertyType="DiffuseTransmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new T1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new T1(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:oD1})}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:nD1|aD1|sD1})}}DE.EXTENSION_NAME=KE;var K$=KE;class CE extends I1{constructor(...Z){super(...Z);this.extensionName=K$}createDiffuseTransmission(){return new DE(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[K$]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(K$,K);let G=$.extensions[K$];if(G.diffuseTransmissionFactor!==void 0)K.setDiffuseTransmissionFactor(G.diffuseTransmissionFactor);if(G.diffuseTransmissionColorFactor!==void 0)K.setDiffuseTransmissionColorFactor(G.diffuseTransmissionColorFactor);if(G.diffuseTransmissionTexture!==void 0){let W=G.diffuseTransmissionTexture,H=Z.textures[Y[W.index].source];K.setDiffuseTransmissionTexture(H),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),W)}if(G.diffuseTransmissionColorTexture!==void 0){let W=G.diffuseTransmissionColorTexture,H=Z.textures[Y[W.index].source];K.setDiffuseTransmissionColorTexture(H),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),W)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let Y=X.getExtension(K$);if(!Y)continue;let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[K$]={diffuseTransmissionFactor:Y.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:Y.getDiffuseTransmissionColorFactor()};if(Y.getDiffuseTransmissionTexture()){let G=Y.getDiffuseTransmissionTexture(),W=Y.getDiffuseTransmissionTextureInfo();K.diffuseTransmissionTexture=Z.createTextureInfoDef(G,W)}if(Y.getDiffuseTransmissionColorTexture()){let G=Y.getDiffuseTransmissionColorTexture(),W=Y.getDiffuseTransmissionColorTextureInfo();K.diffuseTransmissionColorTexture=Z.createTextureInfoDef(G,W)}}return this}}CE.EXTENSION_NAME=K$;class TE extends s1{init(){this.extensionName=GE,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)}}TE.EXTENSION_NAME=GE;var G$=GE;class EE extends I1{constructor(...Z){super(...Z);this.extensionName=G$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createDispersion(){return new TE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[G$]){let Q=this.createDispersion();Z.materials[$].setExtension(G$,Q);let K=Y.extensions[G$];if(K.dispersion!==void 0)Q.setDispersion(K.dispersion)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(G$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[G$]={dispersion:Y.getDispersion()}}}),this}}EE.EXTENSION_NAME=G$;class kE extends s1{init(){this.extensionName=WE,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)}}kE.EXTENSION_NAME=WE;var W$=WE;class IE extends I1{constructor(...Z){super(...Z);this.extensionName=W$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createEmissiveStrength(){return new kE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[W$]){let Q=this.createEmissiveStrength();Z.materials[$].setExtension(W$,Q);let K=Y.extensions[W$];if(K.emissiveStrength!==void 0)Q.setEmissiveStrength(K.emissiveStrength)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(W$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[W$]={emissiveStrength:Y.getEmissiveStrength()}}}),this}}IE.EXTENSION_NAME=W$;class _E extends s1{init(){this.extensionName=HE,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)}}_E.EXTENSION_NAME=HE;var H$=HE;class m2 extends I1{constructor(...Z){super(...Z);this.extensionName=H$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIOR(){return new _E(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[H$]){let Q=this.createIOR();Z.materials[$].setExtension(H$,Q);let K=Y.extensions[H$];if(K.ior!==void 0)Q.setIOR(K.ior)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(H$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[H$]={ior:Y.getIOR()}}}),this}}m2.EXTENSION_NAME=H$;var{R:rD1,G:tD1}=Y9;class SE extends s1{init(){this.extensionName=VE,this.propertyType="Iridescence",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new T1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new T1(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:rD1})}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:tD1})}}SE.EXTENSION_NAME=VE;var V$=VE;class vE extends I1{constructor(...Z){super(...Z);this.extensionName=V$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIridescence(){return new SE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[V$]){let K=this.createIridescence();Z.materials[Q].setExtension(V$,K);let G=$.extensions[V$];if(G.iridescenceFactor!==void 0)K.setIridescenceFactor(G.iridescenceFactor);if(G.iridescenceIor!==void 0)K.setIridescenceIOR(G.iridescenceIor);if(G.iridescenceThicknessMinimum!==void 0)K.setIridescenceThicknessMinimum(G.iridescenceThicknessMinimum);if(G.iridescenceThicknessMaximum!==void 0)K.setIridescenceThicknessMaximum(G.iridescenceThicknessMaximum);if(G.iridescenceTexture!==void 0){let W=G.iridescenceTexture,H=Z.textures[Y[W.index].source];K.setIridescenceTexture(H),Z.setTextureInfo(K.getIridescenceTextureInfo(),W)}if(G.iridescenceThicknessTexture!==void 0){let W=G.iridescenceThicknessTexture,H=Z.textures[Y[W.index].source];K.setIridescenceThicknessTexture(H),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(V$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[V$]={};if(Y.getIridescenceFactor()>0)K.iridescenceFactor=Y.getIridescenceFactor();if(Y.getIridescenceIOR()!==1.3)K.iridescenceIor=Y.getIridescenceIOR();if(Y.getIridescenceThicknessMinimum()!==100)K.iridescenceThicknessMinimum=Y.getIridescenceThicknessMinimum();if(Y.getIridescenceThicknessMaximum()!==400)K.iridescenceThicknessMaximum=Y.getIridescenceThicknessMaximum();if(Y.getIridescenceTexture()){let G=Y.getIridescenceTexture(),W=Y.getIridescenceTextureInfo();K.iridescenceTexture=Z.createTextureInfoDef(G,W)}if(Y.getIridescenceThicknessTexture()){let G=Y.getIridescenceThicknessTexture(),W=Y.getIridescenceThicknessTextureInfo();K.iridescenceThicknessTexture=Z.createTextureInfoDef(G,W)}}}),this}}vE.EXTENSION_NAME=V$;var{R:Cr,G:Tr,B:Er,A:kr}=Y9;class AE extends s1{init(){this.extensionName=zE,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new T1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new T1(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:Cr|Tr|Er|kr,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:Cr|Tr|Er|kr})}}AE.EXTENSION_NAME=zE;var z$=zE;class u2 extends I1{constructor(...Z){super(...Z);this.extensionName=z$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createPBRSpecularGlossiness(){return new AE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[z$]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(z$,K);let G=$.extensions[z$];if(G.diffuseFactor!==void 0)K.setDiffuseFactor(G.diffuseFactor);if(G.specularFactor!==void 0)K.setSpecularFactor(G.specularFactor);if(G.glossinessFactor!==void 0)K.setGlossinessFactor(G.glossinessFactor);if(G.diffuseTexture!==void 0){let W=G.diffuseTexture,H=Z.textures[Y[W.index].source];K.setDiffuseTexture(H),Z.setTextureInfo(K.getDiffuseTextureInfo(),W)}if(G.specularGlossinessTexture!==void 0){let W=G.specularGlossinessTexture,H=Z.textures[Y[W.index].source];K.setSpecularGlossinessTexture(H),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(z$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[z$]={diffuseFactor:Y.getDiffuseFactor(),specularFactor:Y.getSpecularFactor(),glossinessFactor:Y.getGlossinessFactor()};if(Y.getDiffuseTexture()){let G=Y.getDiffuseTexture(),W=Y.getDiffuseTextureInfo();K.diffuseTexture=Z.createTextureInfoDef(G,W)}if(Y.getSpecularGlossinessTexture()){let G=Y.getSpecularGlossinessTexture(),W=Y.getSpecularGlossinessTextureInfo();K.specularGlossinessTexture=Z.createTextureInfoDef(G,W)}}}),this}}u2.EXTENSION_NAME=z$;var{R:eD1,G:ZC1,B:JC1,A:XC1}=Y9;class xE extends s1{init(){this.extensionName=FE,this.propertyType="Sheen",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new T1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new T1(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:eD1|ZC1|JC1,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:XC1})}}xE.EXTENSION_NAME=FE;var F$=FE;class hE extends I1{constructor(...Z){super(...Z);this.extensionName=F$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSheen(){return new xE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[F$]){let K=this.createSheen();Z.materials[Q].setExtension(F$,K);let G=$.extensions[F$];if(G.sheenColorFactor!==void 0)K.setSheenColorFactor(G.sheenColorFactor);if(G.sheenRoughnessFactor!==void 0)K.setSheenRoughnessFactor(G.sheenRoughnessFactor);if(G.sheenColorTexture!==void 0){let W=G.sheenColorTexture,H=Z.textures[Y[W.index].source];K.setSheenColorTexture(H),Z.setTextureInfo(K.getSheenColorTextureInfo(),W)}if(G.sheenRoughnessTexture!==void 0){let W=G.sheenRoughnessTexture,H=Z.textures[Y[W.index].source];K.setSheenRoughnessTexture(H),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(F$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[F$]={sheenColorFactor:Y.getSheenColorFactor(),sheenRoughnessFactor:Y.getSheenRoughnessFactor()};if(Y.getSheenColorTexture()){let G=Y.getSheenColorTexture(),W=Y.getSheenColorTextureInfo();K.sheenColorTexture=Z.createTextureInfoDef(G,W)}if(Y.getSheenRoughnessTexture()){let G=Y.getSheenRoughnessTexture(),W=Y.getSheenRoughnessTextureInfo();K.sheenRoughnessTexture=Z.createTextureInfoDef(G,W)}}}),this}}hE.EXTENSION_NAME=F$;var{R:YC1,G:$C1,B:QC1,A:KC1}=Y9;class fE extends s1{init(){this.extensionName=qE,this.propertyType="Specular",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new T1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new T1(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:KC1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:YC1|$C1|QC1,isColor:!0})}}fE.EXTENSION_NAME=qE;var q$=qE;class d2 extends I1{constructor(...Z){super(...Z);this.extensionName=q$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSpecular(){return new fE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[q$]){let K=this.createSpecular();Z.materials[Q].setExtension(q$,K);let G=$.extensions[q$];if(G.specularFactor!==void 0)K.setSpecularFactor(G.specularFactor);if(G.specularColorFactor!==void 0)K.setSpecularColorFactor(G.specularColorFactor);if(G.specularTexture!==void 0){let W=G.specularTexture,H=Z.textures[Y[W.index].source];K.setSpecularTexture(H),Z.setTextureInfo(K.getSpecularTextureInfo(),W)}if(G.specularColorTexture!==void 0){let W=G.specularColorTexture,H=Z.textures[Y[W.index].source];K.setSpecularColorTexture(H),Z.setTextureInfo(K.getSpecularColorTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(q$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[q$]={};if(Y.getSpecularFactor()!==1)K.specularFactor=Y.getSpecularFactor();if(!z8.eq(Y.getSpecularColorFactor(),[1,1,1]))K.specularColorFactor=Y.getSpecularColorFactor();if(Y.getSpecularTexture()){let G=Y.getSpecularTexture(),W=Y.getSpecularTextureInfo();K.specularTexture=Z.createTextureInfoDef(G,W)}if(Y.getSpecularColorTexture()){let G=Y.getSpecularColorTexture(),W=Y.getSpecularColorTextureInfo();K.specularColorTexture=Z.createTextureInfoDef(G,W)}}}),this}}d2.EXTENSION_NAME=q$;var{R:GC1}=Y9;class yE extends s1{init(){this.extensionName=UE,this.propertyType="Transmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new T1(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:GC1})}}yE.EXTENSION_NAME=UE;var U$=UE;class bE extends I1{constructor(...Z){super(...Z);this.extensionName=U$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createTransmission(){return new yE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[U$]){let K=this.createTransmission();Z.materials[Q].setExtension(U$,K);let G=$.extensions[U$];if(G.transmissionFactor!==void 0)K.setTransmissionFactor(G.transmissionFactor);if(G.transmissionTexture!==void 0){let W=G.transmissionTexture,H=Z.textures[Y[W.index].source];K.setTransmissionTexture(H),Z.setTextureInfo(K.getTransmissionTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(U$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[U$]={transmissionFactor:Y.getTransmissionFactor()};if(Y.getTransmissionTexture()){let G=Y.getTransmissionTexture(),W=Y.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(G,W)}}}),this}}bE.EXTENSION_NAME=U$;class gE extends s1{init(){this.extensionName=LE,this.propertyType="Unlit",this.parentTypes=[s.MATERIAL]}}gE.EXTENSION_NAME=LE;var GG=LE;class c2 extends I1{constructor(...Z){super(...Z);this.extensionName=GG,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createUnlit(){return new gE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((X,Y)=>{if(X.extensions&&X.extensions[GG])Z.materials[Y].setExtension(GG,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(GG)){let Y=Z.materialIndexMap.get(X),$=J.json.materials[Y];$.extensions=$.extensions||{},$.extensions[GG]={}}}),this}}c2.EXTENSION_NAME=GG;class mE extends s1{init(){this.extensionName=w$,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new E0})}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")}}mE.EXTENSION_NAME=w$;class uE extends s1{init(){this.extensionName=w$,this.propertyType="MappingList",this.parentTypes=[s.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new E0})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}uE.EXTENSION_NAME=w$;class f2 extends s1{init(){this.extensionName=w$,this.propertyType="Variant",this.parentTypes=["MappingList"]}}f2.EXTENSION_NAME=w$;var v7=w$;class dE extends I1{constructor(...Z){super(...Z);this.extensionName=v7}createMappingList(){return new uE(this.document.getGraph())}createVariant(Z=""){return new f2(this.document.getGraph(),Z)}createMapping(){return new mE(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof f2)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[v7])return this;let $=(J.json.extensions[v7].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,G)=>{let W=Z.meshes[G];(K.primitives||[]).forEach((V,F)=>{if(!V.extensions||!V.extensions[v7])return;let z=this.createMappingList(),q=V.extensions[v7];for(let U of q.mappings){let B=this.createMapping();if(U.material!==void 0)B.setMaterial(Z.materials[U.material]);for(let L of U.variants||[])B.addVariant($[L]);z.addMapping(B)}W.listPrimitives()[F].setExtension(v7,z)})}),this}write(Z){let J=Z.jsonDoc,X=this.listVariants();if(!X.length)return this;let Y=[],$=new Map;for(let Q of X)$.set(Q,Y.length),Y.push(Z.createPropertyDef(Q));for(let Q of this.document.getRoot().listMeshes()){let K=Z.meshIndexMap.get(Q);Q.listPrimitives().forEach((G,W)=>{let H=G.getExtension(v7);if(!H)return;let V=Z.jsonDoc.json.meshes[K].primitives[W],F=H.listMappings().map((z)=>{let q=Z.createPropertyDef(z),U=z.getMaterial();if(U)q.material=Z.materialIndexMap.get(U);return q.variants=z.listVariants().map((B)=>$.get(B)),q});V.extensions=V.extensions||{},V.extensions[v7]={mappings:F}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[v7]={variants:Y},this}}dE.EXTENSION_NAME=v7;var{G:WC1}=Y9;class cE extends s1{init(){this.extensionName=BE,this.propertyType="Volume",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new T1(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:WC1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}cE.EXTENSION_NAME=BE;var L$=BE;class lE extends I1{constructor(...Z){super(...Z);this.extensionName=L$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createVolume(){return new cE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[L$]){let K=this.createVolume();Z.materials[Q].setExtension(L$,K);let G=$.extensions[L$];if(G.thicknessFactor!==void 0)K.setThicknessFactor(G.thicknessFactor);if(G.attenuationDistance!==void 0)K.setAttenuationDistance(G.attenuationDistance);if(G.attenuationColor!==void 0)K.setAttenuationColor(G.attenuationColor);if(G.thicknessTexture!==void 0){let W=G.thicknessTexture,H=Z.textures[Y[W.index].source];K.setThicknessTexture(H),Z.setTextureInfo(K.getThicknessTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(L$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[L$]={};if(Y.getThicknessFactor()>0)K.thicknessFactor=Y.getThicknessFactor();if(Number.isFinite(Y.getAttenuationDistance()))K.attenuationDistance=Y.getAttenuationDistance();if(!z8.eq(Y.getAttenuationColor(),[1,1,1]))K.attenuationColor=Y.getAttenuationColor();if(Y.getThicknessTexture()){let G=Y.getThicknessTexture(),W=Y.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(G,W)}}}),this}}lE.EXTENSION_NAME=L$;var fr=PD1;class HV extends I1{constructor(...Z){super(...Z);this.extensionName=fr}read(Z){return this}write(Z){return this}}HV.EXTENSION_NAME=fr;var $V=DD1;class yr{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=A2(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=A2(Z).dataFormatDescriptor[0];if(X.colorModel===Ur)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===Lr)return(X.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=A2(Z),X=this.getChannels(Z)>3,Y=0;for(let $=0;$<J.levels.length;$++){let Q=J.levels[$];if(Q.uncompressedByteLength)Y+=Q.uncompressedByteLength;else{let K=Math.max(1,Math.floor(J.pixelWidth/Math.pow(2,$))),G=Math.max(1,Math.floor(J.pixelHeight/Math.pow(2,$))),W=X?16:8;Y+=K/4*(G/4)*W}}return Y}}class pE extends I1{constructor(...Z){super(...Z);this.extensionName=$V,this.prereadTypes=[s.TEXTURE]}static register(){h4.registerFormat("image/ktx2",new yr)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[$V]){let X=J.extensions[$V];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 Y=Z.imageIndexMap.get(X);J.json.textures.forEach(($)=>{if($.source===Y)$.extensions=$.extensions||{},$.extensions[$V]={source:$.source},delete $.source})}}),this}}pE.EXTENSION_NAME=$V;class iE extends s1{init(){this.extensionName=wE,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)}}iE.EXTENSION_NAME=wE;var B$=wE;class nE extends I1{constructor(...Z){super(...Z);this.extensionName=B$}createTransform(){return new iE(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[B$])continue;let Y=this.createTransform(),$=X.extensions[B$];if($.offset!==void 0)Y.setOffset($.offset);if($.rotation!==void 0)Y.setRotation($.rotation);if($.scale!==void 0)Y.setScale($.scale);if($.texCoord!==void 0)Y.setTexCoord($.texCoord);J.setExtension(B$,Y)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,Y]of J){let $=X.getExtension(B$);if(!$)continue;Y.extensions=Y.extensions||{};let Q={},K=z8.eq;if(!K($.getOffset(),[0,0]))Q.offset=$.getOffset();if($.getRotation()!==0)Q.rotation=$.getRotation();if(!K($.getScale(),[1,1]))Q.scale=$.getScale();if($.getTexCoord()!=null)Q.texCoord=$.getTexCoord();Y.extensions[B$]=Q}return this}}nE.EXTENSION_NAME=B$;var HC1=[s.ROOT,s.SCENE,s.NODE,s.MESH,s.MATERIAL,s.TEXTURE,s.ANIMATION];class aE extends s1{init(){this.extensionName=x2,this.propertyType="Packet",this.parentTypes=HC1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",AZ({},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=AZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=tT(this.get("context")),J=tT(this.get("properties"));return AZ({"@context":Z},J)}fromJSONLD(Z){Z=tT(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(`${x2}: Missing context for term, "${Z}".`)}}aE.EXTENSION_NAME=x2;function tT(Z){return JSON.parse(JSON.stringify(Z))}var vZ=x2;class sE extends I1{constructor(...Z){super(...Z);this.extensionName=vZ}createPacket(){return new aE(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[vZ];if(!X||!X.packets)return this;let Y=Z.jsonDoc.json,$=this.document.getRoot(),Q=X.packets.map((W)=>this.createPacket().fromJSONLD(W)),K=[[Y.asset],Y.scenes,Y.nodes,Y.meshes,Y.materials,Y.images,Y.animations],G=[[$],$.listScenes(),$.listNodes(),$.listMeshes(),$.listMaterials(),$.listTextures(),$.listAnimations()];for(let W=0;W<K.length;W++){let H=K[W]||[];for(let V=0;V<H.length;V++){let F=H[V];if(F.extensions&&F.extensions[vZ]){let z=F.extensions[vZ];G[W][V].setExtension(vZ,Q[z.packet])}}}return this}write(Z){let{json:J}=Z.jsonDoc,X=[];for(let Y of this.properties){X.push(Y.toJSONLD());for(let $ of Y.listParents()){let Q;switch($.propertyType){case s.ROOT:Q=J.asset;break;case s.SCENE:Q=J.scenes[Z.sceneIndexMap.get($)];break;case s.NODE:Q=J.nodes[Z.nodeIndexMap.get($)];break;case s.MESH:Q=J.meshes[Z.meshIndexMap.get($)];break;case s.MATERIAL:Q=J.materials[Z.materialIndexMap.get($)];break;case s.TEXTURE:Q=J.images[Z.imageIndexMap.get($)];break;case s.ANIMATION:Q=J.animations[Z.animationIndexMap.get($)];break;default:Q=null,this.document.getLogger().warn(`[${vZ}]: Unsupported parent property, "${$.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[vZ]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[vZ]={packets:X};return this}}sE.EXTENSION_NAME=vZ;var VC1=[WV,OE,RE,PE,CE,EE,IE,m2,vE,u2,d2,hE,bE,c2,dE,lE,HV,pE,nE,sE],vS6=[y2,GV,b2,g2,...VC1];var zC1=r(zT(),1);function FG(){return FG=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},FG.apply(null,arguments)}var{POINTS:br,LINES:l2,LINE_STRIP:FC1,LINE_LOOP:qC1,TRIANGLES:p2,TRIANGLE_STRIP:UC1,TRIANGLE_FAN:LC1}=C8.Mode;function $X(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function A7(Z,J){let X=FG({},Z);for(let Y in J)if(J[Y]!==void 0)X[Y]=J[Y];return X}function $t(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case C8.Mode.POINTS:return J?J.getCount():X.getCount();case C8.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case C8.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case C8.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case C8.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case C8.Mode.TRIANGLE_STRIP:case C8.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw new Error("Unexpected mode: "+Z.getMode())}}var BC1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function eE(Z){return BC1.format(Z)}function wC1(Z,J,X=2){let Y=Z>J?"–":"+",$="%";return Y+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function o2(Z,J){return`${eE(Z)} → ${eE(J)} (${wC1(Z,J)})`}function Kk(Z){let J=[];for(let X of Z.listAttributes())J.push(X);for(let X of Z.listTargets())for(let Y of X.listAttributes())J.push(Y);return Array.from(new Set(J))}function jC1(Z,J,X){Z.swap(J,X);for(let Y of Z.listTargets())Y.swap(J,X)}function OC1(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 xZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function MC1(Z,J=Z){let X=Gk(Z,J);for(let Y=0;Y<X.length;Y++)X[Y]=Y;return X}function Gk(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function RC1(Z){return Z.listParents().some((J)=>J.propertyType!==a.ROOT)}function Qt(Z){for(let J in Z)return!1;return!0}function Kt(Z){let J=_6.fromGraph(Z.getGraph()),X=Z.getMaterial(),Y=J.getRoot().listMaterials().indexOf(X),$=PC1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((W)=>{let H=Z.getAttribute(W),V=H.getElementSize(),F=H.getComponentType();return`${W}:${V}:${F}`}).join("+"),G=Z.listTargets().map((W)=>{return W.listSemantics().sort().map((H)=>{let V=Z.getAttribute(H),F=V.getElementSize(),z=V.getComponentType();return`${H}:${F}:${z}`}).join("+")}).join("~");return`${Y}|${$}|${Q}|${K}|${G}`}function NC1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var PC1={[br]:br,[l2]:l2,[FC1]:l2,[qC1]:l2,[p2]:p2,[UC1]:p2,[LC1]:p2},VG="center",gr={pivot:"center"};function Gt(Z=gr){let J=A7(gr,Z);return $X(VG,(X)=>{let Y=X.getLogger(),$=X.getRoot(),Q=$.listAnimations().length>0||$.listSkins().length>0;X.getRoot().listScenes().forEach((K,G)=>{Y.debug(`${VG}: Scene ${G+1} / ${$.listScenes().length}.`);let W;if(typeof J.pivot==="string"){let V=$T(K);if(W=[(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")W[1]=V.max[1];if(J.pivot==="below")W[1]=V.min[1]}else W=J.pivot;Y.debug(`${VG}: Pivot "${W.join(", ")}".`);let H=[-1*W[0],-1*W[1],-1*W[2]];if(Q){Y.debug(`${VG}: Model contains animation or skin. Adding a wrapper node.`);let V=X.createNode("Pivot").setTranslation(H);K.listChildren().forEach((F)=>V.addChild(F)),K.addChild(V)}else Y.debug(`${VG}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((V)=>{let F=V.getTranslation();V.setTranslation([F[0]+H[0],F[1]+H[1],F[2]+H[2]])})}),Y.debug(`${VG}: Complete.`)})}function DC1(Z){let J=new Set,X=Z,Y;while(Y=X.getParentNode()){if(J.has(Y))throw new Error("Circular dependency in scene graph.");J.add(Y),X=Y}return X.listParents().filter(($)=>$ instanceof sK)}function CC1(Z){let J=DC1(Z),X=Z.getParentNode();if(!X)return Z;Z.setMatrix(Z.getWorldMatrix()),X.removeChild(Z);for(let Y of J)Y.addChild(Z);return Z}var qG=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 TC1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],G=J[5],W=J[6],H=J[7],V=J[8],F=J[9],z=J[10],q=J[11],U=J[12],B=J[13],L=J[14],w=J[15],O=X*G-Y*K,M=X*W-$*K,R=X*H-Q*K,D=Y*W-$*G,N=Y*H-Q*G,C=$*H-Q*W,T=V*B-F*U,E=V*L-z*U,A=V*w-q*U,S=F*L-z*B,x=F*w-q*B,I=z*w-q*L,_=O*I-M*x+R*S+D*A-N*E+C*T;if(!_)return null;return _=1/_,Z[0]=(G*I-W*x+H*S)*_,Z[1]=($*x-Y*I-Q*S)*_,Z[2]=(B*C-L*N+w*D)*_,Z[3]=(z*N-F*C-q*D)*_,Z[4]=(W*A-K*I-H*E)*_,Z[5]=(X*I-$*A+Q*E)*_,Z[6]=(L*R-U*C-w*M)*_,Z[7]=(V*C-z*R+q*M)*_,Z[8]=(K*x-G*A+H*T)*_,Z[9]=(Y*A-X*x-Q*T)*_,Z[10]=(U*N-B*R+w*O)*_,Z[11]=(F*R-V*N-q*O)*_,Z[12]=(G*E-K*S-W*T)*_,Z[13]=(X*S-Y*E+$*T)*_,Z[14]=(B*M-U*D-L*O)*_,Z[15]=(V*D-F*M+z*O)*_,Z}function EC1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],G=Z[6],W=Z[7],H=Z[8],V=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,O=J*G-Y*Q,M=J*W-$*Q,R=X*G-Y*K,D=X*W-$*K,N=Y*W-$*G,C=H*U-V*q,T=H*B-F*q,E=H*L-z*q,A=V*B-F*U,S=V*L-z*U,x=F*L-z*B;return w*x-O*S+M*A+R*E-D*T+N*C}function Wt(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],G=J[4],W=J[5],H=J[6],V=J[7],F=J[8],z=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],O=J[15],M=X[0],R=X[1],D=X[2],N=X[3];return Z[0]=M*Y+R*G+D*F+N*B,Z[1]=M*$+R*W+D*z+N*L,Z[2]=M*Q+R*H+D*q+N*w,Z[3]=M*K+R*V+D*U+N*O,M=X[4],R=X[5],D=X[6],N=X[7],Z[4]=M*Y+R*G+D*F+N*B,Z[5]=M*$+R*W+D*z+N*L,Z[6]=M*Q+R*H+D*q+N*w,Z[7]=M*K+R*V+D*U+N*O,M=X[8],R=X[9],D=X[10],N=X[11],Z[8]=M*Y+R*G+D*F+N*B,Z[9]=M*$+R*W+D*z+N*L,Z[10]=M*Q+R*H+D*q+N*w,Z[11]=M*K+R*V+D*U+N*O,M=X[12],R=X[13],D=X[14],N=X[15],Z[12]=M*Y+R*G+D*F+N*B,Z[13]=M*$+R*W+D*z+N*L,Z[14]=M*Q+R*H+D*q+N*w,Z[15]=M*K+R*V+D*U+N*O,Z}function kC1(){var Z=new qG(9);if(qG!=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 IC1(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 _C1(Z,J){if(Z===J){var X=J[1],Y=J[2],$=J[5];Z[1]=J[3],Z[2]=J[6],Z[3]=X,Z[5]=J[7],Z[6]=Y,Z[7]=$}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 SC1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],G=J[5],W=J[6],H=J[7],V=J[8],F=V*K-G*H,z=-V*Q+G*W,q=H*Q-K*W,U=X*F+Y*z+$*q;if(!U)return null;return U=1/U,Z[0]=F*U,Z[1]=(-V*Y+$*H)*U,Z[2]=(G*Y-$*K)*U,Z[3]=z*U,Z[4]=(V*X-$*W)*U,Z[5]=(-G*X+$*Q)*U,Z[6]=q*U,Z[7]=(-H*X+Y*W)*U,Z[8]=(K*X-Y*Q)*U,Z}function r2(){var Z=new qG(3);if(qG!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function vC1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function Ht(Z,J){var X=J[0],Y=J[1],$=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 AC1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}function xC1(Z,J,X){var Y=J[0],$=J[1],Q=J[2];return Z[0]=Y*X[0]+$*X[3]+Q*X[6],Z[1]=Y*X[1]+$*X[4]+Q*X[7],Z[2]=Y*X[2]+$*X[5]+Q*X[8],Z}var hC1=vC1;(function(){var Z=r2();return function(J,X,Y,$,Q,K){var G,W;if(!X)X=3;if(!Y)Y=0;if($)W=Math.min($*X+Y,J.length);else W=J.length;for(G=Y;G<W;G+=X)Z[0]=J[G],Z[1]=J[G+1],Z[2]=J[G+2],Q(Z,Z,K),J[G]=Z[0],J[G+1]=Z[1],J[G+2]=Z[2];return J}})();var XX="dedup",oE={keepUniqueNames:!1,propertyTypes:[a.ACCESSOR,a.MESH,a.TEXTURE,a.MATERIAL,a.SKIN]};function Vt(Z=oE){let J=A7(oE,Z),X=new Set(J.propertyTypes);for(let Y of J.propertyTypes)if(!oE.propertyTypes.includes(Y))throw new Error(`${XX}: Unsupported deduplication on type "${Y}".`);return $X(XX,(Y)=>{let $=Y.getLogger();if(X.has(a.ACCESSOR))fC1(Y);if(X.has(a.TEXTURE))bC1(Y,J);if(X.has(a.MATERIAL))gC1(Y,J);if(X.has(a.MESH))yC1(Y,J);if(X.has(a.SKIN))mC1(Y,J);$.debug(`${XX}: Complete.`)})}function fC1(Z){let J=Z.getLogger(),X=new Map,Y=new Map,$=new Map,Q=new Map,K=Z.getRoot().listMeshes();K.forEach((F)=>{F.listPrimitives().forEach((z)=>{z.listAttributes().forEach((q)=>G(q,Y)),G(z.getIndices(),X)})});for(let F of Z.getRoot().listAnimations())for(let z of F.listSamplers())G(z.getInput(),$),G(z.getOutput(),Q);function G(F,z){if(!F)return;let q=[F.getCount(),F.getType(),F.getComponentType(),F.getNormalized(),F.getSparse()].join(":"),U=z.get(q);if(!U)z.set(q,U=new Set);U.add(F)}function W(F,z){for(let q=0;q<F.length;q++){let U=F[q],B=o0.toView(U.getArray());if(z.has(U))continue;for(let L=q+1;L<F.length;L++){let w=F[L];if(z.has(w))continue;if(o0.equals(B,o0.toView(w.getArray())))z.set(w,U)}}}let H=0,V=new Map;for(let F of[Y,X,$,Q])for(let z of F.values())H+=z.size,W(Array.from(z),V);J.debug(`${XX}: Merged ${V.size} of ${H} accessors.`),K.forEach((F)=>{F.listPrimitives().forEach((z)=>{z.listAttributes().forEach((U)=>{if(V.has(U))z.swap(U,V.get(U))});let q=z.getIndices();if(q&&V.has(q))z.swap(q,V.get(q))})});for(let F of Z.getRoot().listAnimations())for(let z of F.listSamplers()){let q=z.getInput(),U=z.getOutput();if(q&&V.has(q))z.swap(q,V.get(q));if(U&&V.has(U))z.swap(U,V.get(U))}Array.from(V.keys()).forEach((F)=>F.dispose())}function yC1(Z,J){let X=Z.getLogger(),Y=Z.getRoot(),$=new Map;Y.listAccessors().forEach((G,W)=>$.set(G,W)),Y.listMaterials().forEach((G,W)=>$.set(G,W));let Q=Y.listMeshes().length,K=new Map;for(let G of Y.listMeshes()){let W=[];for(let V of G.listPrimitives())W.push(zt(V,$));let H="";if(J.keepUniqueNames)H+=G.getName()+";";if(H+=W.join(";"),K.has(H)){let V=K.get(H);G.listParents().forEach((F)=>{if(F.propertyType!==a.ROOT)F.swap(G,V)}),G.dispose()}else K.set(H,G)}X.debug(`${XX}: Merged ${Q-K.size} of ${Q} meshes.`)}function bC1(Z,J){let X=Z.getLogger(),Y=Z.getRoot(),$=Y.listTextures(),Q=new Map;for(let K=0;K<$.length;K++){let G=$[K],W=G.getImage();if(Q.has(G))continue;for(let H=K+1;H<$.length;H++){let V=$[H],F=V.getImage();if(Q.has(V))continue;if(G.getMimeType()!==V.getMimeType())continue;if(J.keepUniqueNames&&G.getName()!==V.getName())continue;let z=G.getSize(),q=V.getSize();if(!z||!q)continue;if(z[0]!==q[0])continue;if(z[1]!==q[1])continue;if(!W||!F)continue;if(o0.equals(W,F))Q.set(V,G)}}X.debug(`${XX}: Merged ${Q.size} of ${Y.listTextures().length} textures.`),Array.from(Q.entries()).forEach(([K,G])=>{K.listParents().forEach((W)=>{if(!(W instanceof tY))W.swap(K,G)}),K.dispose()})}function gC1(Z,J){let X=Z.getLogger(),$=Z.getRoot().listMaterials(),Q=new Map,K=new Map,G=new Set;if(!J.keepUniqueNames)G.add("name");for(let W=0;W<$.length;W++){let H=$[W];if(Q.has(H))continue;if(mr(H,K))continue;for(let V=W+1;V<$.length;V++){let F=$[V];if(Q.has(F))continue;if(mr(F,K))continue;if(H.equals(F,G))Q.set(F,H)}}X.debug(`${XX}: Merged ${Q.size} of ${$.length} materials.`),Array.from(Q.entries()).forEach(([W,H])=>{W.listParents().forEach((V)=>{if(!(V instanceof tY))V.swap(W,H)}),W.dispose()})}function mC1(Z,J){let X=Z.getLogger(),$=Z.getRoot().listSkins(),Q=new Map,K=new Set(["joints"]);if(!J.keepUniqueNames)K.add("name");for(let G=0;G<$.length;G++){let W=$[G];if(Q.has(W))continue;for(let H=G+1;H<$.length;H++){let V=$[H];if(Q.has(V))continue;if(W.equals(V,K)&&OC1(W.listJoints(),V.listJoints()))Q.set(V,W)}}X.debug(`${XX}: Merged ${Q.size} of ${$.length} skins.`),Array.from(Q.entries()).forEach(([G,W])=>{G.listParents().forEach((H)=>{if(!(H instanceof tY))H.swap(G,W)}),G.dispose()})}function zt(Z,J){let X=[];for(let Y of Z.listSemantics()){let $=Z.getAttribute(Y);X.push(Y+":"+J.get($))}if(Z instanceof C8){let Y=Z.getIndices();if(Y)X.push("indices:"+J.get(Y));let $=Z.getMaterial();if($)X.push("material:"+J.get($));X.push("mode:"+Z.getMode());for(let Q of Z.listTargets())X.push("target:"+zt(Q,J))}return X.join(",")}function mr(Z,J){if(J.has(Z))return J.get(Z);let X=Z.getGraph(),Y=new Set,$=X.listParentEdges(Z);while($.length>0){let Q=$.pop();if(Q.getAttributes().modifyChild===!0)return J.set(Z,!0),!0;let K=Q.getChild();if(Y.has(K))continue;for(let G of X.listChildEdges(K))$.push(G)}return J.set(Z,!1),!1}function Ft(){var Z=new qG(4);if(qG!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function uC1(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 dC1(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 cC1(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 lC1(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 pC1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return Math.hypot(J,X,Y,$)}var qt=dC1,iC1=cC1,Ut=pC1;(function(){var Z=Ft();return function(J,X,Y,$,Q,K){var G,W;if(!X)X=4;if(!Y)Y=0;if($)W=Math.min($*X+Y,J.length);else W=J.length;for(G=Y;G<W;G+=X)Z[0]=J[G],Z[1]=J[G+1],Z[2]=J[G+2],Z[3]=J[G+3],Q(Z,Z,K),J[G]=Z[0],J[G+1]=Z[1],J[G+2]=Z[2],J[G+3]=Z[3];return J}})();var nC1=/color|emissive|diffuse/i;function aC1(Z){return Z.getGraph().listParentEdges(Z).some(($)=>{return $.getAttributes().isColor||nC1.test($.getName())})?"srgb":null}function sC1(Z){let J=Z.getGraph(),X=new Set,Y=new Set;function $(Q){let K=new Set;for(let G of J.listChildEdges(Q))if(G.getChild()instanceof rY)K.add(G.getName()+"Info");for(let G of J.listChildEdges(Q)){let W=G.getChild();if(X.has(W))continue;if(X.add(W),W instanceof E5&&K.has(G.getName()))Y.add(W);else if(W instanceof aK)$(W)}}return $(Z),Array.from(Y)}function oC1(Z){let X=_6.fromGraph(Z.getGraph()).getRoot(),Y=Z.getGraph().listParentEdges(Z).filter(($)=>$.getParent()!==X).map(($)=>$.getName());return Array.from(new Set(Y))}var zG="prune",Zk=0.011764705882352941,ur={propertyTypes:[a.NODE,a.SKIN,a.MESH,a.CAMERA,a.PRIMITIVE,a.PRIMITIVE_TARGET,a.ANIMATION,a.MATERIAL,a.TEXTURE,a.ACCESSOR,a.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function t2(Z=ur){let J=A7(ur,Z),X=new Set(J.propertyTypes),Y=J.keepExtras;return $X(zG,async($)=>{let Q=$.getLogger(),K=$.getRoot(),G=$.getGraph(),W=new Lt,H=(V)=>W.dispose(V.target);if(G.addEventListener("node:dispose",H),X.has(a.MESH))for(let V of K.listMeshes()){if(V.listPrimitives().length>0)continue;V.dispose()}if(X.has(a.NODE)){if(!J.keepLeaves)for(let V of K.listScenes())Bt(G,V,Y);for(let V of K.listNodes())m9(V,Y)}if(X.has(a.SKIN))for(let V of K.listSkins())m9(V,Y);if(X.has(a.MESH))for(let V of K.listMeshes())m9(V,Y);if(X.has(a.CAMERA))for(let V of K.listCameras())m9(V,Y);if(X.has(a.PRIMITIVE))dr(G,a.PRIMITIVE,Y);if(X.has(a.PRIMITIVE_TARGET))dr(G,a.PRIMITIVE_TARGET,Y);if(!J.keepAttributes&&X.has(a.ACCESSOR)){let V=new Map;for(let F of K.listMeshes())for(let z of F.listPrimitives()){let q=z.getMaterial();if(!q)continue;let U=wt($,z,q),B=tC1(z,U);cr(z,B),z.listTargets().forEach((L)=>cr(L,B)),V.has(q)?V.get(q).add(z):V.set(q,new Set([z]))}for(let[F,z]of V)eC1(F,Array.from(z))}if(!J.keepIndices&&X.has(a.ACCESSOR))for(let V of K.listMeshes())for(let F of V.listPrimitives())rC1(F);if(X.has(a.ANIMATION))for(let V of K.listAnimations()){for(let F of V.listChannels())if(!F.getTargetNode())F.dispose();if(!V.listChannels().length){let F=V.listSamplers();m9(V,Y),F.forEach((z)=>m9(z,Y))}else V.listSamplers().forEach((F)=>m9(F,Y))}if(X.has(a.MATERIAL))K.listMaterials().forEach((V)=>m9(V,Y));if(X.has(a.TEXTURE)){if(K.listTextures().forEach((V)=>m9(V,Y)),!J.keepSolidTextures)await ZT1($)}if(X.has(a.ACCESSOR))K.listAccessors().forEach((V)=>m9(V,Y));if(X.has(a.BUFFER))K.listBuffers().forEach((V)=>m9(V,Y));if(G.removeEventListener("node:dispose",H),!W.empty()){let V=W.entries().map(([F,z])=>`${F} (${z})`).join(", ");Q.info(`${zG}: Removed types... ${V}`)}else Q.debug(`${zG}: No unused properties found.`);Q.debug(`${zG}: Complete.`)})}class Lt{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 m9(Z,J){let X=Z.listParents().filter(($)=>!($ instanceof tY||$ instanceof sY)),Y=J&&!Qt(Z.getExtras());if(!X.length&&!Y)Z.dispose()}function dr(Z,J,X){for(let Y of Z.listEdges()){let $=Y.getParent();if($.propertyType===J)m9($,X)}}function Bt(Z,J,X){if(J.listChildren().forEach((K)=>Bt(Z,K,X)),J instanceof sK)return;let Y=Z.listParentEdges(J).some((K)=>{let G=K.getParent().propertyType;return G!==a.ROOT&&G!==a.SCENE&&G!==a.NODE}),$=Z.listChildren(J).length===0,Q=X&&!Qt(J.getExtras());if($&&!Y&&!Q)J.dispose()}function cr(Z,J){for(let X of J)Z.setAttribute(X,null)}function rC1(Z){let J=Z.getIndices(),X=J&&J.getArray(),Y=Z.listAttributes()[0];if(!X||!Y)return;if(J.getCount()!==Y.getCount())return;for(let $=0,Q=X.length;$<Q;$++)if($!==X[$])return;Z.setIndices(null)}function tC1(Z,J){let X=[];for(let Y of Z.listSemantics())if(Y==="NORMAL"&&!J.has(Y))X.push(Y);else if(Y==="TANGENT"&&!J.has(Y))X.push(Y);else if(Y.startsWith("TEXCOORD_")&&!J.has(Y))X.push(Y);else if(Y.startsWith("COLOR_")&&Y!=="COLOR_0")X.push(Y);return X}function wt(Z,J,X,Y=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let H of Q)if(H.getChild()instanceof rY)K.add(H.getName());for(let H of Q){let V=H.getName(),F=H.getChild();if(F instanceof E5){if(K.has(V.replace(/Info$/,"")))Y.add(`TEXCOORD_${F.getTexCoord()}`)}if(F instanceof rY&&V.match(/normalTexture/i))Y.add("TANGENT");if(F instanceof aK)wt(Z,J,F,Y)}let G=X instanceof D7&&!X.getExtension("KHR_materials_unlit"),W=J.getMode()===C8.Mode.POINTS;if(G&&!W)Y.add("NORMAL");return Y}function eC1(Z,J){let X=sC1(Z),Y=new Set(X.map((W)=>W.getTexCoord())),$=Array.from(Y).sort(),Q=new Map($.map((W,H)=>[W,H])),K=new Map($.map((W,H)=>[`TEXCOORD_${W}`,`TEXCOORD_${H}`]));for(let W of X){let H=W.getTexCoord();W.setTexCoord(Q.get(H))}for(let W of J){let H=W.listSemantics().filter((V)=>V.startsWith("TEXCOORD_")).sort();G(W,H),W.listTargets().forEach((V)=>G(V,H))}function G(W,H){for(let V of H){let F=W.getAttribute(V);if(!F)continue;let z=K.get(V);if(z===V)continue;W.setAttribute(z,F),W.setAttribute(V,null)}}}async function ZT1(Z){let J=Z.getRoot(),X=Z.getGraph(),Y=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var G;let W=await XT1(K);if(!W)return;if(aC1(K)==="srgb")QT.convertSRGBToLinear(W,W);let H=K.getName()||K.getURI(),V=(G=K.getSize())==null?void 0:G.join("x"),F=oC1(K);for(let z of X.listParentEdges(K)){let q=z.getParent();if(q!==J&&JT1(q,W,z.getName(),Y))z.dispose()}if(K.listParents().length===1)K.dispose(),Y.debug(`${zG}: Removed solid-color texture "${H}" (${V}px ${F.join(", ")})`)});await Promise.all(Q)}function JT1(Z,J,X,Y){if(Z instanceof D7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(iC1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(hC1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=Zk;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return Ut(qt(Ft(),J,[0.5,0.5,1,1]))<=Zk}return Y.warn(`${zG}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function XT1(Z){let J=await YT1(Z);if(!J)return null;let X=[1/0,1/0,1/0,1/0],Y=[-1/0,-1/0,-1/0,-1/0],$=[0,0,0,0],[Q,K]=J.shape;for(let G=0;G<Q;G++){for(let W=0;W<K;W++)for(let H=0;H<4;H++)X[H]=Math.min(X[H],J.get(G,W,H)),Y[H]=Math.max(Y[H],J.get(G,W,H));if(Ut(qt($,Y,X))/255>Zk)return null}return lC1($,uC1($,Y,X),0.00196078431372549)}async function YT1(Z){try{return await Xr(Z.getImage(),Z.getMimeType())}catch(J){return null}}var JX=4294967295;class jt{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of Kk(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),Y=Z.getElementSize()*Z.getComponentSize(),$=o0.padNumber(Y);return this.attributes.push({u8:X,byteStride:Y,paddedByteStride:$}),$}hash(Z){let J=0;for(let{u8:X,byteStride:Y,paddedByteStride:$}of this.attributes){for(let Q=0;Q<$;Q++)if(Q<Y)this.u8[J+Q]=X[Z*Y+Q];else this.u8[J+Q]=0;J+=$}return $T1(0,this.u32)}equal(Z,J){for(let{u8:X,byteStride:Y}of this.attributes)for(let $=0;$<Y;$++)if(X[Z*Y+$]!==X[J*Y+$])return!1;return!0}}function $T1(Z,J){for(let $=0,Q=J.length;$<Q;$++){let K=J[$];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 QT1(Z,J,X,Y,$=JX){let Q=J-1,G=X.hash(Y)&Q;for(let W=0;W<=Q;W++){let H=Z[G];if(H===$||X.equal(H,Y))return G;G=G+W+1&Q}throw new Error("Hash table full.")}var w6;(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"})(w6||(w6={}));function YX(Z,J){let X=Z.getAttribute("POSITION"),Y=Z.getIndices();switch(J){case w6.RENDER:return Y?Y.getCount():X.getCount();case w6.RENDER_CACHED:return Y?new Set(Y.getArray()).size:X.getCount();case w6.UPLOAD_NAIVE:case w6.UPLOAD:return X.getCount();case w6.DISTINCT:case w6.DISTINCT_POSITION:return KT1(J);case w6.UNUSED:return Y?X.getCount()-new Set(Y.getArray()).size:0;default:return GT1(J)}}function KT1(Z){throw new Error(`Not implemented: ${Z}`)}function GT1(Z){throw new Error(`Unexpected value: ${Z}`)}function zV(Z,J,X){let Y=_6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=WT1(Z);let $=Z.getIndices(),Q=$?$.getArray():null,K=YX(Z,w6.RENDER),G=Y.createAccessor(),W=K,H=Gk(W,X);for(let F=0;F<W;F++)H[F]=J[Q?Q[F]:F];Z.setIndices(G.setArray(H));let V=Kk(Z);for(let F of Z.listAttributes()){let z=xZ(Y,F);Jk(F,$,J,z,X),Z.swap(F,z)}for(let F of Z.listTargets())for(let z of F.listAttributes()){let q=xZ(Y,z);Jk(z,$,J,q,X),F.swap(z,q)}if($&&$.listParents().length===1)$.dispose();for(let F of V)if(F.listParents().length===1)F.dispose();return Z}function Jk(Z,J,X,Y,$){let Q=Z.getElementSize(),K=Z.getArray(),G=J?J.getArray():null,W=J?J.getCount():Z.getCount(),H=new K.constructor($*Q),V=new Uint8Array($);for(let F=0;F<W;F++){let z=G?G[F]:F,q=X[z];if(V[q])continue;for(let U=0;U<Q;U++)H[q*Q+U]=K[z*Q+U];V[q]=1}return Y.setArray(H)}function WT1(Z){let J=YX(Z,w6.UPLOAD),X=Z.getIndices(),Y=X?X.getArray():null;if(!X||!Y)return[MC1(J,1e6),J];let $=new Uint32Array(J).fill(JX),Q=0;for(let K=0;K<Y.length;K++){let G=Y[K];if($[G]===JX)$[G]=Q++}return[$,Q]}var Xk="weld",n2={overwrite:!0,cleanup:!0};function Wk(Z=n2){let J=A7(n2,Z);return $X(Xk,async(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes()){for(let Q of $.listPrimitives())if(e2(Q,J),YX(Q,w6.RENDER)===0)Q.dispose();if($.listPrimitives().length===0)$.dispose()}if(J.cleanup)await X.transform(t2({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Vt({propertyTypes:[a.ACCESSOR]}));Y.debug(`${Xk}: Complete.`)})}function e2(Z,J=n2){let X=Z.getGraph(),$=_6.fromGraph(X).getLogger(),Q=FG({},n2,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===C8.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),G=Z.getIndices(),W=G==null?void 0:G.getArray(),H=G?G.getCount():K,V=new jt(Z),F=NC1(K+K/4),z=new Uint32Array(F).fill(JX),q=new Uint32Array(K).fill(JX),U=0;for(let B=0;B<H;B++){let L=W?W[B]:B;if(q[L]!==JX)continue;let w=QT1(z,F,V,L,JX),O=z[w];if(O===JX)z[w]=L,q[L]=U++;else q[L]=q[O]}$.debug(`${Xk}: ${o2(K,U)} vertices.`),zV(Z,q,U)}var{FLOAT:HT1}=x0.ComponentType;function Ot(Z,J){let X=Z.getAttribute("POSITION");if(X)lr(J,X);let Y=Z.getAttribute("NORMAL");if(Y)pr(J,Y);let $=Z.getAttribute("TANGENT");if($)ir(J,$);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)lr(J,K);let G=Q.getAttribute("NORMAL");if(G)pr(J,G);let W=Q.getAttribute("TANGENT");if(W)ir(J,W)}if(EC1(J)<0)VT1(Z)}function lr(Z,J){let X=J.getComponentType(),Y=J.getNormalized(),$=J.getArray(),Q=X===HT1?$:new Float32Array($.length),K=r2();for(let G=0,W=J.getCount();G<W;G++){if(Y)K[0]=i0.decodeNormalizedInt($[G*3],X),K[1]=i0.decodeNormalizedInt($[G*3+1],X),K[2]=i0.decodeNormalizedInt($[G*3+2],X);else K[0]=$[G*3],K[1]=$[G*3+1],K[2]=$[G*3+2];AC1(K,K,Z),Q[G*3]=K[0],Q[G*3+1]=K[1],Q[G*3+2]=K[2]}J.setArray(Q).setNormalized(!1)}function pr(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=kC1();IC1(Q,Z),SC1(Q,Q),_C1(Q,Q);let K=r2();for(let G=0,W=J.getCount();G<W;G++){if(Y)K[0]=i0.decodeNormalizedInt(X[G*3],$),K[1]=i0.decodeNormalizedInt(X[G*3+1],$),K[2]=i0.decodeNormalizedInt(X[G*3+2],$);else K[0]=X[G*3],K[1]=X[G*3+1],K[2]=X[G*3+2];if(xC1(K,K,Q),Ht(K,K),Y)X[G*3]=i0.decodeNormalizedInt(K[0],$),X[G*3+1]=i0.decodeNormalizedInt(K[1],$),X[G*3+2]=i0.decodeNormalizedInt(K[2],$);else X[G*3]=K[0],X[G*3+1]=K[1],X[G*3+2]=K[2]}}function ir(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=r2();for(let K=0,G=J.getCount();K<G;K++){if(Y)Q[0]=i0.decodeNormalizedInt(X[K*4],$),Q[1]=i0.decodeNormalizedInt(X[K*4+1],$),Q[2]=i0.decodeNormalizedInt(X[K*4+2],$);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],Ht(Q,Q),Y)X[K*4]=i0.decodeNormalizedInt(Q[0],$),X[K*4+1]=i0.decodeNormalizedInt(Q[1],$),X[K*4+2]=i0.decodeNormalizedInt(Q[2],$);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function VT1(Z){if(Z.getMode()!==C8.Mode.TRIANGLES)return;if(!Z.getIndices())e2(Z);let J=Z.getIndices();for(let X=0,Y=J.getCount();X<Y;X+=3){let $=J.getScalar(X),Q=J.getScalar(X+2);J.setScalar(X,Q),J.setScalar(X+2,$)}}function zT1(Z,J){for(let X of Z.listPrimitives()){let Y=FT1(X,Z);if(X!==Y)Z.removePrimitive(X).addPrimitive(Y)}for(let X of Z.listPrimitives())zV(X),Ot(X,J)}function FT1(Z,J){if(Z.listParents().some((Y)=>Y instanceof uH&&Y!==J))Z=Z.clone();for(let Y of Z.listTargets())if(Y.listParents().some((Q)=>Q instanceof C8&&Q!==Z))Z.removeTarget(Y).addTarget(Y.clone());return Z}var nr=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function Mt(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!i0.eq(X,nr))zT1(J,X);for(let Y of Z.listChildren()){let $=Y.getMatrix();Wt($,$,X),Y.setMatrix($)}return Z.setMatrix(nr)}var{LINES:qT1,LINE_STRIP:UT1,LINE_LOOP:LT1,TRIANGLES:BT1,TRIANGLE_STRIP:wT1,TRIANGLE_FAN:jT1}=C8.Mode;function OT1(Z){let J=Z.getGraph(),X=_6.fromGraph(J);if(!Z.getIndices())e2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=$t(Z),G=new iJ[Y.getComponentType()](Q*2),W=Z.getMode();if(W===UT1)for(let V=0;V<Q;V++)G[V*2]=$[V],G[V*2+1]=$[V+1];else if(W===LT1)for(let V=0;V<Q;V++)if(V<Q-1)G[V*2]=$[V],G[V*2+1]=$[V+1];else G[V*2]=$[V],G[V*2+1]=$[0];else throw new Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(qT1);let H=X.getRoot();if(Y.listParents().some((V)=>V!==H&&V!==Z))Z.setIndices(xZ(X,Y).setArray(G));else Y.setArray(G)}function Rt(Z){let J=Z.getGraph(),X=_6.fromGraph(J);if(!Z.getIndices())e2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=$t(Z),G=new iJ[Y.getComponentType()](Q*3),W=Z.getMode();if(W===wT1)for(let V=0,F=$.length;V<F-2;V++)if(V%2)G[V*3]=$[V+1],G[V*3+1]=$[V],G[V*3+2]=$[V+2];else G[V*3]=$[V],G[V*3+1]=$[V+1],G[V*3+2]=$[V+2];else if(W===jT1)for(let V=0;V<Q;V++)G[V*3]=$[0],G[V*3+1]=$[V+1],G[V*3+2]=$[V+2];else throw new Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(BT1);let H=X.getRoot();if(Y.listParents().some((V)=>V!==H&&V!==Z))Z.setIndices(xZ(X,Y).setArray(G));else Y.setArray(G)}var ar="dequantize",a2={pattern:/^((?!JOINTS_).)*$/};function Nt(Z=a2){let J=A7(a2,Z);return $X(ar,(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes())for(let Q of $.listPrimitives())MT1(Q,J);X.createExtension(HV).dispose(),Y.debug(`${ar}: Complete.`)})}function MT1(Z,J=a2){let X=A7(a2,J);for(let Y of Z.listSemantics())if(X.pattern.test(Y))Yk(Z.getAttribute(Y));for(let Y of Z.listTargets())for(let $ of Y.listSemantics())if(X.pattern.test($))Yk(Y.getAttribute($))}function Yk(Z){let J=Z.getArray();if(!J)return;let X=s2(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function s2(Z,J,X){let Y=new Float32Array(Z.length);for(let $=0,Q=Z.length;$<Q;$++)if(X)Y[$]=i0.decodeNormalizedInt(Z[$],J);else Y[$]=Z[$];return Y}var{TEXTURE_INFO:Pt,ROOT:bS6}=a;function Dt(Z){let J=new _6().setLogger(Z.getLogger()),X=Hk(J,Z);return RT1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function RT1(Z,J,X){X||(X=Hk(Z,J));for(let Y of J.getRoot().listExtensionsUsed()){let $=Z.createExtension(Y.constructor);if(Y.isRequired())$.setRequired(!0)}return NT1(Z,J,PT1(J),X)}function NT1(Z,J,X,Y){Y||(Y=Hk(Z,J));let $=new Map;for(let Q of X)if(!$.has(Q)&&Q.propertyType!==Pt)$.set(Q,Y(Q));for(let[Q,K]of $.entries())K.copy(Q,Y);return $}function Hk(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return(Y)=>{if(Y.propertyType===Pt)return Y;let $=X.get(Y);if(!$)$=new Y.constructor(Z.getGraph()),X.set(Y,$);return $}}function PT1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}var rE="flatten",sr={cleanup:!0};function Ct(Z=sr){let J=A7(sr,Z);return $X(rE,async(X)=>{let Y=X.getRoot(),$=X.getLogger(),Q=new Set;for(let H of Y.listSkins())for(let V of H.listJoints())Q.add(V);let K=new Set;for(let H of Y.listAnimations())for(let V of H.listChannels()){let F=V.getTargetNode();if(F&&V.getTargetPath()!=="weights")K.add(F)}let G=new Set,W=new Set;for(let H of Y.listScenes())H.traverse((V)=>{let F=V.getParentNode();if(!F)return;if(Q.has(F)||G.has(F))G.add(V);if(K.has(F)||W.has(F))W.add(V)});for(let H of Y.listScenes())H.traverse((V)=>{if(K.has(V))return;if(G.has(V))return;if(W.has(V))return;CC1(V)});if(K.size)$.debug(`${rE}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(t2({propertyTypes:[a.NODE],keepLeaves:!1}));$.debug(`${rE}: Complete.`)})}function Tt(Z){return $T(Z)}var DT1={skipValidation:!1},or=4294967295,{LINE_STRIP:CT1,LINE_LOOP:TT1,TRIANGLE_STRIP:ET1,TRIANGLE_FAN:kT1}=C8.Mode;function IT1(Z,J={}){let X=A7(DT1,J),Y=Z[0],$=_6.fromGraph(Y.getGraph());if(!X.skipValidation&&new Set(Z.map(Kt)).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 CT1:case TT1:OT1(q);break;case ET1:case kT1:Rt(q);break}let Q=[],K=new Uint32Array(Z.length),G=0,W=0;for(let q=0;q<Z.length;q++){let U=Z[q],B=U.getIndices(),L=U.getAttribute("POSITION").getCount(),w=B?B.getArray():null,O=B?B.getCount():L,M=new Uint32Array(L).fill(or);for(let R=0;R<O;R++){let D=w?w[R]:R;if(M[D]===or)M[D]=G++,K[q]++}Q.push(M),W+=O}let H=$.createPrimitive().setMode(Y.getMode()).setMaterial(Y.getMaterial());for(let q of Y.listSemantics()){let U=Y.getAttribute(q),B=iJ[U.getComponentType()],L=xZ($,U).setArray(new B(G*U.getElementSize()));H.setAttribute(q,L)}let V=Y.getIndices(),F=V?xZ($,V).setArray(Gk(W,G)):null;H.setIndices(F);let z=0;for(let q=0;q<Q.length;q++){let U=Z[q],B=U.getIndices(),L=B?B.getCount():-1,w=Q[q];if(B&&F)ST1(B,w,F,z),z+=L;for(let O of H.listSemantics()){let M=U.getAttribute(O),R=H.getAttribute(O);_T1(M,B,w,R)}}return H}function _T1(Z,J,X,Y){let $=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),G=Z.getArray(),W=Y.getArray(),H=new Uint8Array(Z.getCount());for(let V=0,F=J?J.getCount():K;V<F;V++){let z=Q?Q[V]:V,q=X[z];if(H[q])continue;for(let U=0;U<$;U++)W[q*$+U]=G[z*$+U];H[q]=1}}function ST1(Z,J,X,Y){let $=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let G=0;G<$;G++){let W=Q[G],H=J[W];K[Y+G]=H}}var $k="join",{ROOT:vT1,NODE:AT1,MESH:xT1,PRIMITIVE:hT1,ACCESSOR:fT1}=a,tE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],rr={keepMeshes:!1,keepNamed:!1,cleanup:!0};function Et(Z=rr){let J=A7(rr,Z);return $X($k,async(X)=>{let Y=X.getRoot(),$=X.getLogger();for(let Q of Y.listScenes())tr(X,Q,J),Q.traverse((K)=>tr(X,K,J));if(J.cleanup)await X.transform(t2({propertyTypes:[AT1,xT1,hT1,fT1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));$.debug(`${$k}: Complete.`)})}function tr(Z,J,X){let Y=Z.getLogger(),$={},Q=J.listChildren();for(let W=0;W<Q.length;W++){let H=Q[W];if(H.listParents().some((z)=>z instanceof sY))continue;let F=H.getMesh();if(!F)continue;if(H.getExtension("EXT_mesh_gpu_instancing"))continue;if(H.getSkin())continue;for(let z of F.listPrimitives()){if(z.listTargets().length>0)continue;let q=z.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;zV(z),bT1(z);let U=Kt(z),B=F.getName()||H.getName();if(X.keepMeshes||X.keepNamed&&B)U+=`|${W}`;if(!(U in $))$[U]={prims:[],primMeshes:[],primNodes:[],dstNode:H,dstMesh:void 0};let L=$[U];L.prims.push(z),L.primNodes.push(H)}}let K=Object.values($).filter(({prims:W})=>W.length>1),G=new Set(K.flatMap((W)=>W.primNodes));for(let W of G){let H=W.getMesh();if(H.listParents().some((F)=>{return F.propertyType!==vT1&&W!==F}))W.setMesh(H.clone())}for(let W of K){let{dstNode:H,primNodes:V}=W;W.dstMesh=H.getMesh(),W.primMeshes=V.map((F)=>F.getMesh())}for(let W of K){let{prims:H,primNodes:V,primMeshes:F,dstNode:z,dstMesh:q}=W,U=z.getMatrix();for(let w=0;w<H.length;w++){let O=V[w],M=F[w],R=H[w];if(M.removePrimitive(R),RC1(R))R=H[w]=yT1(H[w]);if(O!==z)Wt(tE,TC1(tE,U),O.getMatrix()),Ot(R,tE)}let B=IT1(H),L=B.listAttributes()[0].getCount();q.addPrimitive(B),Y.debug(`${$k}: Joined Primitives (${H.length}) containing ${eE(L)} vertices under Node "${z.getName()}".`)}}function yT1(Z){let J=Z.clone();for(let Y of J.listSemantics())J.setAttribute(Y,J.getAttribute(Y).clone());let X=J.getIndices();if(X)J.setIndices(X.clone());return J}function bT1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)Yk(X)}}var{TRANSLATION:gS6,ROTATION:mS6,SCALE:uS6,WEIGHTS:dS6}=sY.TargetPath;var gT1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var cS6=FG({level:"high"},gT1);var mT1="unweld";function uT1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let Y=Z.getGraph(),$=_6.fromGraph(Y),Q=$.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let W of Z.listAttributes())if(Z.swap(W,er($,W,X,J)),W.listParents().length===1)W.dispose();for(let W of Z.listTargets())for(let H of W.listAttributes())if(W.swap(H,er($,H,X,J)),H.listParents().length===1)H.dispose();let G=Z.getAttribute("POSITION").getCount();if(Q.debug(`${mT1}: ${o2(K,G)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function er(Z,J,X,Y){if(Y.has(J)&&Y.get(J).has(X))return Y.get(J).get(X);let $=J.getArray(),K=new $.constructor(X.getCount()*J.getElementSize()),G=X.getArray(),W=J.getElementSize();for(let V=0,F=X.getCount();V<F;V++)for(let z=0;z<W;z++)K[V*W+z]=$[G[V]*W+z];if(!Y.has(J))Y.set(J,new Map);let H=xZ(Z,J).setArray(K);return Y.get(J).set(X,H),H}var Zt;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Zt||(Zt={}));var dT1=0.000001;function cT1(Z,J,X,Y=0.0001){let $=J.length/Z.length,Q=new Array($).fill(0),K=new Array($).fill(0),G=new Array($).fill(0),W=new Array($).fill(0),H=Z.length-1,V=1;for(let F=1;F<H;++F){let z=Z[V-1],q=Z[F],U=Z[F+1],B=(q-z)/(U-z),L=!1;if(q!==U&&(F!==1||q!==Z[0])){if(VV(J,V-1,W),VV(J,F,K),VV(J,F+1,G),X==="slerp"){let w=iT1(Q,W,G,B),O=Xt(W,K)+Xt(K,G);L=!i2(K,w,Y)||O+Number.EPSILON>=Math.PI}else if(X==="lerp"){let w=pT1(Q,W,G,B);L=!i2(K,w,Y)}else if(X==="step")L=!i2(K,W)||!i2(K,G)}if(L){if(F!==V)Z[V]=Z[F],Jt(J,V,VV(J,F,Q));V++}}if(H>0)Z[V]=Z[H],Jt(J,V,VV(J,H,Q)),V++;return V}function VV(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)X[Y]=Z[J*$+Y];return X}function Jt(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)Z[J*$+Y]=X[Y]}function i2(Z,J,X=0){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>X)return!1;return!0}function lT1(Z,J,X){return Z*(1-X)+J*X}function pT1(Z,J,X,Y){for(let $=0;$<J.length;$++)Z[$]=lT1(J[$],X[$],Y);return Z}function iT1(Z,J,X,Y){let $=J[0],Q=J[1],K=J[2],G=J[3],W=X[0],H=X[1],V=X[2],F=X[3],z,q,U,B,L;if(q=$*W+Q*H+K*V+G*F,q<0)q=-q,W=-W,H=-H,V=-V,F=-F;if(1-q>dT1)z=Math.acos(q),U=Math.sin(z),B=Math.sin((1-Y)*z)/U,L=Math.sin(Y*z)/U;else B=1-Y,L=Y;return Z[0]=B*$+L*W,Z[1]=B*Q+L*H,Z[2]=B*K+L*V,Z[3]=B*G+L*F,Z}function Xt(Z,J){let X=nT1(Z,J);return Math.acos(2*X*X-1)}function nT1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var lS6=new Float32Array(0),pS6={ready:Promise.resolve(),resample:cT1,tolerance:0.0001,cleanup:!0};var j$="simplify",{POINTS:kt,LINES:aT1,LINE_STRIP:sT1,LINE_LOOP:oT1,TRIANGLES:rT1,TRIANGLE_STRIP:It,TRIANGLE_FAN:_t}=C8.Mode,St={ratio:0,error:0.0001,lockBorder:!1,cleanup:!0};function vt(Z){let J=A7(St,Z),X=J.simplifier;if(!X)throw new Error(`${j$}: simplifier dependency required — install "meshoptimizer".`);return $X(j$,async(Y)=>{let $=Y.getLogger();await X.ready,await Y.transform(Wk({overwrite:!1,cleanup:J.cleanup}));let Q=0;for(let K of Y.getRoot().listMeshes()){for(let G of K.listPrimitives()){let W=G.getMode();if(W===rT1||W===It||W===_t){if(Yt(G,J),YX(G,w6.RENDER)===0)G.dispose()}else if(G.getMode()===kt&&!!X.simplifyPoints){if(Yt(G,J),YX(G,w6.RENDER)===0)G.dispose()}else Q++}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)$.warn(`${j$}: Skipping simplification of ${Q} primitives: Unsupported draw mode.`);if(J.cleanup)await Y.transform(t2({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Vt({propertyTypes:[a.ACCESSOR]}));$.debug(`${j$}: Complete.`)})}function Yt(Z,J){let X=FG({},St,J),Y=X.simplifier,$=Z.getGraph(),Q=_6.fromGraph($),K=Q.getLogger();switch(Z.getMode()){case kt:return tT1(Q,Z,X);case aT1:case sT1:case oT1:return K.warn(`${j$}: Skipping primitive simplification: Unsupported draw mode.`),Z;case It:case _t:Rt(Z);break}let G=YX(Z,w6.UPLOAD),W=YX(Z,w6.RENDER);if(W<G/2)zV(Z);let H=Z.getAttribute("POSITION"),V=Z.getIndices(),F=H.getArray(),z=V.getArray();if(!(F instanceof Float32Array))F=s2(F,H.getComponentType(),H.getNormalized());if(!(z instanceof Uint32Array))z=new Uint32Array(z);let q=Math.floor(X.ratio*W/3)*3,U=X.lockBorder?["LockBorder"]:[],[B,L]=Y.simplify(z,F,3,q,X.error,U);if(Z.setIndices(xZ(Q,V).setArray(B)),V.listParents().length===1)V.dispose();zV(Z);let w=YX(Z,w6.UPLOAD);if(w<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${j$}: ${o2(G,w)} vertices, error: ${L.toFixed(4)}.`),Z}function tT1(Z,J,X){let Y=X.simplifier,$=Z.getLogger();if(J.getIndices())uT1(J);let K=J.getAttribute("POSITION"),G=J.getAttribute("COLOR_0"),W=K.getCount(),H=K.getArray(),V=G?G.getArray():void 0,F=G?G.getComponentSize():void 0;if(!(H instanceof Float32Array))H=s2(H,K.getComponentType(),K.getNormalized());if(V&&!(V instanceof Float32Array))V=s2(V,K.getComponentType(),K.getNormalized());Y.useExperimentalFeatures=!0;let z=Math.floor(X.ratio*W),q=Y.simplifyPoints(H,3,z,V,F);Y.useExperimentalFeatures=!1;let[U,B]=Y.compactMesh(q);$.debug(`${j$}: ${o2(K.getCount(),B)} vertices.`);for(let L of Kk(J)){let w=xZ(Z,L);if(Jk(L,null,U,w,B),jC1(J,L,w),L.listParents().length===1)L.dispose()}return J}var Qk;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(Qk||(Qk={}));var iS6={resizeFilter:Qk.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var gt=r(bt(),1);var UG={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DIRECTORIES:[(()=>{try{return $9.dirname(m.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))}catch{return null}})(),$9.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 S5{static instance=new S5;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)c.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J.getRoot().listAnimations().map((Y)=>Y.getName())}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)c.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)c.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){c.error(`ModelRegistry.getTrimesh(): Model ${Z} not found!`);return}let Y=X.vertices;if(J!==1){Y=new Float32Array(Y.length);for(let $=0;$<Y.length;$++)Y[$]=X.vertices[$]*J}return{vertices:Y,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)c.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=$9.normalize(Z);for(let X of UG.DIRECTORIES){let Y=$9.normalize(X);if(J.startsWith(Y))return $9.relative(Y,J).replace(/\\/g,"/")}return $9.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of UG.DIRECTORIES){let X=$9.resolve(process.cwd(),J);if(!QX.existsSync(X))continue;let Y=await mB("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let $ of Y)Z.push($9.join(X,$))}return Z}async _loadModelData(Z){let J=await new VT().read(Z),X=Tt(J.getRoot().listScenes()[0]),Y=J.getRoot().listNodes().map((Q)=>Q.getName()),$=this._absoluteModelPathToModelUri(Z);this._modelUriDocuments.set($,J),this._modelUriBoundingBoxes.set($,{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($,await this._buildTrimesh($))}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)}${UG.CHECKSUM_EXT}`;if(!QX.existsSync(J))return!1;let X=this._calculateChecksum(Z),Y=QX.readFileSync(J,"utf8");return X===Y}_calculateChecksum(Z){if(!QX.existsSync(Z))return"";let J=QX.readFileSync(Z);return YE1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=$9.basename(Z),X=J.replace(/\.[^/.]+$/,""),Y=$9.dirname(Z),$=$9.join(Y,UG.OPTIMIZED_DIR,X);return $9.join($,J)}async _buildTrimesh(Z,J=1,X=0.001){let Y=this._modelUriDocuments.get(Z);if(!Y)c.fatalError(`ModelRegistry._buildTrimesh(): Model ${Z} not found!`);let $=Dt(Y);$.setLogger(new k5(gH.WARN)),await $.transform(Gt({pivot:"center"}),Ct(),Et(),Wk(),vt({simplifier:gt.MeshoptSimplifier,ratio:J,error:X}),Nt());for(let H of $.getRoot().listScenes())for(let V of H.listChildren())Mt(V);let Q=$.getRoot().listMeshes()[0];if(!Q){c.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root mesh!`);return}let K=Q.listPrimitives()[0];if(!K){c.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root primitive!`);return}let G=K.getAttribute("POSITION"),W=K.getIndices();if(!G||!W){c.error(`ModelRegistry._buildTrimesh(): Model ${Z} missing required geometry data!`);return}return{vertices:G.getArray(),indices:W.getArray()}}async _optimizeModel(Z,J){let X=$9.dirname(J);QX.rmSync(X,{recursive:!0,force:!0}),QX.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let Y of UG.OPTIMIZER_RUNS){let $=J.replace(/(\.[^/.]+)$/,`${Y.suffix}$1`),{stderr:Q}=await gi("npx",["@gltf-transform/cli","optimize",Z,$,...Y.options]);if(Q)return c.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return QX.writeFileSync(`${J}${UG.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var hZ=r(KH(),1);var BV;(($)=>{$.DYNAMIC="dynamic";$.FIXED="fixed";$.KINEMATIC_POSITION="kinematic_position";$.KINEMATIC_VELOCITY="kinematic_velocity"})(BV||={});var Uk=0.001,mt="dynamic";class O$ extends O0{_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??=mt,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:Y}=this.rotation;return{x:-2*(Z*X+Y*J),y:-2*(J*X-Y*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:Y,principalAngularInertiaLocalFrame:$}=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"]:hZ.default.RigidBodyType.Dynamic,["fixed"]:hZ.default.RigidBodyType.Fixed,["kinematic_position"]:hZ.default.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:hZ.default.RigidBodyType.KinematicVelocityBased}[Z];if(X===void 0)return c.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 c.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 Q9({...Z,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(Z)}createAndAddChildColliders(Z){let J=[];return Z.forEach((X)=>{let Y=this.createAndAddChildCollider(X);if(Y)J.push(Y)}),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 c.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 c.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 c.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,Y])=>{if(X in Z)Y(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 Q9(Z);return this._colliders.add(J),J}_createAndAddPendingChildColliders(Z){let J=[];return Z.forEach((X)=>{let Y=this._createAndAddPendingChildCollider(X);if(Y)J.push(Y)}),J}_createRigidBodyDesc(Z){let J=Z.type??mt;return{["dynamic"]:()=>hZ.default.RigidBodyDesc.dynamic(),["fixed"]:()=>hZ.default.RigidBodyDesc.fixed(),["kinematic_position"]:()=>hZ.default.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>hZ.default.RigidBodyDesc.kinematicVelocityBased()}[J]()}_requireCreated(Z){if(!this._rigidBody||!this._simulation)c.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)c.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)c.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)c.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)c.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)c.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)<Uk&&Math.abs(Z.y)<Uk&&Math.abs(Z.z)<Uk}}var Lk;(($)=>{$[$.Average=0]="Average";$[$.Min=1]="Min";$[$.Multiply=2]="Multiply";$[$.Max=3]="Max"})(Lk||={});var wV;((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"})(wV||={});class Q9 extends O0{_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 Y=S5.instance.getBoundingBox(Z),$=Y.max.x-Y.min.x,Q=Y.max.y-Y.min.y,K=Y.max.z-Y.min.z,G=Math.max($,K),W=Math.min($,K),H=G/W,V=G/Q,F=G*J/2,z=(O)=>Math.max(0.01,O),q=()=>({shape:"block",halfExtents:{x:z($*J/2),y:z(Q*J/2),z:z(K*J/2)}}),U=()=>({shape:"round-cylinder",radius:z(F),halfHeight:z(Q*J/2),borderRadius:z(F*0.1)}),B=()=>{let O=S5.instance.getTrimesh(Z,J);if(!O)return;return{shape:"trimesh",vertices:O.vertices,indices:O.indices}},L=()=>({shape:"wedge",extents:{x:$*J,y:Q*J,z:K*J}}),w=()=>({shape:"capsule",radius:z(F),halfHeight:z(Q*J/2-F)});if(X)switch(X){case"block":return q();case"capsule":return w();case"round-cylinder":return U();case"trimesh":{let O=B();if(!O){c.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return O}case"wedge":return L();default:c.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(H>2)return q();if(V>1.5)return U();return w()}get bounciness(){if(!this._requireNotRemoved("bounciness"))return 0;return this._collider?this._collider.restitution():this._colliderDesc.restitution}get bouncinessCombineRule(){if(!this._requireNotRemoved("bouncinessCombineRule"))return 0;return this._collider?this._collider.restitutionCombineRule():this._colliderDesc.restitutionCombineRule}get collisionGroups(){if(!this._requireNotRemoved("collisionGroups"))return{belongsTo:[],collidesWith:[]};return this._collider?T4.decodeRawCollisionGroups(this._collider.collisionGroups()):T4.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=T4.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 c.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 c.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")c.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 c.error("Collider.combineVoxelStates(): Other collider is not simulated!");if(this.shape!=="voxels")return c.error("Collider.combineVoxelStates(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return c.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|p8.default.ActiveEvents.COLLISION_EVENTS:J&~p8.default.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|p8.default.ActiveEvents.CONTACT_FORCE_EVENTS:J&~p8.default.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 c.error("Collider.propagateVoxelChange(): Other collider is not simulated!");if(this.shape!=="voxels")return c.error("Collider.propagateVoxelChange(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return c.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":{c.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"voxels":{c.error("Collider.setScale(): Voxels colliders cannot be scaled!");return}case"wedge":{c.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:c.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,Y])=>{if(Z[X]!==void 0)Y.call(this,Z[X])})}_autoAddToSimulation(Z){if(Z.simulation)this.addToSimulation(Z.simulation,Z.parentRigidBody)}_buildWedgeConvexHullVertices(Z){let{x:J,y:X,z:Y}=Z,$=J/2,Q=Y/2,K=X/2;return new Float32Array([-$,0-K,-Q,$,0-K,-Q,$,0-K,Q,-$,0-K,Q,-$,X-K,-Q,$,X-K,-Q])}_createColliderDesc(Z){let{shape:J,flags:X}=Z;switch(J){case"ball":{if(!Z.radius)c.fatalError("Ball collider must have a radius!");return p8.default.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)c.fatalError("Block collider must have halfExtents!");return p8.default.ColliderDesc.cuboid(Z.halfExtents.x,Z.halfExtents.y,Z.halfExtents.z)}case"capsule":{if(!Z.halfHeight||!Z.radius)c.fatalError("Capsule collider must have halfHeight and radius!");return p8.default.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)c.fatalError("Cone collider must have radius and halfHeight!");return p8.default.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)c.fatalError("Cylinder collider must have radius and halfHeight!");return p8.default.ColliderDesc.cylinder(Z.halfHeight,Z.radius)}case"round-cylinder":{if(!Z.radius||!Z.halfHeight||!Z.borderRadius)c.fatalError("Round cylinder collider must have radius, halfHeight, and borderRadius!");return p8.default.ColliderDesc.roundCylinder(Z.halfHeight,Z.radius,Z.borderRadius)}case"trimesh":{if(!Z.indices||!Z.vertices)c.fatalError("Trimesh collider must have vertices and indices!");return p8.default.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)c.fatalError("Voxels collider must have coordinates and size!");return p8.default.ColliderDesc.voxels(this._coordinatesToInt32Array(Z.coordinates),Z.size)}case"wedge":{if(!Z.extents)c.fatalError("Wedge collider must have extents!");let Y=this._buildWedgeConvexHullVertices(Z.extents),$=p8.default.ColliderDesc.convexHull(Y);if(!$)throw c.fatalError("Failed to create convex hull for wedge collider!"),new Error("Convex hull creation failed");return $}default:c.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)c.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)c.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)c.error(`Collider._requireNotRemoved(): Collider is removed, invoked method: ${Z}()`);return!this.isRemoved}_setActiveCollisionTypes(){(this._collider??this._colliderDesc).setActiveCollisionTypes(p8.default.ActiveCollisionTypes.DYNAMIC_DYNAMIC|p8.default.ActiveCollisionTypes.DYNAMIC_KINEMATIC|p8.default.ActiveCollisionTypes.DYNAMIC_FIXED|p8.default.ActiveCollisionTypes.KINEMATIC_KINEMATIC|p8.default.ActiveCollisionTypes.KINEMATIC_FIXED)}_coordinatesToInt32Array(Z){let J=new Int32Array(Z.length*3);for(let X=0;X<Z.length;X++){let Y=Z[X],$=X*3;J[$]=Math.floor(Y.x),J[$+1]=Math.floor(Y.y),J[$+2]=Math.floor(Y.z)}return J}}var $E1={shape:"voxels"},Bk;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(Bk||={});class K9 extends O0{_id;_blockTypeRegistry;_customColliderOptions;_halfExtents;_isLiquid;_name;_textureUri;constructor(Z,J={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(J.id<0)c.fatalError("BlockType.constructor(): BlockType id not set.");super();this._id=J.id,this._blockTypeRegistry=Z,this._customColliderOptions=J.customColliderOptions,this._halfExtents=J.halfExtents??{x:0.5,y:0.5,z:0.5},this._isLiquid=J.isLiquid??!1,this._name=J.name,this._textureUri=J.textureUri}get id(){return this._id}get blockTypeRegistry(){return this._blockTypeRegistry}get colliderOptions(){return{...this._customColliderOptions,...$E1}}get halfExtents(){return this._halfExtents}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}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 Q9({...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(T4.isDefaultCollisionGroups(J.collisionGroups))J.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return J}serialize(){return P0.serializeBlockType(this,this._blockTypeRegistry.world.tickAllocator)}}var wk;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(wk||={});class jV extends O0{_blockTypes=new Map;_world;constructor(Z){super();this._world=Z}get world(){return this._world}getAllBlockTypes(Z=!1){return Z?this._world.tickAllocator.getArray(this._blockTypes.values()):Array.from(this._blockTypes.values())}getBlockType(Z){let J=this._blockTypes.get(Z);if(!J)c.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends K9{constructor(Y,$){super(Y,$)}}(this,Z);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,this._world.tickAllocator)}}var aI={};zK(aI,{worldSchema:()=>nI,worldPacketDefinition:()=>A60,vectorSchema:()=>W1,vectorBooleanSchema:()=>Xh1,uiSchema:()=>pI,uiPacketDefinition:()=>S60,uiDatasSchema:()=>iI,uiDatasPacketDefinition:()=>v60,uiDataSendPacketDefinition:()=>B60,uiDataSchema:()=>dV,syncResponseSchema:()=>lI,syncResponsePacketDefinition:()=>_60,syncRequestSchema:()=>jI,syncRequestPacketDefinition:()=>L60,stateRequestSchema:()=>wI,stateRequestPacketDefinition:()=>U60,sceneUIsSchema:()=>cI,sceneUIsPacketDefinition:()=>I60,sceneUISchema:()=>dI,rgbColorSchema:()=>h6,registeredPackets:()=>cw,quaternionSchema:()=>_I,playersSchema:()=>uI,playersPacketDefinition:()=>k60,playerSchema:()=>mI,physicsDebugRenderSchema:()=>gI,physicsDebugRenderPacketDefinition:()=>T60,physicsDebugRaycastsSchema:()=>bI,physicsDebugRaycastsPacketDefinition:()=>E60,physicsDebugRaycastSchema:()=>yI,particleEmittersSchema:()=>fI,particleEmittersPacketDefinition:()=>C60,particleEmitterSchema:()=>hI,outboundPackets:()=>dw,modelNodeOverrideSchema:()=>II,lightsSchema:()=>xI,lightsPacketDefinition:()=>D60,lightSchema:()=>AI,isValidPacket:()=>$h1,inputSchema:()=>BI,inputPacketDefinition:()=>q60,inboundPackets:()=>uw,hexColorSchema:()=>UI,heartbeatSchema:()=>qI,heartbeatPacketDefinition:()=>V60,entitySchema:()=>SI,entitiesSchema:()=>vI,entitiesPacketDefinition:()=>P60,definePacket:()=>I0,debugConfigSchema:()=>LI,debugConfigPacketDefinition:()=>F60,createPacket:()=>ix1,connectionSchema:()=>FI,connectionPacketDefinition:()=>H60,chunksSchema:()=>kI,chunksPacketDefinition:()=>N60,chunkSchema:()=>EI,chatMessagesSchema:()=>TI,chatMessagesPacketDefinition:()=>R60,chatMessageSendPacketDefinition:()=>z60,chatMessageSchema:()=>uV,cameraSchema:()=>CI,cameraPacketDefinition:()=>M60,blocksSchema:()=>NI,blocksPacketDefinition:()=>j60,blockTypesSchema:()=>DI,blockTypesPacketDefinition:()=>O60,blockTypeSchema:()=>PI,blockSchema:()=>RI,bidirectionalPackets:()=>mw,audiosSchema:()=>MI,audiosPacketDefinition:()=>w60,audioSchema:()=>OI,PacketId:()=>S1});var mw={};zK(mw,{heartbeatPacketDefinition:()=>V60,connectionPacketDefinition:()=>H60});var VI=r(G60(),1);class zI extends VI.default{static instance=new VI.default}var S1;((E)=>{E[E.SYNC_REQUEST=0]="SYNC_REQUEST";E[E.INPUT=1]="INPUT";E[E.STATE_REQUEST=2]="STATE_REQUEST";E[E.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";E[E.UI_DATA_SEND=4]="UI_DATA_SEND";E[E.SYNC_RESPONSE=32]="SYNC_RESPONSE";E[E.AUDIOS=33]="AUDIOS";E[E.BLOCKS=34]="BLOCKS";E[E.BLOCK_TYPES=35]="BLOCK_TYPES";E[E.CHAT_MESSAGES=36]="CHAT_MESSAGES";E[E.CHUNKS=37]="CHUNKS";E[E.ENTITIES=38]="ENTITIES";E[E.WORLD=39]="WORLD";E[E.CAMERA=40]="CAMERA";E[E.UI=41]="UI";E[E.UI_DATAS=42]="UI_DATAS";E[E.SCENE_UIS=43]="SCENE_UIS";E[E.LIGHTS=44]="LIGHTS";E[E.PLAYERS=45]="PLAYERS";E[E.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";E[E.CONNECTION=116]="CONNECTION";E[E.HEARTBEAT=117]="HEARTBEAT";E[E.DEBUG_CONFIG=128]="DEBUG_CONFIG";E[E.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";E[E.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(S1||={});function ix1(Z,J,X,Y){if(!Z.validate(J))throw new Error(`Invalid payload for packet with id ${Z.id}. Error: ${zI.instance.errorsText(Z.validate.errors)}`);let $=Y??[];if($[0]=Z.id,$[1]=J,typeof X==="number")$.push(X);return $}function I0(Z,J){return{id:Z,schema:J,validate:zI.instance.compile(J)}}var nx1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},W60={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},ax1={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},sx1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},ox1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},rx1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},tx1={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},ex1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:sx1,ic:{type:"array",items:ax1},d:W60,s:rx1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},Zh1={type:"object",properties:{i:{type:"string"},d:W60},required:["i","d"],additionalProperties:!1},Jh1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:tx1},required:["l","s"],additionalProperties:!1},FI={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},c:{...Zh1,nullable:!0},ca:{...nx1,nullable:!0},d:{type:"array",items:{...Jh1},nullable:!0},pa:{...ox1,nullable:!0},t:{type:"array",items:{...ex1},nullable:!0}},additionalProperties:!1};var H60=I0(116,FI);var qI={type:"null",nullable:!0};var V60=I0(117,qI);var uw={};zK(uw,{uiDataSendPacketDefinition:()=>B60,syncRequestPacketDefinition:()=>L60,stateRequestPacketDefinition:()=>U60,inputPacketDefinition:()=>q60,debugConfigPacketDefinition:()=>F60,chatMessageSendPacketDefinition:()=>z60});var UI={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var uV={type:"object",properties:{m:{type:"string"},c:{...UI,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var z60=I0(3,uV);var LI={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var F60=I0(128,LI);var BI={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 q60=I0(1,BI);var wI={type:"object",properties:{},additionalProperties:!1};var U60=I0(2,wI);var jI={type:"null",nullable:!0};var L60=I0(0,jI);var dV={type:"object",properties:{},additionalProperties:!0};var B60=I0(4,dV);var dw={};zK(dw,{worldPacketDefinition:()=>A60,uiPacketDefinition:()=>S60,uiDatasPacketDefinition:()=>v60,syncResponsePacketDefinition:()=>_60,sceneUIsPacketDefinition:()=>I60,playersPacketDefinition:()=>k60,physicsDebugRenderPacketDefinition:()=>T60,physicsDebugRaycastsPacketDefinition:()=>E60,particleEmittersPacketDefinition:()=>C60,lightsPacketDefinition:()=>D60,entitiesPacketDefinition:()=>P60,chunksPacketDefinition:()=>N60,chatMessagesPacketDefinition:()=>R60,cameraPacketDefinition:()=>M60,blocksPacketDefinition:()=>j60,blockTypesPacketDefinition:()=>O60,audiosPacketDefinition:()=>w60});var W1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var OI={type:"object",properties:{i:{type:"number"},a:{type:"string",nullable:!0},cd:{type:"number",nullable:!0},d:{type:"number",nullable:!0},de:{type:"number",nullable:!0},di:{type:"number",minimum:0,nullable:!0},e:{type:"number",nullable:!0},l:{type:"boolean",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pl:{type:"boolean",nullable:!0},pr:{type:"number",minimum:0,nullable:!0},r:{type:"boolean",nullable:!0},rd:{type:"number",nullable:!0},s:{type:"number",nullable:!0},v:{type:"number",minimum:0,maximum:1,nullable:!0}},required:["i"],additionalProperties:!1};var MI={type:"array",items:{...OI}};var w60=I0(33,MI);var RI={type:"object",properties:{i:{type:"number"},c:W1},required:["i","c"],additionalProperties:!1};var NI={type:"array",items:{...RI}};var j60=I0(34,NI);var PI={type:"object",properties:{i:{type:"number"},l:{type:"boolean",nullable:!0},n:{type:"string",nullable:!0},t:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var DI={type:"array",items:{...PI}};var O60=I0(35,DI);var CI={type:"object",properties:{m:{type:"number",nullable:!0},e:{type:"number",nullable:!0},et:{type:"number",nullable:!0},fo:{type:"number",nullable:!0},ffo:{type:"number",nullable:!0},fv:{type:"number",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pt:{...W1,nullable:!0},pl:{...W1,nullable:!0},s:{type:"array",items:{type:"string"},nullable:!0},sa:{type:"number",nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var TI={type:"array",items:{...uV}};var EI={type:"object",properties:{c:W1,b:{type:"array",items:{type:"number",minimum:0,maximum:255},minItems:4096,maxItems:4096,nullable:!0},rm:{type:"boolean",nullable:!0}},required:["c"],additionalProperties:!1};var kI={type:"array",items:{...EI}};var h6={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 II={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:{...h6,nullable:!0}},required:["n"],additionalProperties:!1};var _I={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var SI={type:"object",properties:{i:{type:"number"},al:{type:"array",items:{type:"string"},nullable:!0},ao:{type:"array",items:{type:"string"},nullable:!0},ap:{type:"number",nullable:!0},as:{type:"array",items:{type:"string"},nullable:!0},bh:{...W1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...II},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{..._I,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...h6,nullable:!0}},required:["i"],additionalProperties:!1};var vI={type:"array",items:{...SI}};var AI={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...h6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",minimum:0,maximum:1,nullable:!0},rm:{type:"boolean",nullable:!0},t:{type:"number",nullable:!0},te:{type:"number",nullable:!0},tp:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var xI={type:"array",items:{...AI}};var hI={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},b:{type:"number",nullable:!0},ce:{...h6,nullable:!0},cev:{...h6,nullable:!0},cs:{...h6,nullable:!0},csv:{...h6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...W1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...W1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pv:{...W1,nullable:!0},r:{type:"number",nullable:!0},rv:{type:"number",nullable:!0},rm:{type:"boolean",nullable:!0},se:{type:"number",nullable:!0},sev:{type:"number",nullable:!0},ss:{type:"number",nullable:!0},ssv:{type:"number",nullable:!0},t:{type:"boolean",nullable:!0},tu:{type:"string",nullable:!0},v:{...W1,nullable:!0},vv:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var fI={type:"array",items:{...hI}};var yI={type:"object",properties:{o:{...W1},d:{...W1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var bI={type:"array",items:{...yI}};var gI={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var mI={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 uI={type:"array",items:{...mI}};var dI={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"object",nullable:!0},t:{type:"string",nullable:!0},v:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var cI={type:"array",items:{...dI}};var lI={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var pI={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var iI={type:"array",items:{...dV}};var Xh1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var nI={type:"object",properties:{i:{type:"number"},ac:{...h6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...h6,nullable:!0},di:{type:"number",nullable:!0},dp:{...W1,nullable:!0},fc:{...h6,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 M60=I0(40,CI);var R60=I0(36,TI);var N60=I0(37,kI);var P60=I0(38,vI);var D60=I0(44,xI);var C60=I0(46,fI);var T60=I0(192,gI);var E60=I0(193,bI);var k60=I0(45,uI);var I60=I0(43,cI);var _60=I0(32,lI);var S60=I0(41,pI);var v60=I0(42,iI);var A60=I0(39,nI);var cw=new Map,Yh1={...mw,...uw,...dw};for(let Z of Object.values(Yh1))if("id"in Z&&"schema"in Z){let J=Z;if(cw.has(J.id))throw new Error(`Packet with id ${J.id} is already registered.`);cw.set(J.id,J)}function $h1(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=cw.get(Z[0]);return!!J&&J.validate(Z[1])}var Y0=aI;var $50=r(X50(),1);import T$ from"fs";import Y50 from"path";var lV="./dev/persistence";class f7{static instance=new f7;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;constructor(){try{this._creativeGateway=new $50.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(`
414
+ >>> no match, partial?`,Z,F,J,z),F===G)return!0}return!1}let U;if(typeof H==="string")U=V===H,this.debug("string match",H,V,U);else U=H.test(V),this.debug("pattern match",H,V,U);if(!U)return!1}if(Q===G&&K===W)return!0;else if(Q===G)return X;else if(K===W)return Q===G-1&&Z[Q]==="";else throw new Error("wtf?")}braceExpand(){return Hn(this.pattern,this.options)}parse(Z){NH(Z);let J=this.options;if(Z==="**")return B6;if(Z==="")return"";let X,Y=null;if(X=Z.match(hw1))Y=J.dot?yw1:fw1;else if(X=Z.match(Cw1))Y=(J.nocase?J.dot?Iw1:kw1:J.dot?Ew1:Tw1)(X[1]);else if(X=Z.match(bw1))Y=(J.nocase?J.dot?mw1:gw1:J.dot?uw1:dw1)(X);else if(X=Z.match(_w1))Y=J.dot?vw1:Sw1;else if(X=Z.match(Aw1))Y=xw1;let $=L6.fromGlob(Z,this.options).toMMPattern();if(Y&&typeof $==="object")Reflect.defineProperty($,"test",{value:Y});return $}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?pw1:J.dot?iw1:nw1,Y=new Set(J.nocase?["i"]:[]),$=Z.map((G)=>{let W=G.map((H)=>{if(H instanceof RegExp)for(let V of H.flags.split(""))Y.add(V);return typeof H==="string"?tw1(H):H===B6?B6:H._src});return W.forEach((H,V)=>{let F=W[V+1],z=W[V-1];if(H!==B6||z===B6)return;if(z===void 0)if(F!==void 0&&F!==B6)W[V+1]="(?:\\/|"+X+"\\/)?"+F;else W[V]=X;else if(F===void 0)W[V-1]=z+"(?:\\/|"+X+")?";else if(F!==B6)W[V-1]=z+"(?:\\/|\\/"+X+"\\/)"+F,W[V+1]=B6}),W.filter((H)=>H!==B6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if($="^"+Q+$+K+"$",this.negate)$="^(?!"+$+").+$";try{this.regexp=new RegExp($,[...Y].join(""))}catch(G){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 Y=this.slashSplit(Z);this.debug(this.pattern,"split",Y);let $=this.set;this.debug(this.pattern,"set",$);let Q=Y[Y.length-1];if(!Q)for(let K=Y.length-2;!Q&&K>=0;K--)Q=Y[K];for(let K=0;K<$.length;K++){let G=$[K],W=Y;if(X.matchBase&&G.length===1)W=[Q];if(this.matchOne(W,G,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return a6.defaults(Z).Minimatch}}a6.AST=L6;a6.Minimatch=A9;a6.escape=gK;a6.unescape=_4;import{fileURLToPath as _j1}from"node:url";var mK=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,zn=new Set,fC=typeof process==="object"&&!!process?process:{},Fn=(Z,J,X,Y)=>{typeof fC.emitWarning==="function"?fC.emitWarning(Z,J,X,Y):console.error(`[${X}] ${J}: ${Z}`)},TB=globalThis.AbortController,Vn=globalThis.AbortSignal;if(typeof TB==="undefined"){Vn=class X{onabort;_onabort=[];reason;aborted=!1;addEventListener(Y,$){this._onabort.push($)}},TB=class X{constructor(){J()}signal=new Vn;abort(Y){if(this.signal.aborted)return;this.signal.reason=Y,this.signal.aborted=!0;for(let $ of this.signal._onabort)$(Y);this.signal.onabort?.(Y)}};let Z=fC.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,Fn("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 ew1=(Z)=>!zn.has(Z),EI6=Symbol("type"),dJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),qn=(Z)=>!dJ(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?DH:null;class DH extends Array{constructor(Z){super(Z);this.fill(0)}}class uK{heap;length;static#Z=!1;static create(Z){let J=qn(Z);if(!J)return[];uK.#Z=!0;let X=new uK(Z,J);return uK.#Z=!1,X}constructor(Z,J){if(!uK.#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 CH{#Z;#J;#Y;#X;#$;#V;#F;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#G;#W;#H;#z;#Q;#U;#B;#L;#j;#E;#O;#k;#N;#R;#M;#C;#w;#_;static unsafeExposeInternals(Z){return{starts:Z.#N,ttls:Z.#R,sizes:Z.#k,keyMap:Z.#H,keyList:Z.#z,valList:Z.#Q,next:Z.#U,prev:Z.#B,get head(){return Z.#L},get tail(){return Z.#j},free:Z.#E,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,Y,$)=>Z.#h(J,X,Y,$),moveToTail:(J)=>Z.#b(J),indexes:(J)=>Z.#T(J),rindexes:(J)=>Z.#I(J),isStale:(J)=>Z.#D(J)}}get max(){return this.#Z}get maxSize(){return this.#J}get calculatedSize(){return this.#W}get size(){return this.#G}get fetchMethod(){return this.#V}get memoMethod(){return this.#F}get dispose(){return this.#Y}get onInsert(){return this.#X}get disposeAfter(){return this.#$}constructor(Z){let{max:J=0,ttl:X,ttlResolution:Y=1,ttlAutopurge:$,updateAgeOnGet:Q,updateAgeOnHas:K,allowStale:G,dispose:W,onInsert:H,disposeAfter:V,noDisposeOnSet:F,noUpdateTTL:z,maxSize:q=0,maxEntrySize:U=0,sizeCalculation:B,fetchMethod:L,memoMethod:w,noDeleteOnFetchRejection:O,noDeleteOnStaleGet:M,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:D,ignoreFetchAbort:N}=Z;if(J!==0&&!dJ(J))throw new TypeError("max option must be a nonnegative integer");let C=J?qn(J):Array;if(!C)throw new Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=U||this.#J,this.sizeCalculation=B,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw new TypeError("sizeCalculation set to non-function")}if(w!==void 0&&typeof w!=="function")throw new TypeError("memoMethod must be a function if defined");if(this.#F=w,L!==void 0&&typeof L!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#V=L,this.#C=!!L,this.#H=new Map,this.#z=new Array(J).fill(void 0),this.#Q=new Array(J).fill(void 0),this.#U=new C(J),this.#B=new C(J),this.#L=0,this.#j=0,this.#E=uK.create(J),this.#G=0,this.#W=0,typeof W==="function")this.#Y=W;if(typeof H==="function")this.#X=H;if(typeof V==="function")this.#$=V,this.#O=[];else this.#$=void 0,this.#O=void 0;if(this.#M=!!this.#Y,this.#_=!!this.#X,this.#w=!!this.#$,this.noDisposeOnSet=!!F,this.noUpdateTTL=!!z,this.noDeleteOnFetchRejection=!!O,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!N,this.maxEntrySize!==0){if(this.#J!==0){if(!dJ(this.#J))throw new TypeError("maxSize must be a positive integer if specified")}if(!dJ(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#m()}if(this.allowStale=!!G,this.noDeleteOnStaleGet=!!M,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=dJ(Y)||Y===0?Y:1,this.ttlAutopurge=!!$,this.ttl=X||0,this.ttl){if(!dJ(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(ew1("LRU_CACHE_UNBOUNDED"))zn.add("LRU_CACHE_UNBOUNDED"),Fn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",CH)}}getRemainingTTL(Z){return this.#H.has(Z)?1/0:0}#K(){let Z=new DH(this.#Z),J=new DH(this.#Z);this.#R=Z,this.#N=J,this.#S=($,Q,K=mK.now())=>{if(J[$]=Q!==0?K:0,Z[$]=Q,Q!==0&&this.ttlAutopurge){let G=setTimeout(()=>{if(this.#D($))this.#v(this.#z[$],"expire")},Q+1);if(G.unref)G.unref()}},this.#A=($)=>{J[$]=Z[$]!==0?mK.now():0},this.#P=($,Q)=>{if(Z[Q]){let K=Z[Q],G=J[Q];if(!K||!G)return;$.ttl=K,$.start=G,$.now=X||Y();let W=$.now-G;$.remainingTTL=K-W}};let X=0,Y=()=>{let $=mK.now();if(this.ttlResolution>0){X=$;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return $};this.getRemainingTTL=($)=>{let Q=this.#H.get($);if(Q===void 0)return 0;let K=Z[Q],G=J[Q];if(!K||!G)return 1/0;let W=(X||Y())-G;return K-W},this.#D=($)=>{let Q=J[$],K=Z[$];return!!K&&!!Q&&(X||Y())-Q>K}}#A=()=>{};#P=()=>{};#S=()=>{};#D=()=>!1;#m(){let Z=new DH(this.#Z);this.#W=0,this.#k=Z,this.#x=(J)=>{this.#W-=Z[J],Z[J]=0},this.#u=(J,X,Y,$)=>{if(this.#q(X))return 0;if(!dJ(Y))if($){if(typeof $!=="function")throw new TypeError("sizeCalculation must be a function");if(Y=$(X,J),!dJ(Y))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 Y},this.#f=(J,X,Y)=>{if(Z[J]=X,this.#J){let $=this.#J-Z[J];while(this.#W>$)this.#y(!0)}if(this.#W+=Z[J],Y)Y.entrySize=X,Y.totalCalculatedSize=this.#W}}#x=(Z)=>{};#f=(Z,J,X)=>{};#u=(Z,J,X,Y)=>{if(X||Y)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:Z=this.allowStale}={}){if(this.#G)for(let J=this.#j;;){if(!this.#d(J))break;if(Z||!this.#D(J))yield J;if(J===this.#L)break;else J=this.#B[J]}}*#I({allowStale:Z=this.allowStale}={}){if(this.#G)for(let J=this.#L;;){if(!this.#d(J))break;if(Z||!this.#D(J))yield J;if(J===this.#j)break;else J=this.#U[J]}}#d(Z){return Z!==void 0&&this.#H.get(this.#z[Z])===Z}*entries(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&this.#z[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#z[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#I())if(this.#Q[Z]!==void 0&&this.#z[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#z[Z],this.#Q[Z]]}*keys(){for(let Z of this.#T()){let J=this.#z[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#I()){let J=this.#z[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#I())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.#T()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;if(Z($,this.#z[X],this))return this.get(this.#z[X],J)}}forEach(Z,J=this){for(let X of this.#T()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#z[X],this)}}rforEach(Z,J=this){for(let X of this.#I()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#z[X],this)}}purgeStale(){let Z=!1;for(let J of this.#I({allowStale:!0}))if(this.#D(J))this.#v(this.#z[J],"expire"),Z=!0;return Z}info(Z){let J=this.#H.get(Z);if(J===void 0)return;let X=this.#Q[J],Y=this.#q(X)?X.__staleWhileFetching:X;if(Y===void 0)return;let $={value:Y};if(this.#R&&this.#N){let Q=this.#R[J],K=this.#N[J];if(Q&&K){let G=Q-(mK.now()-K);$.ttl=G,$.start=Date.now()}}if(this.#k)$.size=this.#k[J];return $}dump(){let Z=[];for(let J of this.#T({allowStale:!0})){let X=this.#z[J],Y=this.#Q[J],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0||X===void 0)continue;let Q={value:$};if(this.#R&&this.#N){Q.ttl=this.#R[J];let K=mK.now()-this.#N[J];Q.start=Math.floor(Date.now()-K)}if(this.#k)Q.size=this.#k[J];Z.unshift([X,Q])}return Z}load(Z){this.clear();for(let[J,X]of Z){if(X.start){let Y=Date.now()-X.start;X.start=mK.now()-Y}this.set(J,X.value,X)}}set(Z,J,X={}){if(J===void 0)return this.delete(Z),this;let{ttl:Y=this.ttl,start:$,noDisposeOnSet:Q=this.noDisposeOnSet,sizeCalculation:K=this.sizeCalculation,status:G}=X,{noUpdateTTL:W=this.noUpdateTTL}=X,H=this.#u(Z,J,X.size||0,K);if(this.maxEntrySize&&H>this.maxEntrySize){if(G)G.set="miss",G.maxEntrySizeExceeded=!0;return this.#v(Z,"set"),this}let V=this.#G===0?void 0:this.#H.get(Z);if(V===void 0){if(V=this.#G===0?this.#j:this.#E.length!==0?this.#E.pop():this.#G===this.#Z?this.#y(!1):this.#G,this.#z[V]=Z,this.#Q[V]=J,this.#H.set(Z,V),this.#U[this.#j]=V,this.#B[V]=this.#j,this.#j=V,this.#G++,this.#f(V,H,G),G)G.set="add";if(W=!1,this.#_)this.#X?.(J,Z,"add")}else{this.#b(V);let F=this.#Q[V];if(J!==F){if(this.#C&&this.#q(F)){F.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:z}=F;if(z!==void 0&&!Q){if(this.#M)this.#Y?.(z,Z,"set");if(this.#w)this.#O?.push([z,Z,"set"])}}else if(!Q){if(this.#M)this.#Y?.(F,Z,"set");if(this.#w)this.#O?.push([F,Z,"set"])}if(this.#x(V),this.#f(V,H,G),this.#Q[V]=J,G){G.set="replace";let z=F&&this.#q(F)?F.__staleWhileFetching:F;if(z!==void 0)G.oldValue=z}}else if(G)G.set="update";if(this.#_)this.onInsert?.(J,Z,J===F?"update":"replace")}if(Y!==0&&!this.#R)this.#K();if(this.#R){if(!W)this.#S(V,Y,$);if(G)this.#P(G,V)}if(!Q&&this.#w&&this.#O){let F=this.#O,z;while(z=F?.shift())this.#$?.(...z)}return this}pop(){try{while(this.#G){let Z=this.#Q[this.#L];if(this.#y(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#w&&this.#O){let Z=this.#O,J;while(J=Z?.shift())this.#$?.(...J)}}}#y(Z){let J=this.#L,X=this.#z[J],Y=this.#Q[J];if(this.#C&&this.#q(Y))Y.__abortController.abort(new Error("evicted"));else if(this.#M||this.#w){if(this.#M)this.#Y?.(Y,X,"evict");if(this.#w)this.#O?.push([Y,X,"evict"])}if(this.#x(J),Z)this.#z[J]=void 0,this.#Q[J]=void 0,this.#E.push(J);if(this.#G===1)this.#L=this.#j=0,this.#E.length=0;else this.#L=this.#U[J];return this.#H.delete(X),this.#G--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:Y}=J,$=this.#H.get(Z);if($!==void 0){let Q=this.#Q[$];if(this.#q(Q)&&Q.__staleWhileFetching===void 0)return!1;if(!this.#D($)){if(X)this.#A($);if(Y)Y.has="hit",this.#P(Y,$);return!0}else if(Y)Y.has="stale",this.#P(Y,$)}else if(Y)Y.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,Y=this.#H.get(Z);if(Y===void 0||!X&&this.#D(Y))return;let $=this.#Q[Y];return this.#q($)?$.__staleWhileFetching:$}#h(Z,J,X,Y){let $=J===void 0?void 0:this.#Q[J];if(this.#q($))return $;let Q=new TB,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let G={signal:Q.signal,options:X,context:Y},W=(U,B=!1)=>{let{aborted:L}=Q.signal,w=X.ignoreFetchAbort&&U!==void 0;if(X.status)if(L&&!B){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,w)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(L&&!w&&!B)return V(Q.signal.reason);let O=z;if(this.#Q[J]===z)if(U===void 0)if(O.__staleWhileFetching)this.#Q[J]=O.__staleWhileFetching;else this.#v(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,U,G.options)}return U},H=(U)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=U;return V(U)},V=(U)=>{let{aborted:B}=Q.signal,L=B&&X.allowStaleOnFetchAbort,w=L||X.allowStaleOnFetchRejection,O=w||X.noDeleteOnFetchRejection,M=z;if(this.#Q[J]===z){if(!O||M.__staleWhileFetching===void 0)this.#v(Z,"fetch");else if(!L)this.#Q[J]=M.__staleWhileFetching}if(w){if(X.status&&M.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return M.__staleWhileFetching}else if(M.__returned===M)throw U},F=(U,B)=>{let L=this.#V?.(Z,$,G);if(L&&L instanceof Promise)L.then((w)=>U(w===void 0?void 0:w),B);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(U(void 0),X.allowStaleOnFetchAbort)U=(w)=>W(w,!0)}})};if(X.status)X.status.fetchDispatched=!0;let z=new Promise(F).then(W,H),q=Object.assign(z,{__abortController:Q,__staleWhileFetching:$,__returned:void 0});if(J===void 0)this.set(Z,q,{...G.options,status:void 0}),J=this.#H.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#C)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof TB}async fetch(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:Y=this.updateAgeOnGet,noDeleteOnStaleGet:$=this.noDeleteOnStaleGet,ttl:Q=this.ttl,noDisposeOnSet:K=this.noDisposeOnSet,size:G=0,sizeCalculation:W=this.sizeCalculation,noUpdateTTL:H=this.noUpdateTTL,noDeleteOnFetchRejection:V=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:F=this.allowStaleOnFetchRejection,ignoreFetchAbort:z=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:U,forceRefresh:B=!1,status:L,signal:w}=J;if(!this.#C){if(L)L.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,status:L})}let O={allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,ttl:Q,noDisposeOnSet:K,size:G,sizeCalculation:W,noUpdateTTL:H,noDeleteOnFetchRejection:V,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:q,ignoreFetchAbort:z,status:L,signal:w},M=this.#H.get(Z);if(M===void 0){if(L)L.fetch="miss";let R=this.#h(Z,M,O,U);return R.__returned=R}else{let R=this.#Q[M];if(this.#q(R)){let E=X&&R.__staleWhileFetching!==void 0;if(L){if(L.fetch="inflight",E)L.returnedStale=!0}return E?R.__staleWhileFetching:R.__returned=R}let D=this.#D(M);if(!B&&!D){if(L)L.fetch="hit";if(this.#b(M),Y)this.#A(M);if(L)this.#P(L,M);return R}let N=this.#h(Z,M,O,U),T=N.__staleWhileFetching!==void 0&&X;if(L){if(L.fetch=D?"stale":"refresh",T&&D)L.returnedStale=!0}return T?N.__staleWhileFetching:N.__returned=N}}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.#F;if(!X)throw new Error("no memoMethod provided to constructor");let{context:Y,forceRefresh:$,...Q}=J,K=this.get(Z,Q);if(!$&&K!==void 0)return K;let G=X(Z,K,{options:Q,context:Y});return this.set(Z,G,Q),G}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:Y=this.updateAgeOnGet,noDeleteOnStaleGet:$=this.noDeleteOnStaleGet,status:Q}=J,K=this.#H.get(Z);if(K!==void 0){let G=this.#Q[K],W=this.#q(G);if(Q)this.#P(Q,K);if(this.#D(K)){if(Q)Q.get="stale";if(!W){if(!$)this.#v(Z,"expire");if(Q&&X)Q.returnedStale=!0;return X?G:void 0}else{if(Q&&X&&G.__staleWhileFetching!==void 0)Q.returnedStale=!0;return X?G.__staleWhileFetching:void 0}}else{if(Q)Q.get="hit";if(W)return G.__staleWhileFetching;if(this.#b(K),Y)this.#A(K);return G}}else if(Q)Q.get="miss"}#c(Z,J){this.#B[J]=Z,this.#U[Z]=J}#b(Z){if(Z!==this.#j){if(Z===this.#L)this.#L=this.#U[Z];else this.#c(this.#B[Z],this.#U[Z]);this.#c(this.#j,Z),this.#j=Z}}delete(Z){return this.#v(Z,"delete")}#v(Z,J){let X=!1;if(this.#G!==0){let Y=this.#H.get(Z);if(Y!==void 0)if(X=!0,this.#G===1)this.#g(J);else{this.#x(Y);let $=this.#Q[Y];if(this.#q($))$.__abortController.abort(new Error("deleted"));else if(this.#M||this.#w){if(this.#M)this.#Y?.($,Z,J);if(this.#w)this.#O?.push([$,Z,J])}if(this.#H.delete(Z),this.#z[Y]=void 0,this.#Q[Y]=void 0,Y===this.#j)this.#j=this.#B[Y];else if(Y===this.#L)this.#L=this.#U[Y];else{let Q=this.#B[Y];this.#U[Q]=this.#U[Y];let K=this.#U[Y];this.#B[K]=this.#B[Y]}this.#G--,this.#E.push(Y)}}if(this.#w&&this.#O?.length){let Y=this.#O,$;while($=Y?.shift())this.#$?.(...$)}return X}clear(){return this.#g("delete")}#g(Z){for(let J of this.#I({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(new Error("deleted"));else{let Y=this.#z[J];if(this.#M)this.#Y?.(X,Y,Z);if(this.#w)this.#O?.push([X,Y,Z])}}if(this.#H.clear(),this.#Q.fill(void 0),this.#z.fill(void 0),this.#R&&this.#N)this.#R.fill(0),this.#N.fill(0);if(this.#k)this.#k.fill(0);if(this.#L=0,this.#j=0,this.#E.length=0,this.#W=0,this.#G=0,this.#w&&this.#O){let J=this.#O,X;while(X=J?.shift())this.#$?.(...X)}}}import{posix as Vj1,win32 as iC}from"node:path";import{fileURLToPath as zj1}from"node:url";import{lstatSync as Fj1,readdir as qj1,readdirSync as Uj1,readlinkSync as Lj1,realpathSync as Bj1}from"fs";import*as wj1 from"node:fs";import{lstat as Oj1,readdir as Mj1,readlink as Rj1,realpath as Nj1}from"node:fs/promises";import{EventEmitter as dC}from"node:events";import jn from"node:stream";import{StringDecoder as Zj1}from"node:string_decoder";var Un=typeof process==="object"&&process?process:{stdout:null,stderr:null},Jj1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof iY||Z instanceof jn||Xj1(Z)||Yj1(Z)),Xj1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof dC&&typeof Z.pipe==="function"&&Z.pipe!==jn.Writable.prototype.pipe,Yj1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof dC&&typeof Z.write==="function"&&typeof Z.end==="function",CZ=Symbol("EOF"),TZ=Symbol("maybeEmitEnd"),cJ=Symbol("emittedEnd"),EB=Symbol("emittingEnd"),TH=Symbol("emittedError"),kB=Symbol("closed"),Ln=Symbol("read"),IB=Symbol("flush"),Bn=Symbol("flushChunk"),S4=Symbol("encoding"),dK=Symbol("decoder"),t8=Symbol("flowing"),EH=Symbol("paused"),cK=Symbol("resume"),e8=Symbol("buffer"),s6=Symbol("pipes"),Z6=Symbol("bufferLength"),yC=Symbol("bufferPush"),_B=Symbol("bufferShift"),k6=Symbol("objectMode"),D8=Symbol("destroyed"),bC=Symbol("error"),gC=Symbol("emitData"),wn=Symbol("emitEnd"),mC=Symbol("emitEnd2"),R7=Symbol("async"),uC=Symbol("abort"),SB=Symbol("aborted"),kH=Symbol("signal"),pY=Symbol("dataListeners"),t5=Symbol("discarded"),IH=(Z)=>Promise.resolve().then(Z),$j1=(Z)=>Z(),Qj1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",Kj1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,Gj1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class cC{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[cK](),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 On extends cC{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Z,J,X){super(Z,J,X);this.proxyErrors=(Y)=>J.emit("error",Y),Z.on("error",this.proxyErrors)}}var Wj1=(Z)=>!!Z.objectMode,Hj1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class iY extends dC{[t8]=!1;[EH]=!1;[s6]=[];[e8]=[];[k6];[S4];[R7];[dK];[CZ]=!1;[cJ]=!1;[EB]=!1;[kB]=!1;[TH]=null;[Z6]=0;[D8]=!1;[kH];[SB]=!1;[pY]=0;[t5]=!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(Wj1(J))this[k6]=!0,this[S4]=null;else if(Hj1(J))this[S4]=J.encoding,this[k6]=!1;else this[k6]=!1,this[S4]=null;if(this[R7]=!!J.async,this[dK]=this[S4]?new Zj1(this[S4]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[e8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[s6]});let{signal:X}=J;if(X)if(this[kH]=X,X.aborted)this[uC]();else X.addEventListener("abort",()=>this[uC]())}get bufferLength(){return this[Z6]}get encoding(){return this[S4]}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[k6]}set objectMode(Z){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[R7]}set["async"](Z){this[R7]=this[R7]||!!Z}[uC](){this[SB]=!0,this.emit("abort",this[kH]?.reason),this.destroy(this[kH]?.reason)}get aborted(){return this[SB]}set aborted(Z){}write(Z,J,X){if(this[SB])return!1;if(this[CZ])throw new Error("write after end");if(this[D8])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 Y=this[R7]?IH:$j1;if(!this[k6]&&!Buffer.isBuffer(Z)){if(Gj1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(Kj1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[k6]){if(this[t8]&&this[Z6]!==0)this[IB](!0);if(this[t8])this.emit("data",Z);else this[yC](Z);if(this[Z6]!==0)this.emit("readable");if(X)Y(X);return this[t8]}if(!Z.length){if(this[Z6]!==0)this.emit("readable");if(X)Y(X);return this[t8]}if(typeof Z==="string"&&!(J===this[S4]&&!this[dK]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[S4])Z=this[dK].write(Z);if(this[t8]&&this[Z6]!==0)this[IB](!0);if(this[t8])this.emit("data",Z);else this[yC](Z);if(this[Z6]!==0)this.emit("readable");if(X)Y(X);return this[t8]}read(Z){if(this[D8])return null;if(this[t5]=!1,this[Z6]===0||Z===0||Z&&Z>this[Z6])return this[TZ](),null;if(this[k6])Z=null;if(this[e8].length>1&&!this[k6])this[e8]=[this[S4]?this[e8].join(""):Buffer.concat(this[e8],this[Z6])];let J=this[Ln](Z||null,this[e8][0]);return this[TZ](),J}[Ln](Z,J){if(this[k6])this[_B]();else{let X=J;if(Z===X.length||Z===null)this[_B]();else if(typeof X==="string")this[e8][0]=X.slice(Z),J=X.slice(0,Z),this[Z6]-=Z;else this[e8][0]=X.subarray(Z),J=X.subarray(0,Z),this[Z6]-=Z}if(this.emit("data",J),!this[e8].length&&!this[CZ])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[CZ]=!0,this.writable=!1,this[t8]||!this[EH])this[TZ]();return this}[cK](){if(this[D8])return;if(!this[pY]&&!this[s6].length)this[t5]=!0;if(this[EH]=!1,this[t8]=!0,this.emit("resume"),this[e8].length)this[IB]();else if(this[CZ])this[TZ]();else this.emit("drain")}resume(){return this[cK]()}pause(){this[t8]=!1,this[EH]=!0,this[t5]=!1}get destroyed(){return this[D8]}get flowing(){return this[t8]}get paused(){return this[EH]}[yC](Z){if(this[k6])this[Z6]+=1;else this[Z6]+=Z.length;this[e8].push(Z)}[_B](){if(this[k6])this[Z6]-=1;else this[Z6]-=this[e8][0].length;return this[e8].shift()}[IB](Z=!1){do;while(this[Bn](this[_B]())&&this[e8].length);if(!Z&&!this[e8].length&&!this[CZ])this.emit("drain")}[Bn](Z){return this.emit("data",Z),this[t8]}pipe(Z,J){if(this[D8])return Z;this[t5]=!1;let X=this[cJ];if(J=J||{},Z===Un.stdout||Z===Un.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[s6].push(!J.proxyErrors?new cC(this,Z,J):new On(this,Z,J)),this[R7])IH(()=>this[cK]());else this[cK]();return Z}unpipe(Z){let J=this[s6].find((X)=>X.dest===Z);if(J){if(this[s6].length===1){if(this[t8]&&this[pY]===0)this[t8]=!1;this[s6]=[]}else this[s6].splice(this[s6].indexOf(J),1);J.unpipe()}}addListener(Z,J){return this.on(Z,J)}on(Z,J){let X=super.on(Z,J);if(Z==="data"){if(this[t5]=!1,this[pY]++,!this[s6].length&&!this[t8])this[cK]()}else if(Z==="readable"&&this[Z6]!==0)super.emit("readable");else if(Qj1(Z)&&this[cJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[TH]){let Y=J;if(this[R7])IH(()=>Y.call(this,this[TH]));else Y.call(this,this[TH])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[pY]=this.listeners("data").length,this[pY]===0&&!this[t5]&&!this[s6].length)this[t8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[pY]=0,!this[t5]&&!this[s6].length)this[t8]=!1}return J}get emittedEnd(){return this[cJ]}[TZ](){if(!this[EB]&&!this[cJ]&&!this[D8]&&this[e8].length===0&&this[CZ]){if(this[EB]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[kB])this.emit("close");this[EB]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==D8&&this[D8])return!1;else if(Z==="data")return!this[k6]&&!X?!1:this[R7]?(IH(()=>this[gC](X)),!0):this[gC](X);else if(Z==="end")return this[wn]();else if(Z==="close"){if(this[kB]=!0,!this[cJ]&&!this[D8])return!1;let $=super.emit("close");return this.removeAllListeners("close"),$}else if(Z==="error"){this[TH]=X,super.emit(bC,X);let $=!this[kH]||this.listeners("error").length?super.emit("error",X):!1;return this[TZ](),$}else if(Z==="resume"){let $=super.emit("resume");return this[TZ](),$}else if(Z==="finish"||Z==="prefinish"){let $=super.emit(Z);return this.removeAllListeners(Z),$}let Y=super.emit(Z,...J);return this[TZ](),Y}[gC](Z){for(let X of this[s6])if(X.dest.write(Z)===!1)this.pause();let J=this[t5]?!1:super.emit("data",Z);return this[TZ](),J}[wn](){if(this[cJ])return!1;return this[cJ]=!0,this.readable=!1,this[R7]?(IH(()=>this[mC]()),!0):this[mC]()}[mC](){if(this[dK]){let J=this[dK].end();if(J){for(let X of this[s6])X.dest.write(J);if(!this[t5])super.emit("data",J)}}for(let J of this[s6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[k6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[k6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[k6])throw new Error("cannot concat in objectMode");let Z=await this.collect();return this[S4]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(D8,()=>J(new Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[t5]=!1;let Z=!1,J=async()=>{return this.pause(),Z=!0,{value:void 0,done:!0}};return{next:()=>{if(Z)return J();let Y=this.read();if(Y!==null)return Promise.resolve({done:!1,value:Y});if(this[CZ])return J();let $,Q,K=(V)=>{this.off("data",G),this.off("end",W),this.off(D8,H),J(),Q(V)},G=(V)=>{this.off("error",K),this.off("end",W),this.off(D8,H),this.pause(),$({value:V,done:!!this[CZ]})},W=()=>{this.off("error",K),this.off("data",G),this.off(D8,H),J(),$({done:!0,value:void 0})},H=()=>K(new Error("stream destroyed"));return new Promise((V,F)=>{Q=F,$=V,this.once(D8,H),this.once("error",K),this.once("end",W),this.once("data",G)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[t5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(bC,J),this.off(D8,J),this.off("end",J),Z=!0,{done:!0,value:void 0}},X=()=>{if(Z)return J();let Y=this.read();return Y===null?J():{done:!1,value:Y}};return this.once("end",J),this.once(bC,J),this.once(D8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[D8]){if(Z)this.emit("error",Z);else this.emit(D8);return this}this[D8]=!0,this[t5]=!0,this[e8].length=0,this[Z6]=0;let J=this;if(typeof J.close==="function"&&!this[kB])J.close();if(Z)this.emit("error",Z);else this.emit(D8);return this}static get isStream(){return Jj1}}var jj1=Bj1.native,SH={lstatSync:Fj1,readdir:qj1,readdirSync:Uj1,readlinkSync:Lj1,realpathSync:jj1,promises:{lstat:Oj1,readdir:Mj1,readlink:Rj1,realpath:Nj1}},Dn=(Z)=>!Z||Z===SH||Z===wj1?SH:{...SH,...Z,promises:{...SH.promises,...Z.promises||{}}},Cn=/^\\\\\?\\([a-z]:)\\?$/i,Pj1=(Z)=>Z.replace(/\//g,"\\").replace(Cn,"$1\\"),Dj1=/[\\\/]/,h9=0,Tn=1,En=2,N7=4,kn=6,In=8,nY=10,_n=12,x9=15,_H=~x9,lC=16,Mn=32,vH=64,v4=128,vB=256,xB=512,Rn=vH|v4|xB,Cj1=1023,pC=(Z)=>Z.isFile()?In:Z.isDirectory()?N7:Z.isSymbolicLink()?nY:Z.isCharacterDevice()?En:Z.isBlockDevice()?kn:Z.isSocket()?_n:Z.isFIFO()?Tn:h9,Nn=new Map,AH=(Z)=>{let J=Nn.get(Z);if(J)return J;let X=Z.normalize("NFKD");return Nn.set(Z,X),X},Pn=new Map,AB=(Z)=>{let J=Pn.get(Z);if(J)return J;let X=AH(Z.toLowerCase());return Pn.set(Z,X),X};class nC extends CH{constructor(){super({max:256})}}class Sn extends CH{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var vn=Symbol("PathScurry setAsCwd");class o6{name;root;roots;parent;nocase;isCWD=!1;#Z;#J;get dev(){return this.#J}#Y;get mode(){return this.#Y}#X;get nlink(){return this.#X}#$;get uid(){return this.#$}#V;get gid(){return this.#V}#F;get rdev(){return this.#F}#G;get blksize(){return this.#G}#W;get ino(){return this.#W}#H;get size(){return this.#H}#z;get blocks(){return this.#z}#Q;get atimeMs(){return this.#Q}#U;get mtimeMs(){return this.#U}#B;get ctimeMs(){return this.#B}#L;get birthtimeMs(){return this.#L}#j;get atime(){return this.#j}#E;get mtime(){return this.#E}#O;get ctime(){return this.#O}#k;get birthtime(){return this.#k}#N;#R;#M;#C;#w;#_;#K;#A;#P;#S;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=h9,X,Y,$,Q,K){if(this.name=Z,this.#N=$?AB(Z):AH(Z),this.#K=J&Cj1,this.nocase=$,this.roots=Y,this.root=X||this,this.#A=Q,this.#M=K.fullpath,this.#w=K.relative,this.#_=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=Dn(K.fs)}depth(){if(this.#R!==void 0)return this.#R;if(!this.parent)return this.#R=0;return this.#R=this.parent.depth()+1}childrenCache(){return this.#A}resolve(Z){if(!Z)return this;let J=this.getRootString(Z),Y=Z.substring(J.length).split(this.splitSep);return J?this.getRoot(J).#D(Y):this.#D(Y)}#D(Z){let J=this;for(let X of Z)J=J.child(X);return J}children(){let Z=this.#A.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#A.set(this,J),this.#K&=~lC,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),Y=this.nocase?AB(Z):AH(Z);for(let G of X)if(G.#N===Y)return G;let $=this.parent?this.sep:"",Q=this.#M?this.#M+$+Z:void 0,K=this.newChild(Z,h9,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=v4;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#w!==void 0)return this.#w;let Z=this.name,J=this.parent;if(!J)return this.#w=this.name;let X=J.relative();return X+(!X||!J.parent?"":this.sep)+Z}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#_!==void 0)return this.#_;let Z=this.name,J=this.parent;if(!J)return this.#_=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#M!==void 0)return this.#M;let Z=this.name,J=this.parent;if(!J)return this.#M=this.name;let Y=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#M=Y}fullpathPosix(){if(this.#C!==void 0)return this.#C;if(this.sep==="/")return this.#C=this.fullpath();if(!this.parent){let Y=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(Y))return this.#C=`//?/${Y}`;else return this.#C=Y}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#C=X}isUnknown(){return(this.#K&x9)===h9}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&x9)===In}isDirectory(){return(this.#K&x9)===N7}isCharacterDevice(){return(this.#K&x9)===En}isBlockDevice(){return(this.#K&x9)===kn}isFIFO(){return(this.#K&x9)===Tn}isSocket(){return(this.#K&x9)===_n}isSymbolicLink(){return(this.#K&nY)===nY}lstatCached(){return this.#K&Mn?this:void 0}readlinkCached(){return this.#P}realpathCached(){return this.#S}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#P)return!0;if(!this.parent)return!1;let Z=this.#K&x9;return!(Z!==h9&&Z!==nY||this.#K&vB||this.#K&v4)}calledReaddir(){return!!(this.#K&lC)}isENOENT(){return!!(this.#K&v4)}isNamed(Z){return!this.nocase?this.#N===AH(Z):this.#N===AB(Z)}async readlink(){let Z=this.#P;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.#P=X}catch(J){this.#y(J.code);return}}readlinkSync(){let Z=this.#P;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.#P=X}catch(J){this.#y(J.code);return}}#m(Z){this.#K|=lC;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#x()}}#x(){if(this.#K&v4)return;this.#K=(this.#K|v4)&_H,this.#f()}#f(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#x()}#u(){this.#K|=xB,this.#T()}#T(){if(this.#K&vH)return;let Z=this.#K;if((Z&x9)===N7)Z&=_H;this.#K=Z|vH,this.#f()}#I(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#T();else if(Z==="ENOENT")this.#x();else this.children().provisional=0}#d(Z=""){if(Z==="ENOTDIR")this.parent.#T();else if(Z==="ENOENT")this.#x()}#y(Z=""){let J=this.#K;if(J|=vB,Z==="ENOENT")J|=v4;if(Z==="EINVAL"||Z==="UNKNOWN")J&=_H;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#T()}#h(Z,J){return this.#c(Z,J)||this.#q(Z,J)}#q(Z,J){let X=pC(Z),Y=this.newChild(Z.name,X,{parent:this}),$=Y.#K&x9;if($!==N7&&$!==nY&&$!==h9)Y.#K|=vH;return J.unshift(Y),J.provisional++,Y}#c(Z,J){for(let X=J.provisional;X<J.length;X++){let Y=J[X];if((this.nocase?AB(Z.name):AH(Z.name))!==Y.#N)continue;return this.#b(Z,Y,X,J)}}#b(Z,J,X,Y){let $=J.name;if(J.#K=J.#K&_H|pC(Z),$!==Z.name)J.name=Z.name;if(X!==Y.provisional){if(X===Y.length-1)Y.pop();else Y.splice(X,1);Y.unshift(J)}return Y.provisional++,J}async lstat(){if((this.#K&v4)===0)try{return this.#v(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#d(Z.code)}}lstatSync(){if((this.#K&v4)===0)try{return this.#v(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#d(Z.code)}}#v(Z){let{atime:J,atimeMs:X,birthtime:Y,birthtimeMs:$,blksize:Q,blocks:K,ctime:G,ctimeMs:W,dev:H,gid:V,ino:F,mode:z,mtime:q,mtimeMs:U,nlink:B,rdev:L,size:w,uid:O}=Z;this.#j=J,this.#Q=X,this.#k=Y,this.#L=$,this.#G=Q,this.#z=K,this.#O=G,this.#B=W,this.#J=H,this.#V=V,this.#W=F,this.#Y=z,this.#E=q,this.#U=U,this.#X=B,this.#F=L,this.#H=w,this.#$=O;let M=pC(Z);if(this.#K=this.#K&_H|M|Mn,M!==h9&&M!==N7&&M!==nY)this.#K|=vH}#g=[];#p=!1;#i(Z){this.#p=!1;let J=this.#g.slice();this.#g.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 $=X.slice(0,X.provisional);if(J)Z(null,$);else queueMicrotask(()=>Z(null,$));return}if(this.#g.push(Z),this.#p)return;this.#p=!0;let Y=this.fullpath();this.#Z.readdir(Y,{withFileTypes:!0},($,Q)=>{if($)this.#I($.code),X.provisional=0;else{for(let K of Q)this.#h(K,X);this.#m(X)}this.#i(X.slice(0,X.provisional));return})}#l;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.#l)await this.#l;else{let X=()=>{};this.#l=new Promise((Y)=>X=Y);try{for(let Y of await this.#Z.promises.readdir(J,{withFileTypes:!0}))this.#h(Y,Z);this.#m(Z)}catch(Y){this.#I(Y.code),Z.provisional=0}this.#l=void 0,X()}return Z.slice(0,Z.provisional)}readdirSync(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();try{for(let X of this.#Z.readdirSync(J,{withFileTypes:!0}))this.#h(X,Z);this.#m(Z)}catch(X){this.#I(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&Rn)return!1;let Z=x9&this.#K;if(!(Z===h9||Z===N7||Z===nY))return!1;return!0}shouldWalk(Z,J){return(this.#K&N7)===N7&&!(this.#K&Rn)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#S)return this.#S;if((xB|vB|v4)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#S=this.resolve(Z)}catch(Z){this.#u()}}realpathSync(){if(this.#S)return this.#S;if((xB|vB|v4)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#S=this.resolve(Z)}catch(Z){this.#u()}}[vn](Z){if(Z===this)return;Z.isCWD=!1,this.isCWD=!0;let J=new Set([]),X=[],Y=this;while(Y&&Y.parent)J.add(Y),Y.#w=X.join(this.sep),Y.#_=X.join("/"),Y=Y.parent,X.push("..");Y=Z;while(Y&&Y.parent&&!J.has(Y))Y.#w=void 0,Y.#_=void 0,Y=Y.parent}}class hB extends o6{sep="\\";splitSep=Dj1;constructor(Z,J=h9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}newChild(Z,J=h9,X={}){return new hB(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return iC.parse(Z).root}getRoot(Z){if(Z=Pj1(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 xH(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(Cn,"$1\\"),Z===J}}class fB extends o6{splitSep="/";sep="/";constructor(Z,J=h9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=h9,X={}){return new fB(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class aC{root;rootPath;roots;cwd;#Z;#J;#Y;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:Y,childrenCacheSize:$=16384,fs:Q=SH}={}){if(this.#X=Dn(Q),Z instanceof URL||Z.startsWith("file://"))Z=zj1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new nC,this.#J=new nC,this.#Y=new Sn($);let G=K.substring(this.rootPath.length).split(X);if(G.length===1&&!G[0])G.pop();if(Y===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=Y,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let W=this.root,H=G.length-1,V=J.sep,F=this.rootPath,z=!1;for(let q of G){let U=H--;W=W.child(q,{relative:new Array(U).fill("..").join(V),relativePosix:new Array(U).fill("..").join("/"),fullpath:F+=(z?"":V)+q}),z=!0}this.cwd=W}depth(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.depth()}childrenCache(){return this.#Y}resolve(...Z){let J="";for(let $=Z.length-1;$>=0;$--){let Q=Z[$];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 Y=this.cwd.resolve(J).fullpath();return this.#Z.set(J,Y),Y}resolvePosix(...Z){let J="";for(let $=Z.length-1;$>=0;$--){let Q=Z[$];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 Y=this.cwd.resolve(J).fullpathPosix();return this.#J.set(J,Y),Y}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 o6))J=Z,Z=this.cwd;let{withFileTypes:X}=J;if(!Z.canReaddir())return[];else{let Y=await Z.readdir();return X?Y:Y.map(($)=>$.name)}}readdirSync(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof o6))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((Y)=>Y.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 o6))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 o6))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 o6))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 o6))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 o6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let G=new Set,W=(V,F)=>{G.add(V),V.readdirCB((z,q)=>{if(z)return F(z);let U=q.length;if(!U)return F();let B=()=>{if(--U===0)F()};for(let L of q){if(!$||$(L))K.push(X?L:L.fullpath());if(Y&&L.isSymbolicLink())L.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(G,Q)?W(w,B):B());else if(L.shouldWalk(G,Q))W(L,B);else B()}},!0)},H=Z;return new Promise((V,F)=>{W(H,(z)=>{if(z)return F(z);V(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof o6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let G=new Set([Z]);for(let W of G){let H=W.readdirSync();for(let V of H){if(!$||$(V))K.push(X?V:V.fullpath());let F=V;if(V.isSymbolicLink()){if(!(Y&&(F=V.realpathSync())))continue;if(F.isUnknown())F.lstatSync()}if(F.shouldWalk(G,Q))G.add(F)}}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 o6))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 o6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J;if(!$||$(Z))yield X?Z:Z.fullpath();let K=new Set([Z]);for(let G of K){let W=G.readdirSync();for(let H of W){if(!$||$(H))yield X?H:H.fullpath();let V=H;if(H.isSymbolicLink()){if(!(Y&&(V=H.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 o6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new iY({objectMode:!0});if(!$||$(Z))K.write(X?Z:Z.fullpath());let G=new Set,W=[Z],H=0,V=()=>{let F=!1;while(!F){let z=W.shift();if(!z){if(H===0)K.end();return}H++,G.add(z);let q=(B,L,w=!1)=>{if(B)return K.emit("error",B);if(Y&&!w){let O=[];for(let M of L)if(M.isSymbolicLink())O.push(M.realpath().then((R)=>R?.isUnknown()?R.lstat():R));if(O.length){Promise.all(O).then(()=>q(null,L,!0));return}}for(let O of L)if(O&&(!$||$(O))){if(!K.write(X?O:O.fullpath()))F=!0}H--;for(let O of L){let M=O.realpathCached()||O;if(M.shouldWalk(G,Q))W.push(M)}if(F&&!K.flowing)K.once("drain",V);else if(!U)V()},U=!0;z.readdirCB(q,!0),U=!1}};return V(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof o6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new iY({objectMode:!0}),G=new Set;if(!$||$(Z))K.write(X?Z:Z.fullpath());let W=[Z],H=0,V=()=>{let F=!1;while(!F){let z=W.shift();if(!z){if(H===0)K.end();return}H++,G.add(z);let q=z.readdirSync();for(let U of q)if(!$||$(U)){if(!K.write(X?U:U.fullpath()))F=!0}H--;for(let U of q){let B=U;if(U.isSymbolicLink()){if(!(Y&&(B=U.realpathSync())))continue;if(B.isUnknown())B.lstatSync()}if(B.shouldWalk(G,Q))W.push(B)}}if(F&&!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[vn](J)}}class xH extends aC{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,iC,"\\",{...J,nocase:X});this.nocase=X;for(let Y=this.cwd;Y;Y=Y.parent)Y.nocase=this.nocase}parseRootPath(Z){return iC.parse(Z).root.toUpperCase()}newRoot(Z){return new hB(this.rootPath,N7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class hH extends aC{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,Vj1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new fB(this.rootPath,N7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class yB extends hH{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var gI6=process.platform==="win32"?hB:fB,An=process.platform==="win32"?xH:process.platform==="darwin"?yB:hH;var Tj1=(Z)=>Z.length>=1,Ej1=(Z)=>Z.length>=1;class lK{#Z;#J;#Y;length;#X;#$;#V;#F;#G;#W;#H=!0;constructor(Z,J,X,Y){if(!Tj1(Z))throw new TypeError("empty pattern list");if(!Ej1(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.#Y=X,this.#X=Y,this.#Y===0){if(this.isUNC()){let[$,Q,K,G,...W]=this.#Z,[H,V,F,z,...q]=this.#J;if(W[0]==="")W.shift(),q.shift();let U=[$,Q,K,G,""].join("/"),B=[H,V,F,z,""].join("/");this.#Z=[U,...W],this.#J=[B,...q],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[$,...Q]=this.#Z,[K,...G]=this.#J;if(Q[0]==="")Q.shift(),G.shift();let W=$+"/",H=K+"/";this.#Z=[W,...Q],this.#J=[H,...G],this.length=this.#Z.length}}}pattern(){return this.#Z[this.#Y]}isString(){return typeof this.#Z[this.#Y]==="string"}isGlobstar(){return this.#Z[this.#Y]===B6}isRegExp(){return this.#Z[this.#Y]instanceof RegExp}globString(){return this.#V=this.#V||(this.#Y===0?this.isAbsolute()?this.#J[0]+this.#J.slice(1).join("/"):this.#J.join("/"):this.#J.slice(this.#Y).join("/"))}hasMore(){return this.length>this.#Y+1}rest(){if(this.#$!==void 0)return this.#$;if(!this.hasMore())return this.#$=null;return this.#$=new lK(this.#Z,this.#J,this.#Y+1,this.#X),this.#$.#W=this.#W,this.#$.#G=this.#G,this.#$.#F=this.#F,this.#$}isUNC(){let Z=this.#Z;return this.#G!==void 0?this.#G:this.#G=this.#X==="win32"&&this.#Y===0&&Z[0]===""&&Z[1]===""&&typeof Z[2]==="string"&&!!Z[2]&&typeof Z[3]==="string"&&!!Z[3]}isDrive(){let Z=this.#Z;return this.#F!==void 0?this.#F:this.#F=this.#X==="win32"&&this.#Y===0&&this.length>1&&typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0])}isAbsolute(){let Z=this.#Z;return this.#W!==void 0?this.#W:this.#W=Z[0]===""&&Z.length>1||this.isDrive()||this.isUNC()}root(){let Z=this.#Z[0];return typeof Z==="string"&&this.isAbsolute()&&this.#Y===0?Z:""}checkFollowGlobstar(){return!(this.#Y===0||!this.isGlobstar()||!this.#H)}markFollowGlobstar(){if(this.#Y===0||!this.isGlobstar()||!this.#H)return!1;return this.#H=!1,!0}}var kj1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class fH{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:Y,noglobstar:$,platform:Q=kj1}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=Q,this.mmopts={dot:!0,nobrace:J,nocase:X,noext:Y,noglobstar:$,optimizationLevel:2,platform:Q,nocomment:!0,nonegate:!0};for(let K of Z)this.add(K)}add(Z){let J=new A9(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let Y=J.set[X],$=J.globParts[X];if(!Y||!$)throw new Error("invalid pattern object");while(Y[0]==="."&&$[0]===".")Y.shift(),$.shift();let Q=new lK(Y,$,0,this.platform),K=new A9(Q.globString(),this.mmopts),G=$[$.length-1]==="**",W=Q.isAbsolute();if(W)this.absolute.push(K);else this.relative.push(K);if(G)if(W)this.absoluteChildren.push(K);else this.relativeChildren.push(K)}}ignored(Z){let J=Z.fullpath(),X=`${J}/`,Y=Z.relative()||".",$=`${Y}/`;for(let Q of this.relative)if(Q.match(Y)||Q.match($))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 Y of this.relativeChildren)if(Y.match(X))return!0;for(let Y of this.absoluteChildren)if(Y.match(J))return!0;return!1}}class sC{store;constructor(Z=new Map){this.store=Z}copy(){return new sC(new Map(this.store))}hasWalked(Z,J){return this.store.get(Z.fullpath())?.has(J.globString())}storeWalked(Z,J){let X=Z.fullpath(),Y=this.store.get(X);if(Y)Y.add(J.globString());else this.store.set(X,new Set([J.globString()]))}}class xn{store=new Map;add(Z,J,X){let Y=(J?2:0)|(X?1:0),$=this.store.get(Z);this.store.set(Z,$===void 0?Y:Y&$)}entries(){return[...this.store.entries()].map(([Z,J])=>[Z,!!(J&2),!!(J&1)])}}class hn{store=new Map;add(Z,J){if(!Z.canReaddir())return;let X=this.store.get(Z);if(X){if(!X.find((Y)=>Y.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 yH{hasWalkedCache;matches=new xn;subwalks=new hn;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new sC}processPatterns(Z,J){this.patterns=J;let X=J.map((Y)=>[Z,Y]);for(let[Y,$]of X){this.hasWalkedCache.storeWalked(Y,$);let Q=$.root(),K=$.isAbsolute()&&this.opts.absolute!==!1;if(Q){Y=Y.resolve(Q==="/"&&this.opts.root!==void 0?this.opts.root:Q);let V=$.rest();if(!V){this.matches.add(Y,!0,!1);continue}else $=V}if(Y.isENOENT())continue;let G,W,H=!1;while(typeof(G=$.pattern())==="string"&&(W=$.rest()))Y=Y.resolve(G),$=W,H=!0;if(G=$.pattern(),W=$.rest(),H){if(this.hasWalkedCache.hasWalked(Y,$))continue;this.hasWalkedCache.storeWalked(Y,$)}if(typeof G==="string"){let V=G===".."||G===""||G===".";this.matches.add(Y.resolve(G),K,V);continue}else if(G===B6){if(!Y.isSymbolicLink()||this.follow||$.checkFollowGlobstar())this.subwalks.add(Y,$);let V=W?.pattern(),F=W?.rest();if(!W||(V===""||V===".")&&!F)this.matches.add(Y,K,V===""||V===".");else if(V===".."){let z=Y.parent||Y;if(!F)this.matches.add(z,K,!0);else if(!this.hasWalkedCache.hasWalked(z,F))this.subwalks.add(z,F)}}else if(G instanceof RegExp)this.subwalks.add(Y,$)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new yH(this.opts,this.hasWalkedCache)}filterEntries(Z,J){let X=this.subwalks.get(Z),Y=this.child();for(let $ of J)for(let Q of X){let K=Q.isAbsolute(),G=Q.pattern(),W=Q.rest();if(G===B6)Y.testGlobstar($,Q,W,K);else if(G instanceof RegExp)Y.testRegExp($,G,W,K);else Y.testString($,G,W,K)}return Y}testGlobstar(Z,J,X,Y){if(this.dot||!Z.name.startsWith(".")){if(!J.hasMore())this.matches.add(Z,Y,!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 $=X.pattern();if(typeof $==="string"&&$!==".."&&$!==""&&$!==".")this.testString(Z,$,X.rest(),Y);else if($===".."){let Q=Z.parent||Z;this.subwalks.add(Q,X)}else if($ instanceof RegExp)this.testRegExp(Z,$,X.rest(),Y)}}testRegExp(Z,J,X,Y){if(!J.test(Z.name))return;if(!X)this.matches.add(Z,Y,!1);else this.subwalks.add(Z,X)}testString(Z,J,X,Y){if(!Z.isNamed(J))return;if(!X)this.matches.add(Z,Y,!1);else this.subwalks.add(Z,X)}}var Ij1=(Z,J)=>typeof Z==="string"?new fH([Z],J):Array.isArray(Z)?new fH(Z,J):Z;class oC{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#J;#Y;signal;maxDepth;includeChildMatches;constructor(Z,J,X){if(this.patterns=Z,this.path=J,this.opts=X,this.#Y=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#J=Ij1(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)}#$(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 $=Z.isUnknown()||this.opts.stat?await Z.lstat():Z;if(this.opts.follow&&this.opts.nodir&&$?.isSymbolicLink()){let Q=await $.realpath();if(Q&&(Q.isUnknown()||this.opts.stat))await Q.lstat()}return this.matchCheckTest($,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 $=Z.isUnknown()||this.opts.stat?Z.lstatSync():Z;if(this.opts.follow&&this.opts.nodir&&$?.isSymbolicLink()){let Q=$.realpathSync();if(Q&&(Q?.isUnknown()||this.opts.stat))Q.lstatSync()}return this.matchCheckTest($,J)}matchFinish(Z,J){if(this.#X(Z))return;if(!this.includeChildMatches&&this.#J?.add){let $=`${Z.relativePosix()}/**`;this.#J.add($)}let X=this.opts.absolute===void 0?J:this.opts.absolute;this.seen.add(Z);let Y=this.opts.mark&&Z.isDirectory()?this.#Y:"";if(this.opts.withFileTypes)this.matchEmit(Z);else if(X){let $=this.opts.posix?Z.fullpathPosix():Z.fullpath();this.matchEmit($+Y)}else{let $=this.opts.posix?Z.relativePosix():Z.relative(),Q=this.opts.dotRelative&&!$.startsWith(".."+this.#Y)?"."+this.#Y:"";this.matchEmit(!$?"."+Y:Q+$+Y)}}async match(Z,J,X){let Y=await this.matchCheck(Z,X);if(Y)this.matchFinish(Y,J)}matchSync(Z,J,X){let Y=this.matchCheckSync(Z,X);if(Y)this.matchFinish(Y,J)}walkCB(Z,J,X){if(this.signal?.aborted)X();this.walkCB2(Z,J,new yH(this.opts),X)}walkCB2(Z,J,X,Y){if(this.#$(Z))return Y();if(this.signal?.aborted)Y();if(this.paused){this.onResume(()=>this.walkCB2(Z,J,X,Y));return}X.processPatterns(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,G,W]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,G,W).then(()=>Q())}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let G=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,G,X,Q);else K.readdirCB((W,H)=>this.walkCB3(K,H,X,Q),!0)}Q()}walkCB3(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,G,W]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,G,W).then(()=>Q())}for(let[K,G]of X.subwalks.entries())$++,this.walkCB2(K,G,X.child(),Q);Q()}walkCBSync(Z,J,X){if(this.signal?.aborted)X();this.walkCB2Sync(Z,J,new yH(this.opts),X)}walkCB2Sync(Z,J,X,Y){if(this.#$(Z))return Y();if(this.signal?.aborted)Y();if(this.paused){this.onResume(()=>this.walkCB2Sync(Z,J,X,Y));return}X.processPatterns(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,G,W]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,G,W)}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let G=K.readdirSync();this.walkCB3Sync(K,G,X,Q)}Q()}walkCB3Sync(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,G,W]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,G,W)}for(let[K,G]of X.subwalks.entries())$++,this.walkCB2Sync(K,G,X.child(),Q);Q()}}class bB extends oC{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 gB extends oC{results;constructor(Z,J,X){super(Z,J,X);this.results=new iY({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 Sj1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class P7{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=_j1(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((G)=>G.replace(/\\/g,"/"));if(this.matchBase){if(J.noglobstar)throw new TypeError("base matching requires globstar");Z=Z.map((G)=>G.includes("/")?G:`./**/${G}`)}if(this.pattern=Z,this.platform=J.platform||Sj1,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 G=J.platform==="win32"?xH:J.platform==="darwin"?yB:J.platform?hH:An;this.scurry=new G(this.cwd,{nocase:J.nocase,fs:J.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",Y={...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},$=this.pattern.map((G)=>new A9(G,Y)),[Q,K]=$.reduce((G,W)=>{return G[0].push(...W.set),G[1].push(...W.globParts),G},[[],[]]);this.patterns=Q.map((G,W)=>{let H=K[W];if(!H)throw new Error("invalid pattern object");return new lK(G,H,0,this.platform)})}async walk(){return[...await new bB(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 bB(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 gB(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 gB(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 rC=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new A9(X,J).hasMagic())return!0;return!1};function uB(Z,J={}){return new P7(Z,J).streamSync()}function yn(Z,J={}){return new P7(Z,J).stream()}function bn(Z,J={}){return new P7(Z,J).walkSync()}async function fn(Z,J={}){return new P7(Z,J).walk()}function dB(Z,J={}){return new P7(Z,J).iterateSync()}function gn(Z,J={}){return new P7(Z,J).iterate()}var vj1=uB,Aj1=Object.assign(yn,{sync:uB}),xj1=dB,hj1=Object.assign(gn,{sync:dB}),fj1=Object.assign(bn,{stream:uB,iterate:dB}),mB=Object.assign(fn,{glob:fn,globSync:bn,sync:fj1,globStream:yn,stream:Aj1,globStreamSync:uB,streamSync:vj1,globIterate:gn,iterate:hj1,globIterateSync:dB,iterateSync:xj1,Glob:P7,hasMagic:rC,escape:gK,unescape:_4});mB.glob=mB;class tC{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 Y=this._listeners[Z];if(Y!==void 0){let $=Y.indexOf(J);if($!==-1)Y.splice($,1)}return this}dispatchEvent(Z){let X=this._listeners[Z.type];if(X!==void 0){let Y=X.slice(0);for(let $=0,Q=Y.length;$<Q;$++)Y[$].call(this,Z)}return this}dispose(){for(let Z in this._listeners)delete this._listeners[Z]}}class T5{constructor(Z,J,X,Y={}){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=Y,!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 pK extends tC{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,Y){let $=new T5(Z,J,X,Y);this._edges.add($);let Q=$.getParent();if(!this._parentEdges.has(Q))this._parentEdges.set(Q,new Set);this._parentEdges.get(Q).add($);let K=$.getChild();if(!this._childEdges.has(K))this._childEdges.set(K,new Set);return this._childEdges.get(K).add($),$}_destroyEdge(Z){return this._edges.delete(Z),this._parentEdges.get(Z.getParent()).delete(Z),this._childEdges.get(Z.getChild()).delete(Z),this}}function bH(){return bH=Object.assign||function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)if(Object.prototype.hasOwnProperty.call(X,Y))Z[Y]=X[Y]}return Z},bH.apply(this,arguments)}class I6{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 E0{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 e1{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 y0=Symbol("attributes"),A4=Symbol("immutableKeys");class iK extends tC{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[y0]=void 0,this[A4]=void 0,this.graph=Z,this[A4]=new Set,this[y0]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let Y=Z[X];if(Y instanceof iK){let $=this.graph._createEdge(X,this,Y);this[A4].add(X),J[X]=$}else J[X]=Y}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[y0]){let Y=this[y0][X];if(Y instanceof T5){let $=Y;if($.getChild()===Z)this.setRef(X,J,$.getAttributes())}else if(Y instanceof I6)for(let $ of Y.listRefsByChild(Z)){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if(Y instanceof E0){let $=Y.getRefByChild(Z);if($){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if(Y instanceof e1)for(let $ of Y.keys()){let Q=Y.get($);if(Q.getChild()===Z)this.setRefMap(X,$,J,Q.getAttributes())}}return this}get(Z){return this[y0][Z]}set(Z,J){return this[y0][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[y0][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[A4].has(Z))throw new Error(`Cannot overwrite immutable attribute, "${Z}".`);let Y=this[y0][Z];if(Y)Y.dispose();if(!J)return this;let $=this.graph._createEdge(Z,this,J,X);return this[y0][Z]=$,this.dispatchEvent({type:"change",attribute:Z})}listRefs(Z){return this.assertRefList(Z).values().map((X)=>X.getChild())}addRef(Z,J,X){let Y=this.graph._createEdge(Z,this,J,X);return this.assertRefList(Z).add(Y),this.dispatchEvent({type:"change",attribute:Z})}removeRef(Z,J){let X=this.assertRefList(Z);if(X instanceof I6)for(let Y of X.listRefsByChild(J))Y.dispose();else{let Y=X.getRefByChild(J);if(Y)Y.dispose()}return this}assertRefList(Z){let J=this[y0][Z];if(J instanceof I6||J instanceof E0)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 Y=this.assertRefMap(Z).get(J);return Y?Y.getChild():null}setRefMap(Z,J,X,Y){let $=this.assertRefMap(Z),Q=$.get(J);if(Q)Q.dispose();if(!X)return this;Y=Object.assign(Y||{},{key:J});let K=this.graph._createEdge(Z,this,X,bH({},Y,{key:J}));return $.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[y0][Z];if(J instanceof e1)return J;throw new Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(bH({},Z,{target:this})),this.graph.dispatchEvent(bH({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[y0][J]===Z){if(this[y0][J]=null,this[A4].has(J))Z.getChild().dispose()}else if(this[y0][J]instanceof I6)this[y0][J].remove(Z);else if(this[y0][J]instanceof E0)this[y0][J].remove(Z);else if(this[y0][J]instanceof e1){let X=this[y0][J];for(let Y of X.keys())if(X.get(Y)===Z)X.delete(Y)}else return;this.graph._destroyEdge(Z),this.dispatchEvent({type:"change",attribute:J})}}var nn="v4.1.1",aB="@glb.bin",a;(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"})(a||(a={}));var sB;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(sB||(sB={}));var e5;(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"})(e5||(e5={}));var oB;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(oB||(oB={}));var EZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(EZ||(EZ={}));var iJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array},ZT=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 yj1(){var Z=new ZT(3);if(ZT!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function eC(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function bj1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}(function(){var Z=yj1();return function(J,X,Y,$,Q,K){var G,W;if(!X)X=3;if(!Y)Y=0;if($)W=Math.min($*X+Y,J.length);else W=J.length;for(G=Y;G<W;G+=X)Z[0]=J[G],Z[1]=J[G+1],Z[2]=J[G+2],Q(Z,Z,K),J[G]=Z[0],J[G+1]=Z[1],J[G+2]=Z[2];return J}})();function $T(Z){let J=an(),X=Z.propertyType===a.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=gj1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))JT(K.min,J),JT(K.max,J)});return J}function gj1(Z,J){let X=an();for(let Y of Z.listPrimitives()){let $=Y.getAttribute("POSITION"),Q=Y.getIndices();if(!$)continue;let K=[0,0,0],G=[0,0,0];for(let W=0,H=Q?Q.getCount():$.getCount();W<H;W++){let V=Q?Q.getScalar(W):W;K=$.getElement(V,K),G=bj1(G,K,J),JT(G,X)}}return X}function JT(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 an(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class o0{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let Y=0;Y<J.length;Y++)X[Y]=J.charCodeAt(Y);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 $ of Z)J+=$.byteLength;let X=new Uint8Array(J),Y=0;for(let $ 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 Y=new Uint8Array(X);if(Y.set(Z),J!==0)for(let $=Z.byteLength;$<X;$++)Y[$]=J;return Y}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 QT{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^Y*255<<8^$*255<<0}static convertSRGBToLinear(Z,J){let X=Z,Y=J;for(let $=0;$<3;$++)Y[$]=X[$]<0.04045?X[$]*0.0773993808:Math.pow(X[$]*0.9478672986+0.0521327014,2.4);return J}static convertLinearToSRGB(Z,J){let X=Z,Y=J;for(let $=0;$<3;$++)Y[$]=X[$]<0.0031308?X[$]*12.92:1.055*Math.pow(X[$],0.41666)-0.055;return J}}class sn{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,Y;while(J.byteLength){if(X=J.getUint16(0,!1),mj1(J,X),Y=J.getUint8(X+1),Y===192||Y===193||Y===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 eB{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(o0.decodeText(Z.slice(12,16))===eB.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}}eB.PNG_FRIED_CHUNK_NAME="CgBI";class kZ{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,Y=4,$=this.getSize(Z,J);if(!$)return null;while($[0]>1||$[1]>1)X+=$[0]*$[1]*Y,$[0]=Math.max(Math.floor($[0]/2),1),$[1]=Math.max(Math.floor($[1]/2),1);return X+=1*Y,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}`}}kZ.impls={"image/jpeg":new sn,"image/png":new eB};function mj1(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 IZ{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 kZ.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 mn(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function aY(Z){if(mn(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(mn(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var XT,gH;(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"})(gH||(gH={}));class k5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=k5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=k5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=k5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=k5.Verbosity.ERROR)console.error(Z)}}XT=k5;k5.Verbosity=gH;k5.DEFAULT_INSTANCE=new XT(XT.Verbosity.INFO);function uj1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],G=Z[6],W=Z[7],H=Z[8],V=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,O=J*G-Y*Q,M=J*W-$*Q,R=X*G-Y*K,D=X*W-$*K,N=Y*W-$*G,C=H*U-V*q,T=H*B-F*q,E=H*L-z*q,A=V*B-F*U,S=V*L-z*U,x=F*L-z*B;return w*x-O*S+M*A+R*E-D*T+N*C}function dj1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],G=J[4],W=J[5],H=J[6],V=J[7],F=J[8],z=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],O=J[15],M=X[0],R=X[1],D=X[2],N=X[3];return Z[0]=M*Y+R*G+D*F+N*B,Z[1]=M*$+R*W+D*z+N*L,Z[2]=M*Q+R*H+D*q+N*w,Z[3]=M*K+R*V+D*U+N*O,M=X[4],R=X[5],D=X[6],N=X[7],Z[4]=M*Y+R*G+D*F+N*B,Z[5]=M*$+R*W+D*z+N*L,Z[6]=M*Q+R*H+D*q+N*w,Z[7]=M*K+R*V+D*U+N*O,M=X[8],R=X[9],D=X[10],N=X[11],Z[8]=M*Y+R*G+D*F+N*B,Z[9]=M*$+R*W+D*z+N*L,Z[10]=M*Q+R*H+D*q+N*w,Z[11]=M*K+R*V+D*U+N*O,M=X[12],R=X[13],D=X[14],N=X[15],Z[12]=M*Y+R*G+D*F+N*B,Z[13]=M*$+R*W+D*z+N*L,Z[14]=M*Q+R*H+D*q+N*w,Z[15]=M*K+R*V+D*U+N*O,Z}function cj1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],G=J[6],W=J[8],H=J[9],V=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,G),Z[2]=Math.hypot(W,H,V),Z}function lj1(Z,J){var X=new ZT(3);cj1(X,J);var Y=1/X[0],$=1/X[1],Q=1/X[2],K=J[0]*Y,G=J[1]*$,W=J[2]*Q,H=J[4]*Y,V=J[5]*$,F=J[6]*Q,z=J[8]*Y,q=J[9]*$,U=J[10]*Q,B=K+V+U,L=0;if(B>0)L=Math.sqrt(B+1)*2,Z[3]=0.25*L,Z[0]=(F-q)/L,Z[1]=(z-W)/L,Z[2]=(G-H)/L;else if(K>V&&K>U)L=Math.sqrt(1+K-V-U)*2,Z[3]=(F-q)/L,Z[0]=0.25*L,Z[1]=(G+H)/L,Z[2]=(z+W)/L;else if(V>U)L=Math.sqrt(1+V-K-U)*2,Z[3]=(z-W)/L,Z[0]=(G+H)/L,Z[1]=0.25*L,Z[2]=(F+q)/L;else L=Math.sqrt(1+U-K-V)*2,Z[3]=(G-H)/L,Z[0]=(z+W)/L,Z[1]=(F+q)/L,Z[2]=0.25*L;return Z}class i0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(i0.clamp(Z,0,1)*65535);case 5121:return Math.round(i0.clamp(Z,0,1)*255);case 5122:return Math.round(i0.clamp(Z,-1,1)*32767);case 5120:return Math.round(i0.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=eC([Z[0],Z[1],Z[2]]),Q=eC([Z[4],Z[5],Z[6]]),K=eC([Z[8],Z[9],Z[10]]);if(uj1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let W=Z.slice(),H=1/$,V=1/Q,F=1/K;W[0]*=H,W[1]*=H,W[2]*=H,W[4]*=V,W[5]*=V,W[6]*=V,W[8]*=F,W[9]*=F,W[10]*=F,lj1(X,W),Y[0]=$,Y[1]=Q,Y[2]=K}static compose(Z,J,X,Y){let $=Y,Q=J[0],K=J[1],G=J[2],W=J[3],H=Q+Q,V=K+K,F=G+G,z=Q*H,q=Q*V,U=Q*F,B=K*V,L=K*F,w=G*F,O=W*H,M=W*V,R=W*F,D=X[0],N=X[1],C=X[2];return $[0]=(1-(B+w))*D,$[1]=(q+R)*D,$[2]=(U-M)*D,$[3]=0,$[4]=(q-R)*N,$[5]=(1-(z+w))*N,$[6]=(L+O)*N,$[7]=0,$[8]=(U+M)*C,$[9]=(L-O)*C,$[10]=(1-(z+B))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function pj1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function ij1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),Y=J.values();if(X.length!==Y.length)return!1;for(let $=0;$<X.length;$++){let Q=X[$],K=Y[$];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function nj1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),Y=J.keys();if(X.length!==Y.length)return!1;for(let $ of X){let Q=Z.get($),K=J.get($);if(!!Q!==!!K)return!1;let G=Q.getChild(),W=K.getChild();if(G===W)continue;if(!G.equals(W))return!1}return!0}function on(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 rn(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!aY(Z)||!aY(J))return Z===J;let X=Z,Y=J,$=0,Q=0,K;for(K in X)$++;for(K in Y)Q++;if($!==Q)return!1;for(K in X){let G=X[K],W=Y[K];if(rB(G)&&rB(W)){if(!on(G,W))return!1}else if(aY(G)&&aY(W)){if(!rn(G,W))return!1}else if(G!==W)return!1}return!0}function rB(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var un="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",aj1=999,sj1=6,dn=new Set,oj1=function Z(){let J="";for(let X=0;X<sj1;X++)J+=un.charAt(Math.floor(Math.random()*un.length));return J},tn=function Z(){for(let J=0;J<aj1;J++){let X=oj1();if(!dn.has(X))return dn.add(X),X}return""},cn="https://null.example";class f9{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return IZ.basename(new URL(Z,cn).pathname)}static extension(Z){return IZ.extension(new URL(Z,cn).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),Y=J.split("/");X.pop();for(let $=0;$<Y.length;$++){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)}}f9.DEFAULT_INIT={};f9.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var pJ=(Z)=>Z,rj1=new Set;class Z2 extends iK{constructor(Z,J=""){super(Z);this[y0].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,pJ)}copy(Z,J=pJ){for(let X in this[y0]){let Y=this[y0][X];if(Y instanceof T5){if(!this[A4].has(X))Y.dispose()}else if(Y instanceof I6||Y instanceof E0)for(let $ of Y.values())$.dispose();else if(Y instanceof e1)for(let $ of Y.values())$.dispose()}for(let X in Z[y0]){let Y=this[y0][X],$=Z[y0][X];if($ instanceof T5)if(this[A4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof E0||$ instanceof I6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof e1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(aY($))this[y0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[y0][X]=$.slice();else this[y0][X]=$}return this}equals(Z,J=rj1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[y0]){if(J.has(X))continue;let Y=this[y0][X],$=Z[y0][X];if(Y instanceof T5||$ instanceof T5){if(!pj1(Y,$))return!1}else if(Y instanceof E0||$ instanceof E0||Y instanceof I6||$ instanceof I6){if(!ij1(Y,$))return!1}else if(Y instanceof e1||$ instanceof e1){if(!nj1(Y,$))return!1}else if(aY(Y)||aY($)){if(!rn(Y,$))return!1}else if(rB(Y)||rB($)){if(!on(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 S6 extends Z2{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new e1})}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 x0 extends S6{init(){this.propertyType=a.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:x0.Type.SCALAR,componentType:x0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case x0.Type.SCALAR:return 1;case x0.Type.VEC2:return 2;case x0.Type.VEC3:return 3;case x0.Type.VEC4:return 4;case x0.Type.MAT2:return 4;case x0.Type.MAT3:return 9;case x0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case x0.ComponentType.BYTE:return 1;case x0.ComponentType.UNSIGNED_BYTE:return 1;case x0.ComponentType.SHORT:return 2;case x0.ComponentType.UNSIGNED_SHORT:return 2;case x0.ComponentType.UNSIGNED_INT:return 4;case x0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMin(Z),J)for(let $=0;$<X;$++)Z[$]=i0.decodeNormalizedInt(Z[$],Y);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMax(Z),J)for(let $=0;$<X;$++)Z[$]=i0.decodeNormalizedInt(Z[$],Y);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=-1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+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 x0.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(),Y=this.getArray();if(this.getNormalized())return i0.decodeNormalizedInt(Y[Z*J],X);return Y[Z*J]}setScalar(Z,J){let X=this.getElementSize(),Y=this.getComponentType(),$=this.getArray();if(this.getNormalized())$[Z*X]=i0.encodeNormalizedInt(J,Y);else $[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)J[K]=i0.decodeNormalizedInt(Q[Z*Y+K],$);else J[K]=Q[Z*Y+K];return J}setElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)Q[Z*Y+K]=i0.encodeNormalizedInt(J[K],$);else Q[Z*Y+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?tj1(Z):x0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}x0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};x0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function tj1(Z){switch(Z.constructor){case Float32Array:return x0.ComponentType.FLOAT;case Uint32Array:return x0.ComponentType.UNSIGNED_INT;case Uint16Array:return x0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return x0.ComponentType.UNSIGNED_BYTE;case Int16Array:return x0.ComponentType.SHORT;case Int8Array:return x0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class KT extends S6{init(){this.propertyType=a.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new E0,samplers:new E0})}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 sY extends S6{init(){this.propertyType=a.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)}}sY.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class nK extends S6{init(){this.propertyType=a.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:nK.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:e5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:e5.OTHER})}}nK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class GT extends S6{init(){this.propertyType=a.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class oY extends S6{init(){this.propertyType=a.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:oY.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)}}oY.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class aK extends Z2{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}aK.EXTENSION_NAME=void 0;class E5 extends S6{init(){this.propertyType=a.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:E5.WrapMode.REPEAT,wrapT:E5.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)}}E5.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};E5.MagFilter={NEAREST:9728,LINEAR:9729};E5.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:cB,G:lB,B:pB,A:ej1}=oB;class D7 extends S6{init(){this.propertyType=a.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:D7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new E5(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new E5(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new E5(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new E5(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new E5(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:cB|lB|pB|ej1,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:cB|lB|pB,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:cB|lB|pB})}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:cB})}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:lB|pB})}}D7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class uH extends S6{init(){this.propertyType=a.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new E0})}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 J2 extends S6{init(){this.propertyType=a.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 E0})}copy(Z,J=pJ){if(J===pJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return i0.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),Y=this.get("scale").slice();return i0.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return i0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return i0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return i0.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let Y=this;Y!=null;Y=Y.getParentNode())Z.push(Y);let J,X=Z.pop().getMatrix();while(J=Z.pop())dj1(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===a.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===a.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 C8 extends S6{init(){this.propertyType=a.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:C8.Mode.TRIANGLES,material:null,indices:null,attributes:new e1,targets:new E0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:e5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:e5.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)}}C8.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class WT extends Z2{init(){this.propertyType=a.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new e1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:e5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function r6(){return r6=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},r6.apply(null,arguments)}class sK extends S6{init(){this.propertyType=a.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new E0})}copy(Z,J=pJ){if(J===pJ)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 HT extends S6{init(){this.propertyType=a.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new E0})}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:e5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class rY extends S6{init(){this.propertyType=a.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||kZ.extensionToMimeType(IZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=kZ.extensionToMimeType(IZ.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",o0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return kZ.getSize(Z,this.getMimeType())}}class tY extends S6{init(){this.propertyType=a.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${nn}`,version:"2.0"},defaultScene:null,accessors:new E0,animations:new E0,buffers:new E0,cameras:new E0,materials:new E0,meshes:new E0,nodes:new E0,scenes:new E0,skins:new E0,textures:new E0})}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=pJ){if(J===pJ)throw new Error("Root cannot be copied.");this.set("asset",r6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(r6({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let Y=Z.getExtension(X);this.setExtension(X,J(Y))}return this}_addChildOfRoot(Z){if(Z instanceof sK)this.addRef("scenes",Z);else if(Z instanceof J2)this.addRef("nodes",Z);else if(Z instanceof oY)this.addRef("cameras",Z);else if(Z instanceof HT)this.addRef("skins",Z);else if(Z instanceof uH)this.addRef("meshes",Z);else if(Z instanceof D7)this.addRef("materials",Z);else if(Z instanceof rY)this.addRef("textures",Z);else if(Z instanceof KT)this.addRef("animations",Z);else if(Z instanceof x0)this.addRef("accessors",Z);else if(Z instanceof GT)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 _6{static fromGraph(Z){return _6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new pK,this._root=new tY(this._graph),this._logger=k5.DEFAULT_INSTANCE,_6._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((Y)=>Y.extensionName===J)||new Z(this)}createScene(Z=""){return new sK(this._graph,Z)}createNode(Z=""){return new J2(this._graph,Z)}createCamera(Z=""){return new oY(this._graph,Z)}createSkin(Z=""){return new HT(this._graph,Z)}createMesh(Z=""){return new uH(this._graph,Z)}createPrimitive(){return new C8(this._graph)}createPrimitiveTarget(Z=""){return new WT(this._graph,Z)}createMaterial(Z=""){return new D7(this._graph,Z)}createTexture(Z=""){return new rY(this._graph,Z)}createAnimation(Z=""){return new KT(this._graph,Z)}createAnimationChannel(Z=""){return new sY(this._graph,Z)}createAnimationSampler(Z=""){return new nK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new x0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new GT(this._graph,Z)}}_6._GRAPH_DOCUMENTS=new WeakMap;class en{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 Y=X,$=Y.target;if($ instanceof aK&&$.extensionName===this.extensionName){if(Y.type==="node:create")this._addExtensionProperty($);if(Y.type==="node:dispose")this._removeExtensionProperty($)}};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}}en.EXTENSION_NAME=void 0;class Za{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 Y=this.jsonDoc.json.samplers[X.sampler];if(Y.magFilter!==void 0)Z.setMagFilter(Y.magFilter);if(Y.minFilter!==void 0)Z.setMinFilter(Y.minFilter);if(Y.wrapS!==void 0)Z.setWrapS(Y.wrapS);if(Y.wrapT!==void 0)Z.setWrapT(Y.wrapT)}}var ln={logger:k5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},ZO1=new Set([a.BUFFER,a.TEXTURE,a.MATERIAL,a.MESH,a.PRIMITIVE,a.NODE,a.SCENE]);class Ja{static read(Z,J=ln){let X=r6({},ln,J),{json:Y}=Z,$=new _6().setLogger(X.logger);this.validate(Z,X);let Q=new Za(Z),K=Y.asset,G=$.getRoot().getAsset();if(K.copyright)G.copyright=K.copyright;if(K.extras)G.extras=K.extras;if(Y.extras!==void 0)$.getRoot().setExtras(r6({},Y.extras));let W=Y.extensionsUsed||[],H=Y.extensionsRequired||[];X.extensions.sort((N,C)=>N.EXTENSION_NAME>C.EXTENSION_NAME?1:-1);for(let N of X.extensions)if(W.includes(N.EXTENSION_NAME)){let C=$.createExtension(N).setRequired(H.includes(N.EXTENSION_NAME)),T=C.prereadTypes.filter((E)=>!ZO1.has(E));if(T.length)X.logger.warn(`Preread hooks for some types (${T.join()}), requested by extension ${C.extensionName}, are unsupported. Please file an issue or a PR.`);for(let E of C.readDependencies)C.install(E,X.dependencies[E])}let V=Y.buffers||[];$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.BUFFER)).forEach((N)=>N.preread(Q,a.BUFFER)),Q.buffers=V.map((N)=>{let C=$.createBuffer(N.name);if(N.extras)C.setExtras(N.extras);if(N.uri&&N.uri.indexOf("__")!==0)C.setURI(N.uri);return C});let F=Y.bufferViews||[];Q.bufferViewBuffers=F.map((N,C)=>{if(!Q.bufferViews[C]){let T=Z.json.buffers[N.buffer],E=T.uri?Z.resources[T.uri]:Z.resources[aB],A=N.byteOffset||0;Q.bufferViews[C]=o0.toView(E,A,N.byteLength)}return Q.buffers[N.buffer]});let z=Y.accessors||[];Q.accessors=z.map((N)=>{let C=Q.bufferViewBuffers[N.bufferView],T=$.createAccessor(N.name,C).setType(N.type);if(N.extras)T.setExtras(N.extras);if(N.normalized!==void 0)T.setNormalized(N.normalized);if(N.bufferView===void 0)return T;return T.setArray(nB(N,Q)),T});let q=Y.images||[],U=Y.textures||[];$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.TEXTURE)).forEach((N)=>N.preread(Q,a.TEXTURE)),Q.textures=q.map((N)=>{let C=$.createTexture(N.name);if(N.extras)C.setExtras(N.extras);if(N.bufferView!==void 0){let T=Y.bufferViews[N.bufferView],E=Z.json.buffers[T.buffer],A=E.uri?Z.resources[E.uri]:Z.resources[aB],S=T.byteOffset||0,x=T.byteLength,I=A.slice(S,S+x);C.setImage(I)}else if(N.uri!==void 0){if(C.setImage(Z.resources[N.uri]),N.uri.indexOf("__")!==0)C.setURI(N.uri)}if(N.mimeType!==void 0)C.setMimeType(N.mimeType);else if(N.uri){let T=IZ.extension(N.uri);C.setMimeType(kZ.extensionToMimeType(T))}return C}),$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.MATERIAL)).forEach((N)=>N.preread(Q,a.MATERIAL));let B=Y.materials||[];Q.materials=B.map((N)=>{let C=$.createMaterial(N.name);if(N.extras)C.setExtras(N.extras);if(N.alphaMode!==void 0)C.setAlphaMode(N.alphaMode);if(N.alphaCutoff!==void 0)C.setAlphaCutoff(N.alphaCutoff);if(N.doubleSided!==void 0)C.setDoubleSided(N.doubleSided);let T=N.pbrMetallicRoughness||{};if(T.baseColorFactor!==void 0)C.setBaseColorFactor(T.baseColorFactor);if(N.emissiveFactor!==void 0)C.setEmissiveFactor(N.emissiveFactor);if(T.metallicFactor!==void 0)C.setMetallicFactor(T.metallicFactor);if(T.roughnessFactor!==void 0)C.setRoughnessFactor(T.roughnessFactor);if(T.baseColorTexture!==void 0){let E=T.baseColorTexture,A=Q.textures[U[E.index].source];C.setBaseColorTexture(A),Q.setTextureInfo(C.getBaseColorTextureInfo(),E)}if(N.emissiveTexture!==void 0){let E=N.emissiveTexture,A=Q.textures[U[E.index].source];C.setEmissiveTexture(A),Q.setTextureInfo(C.getEmissiveTextureInfo(),E)}if(N.normalTexture!==void 0){let E=N.normalTexture,A=Q.textures[U[E.index].source];if(C.setNormalTexture(A),Q.setTextureInfo(C.getNormalTextureInfo(),E),N.normalTexture.scale!==void 0)C.setNormalScale(N.normalTexture.scale)}if(N.occlusionTexture!==void 0){let E=N.occlusionTexture,A=Q.textures[U[E.index].source];if(C.setOcclusionTexture(A),Q.setTextureInfo(C.getOcclusionTextureInfo(),E),N.occlusionTexture.strength!==void 0)C.setOcclusionStrength(N.occlusionTexture.strength)}if(T.metallicRoughnessTexture!==void 0){let E=T.metallicRoughnessTexture,A=Q.textures[U[E.index].source];C.setMetallicRoughnessTexture(A),Q.setTextureInfo(C.getMetallicRoughnessTextureInfo(),E)}return C}),$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.MESH)).forEach((N)=>N.preread(Q,a.MESH));let L=Y.meshes||[];$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.PRIMITIVE)).forEach((N)=>N.preread(Q,a.PRIMITIVE)),Q.meshes=L.map((N)=>{let C=$.createMesh(N.name);if(N.extras)C.setExtras(N.extras);if(N.weights!==void 0)C.setWeights(N.weights);return(N.primitives||[]).forEach((E)=>{let A=$.createPrimitive();if(E.extras)A.setExtras(E.extras);if(E.material!==void 0)A.setMaterial(Q.materials[E.material]);if(E.mode!==void 0)A.setMode(E.mode);for(let[I,_]of Object.entries(E.attributes||{}))A.setAttribute(I,Q.accessors[_]);if(E.indices!==void 0)A.setIndices(Q.accessors[E.indices]);let S=N.extras&&N.extras.targetNames||[];(E.targets||[]).forEach((I,_)=>{let y=S[_]||_.toString(),u=$.createPrimitiveTarget(y);for(let[n,o]of Object.entries(I))u.setAttribute(n,Q.accessors[o]);A.addTarget(u)}),C.addPrimitive(A)}),C});let w=Y.cameras||[];Q.cameras=w.map((N)=>{let C=$.createCamera(N.name).setType(N.type);if(N.extras)C.setExtras(N.extras);if(N.type===oY.Type.PERSPECTIVE){let T=N.perspective;if(C.setYFov(T.yfov),C.setZNear(T.znear),T.zfar!==void 0)C.setZFar(T.zfar);if(T.aspectRatio!==void 0)C.setAspectRatio(T.aspectRatio)}else{let T=N.orthographic;C.setZNear(T.znear).setZFar(T.zfar).setXMag(T.xmag).setYMag(T.ymag)}return C});let O=Y.nodes||[];$.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.NODE)).forEach((N)=>N.preread(Q,a.NODE)),Q.nodes=O.map((N)=>{let C=$.createNode(N.name);if(N.extras)C.setExtras(N.extras);if(N.translation!==void 0)C.setTranslation(N.translation);if(N.rotation!==void 0)C.setRotation(N.rotation);if(N.scale!==void 0)C.setScale(N.scale);if(N.matrix!==void 0){let T=[0,0,0],E=[0,0,0,1],A=[1,1,1];i0.decompose(N.matrix,T,E,A),C.setTranslation(T),C.setRotation(E),C.setScale(A)}if(N.weights!==void 0)C.setWeights(N.weights);return C});let M=Y.skins||[];Q.skins=M.map((N)=>{let C=$.createSkin(N.name);if(N.extras)C.setExtras(N.extras);if(N.inverseBindMatrices!==void 0)C.setInverseBindMatrices(Q.accessors[N.inverseBindMatrices]);if(N.skeleton!==void 0)C.setSkeleton(Q.nodes[N.skeleton]);for(let T of N.joints)C.addJoint(Q.nodes[T]);return C}),O.map((N,C)=>{let T=Q.nodes[C];if((N.children||[]).forEach((A)=>T.addChild(Q.nodes[A])),N.mesh!==void 0)T.setMesh(Q.meshes[N.mesh]);if(N.camera!==void 0)T.setCamera(Q.cameras[N.camera]);if(N.skin!==void 0)T.setSkin(Q.skins[N.skin])});let R=Y.animations||[];Q.animations=R.map((N)=>{let C=$.createAnimation(N.name);if(N.extras)C.setExtras(N.extras);let E=(N.samplers||[]).map((S)=>{let x=$.createAnimationSampler().setInput(Q.accessors[S.input]).setOutput(Q.accessors[S.output]).setInterpolation(S.interpolation||nK.Interpolation.LINEAR);if(S.extras)x.setExtras(S.extras);return C.addSampler(x),x});return(N.channels||[]).forEach((S)=>{let x=$.createAnimationChannel().setSampler(E[S.sampler]).setTargetPath(S.target.path);if(S.target.node!==void 0)x.setTargetNode(Q.nodes[S.target.node]);if(S.extras)x.setExtras(S.extras);C.addChannel(x)}),C});let D=Y.scenes||[];if($.getRoot().listExtensionsUsed().filter((N)=>N.prereadTypes.includes(a.SCENE)).forEach((N)=>N.preread(Q,a.SCENE)),Q.scenes=D.map((N)=>{let C=$.createScene(N.name);if(N.extras)C.setExtras(N.extras);return(N.nodes||[]).map((E)=>Q.nodes[E]).forEach((E)=>C.addChild(E)),C}),Y.scene!==void 0)$.getRoot().setDefaultScene(Q.scenes[Y.scene]);return $.getRoot().listExtensionsUsed().forEach((N)=>N.read(Q)),z.forEach((N,C)=>{let T=Q.accessors[C],E=!!N.sparse,A=!N.bufferView&&!T.getArray();if(E||A)T.setSparse(!0).setArray(XO1(N,Q))}),$}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 Y of X.extensionsRequired)if(!J.extensions.find(($)=>$.EXTENSION_NAME===Y))throw new Error(`Missing required extension, "${Y}".`)}if(X.extensionsUsed){for(let Y of X.extensionsUsed)if(!J.extensions.find(($)=>$.EXTENSION_NAME===Y))J.logger.warn(`Missing optional extension, "${Y}".`)}}}function JO1(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=iJ[Z.componentType],K=x0.getElementSize(Z.type),G=Q.BYTES_PER_ELEMENT,W=Z.byteOffset||0,H=new Q(Z.count*K),V=new DataView(Y.buffer,Y.byteOffset,Y.byteLength),F=$.byteStride;for(let z=0;z<Z.count;z++)for(let q=0;q<K;q++){let U=W+z*F+q*G,B;switch(Z.componentType){case x0.ComponentType.FLOAT:B=V.getFloat32(U,!0);break;case x0.ComponentType.UNSIGNED_INT:B=V.getUint32(U,!0);break;case x0.ComponentType.UNSIGNED_SHORT:B=V.getUint16(U,!0);break;case x0.ComponentType.UNSIGNED_BYTE:B=V.getUint8(U);break;case x0.ComponentType.SHORT:B=V.getInt16(U,!0);break;case x0.ComponentType.BYTE:B=V.getInt8(U);break;default:throw new Error(`Unexpected componentType "${Z.componentType}".`)}H[z*K+q]=B}return H}function nB(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=iJ[Z.componentType],K=x0.getElementSize(Z.type),G=Q.BYTES_PER_ELEMENT,W=K*G;if($.byteStride!==void 0&&$.byteStride!==W)return JO1(Z,J);let H=Y.byteOffset+(Z.byteOffset||0),V=Z.count*K*G;return new Q(Y.buffer.slice(H,H+V))}function XO1(Z,J){let X=iJ[Z.componentType],Y=x0.getElementSize(Z.type),$;if(Z.bufferView!==void 0)$=nB(Z,J);else $=new X(Z.count*Y);let Q=Z.sparse;if(!Q)return $;let K=Q.count,G=r6({},Z,Q.indices,{count:K,type:"SCALAR"}),W=r6({},Z,Q.values,{count:K}),H=nB(G,J),V=nB(W,J);for(let F=0;F<G.count;F++)for(let z=0;z<Y;z++)$[H[F]*Y+z]=V[F*Y+z];return $}var mH;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(mH||(mH={}));class lJ{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 Y=Z.getRoot(),$=Y.listBuffers().length,Q=Y.listTextures().length;this.bufferURIGenerator=new YT($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new YT(Q>1,(K)=>YO1(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()},Y=JSON.stringify(X);if(!this.samplerDefIndexMap.has(Y))this.samplerDefIndexMap.set(Y,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let $={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get(Y)},Q=JSON.stringify($);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push($);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((Y)=>Y.getName()==="attributes"&&Y.getAttributes().key==="POSITION"||Y.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===EZ.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 Y=kZ.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,Y),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let Y=this.jsonDoc.resources;if(!(Z in Y)){Y[Z]=J;return}if(J===Y[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let $=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn($);return}throw new Error($)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return e5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:Y}=X.getAttributes();if(Y)return Y;if(X.getParent().propertyType!==a.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return e5.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}}lJ.BufferViewTarget=mH;lJ.BufferViewUsage=e5;lJ.USAGE_TO_TARGET={[e5.ARRAY_BUFFER]:mH.ARRAY_BUFFER,[e5.ELEMENT_ARRAY_BUFFER]:mH.ELEMENT_ARRAY_BUFFER};class YT{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 YO1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:iB}=lJ,{UNSIGNED_INT:$O1,UNSIGNED_SHORT:QO1,UNSIGNED_BYTE:KO1}=x0.ComponentType,GO1=new Set([a.ACCESSOR,a.BUFFER,a.MATERIAL,a.MESH]);class Xa{static write(Z,J){let X=Z.getGraph(),Y=Z.getRoot(),$={asset:r6({generator:`glTF-Transform ${nn}`},Y.getAsset()),extras:r6({},Y.getExtras())},Q={json:$,resources:{}},K=new lJ(Z,Q,J),G=J.logger||k5.DEFAULT_INSTANCE,W=new Set(J.extensions.map((L)=>L.EXTENSION_NAME)),H=Z.getRoot().listExtensionsUsed().filter((L)=>W.has(L.extensionName)).sort((L,w)=>L.extensionName>w.extensionName?1:-1),V=Z.getRoot().listExtensionsRequired().filter((L)=>W.has(L.extensionName)).sort((L,w)=>L.extensionName>w.extensionName?1:-1);if(H.length<Z.getRoot().listExtensionsUsed().length)G.warn("Some extensions were not registered for I/O, and will not be written.");for(let L of H){let w=L.prewriteTypes.filter((O)=>!GO1.has(O));if(w.length)G.warn(`Prewrite hooks for some types (${w.join()}), requested by extension ${L.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of L.writeDependencies)L.install(O,J.dependencies[O])}function F(L,w,O,M){let R=[],D=0;for(let T of L){let E=K.createAccessorDef(T);E.bufferView=$.bufferViews.length;let A=T.getArray(),S=o0.pad(o0.toView(A));E.byteOffset=D,D+=S.byteLength,R.push(S),K.accessorIndexMap.set(T,$.accessors.length),$.accessors.push(E)}let N=o0.concat(R),C={buffer:w,byteOffset:O,byteLength:N.byteLength};if(M)C.target=M;return $.bufferViews.push(C),{buffers:R,byteLength:D}}function z(L,w,O){let M=L[0].getCount(),R=0;for(let E of L){let A=K.createAccessorDef(E);A.bufferView=$.bufferViews.length,A.byteOffset=R;let S=E.getElementSize(),x=E.getComponentSize();R+=o0.padNumber(S*x),K.accessorIndexMap.set(E,$.accessors.length),$.accessors.push(A)}let D=M*R,N=new ArrayBuffer(D),C=new DataView(N);for(let E=0;E<M;E++){let A=0;for(let S of L){let x=S.getElementSize(),I=S.getComponentSize(),_=S.getComponentType(),y=S.getArray();for(let u=0;u<x;u++){let n=E*R+A+u*I,o=y[E*x+u];switch(_){case x0.ComponentType.FLOAT:C.setFloat32(n,o,!0);break;case x0.ComponentType.BYTE:C.setInt8(n,o);break;case x0.ComponentType.SHORT:C.setInt16(n,o,!0);break;case x0.ComponentType.UNSIGNED_BYTE:C.setUint8(n,o);break;case x0.ComponentType.UNSIGNED_SHORT:C.setUint16(n,o,!0);break;case x0.ComponentType.UNSIGNED_INT:C.setUint32(n,o,!0);break;default:throw new Error("Unexpected component type: "+_)}}A+=o0.padNumber(x*I)}}let T={buffer:w,byteOffset:O,byteLength:D,byteStride:R,target:lJ.BufferViewTarget.ARRAY_BUFFER};return $.bufferViews.push(T),{byteLength:D,buffers:[new Uint8Array(N)]}}function q(L,w,O){let M=[],R=0,D=new Map,N=-1/0,C=!1;for(let _ of L){let y=K.createAccessorDef(_);$.accessors.push(y),K.accessorIndexMap.set(_,$.accessors.length-1);let u=[],n=[],o=[],Q0=new Array(_.getElementSize()).fill(0);for(let r0=0,A8=_.getCount();r0<A8;r0++){if(_.getElement(r0,o),i0.eq(o,Q0,0))continue;N=Math.max(r0,N),u.push(r0);for(let r1=0;r1<o.length;r1++)n.push(o[r1])}let G0=u.length,S0={accessorDef:y,count:G0};if(D.set(_,S0),G0===0)continue;if(G0>_.getCount()/2)C=!0;let v0=iJ[_.getComponentType()];S0.indices=u,S0.values=new v0(n)}if(!Number.isFinite(N))return{buffers:M,byteLength:R};if(C)G.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let T=N<255?Uint8Array:N<65535?Uint16Array:Uint32Array,E=N<255?KO1:N<65535?QO1:$O1,A={buffer:w,byteOffset:O+R,byteLength:0};for(let _ of L){let y=D.get(_);if(y.count===0)continue;y.indicesByteOffset=A.byteLength;let u=o0.pad(o0.toView(new T(y.indices)));M.push(u),R+=u.byteLength,A.byteLength+=u.byteLength}$.bufferViews.push(A);let S=$.bufferViews.length-1,x={buffer:w,byteOffset:O+R,byteLength:0};for(let _ of L){let y=D.get(_);if(y.count===0)continue;y.valuesByteOffset=x.byteLength;let u=o0.pad(o0.toView(y.values));M.push(u),R+=u.byteLength,x.byteLength+=u.byteLength}$.bufferViews.push(x);let I=$.bufferViews.length-1;for(let _ of L){let y=D.get(_);if(y.count===0)continue;y.accessorDef.sparse={count:y.count,indices:{bufferView:S,byteOffset:y.indicesByteOffset,componentType:E},values:{bufferView:I,byteOffset:y.valuesByteOffset}}}return{buffers:M,byteLength:R}}if($.accessors=[],$.bufferViews=[],$.samplers=[],$.textures=[],$.images=Y.listTextures().map((L,w)=>{let O=K.createPropertyDef(L);if(L.getMimeType())O.mimeType=L.getMimeType();let M=L.getImage();if(M)K.createImageData(O,M,L);return K.imageIndexMap.set(L,w),O}),H.filter((L)=>L.prewriteTypes.includes(a.ACCESSOR)).forEach((L)=>L.prewrite(K,a.ACCESSOR)),Y.listAccessors().forEach((L)=>{let{accessorUsageGroupedByParent:w,accessorParents:O}=K;if(K.accessorIndexMap.has(L))return;let M=K.getAccessorUsage(L);if(K.addAccessorToUsageGroup(L,M),w.has(M)){let R=X.listParents(L).find((D)=>D.propertyType!==a.ROOT);O.set(L,R)}}),H.filter((L)=>L.prewriteTypes.includes(a.BUFFER)).forEach((L)=>L.prewrite(K,a.BUFFER)),(Y.listAccessors().length>0||K.otherBufferViews.size>0||Y.listTextures().length>0&&J.format===EZ.GLB)&&Y.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");if($.buffers=[],Y.listBuffers().forEach((L,w)=>{let O=K.createPropertyDef(L),M=K.accessorUsageGroupedByParent,R=L.listParents().filter((x)=>x instanceof x0),D=new Set(R.map((x)=>K.accessorParents.get(x))),N=new Map(Array.from(D).map((x,I)=>[x,I])),C={};for(let x of R){var T;if(K.accessorIndexMap.has(x))continue;let I=K.getAccessorUsage(x),_=I;if(M.has(I)){let y=K.accessorParents.get(x);_+=`:${N.get(y)}`}C[T=_]||(C[T]={usage:I,accessors:[]}),C[_].accessors.push(x)}let E=[],A=$.buffers.length,S=0;for(let{usage:x,accessors:I}of Object.values(C))if(x===iB.ARRAY_BUFFER&&J.vertexLayout===sB.INTERLEAVED){let _=z(I,A,S);S+=_.byteLength;for(let y of _.buffers)E.push(y)}else if(x===iB.ARRAY_BUFFER)for(let _ of I){let y=z([_],A,S);S+=y.byteLength;for(let u of y.buffers)E.push(u)}else if(x===iB.SPARSE){let _=q(I,A,S);S+=_.byteLength;for(let y of _.buffers)E.push(y)}else if(x===iB.ELEMENT_ARRAY_BUFFER){let _=lJ.BufferViewTarget.ELEMENT_ARRAY_BUFFER,y=F(I,A,S,_);S+=y.byteLength;for(let u of y.buffers)E.push(u)}else{let _=F(I,A,S);S+=_.byteLength;for(let y of _.buffers)E.push(y)}if(K.imageBufferViews.length&&w===0){for(let x=0;x<K.imageBufferViews.length;x++)if($.bufferViews[$.images[x].bufferView].byteOffset=S,S+=K.imageBufferViews[x].byteLength,E.push(K.imageBufferViews[x]),S%8){let I=8-S%8;S+=I,E.push(new Uint8Array(I))}}if(K.otherBufferViews.has(L))for(let x of K.otherBufferViews.get(L))$.bufferViews.push({buffer:A,byteOffset:S,byteLength:x.byteLength}),K.otherBufferViewsIndexMap.set(x,$.bufferViews.length-1),S+=x.byteLength,E.push(x);if(S){let x;if(J.format===EZ.GLB)x=aB;else x=K.bufferURIGenerator.createURI(L,"bin"),O.uri=x;O.byteLength=S,K.assignResourceURI(x,o0.concat(E),!0)}$.buffers.push(O),K.bufferIndexMap.set(L,w)}),Y.listAccessors().find((L)=>!L.getBuffer()))G.warn("Skipped writing one or more Accessors: no Buffer assigned.");H.filter((L)=>L.prewriteTypes.includes(a.MATERIAL)).forEach((L)=>L.prewrite(K,a.MATERIAL)),$.materials=Y.listMaterials().map((L,w)=>{let O=K.createPropertyDef(L);if(L.getAlphaMode()!==D7.AlphaMode.OPAQUE)O.alphaMode=L.getAlphaMode();if(L.getAlphaMode()===D7.AlphaMode.MASK)O.alphaCutoff=L.getAlphaCutoff();if(L.getDoubleSided())O.doubleSided=!0;if(O.pbrMetallicRoughness={},!i0.eq(L.getBaseColorFactor(),[1,1,1,1]))O.pbrMetallicRoughness.baseColorFactor=L.getBaseColorFactor();if(!i0.eq(L.getEmissiveFactor(),[0,0,0]))O.emissiveFactor=L.getEmissiveFactor();if(L.getRoughnessFactor()!==1)O.pbrMetallicRoughness.roughnessFactor=L.getRoughnessFactor();if(L.getMetallicFactor()!==1)O.pbrMetallicRoughness.metallicFactor=L.getMetallicFactor();if(L.getBaseColorTexture()){let M=L.getBaseColorTexture(),R=L.getBaseColorTextureInfo();O.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(M,R)}if(L.getEmissiveTexture()){let M=L.getEmissiveTexture(),R=L.getEmissiveTextureInfo();O.emissiveTexture=K.createTextureInfoDef(M,R)}if(L.getNormalTexture()){let M=L.getNormalTexture(),R=L.getNormalTextureInfo(),D=K.createTextureInfoDef(M,R);if(L.getNormalScale()!==1)D.scale=L.getNormalScale();O.normalTexture=D}if(L.getOcclusionTexture()){let M=L.getOcclusionTexture(),R=L.getOcclusionTextureInfo(),D=K.createTextureInfoDef(M,R);if(L.getOcclusionStrength()!==1)D.strength=L.getOcclusionStrength();O.occlusionTexture=D}if(L.getMetallicRoughnessTexture()){let M=L.getMetallicRoughnessTexture(),R=L.getMetallicRoughnessTextureInfo();O.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(M,R)}return K.materialIndexMap.set(L,w),O}),H.filter((L)=>L.prewriteTypes.includes(a.MESH)).forEach((L)=>L.prewrite(K,a.MESH)),$.meshes=Y.listMeshes().map((L,w)=>{let O=K.createPropertyDef(L),M=null;if(O.primitives=L.listPrimitives().map((R)=>{let D={attributes:{}};D.mode=R.getMode();let N=R.getMaterial();if(N)D.material=K.materialIndexMap.get(N);if(Object.keys(R.getExtras()).length)D.extras=R.getExtras();let C=R.getIndices();if(C)D.indices=K.accessorIndexMap.get(C);for(let T of R.listSemantics())D.attributes[T]=K.accessorIndexMap.get(R.getAttribute(T));for(let T of R.listTargets()){let E={};for(let A of T.listSemantics())E[A]=K.accessorIndexMap.get(T.getAttribute(A));D.targets=D.targets||[],D.targets.push(E)}if(R.listTargets().length&&!M)M=R.listTargets().map((T)=>T.getName());return D}),L.getWeights().length)O.weights=L.getWeights();if(M)O.extras=O.extras||{},O.extras.targetNames=M;return K.meshIndexMap.set(L,w),O}),$.cameras=Y.listCameras().map((L,w)=>{let O=K.createPropertyDef(L);if(O.type=L.getType(),O.type===oY.Type.PERSPECTIVE){O.perspective={znear:L.getZNear(),zfar:L.getZFar(),yfov:L.getYFov()};let M=L.getAspectRatio();if(M!==null)O.perspective.aspectRatio=M}else O.orthographic={znear:L.getZNear(),zfar:L.getZFar(),xmag:L.getXMag(),ymag:L.getYMag()};return K.cameraIndexMap.set(L,w),O}),$.nodes=Y.listNodes().map((L,w)=>{let O=K.createPropertyDef(L);if(!i0.eq(L.getTranslation(),[0,0,0]))O.translation=L.getTranslation();if(!i0.eq(L.getRotation(),[0,0,0,1]))O.rotation=L.getRotation();if(!i0.eq(L.getScale(),[1,1,1]))O.scale=L.getScale();if(L.getWeights().length)O.weights=L.getWeights();return K.nodeIndexMap.set(L,w),O}),$.skins=Y.listSkins().map((L,w)=>{let O=K.createPropertyDef(L),M=L.getInverseBindMatrices();if(M)O.inverseBindMatrices=K.accessorIndexMap.get(M);let R=L.getSkeleton();if(R)O.skeleton=K.nodeIndexMap.get(R);return O.joints=L.listJoints().map((D)=>K.nodeIndexMap.get(D)),K.skinIndexMap.set(L,w),O}),Y.listNodes().forEach((L,w)=>{let O=$.nodes[w],M=L.getMesh();if(M)O.mesh=K.meshIndexMap.get(M);let R=L.getCamera();if(R)O.camera=K.cameraIndexMap.get(R);let D=L.getSkin();if(D)O.skin=K.skinIndexMap.get(D);if(L.listChildren().length>0)O.children=L.listChildren().map((N)=>K.nodeIndexMap.get(N))}),$.animations=Y.listAnimations().map((L,w)=>{let O=K.createPropertyDef(L),M=new Map;return O.samplers=L.listSamplers().map((R,D)=>{let N=K.createPropertyDef(R);return N.input=K.accessorIndexMap.get(R.getInput()),N.output=K.accessorIndexMap.get(R.getOutput()),N.interpolation=R.getInterpolation(),M.set(R,D),N}),O.channels=L.listChannels().map((R)=>{let D=K.createPropertyDef(R);return D.sampler=M.get(R.getSampler()),D.target={node:K.nodeIndexMap.get(R.getTargetNode()),path:R.getTargetPath()},D}),K.animationIndexMap.set(L,w),O}),$.scenes=Y.listScenes().map((L,w)=>{let O=K.createPropertyDef(L);return O.nodes=L.listChildren().map((M)=>K.nodeIndexMap.get(M)),K.sceneIndexMap.set(L,w),O});let B=Y.getDefaultScene();if(B)$.scene=Y.listScenes().indexOf(B);return $.extensionsUsed=H.map((L)=>L.extensionName),$.extensionsRequired=V.map((L)=>L.extensionName),H.forEach((L)=>L.write(K)),WO1($),Q}}function WO1(Z){let J=[];for(let X in Z){let Y=Z[X];if(Array.isArray(Y)&&Y.length===0)J.push(X);else if(Y===null||Y==="")J.push(X);else if(Y&&typeof Y==="object"&&Object.keys(Y).length===0)J.push(X)}for(let X of J)delete Z[X]}var tB;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(tB||(tB={}));class Ya{constructor(){this._logger=k5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=sB.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=pn(J)?this._binaryToJSON(J):{json:JSON.parse(o0.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),Ja.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(o0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some((Y)=>HO1(J,Y)))throw new Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some((Y)=>VO1(J,Y)))throw new Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(o0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===EZ.GLB&&Z.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Xa.write(Z,{format:J.format||EZ.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:r6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:EZ.GLB}),Y=new Uint32Array([1179937895,2,12]),$=JSON.stringify(J),Q=o0.pad(o0.encodeText($),32),K=o0.toView(new Uint32Array([Q.byteLength,1313821514])),G=o0.concat([K,Q]);Y[Y.length-1]+=G.byteLength;let W=Object.values(X)[0];if(!W||!W.byteLength)return o0.concat([o0.toView(Y),G]);let H=o0.pad(W,0),V=o0.toView(new Uint32Array([H.byteLength,5130562])),F=o0.concat([V,H]);return Y[Y.length-1]+=F.byteLength,o0.concat([o0.toView(Y),G,F])}async _readResourcesExternal(Z,J){var X=this;let Y=Z.json.images||[],$=Z.json.buffers||[],Q=[...Y,...$].map(async function(K){let G=K.uri;if(!G||G.match(/data:/))return Promise.resolve();Z.resources[G]=await X.readURI(X.resolve(J,G),"view"),X.lastReadBytes+=Z.resources[G].byteLength});await Promise.all(Q)}_readResourcesInternal(Z){function J($){if(!$.uri)return;if($.uri in Z.resources){o0.assertView(Z.resources[$.uri]);return}if($.uri.match(/data:/)){let Q=`__${tn()}.${IZ.extension($.uri)}`;Z.resources[Q]=o0.createBufferFromDataURI($.uri),$.uri=Q}}(Z.json.images||[]).forEach(($)=>{if($.bufferView===void 0&&$.uri===void 0)throw new Error("Missing resource URI or buffer view.");J($)}),(Z.json.buffers||[]).forEach(J)}_copyJSON(Z){let{images:J,buffers:X}=Z.json;if(Z={json:r6({},Z.json),resources:r6({},Z.resources)},J)Z.json.images=J.map((Y)=>r6({},Y));if(X)Z.json.buffers=X.map((Y)=>r6({},Y));return Z}_binaryToJSON(Z){if(!pn(Z))throw new Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==tB.JSON)throw new Error("Missing required GLB JSON chunk.");let X=20,Y=J[0],$=o0.decodeText(o0.toView(Z,X,Y)),Q=JSON.parse($),K=X+Y;if(Z.byteLength<=K)return{json:Q,resources:{}};let G=new Uint32Array(Z.buffer,Z.byteOffset+K,2);if(G[1]!==tB.BIN)return{json:Q,resources:{}};let W=G[0],H=o0.toView(Z,K+8,W);return{json:Q,resources:{[aB]:H}}}}function HO1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function VO1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function pn(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 VT extends Ya{constructor(Z=null,J=f9.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(),f9.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(f9.isAbsoluteURL(Z)||f9.isAbsoluteURL(J))return f9.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(f9.isAbsoluteURL(Z))return f9.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:Y,resources:$}=await this.writeJSON(J,{format:EZ.GLTF,basename:IZ.basename(Z)}),{_fs:Q,_path:K}=this,G=K.dirname(Z),W=JSON.stringify(Y,null,2);await Q.writeFile(Z,W),this.lastWriteBytes+=W.length;for(let H of zO1(Object.keys($),10))await Promise.all(H.map(async function(V){if(f9.isAbsoluteURL(V)){if(f9.extension(V)==="bin")throw new Error(`Cannot write buffer to path "${V}".`);return}let F=K.join(G,decodeURIComponent(V));await Q.mkdir(K.dirname(F),{recursive:!0}),await Q.writeFile(F,$[V]),X.lastWriteBytes+=$[V].byteLength}))}async _writeGLB(Z,J){let X=await this.writeBinary(J);await this._fs.writeFile(Z,X),this.lastWriteBytes=X.byteLength}}function zO1(Z,J){let X=[];for(let Y=0,$=Z.length;Y<$;Y+=J){let Q=[];for(let K=0;K<J&&Y+K<$;K++)Q.push(Z[Y+K]);X.push(Q)}return X}var Zr=r(zT(),1),Jr=r(fo(),1),XD1=r(eo(),1);async function YD1(Z,J){if(!(Z instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:Y}=await Jr.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return Zr.default(new Uint8Array(X),[Y.width,Y.height,4],[4,4*Y.width|0,1],0)}async function Xr(Z,J){return YD1(Z)}var $D1="v4.1.3",cT="@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 Yr;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(Yr||(Yr={}));var X9;(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"})(X9||(X9={}));var Y9;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(Y9||(Y9={}));var yT;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(yT||(yT={}));var bT=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 QD1(){var Z=new bT(3);if(bT!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function fT(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function KD1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}(function(){var Z=QD1();return function(J,X,Y,$,Q,K){var G,W;if(!X)X=3;if(!Y)Y=0;if($)W=Math.min($*X+Y,J.length);else W=J.length;for(G=Y;G<W;G+=X)Z[0]=J[G],Z[1]=J[G+1],Z[2]=J[G+2],Q(Z,Z,K),J[G]=Z[0],J[G+1]=Z[1],J[G+2]=Z[2];return J}})();function Gr(Z){let J=Wr(),X=Z.propertyType===s.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=GD1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))gT(K.min,J),gT(K.max,J)});return J}function GD1(Z,J){let X=Wr();for(let Y of Z.listPrimitives()){let $=Y.getAttribute("POSITION"),Q=Y.getIndices();if(!$)continue;let K=[0,0,0],G=[0,0,0];for(let W=0,H=Q?Q.getCount():$.getCount();W<H;W++){let V=Q?Q.getScalar(W):W;K=$.getElement(V,K),G=KD1(G,K,J),gT(G,X)}}return X}function gT(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 Wr(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class v6{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let Y=0;Y<J.length;Y++)X[Y]=J.charCodeAt(Y);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 $ of Z)J+=$.byteLength;let X=new Uint8Array(J),Y=0;for(let $ 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 Y=new Uint8Array(X);if(Y.set(Z),J!==0)for(let $=Z.byteLength;$<X;$++)Y[$]=J;return Y}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 Hr{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,Y;while(J.byteLength){if(X=J.getUint16(0,!1),WD1(J,X),Y=J.getUint8(X+1),Y===192||Y===193||Y===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 _2{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(v6.decodeText(Z.slice(12,16))===_2.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}}_2.PNG_FRIED_CHUNK_NAME="CgBI";class h4{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,Y=4,$=this.getSize(Z,J);if(!$)return null;while($[0]>1||$[1]>1)X+=$[0]*$[1]*Y,$[0]=Math.max(Math.floor($[0]/2),1),$[1]=Math.max(Math.floor($[1]/2),1);return X+=1*Y,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}`}}h4.impls={"image/jpeg":new Hr,"image/png":new _2};function WD1(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 rH{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 h4.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 $r(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function X$(Z){if($r(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if($r(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var mT,uT;(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"})(uT||(uT={}));class _7{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=_7.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=_7.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=_7.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=_7.Verbosity.ERROR)console.error(Z)}}mT=_7;_7.Verbosity=uT;_7.DEFAULT_INSTANCE=new mT(mT.Verbosity.INFO);function HD1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],G=Z[6],W=Z[7],H=Z[8],V=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,O=J*G-Y*Q,M=J*W-$*Q,R=X*G-Y*K,D=X*W-$*K,N=Y*W-$*G,C=H*U-V*q,T=H*B-F*q,E=H*L-z*q,A=V*B-F*U,S=V*L-z*U,x=F*L-z*B;return w*x-O*S+M*A+R*E-D*T+N*C}function VD1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],G=J[4],W=J[5],H=J[6],V=J[7],F=J[8],z=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],O=J[15],M=X[0],R=X[1],D=X[2],N=X[3];return Z[0]=M*Y+R*G+D*F+N*B,Z[1]=M*$+R*W+D*z+N*L,Z[2]=M*Q+R*H+D*q+N*w,Z[3]=M*K+R*V+D*U+N*O,M=X[4],R=X[5],D=X[6],N=X[7],Z[4]=M*Y+R*G+D*F+N*B,Z[5]=M*$+R*W+D*z+N*L,Z[6]=M*Q+R*H+D*q+N*w,Z[7]=M*K+R*V+D*U+N*O,M=X[8],R=X[9],D=X[10],N=X[11],Z[8]=M*Y+R*G+D*F+N*B,Z[9]=M*$+R*W+D*z+N*L,Z[10]=M*Q+R*H+D*q+N*w,Z[11]=M*K+R*V+D*U+N*O,M=X[12],R=X[13],D=X[14],N=X[15],Z[12]=M*Y+R*G+D*F+N*B,Z[13]=M*$+R*W+D*z+N*L,Z[14]=M*Q+R*H+D*q+N*w,Z[15]=M*K+R*V+D*U+N*O,Z}function zD1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],G=J[6],W=J[8],H=J[9],V=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,G),Z[2]=Math.hypot(W,H,V),Z}function FD1(Z,J){var X=new bT(3);zD1(X,J);var Y=1/X[0],$=1/X[1],Q=1/X[2],K=J[0]*Y,G=J[1]*$,W=J[2]*Q,H=J[4]*Y,V=J[5]*$,F=J[6]*Q,z=J[8]*Y,q=J[9]*$,U=J[10]*Q,B=K+V+U,L=0;if(B>0)L=Math.sqrt(B+1)*2,Z[3]=0.25*L,Z[0]=(F-q)/L,Z[1]=(z-W)/L,Z[2]=(G-H)/L;else if(K>V&&K>U)L=Math.sqrt(1+K-V-U)*2,Z[3]=(F-q)/L,Z[0]=0.25*L,Z[1]=(G+H)/L,Z[2]=(z+W)/L;else if(V>U)L=Math.sqrt(1+V-K-U)*2,Z[3]=(z-W)/L,Z[0]=(G+H)/L,Z[1]=0.25*L,Z[2]=(F+q)/L;else L=Math.sqrt(1+U-K-V)*2,Z[3]=(G-H)/L,Z[0]=(z+W)/L,Z[1]=(F+q)/L,Z[2]=0.25*L;return Z}class z8{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>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(z8.clamp(Z,0,1)*65535);case 5121:return Math.round(z8.clamp(Z,0,1)*255);case 5122:return Math.round(z8.clamp(Z,-1,1)*32767);case 5120:return Math.round(z8.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=fT([Z[0],Z[1],Z[2]]),Q=fT([Z[4],Z[5],Z[6]]),K=fT([Z[8],Z[9],Z[10]]);if(HD1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let W=Z.slice(),H=1/$,V=1/Q,F=1/K;W[0]*=H,W[1]*=H,W[2]*=H,W[4]*=V,W[5]*=V,W[6]*=V,W[8]*=F,W[9]*=F,W[10]*=F,FD1(X,W),Y[0]=$,Y[1]=Q,Y[2]=K}static compose(Z,J,X,Y){let $=Y,Q=J[0],K=J[1],G=J[2],W=J[3],H=Q+Q,V=K+K,F=G+G,z=Q*H,q=Q*V,U=Q*F,B=K*V,L=K*F,w=G*F,O=W*H,M=W*V,R=W*F,D=X[0],N=X[1],C=X[2];return $[0]=(1-(B+w))*D,$[1]=(q+R)*D,$[2]=(U-M)*D,$[3]=0,$[4]=(q-R)*N,$[5]=(1-(z+w))*N,$[6]=(L+O)*N,$[7]=0,$[8]=(U+M)*C,$[9]=(L-O)*C,$[10]=(1-(z+B))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function qD1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function UD1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),Y=J.values();if(X.length!==Y.length)return!1;for(let $=0;$<X.length;$++){let Q=X[$],K=Y[$];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function LD1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),Y=J.keys();if(X.length!==Y.length)return!1;for(let $ of X){let Q=Z.get($),K=J.get($);if(!!Q!==!!K)return!1;let G=Q.getChild(),W=K.getChild();if(G===W)continue;if(!G.equals(W))return!1}return!0}function Vr(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 zr(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!X$(Z)||!X$(J))return Z===J;let X=Z,Y=J,$=0,Q=0,K;for(K in X)$++;for(K in Y)Q++;if($!==Q)return!1;for(K in X){let G=X[K],W=Y[K];if(E2(G)&&E2(W)){if(!Vr(G,W))return!1}else if(X$(G)&&X$(W)){if(!zr(G,W))return!1}else if(G!==W)return!1}return!0}function E2(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Qr="https://null.example";class lT{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return rH.basename(new URL(Z,Qr).pathname)}static extension(Z){return rH.extension(new URL(Z,Qr).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),Y=J.split("/");X.pop();for(let $=0;$<Y.length;$++){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)}}lT.DEFAULT_INIT={};lT.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var tJ=(Z)=>Z,BD1=new Set;class S2 extends iK{constructor(Z,J=""){super(Z);this[y0].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,tJ)}copy(Z,J=tJ){for(let X in this[y0]){let Y=this[y0][X];if(Y instanceof T5){if(!this[A4].has(X))Y.dispose()}else if(Y instanceof I6||Y instanceof E0)for(let $ of Y.values())$.dispose();else if(Y instanceof e1)for(let $ of Y.values())$.dispose()}for(let X in Z[y0]){let Y=this[y0][X],$=Z[y0][X];if($ instanceof T5)if(this[A4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof E0||$ instanceof I6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof e1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(X$($))this[y0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[y0][X]=$.slice();else this[y0][X]=$}return this}equals(Z,J=BD1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[y0]){if(J.has(X))continue;let Y=this[y0][X],$=Z[y0][X];if(Y instanceof T5||$ instanceof T5){if(!qD1(Y,$))return!1}else if(Y instanceof E0||$ instanceof E0||Y instanceof I6||$ instanceof I6){if(!UD1(Y,$))return!1}else if(Y instanceof e1||$ instanceof e1){if(!LD1(Y,$))return!1}else if(X$(Y)||X$($)){if(!zr(Y,$))return!1}else if(E2(Y)||E2($)){if(!Vr(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 A6 extends S2{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new e1})}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 T0 extends A6{init(){this.propertyType=s.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:T0.Type.SCALAR,componentType:T0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case T0.Type.SCALAR:return 1;case T0.Type.VEC2:return 2;case T0.Type.VEC3:return 3;case T0.Type.VEC4:return 4;case T0.Type.MAT2:return 4;case T0.Type.MAT3:return 9;case T0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case T0.ComponentType.BYTE:return 1;case T0.ComponentType.UNSIGNED_BYTE:return 1;case T0.ComponentType.SHORT:return 2;case T0.ComponentType.UNSIGNED_SHORT:return 2;case T0.ComponentType.UNSIGNED_INT:return 4;case T0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMin(Z),J)for(let $=0;$<X;$++)Z[$]=z8.decodeNormalizedInt(Z[$],Y);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMax(Z),J)for(let $=0;$<X;$++)Z[$]=z8.decodeNormalizedInt(Z[$],Y);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=-1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+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 T0.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(),Y=this.getArray();if(this.getNormalized())return z8.decodeNormalizedInt(Y[Z*J],X);return Y[Z*J]}setScalar(Z,J){let X=this.getElementSize(),Y=this.getComponentType(),$=this.getArray();if(this.getNormalized())$[Z*X]=z8.encodeNormalizedInt(J,Y);else $[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)J[K]=z8.decodeNormalizedInt(Q[Z*Y+K],$);else J[K]=Q[Z*Y+K];return J}setElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)Q[Z*Y+K]=z8.encodeNormalizedInt(J[K],$);else Q[Z*Y+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?wD1(Z):T0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}T0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};T0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function wD1(Z){switch(Z.constructor){case Float32Array:return T0.ComponentType.FLOAT;case Uint32Array:return T0.ComponentType.UNSIGNED_INT;case Uint16Array:return T0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return T0.ComponentType.UNSIGNED_BYTE;case Int16Array:return T0.ComponentType.SHORT;case Int8Array:return T0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class pT extends A6{init(){this.propertyType=s.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new E0,samplers:new E0})}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 eH extends A6{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)}}eH.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class QG extends A6{init(){this.propertyType=s.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:QG.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:X9.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:X9.OTHER})}}QG.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class iT extends A6{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 ZV extends A6{init(){this.propertyType=s.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:ZV.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)}}ZV.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class s1 extends S2{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}s1.EXTENSION_NAME=void 0;class T1 extends A6{init(){this.propertyType=s.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:T1.WrapMode.REPEAT,wrapT:T1.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)}}T1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};T1.MagFilter={NEAREST:9728,LINEAR:9729};T1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:D2,G:C2,B:T2,A:jD1}=Y9;class JV extends A6{init(){this.propertyType=s.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:JV.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new T1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new T1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new T1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new T1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new T1(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:D2|C2|T2|jD1,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:D2|C2|T2,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:D2|C2|T2})}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:D2})}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:C2|T2})}}JV.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class nT extends A6{init(){this.propertyType=s.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new E0})}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 aT extends A6{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 E0})}copy(Z,J=tJ){if(J===tJ)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 z8.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),Y=this.get("scale").slice();return z8.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return z8.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return z8.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return z8.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let Y=this;Y!=null;Y=Y.getParentNode())Z.push(Y);let J,X=Z.pop().getMatrix();while(J=Z.pop())VD1(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 eJ extends A6{init(){this.propertyType=s.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:eJ.Mode.TRIANGLES,material:null,indices:null,attributes:new e1,targets:new E0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:X9.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:X9.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)}}eJ.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class Fr extends S2{init(){this.propertyType=s.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new e1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:X9.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function k2(){return k2=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},k2.apply(null,arguments)}class sT extends A6{init(){this.propertyType=s.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new E0})}copy(Z,J=tJ){if(J===tJ)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 oT extends A6{init(){this.propertyType=s.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new E0})}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:X9.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class rT extends A6{init(){this.propertyType=s.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||h4.extensionToMimeType(rH.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=h4.extensionToMimeType(rH.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",v6.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return h4.getSize(Z,this.getMimeType())}}class v2 extends A6{init(){this.propertyType=s.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${$D1}`,version:"2.0"},defaultScene:null,accessors:new E0,animations:new E0,buffers:new E0,cameras:new E0,materials:new E0,meshes:new E0,nodes:new E0,scenes:new E0,skins:new E0,textures:new E0})}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=tJ){if(J===tJ)throw new Error("Root cannot be copied.");this.set("asset",k2({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(k2({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let Y=Z.getExtension(X);this.setExtension(X,J(Y))}return this}_addChildOfRoot(Z){if(Z instanceof sT)this.addRef("scenes",Z);else if(Z instanceof aT)this.addRef("nodes",Z);else if(Z instanceof ZV)this.addRef("cameras",Z);else if(Z instanceof oT)this.addRef("skins",Z);else if(Z instanceof nT)this.addRef("meshes",Z);else if(Z instanceof JV)this.addRef("materials",Z);else if(Z instanceof rT)this.addRef("textures",Z);else if(Z instanceof pT)this.addRef("animations",Z);else if(Z instanceof T0)this.addRef("accessors",Z);else if(Z instanceof iT)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 I2{static fromGraph(Z){return I2._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new pK,this._root=new v2(this._graph),this._logger=_7.DEFAULT_INSTANCE,I2._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((Y)=>Y.extensionName===J)||new Z(this)}createScene(Z=""){return new sT(this._graph,Z)}createNode(Z=""){return new aT(this._graph,Z)}createCamera(Z=""){return new ZV(this._graph,Z)}createSkin(Z=""){return new oT(this._graph,Z)}createMesh(Z=""){return new nT(this._graph,Z)}createPrimitive(){return new eJ(this._graph)}createPrimitiveTarget(Z=""){return new Fr(this._graph,Z)}createMaterial(Z=""){return new JV(this._graph,Z)}createTexture(Z=""){return new rT(this._graph,Z)}createAnimation(Z=""){return new pT(this._graph,Z)}createAnimationChannel(Z=""){return new eH(this._graph,Z)}createAnimationSampler(Z=""){return new QG(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new T0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new iT(this._graph,Z)}}I2._GRAPH_DOCUMENTS=new WeakMap;class I1{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 Y=X,$=Y.target;if($ instanceof s1&&$.extensionName===this.extensionName){if(Y.type==="node:create")this._addExtensionProperty($);if(Y.type==="node:dispose")this._removeExtensionProperty($)}};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}}I1.EXTENSION_NAME=void 0;var MS6={logger:_7.DEFAULT_INSTANCE,extensions:[],dependencies:{}},RS6=new Set([s.BUFFER,s.TEXTURE,s.MATERIAL,s.MESH,s.PRIMITIVE,s.NODE,s.SCENE]);var tH;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(tH||(tH={}));class ZX{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 Y=Z.getRoot(),$=Y.listBuffers().length,Q=Y.listTextures().length;this.bufferURIGenerator=new dT($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new dT(Q>1,(K)=>OD1(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()},Y=JSON.stringify(X);if(!this.samplerDefIndexMap.has(Y))this.samplerDefIndexMap.set(Y,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let $={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get(Y)},Q=JSON.stringify($);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push($);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((Y)=>Y.getName()==="attributes"&&Y.getAttributes().key==="POSITION"||Y.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===yT.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 Y=h4.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,Y),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let Y=this.jsonDoc.resources;if(!(Z in Y)){Y[Z]=J;return}if(J===Y[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let $=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn($);return}throw new Error($)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return X9.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:Y}=X.getAttributes();if(Y)return Y;if(X.getParent().propertyType!==s.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return X9.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}}ZX.BufferViewTarget=tH;ZX.BufferViewUsage=X9;ZX.USAGE_TO_TARGET={[X9.ARRAY_BUFFER]:tH.ARRAY_BUFFER,[X9.ELEMENT_ARRAY_BUFFER]:tH.ELEMENT_ARRAY_BUFFER};class dT{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 OD1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{UNSIGNED_INT:NS6,UNSIGNED_SHORT:PS6,UNSIGNED_BYTE:DS6}=T0.ComponentType,CS6=new Set([s.ACCESSOR,s.BUFFER,s.MATERIAL,s.MESH]);var Kr;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(Kr||(Kr={}));var Ur=163,Lr=166;function MD1(){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 KG{constructor(Z,J,X,Y){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(Z.buffer,Z.byteOffset+J,X),this._littleEndian=Y,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,Y=0;while(this._dataView.getUint8(this._offset)!==J&&Y<Z)Y++,this._offset++;if(Y<Z)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+X,Y)}}var kS6=new Uint8Array([0]),J5=[171,75,84,88,32,50,48,187,13,10,26,10];function qr(Z){return new TextDecoder().decode(Z)}function A2(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,J5.length);if(J[0]!==J5[0]||J[1]!==J5[1]||J[2]!==J5[2]||J[3]!==J5[3]||J[4]!==J5[4]||J[5]!==J5[5]||J[6]!==J5[6]||J[7]!==J5[7]||J[8]!==J5[8]||J[9]!==J5[9]||J[10]!==J5[10]||J[11]!==J5[11])throw new Error("Missing KTX 2.0 identifier.");let X=MD1(),Y=17*Uint32Array.BYTES_PER_ELEMENT,$=new KG(Z,J5.length,Y,!0);X.vkFormat=$._nextUint32(),X.typeSize=$._nextUint32(),X.pixelWidth=$._nextUint32(),X.pixelHeight=$._nextUint32(),X.pixelDepth=$._nextUint32(),X.layerCount=$._nextUint32(),X.faceCount=$._nextUint32();let Q=$._nextUint32();X.supercompressionScheme=$._nextUint32();let K=$._nextUint32(),G=$._nextUint32(),W=$._nextUint32(),H=$._nextUint32(),V=$._nextUint64(),F=$._nextUint64(),z=Q*3*8,q=new KG(Z,J5.length+Y,z,!0);for(let q6=0;q6<Q;q6++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+q._nextUint64(),q._nextUint64()),uncompressedByteLength:q._nextUint64()});let U=new KG(Z,K,G,!0);U._skip(4);let B=U._nextUint16(),L=U._nextUint16(),w=U._nextUint16(),O=U._nextUint16(),M=U._nextUint8(),R=U._nextUint8(),D=U._nextUint8(),N=U._nextUint8(),C=[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],T=[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],A={vendorId:B,descriptorType:L,versionNumber:w,colorModel:M,colorPrimaries:R,transferFunction:D,flags:N,texelBlockDimension:C,bytesPlane:T,samples:[]},S=6,x=4,I=(O/4-S)/x;for(let q6=0;q6<I;q6++){let LZ={bitOffset:U._nextUint16(),bitLength:U._nextUint8(),channelType:U._nextUint8(),samplePosition:[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(LZ.channelType&64)LZ.sampleLower=U._nextInt32(),LZ.sampleUpper=U._nextInt32();else LZ.sampleLower=U._nextUint32(),LZ.sampleUpper=U._nextUint32();A.samples[q6]=LZ}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(A);let _=new KG(Z,W,H,!0);while(_._offset<H){let q6=_._nextUint32(),LZ=_._scan(q6),MU=qr(LZ);if(X.keyValue[MU]=_._nextUint8Array(q6-LZ.byteLength-1),MU.match(/^ktx/i)){let hm=qr(X.keyValue[MU]);X.keyValue[MU]=hm.substring(0,hm.lastIndexOf("\x00"))}let DV1=q6%4?4-q6%4:0;_._skip(DV1)}if(F<=0)return X;let y=new KG(Z,V,F,!0),u=y._nextUint16(),n=y._nextUint16(),o=y._nextUint32(),Q0=y._nextUint32(),G0=y._nextUint32(),S0=y._nextUint32(),v0=[];for(let q6=0;q6<Q;q6++)v0.push({imageFlags:y._nextUint32(),rgbSliceByteOffset:y._nextUint32(),rgbSliceByteLength:y._nextUint32(),alphaSliceByteOffset:y._nextUint32(),alphaSliceByteLength:y._nextUint32()});let r0=V+y._offset,A8=r0+o,r1=A8+Q0,U7=r1+G0,N4=new Uint8Array(Z.buffer,Z.byteOffset+r0,o),HK=new Uint8Array(Z.buffer,Z.byteOffset+A8,Q0),VK=new Uint8Array(Z.buffer,Z.byteOffset+r1,G0),IY=new Uint8Array(Z.buffer,Z.byteOffset+U7,S0);return X.globalData={endpointCount:u,selectorCount:n,imageDescs:v0,endpointsData:N4,selectorsData:HK,tablesData:VK,extendedData:IY},X}var XE="EXT_mesh_gpu_instancing",eT="EXT_meshopt_compression",RD1="EXT_texture_webp",ND1="EXT_texture_avif",Ir="KHR_draco_mesh_compression",YE="KHR_lights_punctual",$E="KHR_materials_anisotropy",QE="KHR_materials_clearcoat",KE="KHR_materials_diffuse_transmission",GE="KHR_materials_dispersion",WE="KHR_materials_emissive_strength",HE="KHR_materials_ior",VE="KHR_materials_iridescence",zE="KHR_materials_pbrSpecularGlossiness",FE="KHR_materials_sheen",qE="KHR_materials_specular",UE="KHR_materials_transmission",LE="KHR_materials_unlit",BE="KHR_materials_volume",w$="KHR_materials_variants",PD1="KHR_mesh_quantization",DD1="KHR_texture_basisu",wE="KHR_texture_transform",x2="KHR_xmp_json_ld",ZE="INSTANCE_ATTRIBUTE";class jE extends s1{init(){this.extensionName=XE,this.propertyType="InstancedMesh",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new e1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:ZE})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}jE.EXTENSION_NAME=XE;var Y$=XE;class y2 extends I1{constructor(...Z){super(...Z);this.extensionName=Y$,this.provideTypes=[s.NODE],this.prewriteTypes=[s.ACCESSOR]}createInstancedMesh(){return new jE(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[Y$])return;let Q=Y.extensions[Y$],K=this.createInstancedMesh();for(let G in Q.attributes)K.setAttribute(G,Z.accessors[Q.attributes[G]]);Z.nodes[$].setExtension(Y$,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(ZE);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,ZE);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let Y=X.getExtension(Y$);if(Y){let $=Z.nodeIndexMap.get(X),Q=J.json.nodes[$],K={attributes:{}};Y.listSemantics().forEach((G)=>{let W=Y.getAttribute(G);K.attributes[G]=Z.accessorIndexMap.get(W)}),Q.extensions=Q.extensions||{},Q.extensions[Y$]=K}}),this}}y2.EXTENSION_NAME=Y$;function AZ(){return AZ=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},AZ.apply(null,arguments)}var QV;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(QV||(QV={}));var WG;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(WG||(WG={}));var F8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})(F8||(F8={}));var{BYTE:CD1,SHORT:Br,FLOAT:TD1}=T0.ComponentType,{encodeNormalizedInt:wr,decodeNormalizedInt:JE}=z8;function ED1(Z,J,X,Y){let{filter:$,bits:Q}=Y,K={array:Z.getArray(),byteStride:Z.getElementSize()*Z.getComponentSize(),componentType:Z.getComponentType(),normalized:Z.getNormalized()};if(X!==WG.ATTRIBUTES)return K;if($!==F8.NONE){let G=Z.getNormalized()?kD1(Z):new Float32Array(K.array);switch($){case F8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=TD1,K.normalized=!1,K.array=J.encodeFilterExp(G,Z.getCount(),K.byteStride,Q);break;case F8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?Br:CD1,K.normalized=!0,G=Z.getElementSize()===3?_D1(G):G,K.array=J.encodeFilterOct(G,Z.getCount(),K.byteStride,Q);break;case F8.QUATERNION:K.byteStride=8,K.componentType=Br,K.normalized=!0,K.array=J.encodeFilterQuat(G,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((W)=>JE(W,Z.getComponentType())),K.max=K.max.map((W)=>JE(W,Z.getComponentType()));if(K.normalized)K.min=K.min.map((W)=>wr(W,K.componentType)),K.max=K.max.map((W)=>wr(W,K.componentType))}else if(K.byteStride%4)K.array=ID1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function kD1(Z){let J=Z.getComponentType(),X=Z.getArray(),Y=new Float32Array(X.length);for(let $=0;$<X.length;$++)Y[$]=JE(X[$],J);return Y}function ID1(Z,J){let Y=v6.padNumber(Z.BYTES_PER_ELEMENT*J)/Z.BYTES_PER_ELEMENT,$=Z.length/J,Q=new Z.constructor($*Y);for(let K=0;K*J<Z.length;K++)for(let G=0;G<J;G++)Q[K*Y+G]=Z[K*J+G];return Q}function _D1(Z){let J=new Float32Array(Z.length*4/3);for(let X=0,Y=Z.length/3;X<Y;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 SD1(Z,J){if(J===ZX.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some((Y)=>{return Y instanceof eJ&&Y.getMode()===eJ.Mode.TRIANGLES})?WG.TRIANGLES:WG.INDICES;return WG.ATTRIBUTES}function vD1(Z,J){let X=J.getGraph().listParentEdges(Z).filter((Y)=>!(Y.getParent()instanceof v2));for(let Y of X){let $=Y.getName(),Q=Y.getAttributes().key||"",K=Y.getParent().propertyType===s.PRIMITIVE_TARGET;if($==="indices")return{filter:F8.NONE};if($==="attributes"){if(Q==="POSITION")return{filter:F8.NONE};if(Q==="TEXCOORD_0")return{filter:F8.NONE};if(Q.startsWith("JOINTS_"))return{filter:F8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:F8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:F8.NONE}:{filter:F8.OCTAHEDRAL,bits:8}}if($==="output"){let G=_r(Z);if(G==="rotation")return{filter:F8.QUATERNION,bits:16};if(G==="translation")return{filter:F8.EXPONENTIAL,bits:12};if(G==="scale")return{filter:F8.EXPONENTIAL,bits:12};return{filter:F8.NONE}}if($==="input")return{filter:F8.NONE};if($==="inverseBindMatrices")return{filter:F8.NONE}}return{filter:F8.NONE}}function _r(Z){for(let J of Z.listParents()){if(!(J instanceof QG))continue;for(let X of J.listParents()){if(!(X instanceof eH))continue;return X.getTargetPath()}}return null}function AD1(Z){if(!Z.extensions||!Z.extensions[eT])return!1;return!!Z.extensions[eT].fallback}var X5=eT,jr={method:QV.QUANTIZE};class GV extends I1{constructor(...Z){super(...Z);this.extensionName=X5,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=jr,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=AZ({},jr,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${X5}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${X5}]: 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(!Y.extensions||!Y.extensions[X5])return;let Q=Y.extensions[X5],K=Q.byteOffset||0,G=Q.byteLength||0,W=Q.count,H=Q.byteStride,V=new Uint8Array(W*H),F=J.json.buffers[Q.buffer],z=F.uri?J.resources[F.uri]:J.resources[cT],q=v6.toView(z,K,G);this._decoder.decodeGltfBuffer(V,W,H,q,Q.mode,Q.filter),Z.bufferViews[$]=V})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y)=>{if(!Y.extensions||!Y.extensions[X5])return;let $=Y.extensions[X5],Q=Z.buffers[$.buffer],K=Z.buffers[Y.buffer],G=J.json.buffers[Y.buffer];if(AD1(G))this._decoderFallbackBufferMap.set(K,Q)})}read(Z){if(!this.isRequired())return this;for(let[J,X]of this._decoderFallbackBufferMap){for(let Y of J.listParents())if(Y instanceof T0)Y.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,Y=this._encoderOptions,$=this.document.getGraph(),Q=this.document.createBuffer(),K=this.document.getRoot().listBuffers().indexOf(Q),G=1,W=new Map,H=(V)=>{for(let F of $.listParents(V)){if(F.propertyType===s.ROOT)continue;let z=W.get(V);if(z===void 0)W.set(V,z=G++);return z}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let V of this.document.getRoot().listAccessors()){if(_r(V)==="weights")continue;if(V.getSparse())continue;let F=Z.getAccessorUsage(V),z=Z.accessorUsageGroupedByParent.has(F)?H(V):null,q=SD1(V,F),U=Y.method===QV.FILTER?vD1(V,this.document):{filter:F8.NONE},B=ED1(V,X,q,U),{array:L,byteStride:w}=B,O=V.getBuffer();if(!O)throw new Error(`${X5}: Missing buffer for accessor.`);let M=this.document.getRoot().listBuffers().indexOf(O),R=[F,z,q,U.filter,w,M].join(":"),D=this._encoderBufferViews[R],N=this._encoderBufferViewData[R],C=this._encoderBufferViewAccessors[R];if(!D||!N)C=this._encoderBufferViewAccessors[R]=[],N=this._encoderBufferViewData[R]=[],D=this._encoderBufferViews[R]={buffer:K,target:ZX.USAGE_TO_TARGET[F],byteOffset:0,byteLength:0,byteStride:F===ZX.BufferViewUsage.ARRAY_BUFFER?w:void 0,extensions:{[X5]:{buffer:M,byteOffset:0,byteLength:0,mode:q,filter:U.filter!==F8.NONE?U.filter:void 0,byteStride:w,count:0}}};let T=Z.createAccessorDef(V);if(T.componentType=B.componentType,T.normalized=B.normalized,T.byteOffset=D.byteLength,T.min&&B.min)T.min=B.min;if(T.max&&B.max)T.max=B.max;Z.accessorIndexMap.set(V,J.accessors.length),J.accessors.push(T),C.push(T),N.push(new Uint8Array(L.buffer,L.byteOffset,L.byteLength)),D.byteLength+=L.byteLength,D.extensions.EXT_meshopt_compression.count+=V.getCount()}}_prewriteBuffers(Z){let J=this._encoder;for(let X in this._encoderBufferViews){let Y=this._encoderBufferViews[X],$=this._encoderBufferViewData[X],Q=this.document.getRoot().listBuffers()[Y.extensions[X5].buffer],K=Z.otherBufferViews.get(Q)||[],{count:G,byteStride:W,mode:H}=Y.extensions[X5],V=v6.concat($),F=J.encodeGltfBuffer(V,G,W,H),z=v6.pad(F);Y.extensions[X5].byteLength=F.byteLength,$.length=0,$.push(z),K.push(z),Z.otherBufferViews.set(Q,K)}}write(Z){let J=0;for(let Q in this._encoderBufferViews){let K=this._encoderBufferViews[Q],G=this._encoderBufferViewData[Q][0],W=Z.otherBufferViewsIndexMap.get(G),H=this._encoderBufferViewAccessors[Q];for(let q of H)q.bufferView=W;let V=Z.jsonDoc.json.bufferViews[W],F=V.byteOffset||0;Object.assign(V,K),V.byteOffset=J;let z=V.extensions[X5];z.byteOffset=F,J+=v6.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,Y=Z.bufferIndexMap.get(X),$=Z.jsonDoc.json.buffers[Y];return $.byteLength=J,$.extensions={[X5]:{fallback:!0}},X.dispose(),this}}GV.EXTENSION_NAME=X5;GV.EncoderMethod=QV;var XV=ND1;class Sr{match(Z){return Z.length>=12&&v6.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=Or(J,0);if(!X)return null;let Y=X.end;while(X=Or(J,Y))if(X.type==="meta")Y=X.start+4;else if(X.type==="iprp"||X.type==="ipco")Y=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 Y=X.end;return null}getChannels(Z){return 4}}class b2 extends I1{constructor(...Z){super(...Z);this.extensionName=XV,this.prereadTypes=[s.TEXTURE]}static register(){h4.registerFormat("image/avif",new Sr)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[XV])X.source=X.extensions[XV].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 Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[XV]={source:Q.source},delete Q.source})}}),this}}b2.EXTENSION_NAME=XV;function Or(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:v6.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}var YV=RD1;class vr{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=v6.decodeText(Z.slice(0,4)),X=v6.decodeText(Z.slice(8,12));if(J!=="RIFF"||X!=="WEBP")return null;let Y=new DataView(Z.buffer,Z.byteOffset),$=12;while($<Y.byteLength){let Q=v6.decodeText(new Uint8Array([Y.getUint8($),Y.getUint8($+1),Y.getUint8($+2),Y.getUint8($+3)])),K=Y.getUint32($+4,!0);if(Q==="VP8 "){let G=Y.getInt16($+14,!0)&16383,W=Y.getInt16($+16,!0)&16383;return[G,W]}else if(Q==="VP8L"){let G=Y.getUint8($+9),W=Y.getUint8($+10),H=Y.getUint8($+11),V=Y.getUint8($+12),F=1+((W&63)<<8|G),z=1+((V&15)<<10|H<<2|(W&192)>>6);return[F,z]}$+=8+K+K%2}return null}getChannels(Z){return 4}}class g2 extends I1{constructor(...Z){super(...Z);this.extensionName=YV,this.prereadTypes=[s.TEXTURE]}static register(){h4.registerFormat("image/webp",new vr)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[YV])X.source=X.extensions[YV].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 Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[YV]={source:Q.source},delete Q.source})}}),this}}g2.EXTENSION_NAME=YV;var Mr=Ir,l8,Ar,xr;function xD1(Z,J){let X=new l8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==l8.TRIANGULAR_MESH)throw new Error(`[${Mr}] Unknown geometry type.`);let $=new l8.Mesh;if(!Z.DecodeBufferToMesh(X,$).ok()||$.ptr===0)throw new Error(`[${Mr}] Decoding failure.`);return $}finally{l8.destroy(X)}}function hD1(Z,J){let Y=J.num_faces()*3,$,Q;if(J.num_points()<=65534){let K=Y*Uint16Array.BYTES_PER_ELEMENT;$=l8._malloc(K),Z.GetTrianglesUInt16Array(J,K,$),Q=new Uint16Array(l8.HEAPU16.buffer,$,Y).slice()}else{let K=Y*Uint32Array.BYTES_PER_ELEMENT;$=l8._malloc(K),Z.GetTrianglesUInt32Array(J,K,$),Q=new Uint32Array(l8.HEAPU32.buffer,$,Y).slice()}return l8._free($),Q}function fD1(Z,J,X,Y){let $=xr[Y.componentType],Q=Ar[Y.componentType],K=X.num_components(),W=J.num_points()*K,H=W*Q.BYTES_PER_ELEMENT,V=l8._malloc(H);Z.GetAttributeDataArrayForAllPoints(J,X,$,H,V);let F=new Q(l8.HEAPF32.buffer,V,W).slice();return l8._free(V),F}function yD1(Z){l8=Z,Ar={[T0.ComponentType.FLOAT]:Float32Array,[T0.ComponentType.UNSIGNED_INT]:Uint32Array,[T0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[T0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[T0.ComponentType.SHORT]:Int16Array,[T0.ComponentType.BYTE]:Int8Array},xr={[T0.ComponentType.FLOAT]:l8.DT_FLOAT32,[T0.ComponentType.UNSIGNED_INT]:l8.DT_UINT32,[T0.ComponentType.UNSIGNED_SHORT]:l8.DT_UINT16,[T0.ComponentType.UNSIGNED_BYTE]:l8.DT_UINT8,[T0.ComponentType.SHORT]:l8.DT_INT16,[T0.ComponentType.BYTE]:l8.DT_INT8}}var b9,KV;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(KV||(KV={}));var g9;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(g9||(g9={}));var hr={[g9.POSITION]:14,[g9.NORMAL]:10,[g9.COLOR]:8,[g9.TEX_COORD]:12,[g9.GENERIC]:12},Rr={decodeSpeed:5,encodeSpeed:5,method:KV.EDGEBREAKER,quantizationBits:hr,quantizationVolume:"mesh"};function bD1(Z){b9=Z}function gD1(Z,J=Rr){let X=AZ({},Rr,J);X.quantizationBits=AZ({},hr,J.quantizationBits);let Y=new b9.MeshBuilder,$=new b9.Mesh,Q=new b9.ExpertEncoder($),K={},G=new b9.DracoInt8Array,W=Z.listTargets().length>0,H=!1;for(let B of Z.listSemantics()){let L=Z.getAttribute(B);if(L.getSparse()){H=!0;continue}let w=mD1(B),O=uD1(Y,L.getComponentType(),$,b9[w],L.getCount(),L.getElementSize(),L.getArray());if(O===-1)throw new Error(`Error compressing "${B}" attribute.`);if(K[B]=O,X.quantizationVolume==="mesh"||B!=="POSITION")Q.SetAttributeQuantization(O,X.quantizationBits[w]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:M}=X,R=Math.max(M.max[0]-M.min[0],M.max[1]-M.min[1],M.max[2]-M.min[2]);Q.SetAttributeExplicitQuantization(O,X.quantizationBits[w],L.getElementSize(),M.min,R)}else throw new Error("Invalid quantization volume state.")}let V=Z.getIndices();if(!V)throw new h2("Primitive must have indices.");if(Y.AddFacesToMesh($,V.getCount()/3,V.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===KV.SEQUENTIAL||W||H)Q.SetEncodingMethod(b9.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(b9.MESH_EDGEBREAKER_ENCODING);let F=Q.EncodeToDracoBuffer(!(W||H),G);if(F<=0)throw new h2("Error applying Draco compression.");let z=new Uint8Array(F);for(let B=0;B<F;++B)z[B]=G.GetValue(B);let q=Q.GetNumberOfEncodedPoints(),U=Q.GetNumberOfEncodedFaces()*3;return b9.destroy(G),b9.destroy($),b9.destroy(Y),b9.destroy(Q),{numVertices:q,numIndices:U,data:z,attributeIDs:K}}function mD1(Z){if(Z==="POSITION")return g9.POSITION;else if(Z==="NORMAL")return g9.NORMAL;else if(Z.startsWith("COLOR_"))return g9.COLOR;else if(Z.startsWith("TEXCOORD_"))return g9.TEX_COORD;return g9.GENERIC}function uD1(Z,J,X,Y,$,Q,K){switch(J){case T0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,Y,$,Q,K);case T0.ComponentType.BYTE:return Z.AddInt8Attribute(X,Y,$,Q,K);case T0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,Y,$,Q,K);case T0.ComponentType.SHORT:return Z.AddInt16Attribute(X,Y,$,Q,K);case T0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,Y,$,Q,K);case T0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,Y,$,Q,K);default:throw new Error(`Unexpected component type, "${J}".`)}}class h2 extends Error{}var E8=Ir;class WV extends I1{constructor(...Z){super(...Z);this.extensionName=E8,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,yD1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,bD1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw new Error(`[${E8}] Please install extension dependency, "draco3d.decoder".`);let J=this.document.getLogger(),X=Z.jsonDoc,Y=new Map;try{let $=X.json.meshes||[];for(let Q of $)for(let K of Q.primitives){if(!K.extensions||!K.extensions[E8])continue;let G=K.extensions[E8],[W,H]=Y.get(G.bufferView)||[];if(!H||!W){let V=X.json.bufferViews[G.bufferView],F=X.json.buffers[V.buffer],z=F.uri?X.resources[F.uri]:X.resources[cT],q=V.byteOffset||0,U=V.byteLength,B=v6.toView(z,q,U);W=new this._decoderModule.Decoder,H=xD1(W,B),Y.set(G.bufferView,[W,H]),J.debug(`[${E8}] Decompressed ${B.byteLength} bytes.`)}for(let V in G.attributes){let F=Z.jsonDoc.json.accessors[K.attributes[V]],z=W.GetAttributeByUniqueId(H,G.attributes[V]),q=fD1(W,H,z,F);Z.accessors[K.attributes[V]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(hD1(W,H))}}finally{for(let[$,Q]of Array.from(Y.values()))this._decoderModule.destroy($),this._decoderModule.destroy(Q)}return this}read(Z){return this}prewrite(Z,J){if(!this._encoderModule)throw new Error(`[${E8}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${E8}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let Y=dD1(this.document),$=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${E8}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=Gr(this.document.getRoot().listScenes().pop());for(let K of Array.from(Y.keys())){let G=Y.get(K);if(!G)throw new Error("Unexpected primitive.");if($.has(G)){$.set(G,$.get(G));continue}let W=K.getIndices(),H=Z.jsonDoc.json.accessors,V;try{V=gD1(K,AZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof h2){X.warn(`[${E8}]: ${q.message} Skipping primitive compression.`);continue}throw q}$.set(G,V);let F=Z.createAccessorDef(W);if(F.count=V.numIndices,Z.accessorIndexMap.set(W,H.length),H.push(F),V.numVertices>65534&&T0.getComponentSize(F.componentType)<=2)F.componentType=T0.ComponentType.UNSIGNED_INT;else if(V.numVertices>254&&T0.getComponentSize(F.componentType)<=1)F.componentType=T0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let U=K.getAttribute(q);if(V.attributeIDs[q]===void 0)continue;let B=Z.createAccessorDef(U);B.count=V.numVertices,Z.accessorIndexMap.set(U,H.length),H.push(B)}let z=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(z))Z.otherBufferViews.set(z,[]);Z.otherBufferViews.get(z).push(V.data)}return X.debug(`[${E8}] Compressed ${Y.size} primitives.`),Z.extensionData[E8]={primitiveHashMap:Y,primitiveEncodingMap:$},this}write(Z){let J=Z.extensionData[E8];for(let X of this.document.getRoot().listMeshes()){let Y=Z.jsonDoc.json.meshes[Z.meshIndexMap.get(X)];for(let $=0;$<X.listPrimitives().length;$++){let Q=X.listPrimitives()[$],K=Y.primitives[$],G=J.primitiveHashMap.get(Q);if(!G)continue;let W=J.primitiveEncodingMap.get(G);if(!W)continue;K.extensions=K.extensions||{},K.extensions[E8]={bufferView:Z.otherBufferViewsIndexMap.get(W.data),attributes:W.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter((Y)=>Y!==E8),X.extensionsRequired=(X.extensionsRequired||[]).filter((Y)=>Y!==E8)}return this}}WV.EXTENSION_NAME=E8;WV.EncoderMethod=KV;function dD1(Z){let J=Z.getLogger(),X=new Set,Y=new Set,$=0,Q=0;for(let F of Z.getRoot().listMeshes())for(let z of F.listPrimitives())if(!z.getIndices())Y.add(z),$++;else if(z.getMode()!==eJ.Mode.TRIANGLES)Y.add(z),Q++;else X.add(z);if($>0)J.warn(`[${E8}] Skipping Draco compression of ${$} non-indexed primitives.`);if(Q>0)J.warn(`[${E8}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),G=new Map;for(let F=0;F<K.length;F++)G.set(K[F],F);let W=new Map,H=new Set,V=new Map;for(let F of Array.from(X)){let z=Nr(F,G);if(H.has(z)){V.set(F,z);continue}if(W.has(F.getIndices())){let q=F.getIndices(),U=q.clone();G.set(U,Z.getRoot().listAccessors().length-1),F.swap(q,U)}for(let q of F.listAttributes())if(W.has(q)){let U=q.clone();G.set(U,Z.getRoot().listAccessors().length-1),F.swap(q,U)}z=Nr(F,G),H.add(z),V.set(F,z),W.set(F.getIndices(),z);for(let q of F.listAttributes())W.set(q,z)}for(let F of Array.from(W.keys())){let z=new Set(F.listParents().map((q)=>q.propertyType));if(z.size!==2||!z.has(s.PRIMITIVE)||!z.has(s.ROOT))throw new Error(`[${E8}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let F of Array.from(X)){let z=V.get(F),q=F.getIndices();if(W.get(q)!==z||F.listAttributes().some((U)=>W.get(U)!==z))throw new Error(`[${E8}] Draco primitives must share all, or no, accessors.`)}for(let F of Array.from(Y)){let z=F.getIndices();if(W.has(z)||F.listAttributes().some((q)=>W.has(q)))throw new Error(`[${E8}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return V}function Nr(Z,J){let X=[],Y=Z.getIndices();X.push(J.get(Y));for(let $ of Z.listAttributes())X.push(J.get($));return X.sort().join("|")}class HG extends s1{init(){this.extensionName=YE,this.propertyType="Light",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:HG.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)}}HG.EXTENSION_NAME=YE;HG.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};var S7=YE;class OE extends I1{constructor(...Z){super(...Z);this.extensionName=S7}createLight(Z=""){return new HG(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[S7])return this;let $=(J.json.extensions[S7].lights||[]).map((Q)=>{var K,G;let W=this.createLight().setName(Q.name||"").setType(Q.type);if(Q.color!==void 0)W.setColor(Q.color);if(Q.intensity!==void 0)W.setIntensity(Q.intensity);if(Q.range!==void 0)W.setRange(Q.range);if(((K=Q.spot)==null?void 0:K.innerConeAngle)!==void 0)W.setInnerConeAngle(Q.spot.innerConeAngle);if(((G=Q.spot)==null?void 0:G.outerConeAngle)!==void 0)W.setOuterConeAngle(Q.spot.outerConeAngle);return W});return J.json.nodes.forEach((Q,K)=>{if(!Q.extensions||!Q.extensions[S7])return;let G=Q.extensions[S7];Z.nodes[K].setExtension(S7,$[G.light])}),this}write(Z){let J=Z.jsonDoc;if(this.properties.size===0)return this;let X=[],Y=new Map;for(let $ of this.properties){let Q=$,K={type:Q.getType()};if(!z8.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()===HG.Type.SPOT)K.spot={innerConeAngle:Q.getInnerConeAngle(),outerConeAngle:Q.getOuterConeAngle()};X.push(K),Y.set(Q,X.length-1)}return this.document.getRoot().listNodes().forEach(($)=>{let Q=$.getExtension(S7);if(Q){let K=Z.nodeIndexMap.get($),G=J.json.nodes[K];G.extensions=G.extensions||{},G.extensions[S7]={light:Y.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[S7]={lights:X},this}}OE.EXTENSION_NAME=S7;var{R:cD1,G:lD1,B:pD1}=Y9;class ME extends s1{init(){this.extensionName=$E,this.propertyType="Anisotropy",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new T1(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:cD1|lD1|pD1})}}ME.EXTENSION_NAME=$E;var $$=$E;class RE extends I1{constructor(...Z){super(...Z);this.extensionName=$$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createAnisotropy(){return new ME(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[$$]){let K=this.createAnisotropy();Z.materials[Q].setExtension($$,K);let G=$.extensions[$$];if(G.anisotropyStrength!==void 0)K.setAnisotropyStrength(G.anisotropyStrength);if(G.anisotropyRotation!==void 0)K.setAnisotropyRotation(G.anisotropyRotation);if(G.anisotropyTexture!==void 0){let W=G.anisotropyTexture,H=Z.textures[Y[W.index].source];K.setAnisotropyTexture(H),Z.setTextureInfo(K.getAnisotropyTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension($$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[$$]={};if(Y.getAnisotropyStrength()>0)K.anisotropyStrength=Y.getAnisotropyStrength();if(Y.getAnisotropyRotation()!==0)K.anisotropyRotation=Y.getAnisotropyRotation();if(Y.getAnisotropyTexture()){let G=Y.getAnisotropyTexture(),W=Y.getAnisotropyTextureInfo();K.anisotropyTexture=Z.createTextureInfoDef(G,W)}}}),this}}RE.EXTENSION_NAME=$$;var{R:Pr,G:Dr,B:iD1}=Y9;class NE extends s1{init(){this.extensionName=QE,this.propertyType="Clearcoat",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new T1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new T1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new T1(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:Pr})}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:Dr})}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:Pr|Dr|iD1})}}NE.EXTENSION_NAME=QE;var Q$=QE;class PE extends I1{constructor(...Z){super(...Z);this.extensionName=Q$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createClearcoat(){return new NE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[Q$]){let K=this.createClearcoat();Z.materials[Q].setExtension(Q$,K);let G=$.extensions[Q$];if(G.clearcoatFactor!==void 0)K.setClearcoatFactor(G.clearcoatFactor);if(G.clearcoatRoughnessFactor!==void 0)K.setClearcoatRoughnessFactor(G.clearcoatRoughnessFactor);if(G.clearcoatTexture!==void 0){let W=G.clearcoatTexture,H=Z.textures[Y[W.index].source];K.setClearcoatTexture(H),Z.setTextureInfo(K.getClearcoatTextureInfo(),W)}if(G.clearcoatRoughnessTexture!==void 0){let W=G.clearcoatRoughnessTexture,H=Z.textures[Y[W.index].source];K.setClearcoatRoughnessTexture(H),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),W)}if(G.clearcoatNormalTexture!==void 0){let W=G.clearcoatNormalTexture,H=Z.textures[Y[W.index].source];if(K.setClearcoatNormalTexture(H),Z.setTextureInfo(K.getClearcoatNormalTextureInfo(),W),W.scale!==void 0)K.setClearcoatNormalScale(W.scale)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(Q$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[Q$]={clearcoatFactor:Y.getClearcoatFactor(),clearcoatRoughnessFactor:Y.getClearcoatRoughnessFactor()};if(Y.getClearcoatTexture()){let G=Y.getClearcoatTexture(),W=Y.getClearcoatTextureInfo();K.clearcoatTexture=Z.createTextureInfoDef(G,W)}if(Y.getClearcoatRoughnessTexture()){let G=Y.getClearcoatRoughnessTexture(),W=Y.getClearcoatRoughnessTextureInfo();K.clearcoatRoughnessTexture=Z.createTextureInfoDef(G,W)}if(Y.getClearcoatNormalTexture()){let G=Y.getClearcoatNormalTexture(),W=Y.getClearcoatNormalTextureInfo();if(K.clearcoatNormalTexture=Z.createTextureInfoDef(G,W),Y.getClearcoatNormalScale()!==1)K.clearcoatNormalTexture.scale=Y.getClearcoatNormalScale()}}}),this}}PE.EXTENSION_NAME=Q$;var{R:nD1,G:aD1,B:sD1,A:oD1}=Y9;class DE extends s1{init(){this.extensionName=KE,this.propertyType="DiffuseTransmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new T1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new T1(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:oD1})}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:nD1|aD1|sD1})}}DE.EXTENSION_NAME=KE;var K$=KE;class CE extends I1{constructor(...Z){super(...Z);this.extensionName=K$}createDiffuseTransmission(){return new DE(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[K$]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(K$,K);let G=$.extensions[K$];if(G.diffuseTransmissionFactor!==void 0)K.setDiffuseTransmissionFactor(G.diffuseTransmissionFactor);if(G.diffuseTransmissionColorFactor!==void 0)K.setDiffuseTransmissionColorFactor(G.diffuseTransmissionColorFactor);if(G.diffuseTransmissionTexture!==void 0){let W=G.diffuseTransmissionTexture,H=Z.textures[Y[W.index].source];K.setDiffuseTransmissionTexture(H),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),W)}if(G.diffuseTransmissionColorTexture!==void 0){let W=G.diffuseTransmissionColorTexture,H=Z.textures[Y[W.index].source];K.setDiffuseTransmissionColorTexture(H),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),W)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let Y=X.getExtension(K$);if(!Y)continue;let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[K$]={diffuseTransmissionFactor:Y.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:Y.getDiffuseTransmissionColorFactor()};if(Y.getDiffuseTransmissionTexture()){let G=Y.getDiffuseTransmissionTexture(),W=Y.getDiffuseTransmissionTextureInfo();K.diffuseTransmissionTexture=Z.createTextureInfoDef(G,W)}if(Y.getDiffuseTransmissionColorTexture()){let G=Y.getDiffuseTransmissionColorTexture(),W=Y.getDiffuseTransmissionColorTextureInfo();K.diffuseTransmissionColorTexture=Z.createTextureInfoDef(G,W)}}return this}}CE.EXTENSION_NAME=K$;class TE extends s1{init(){this.extensionName=GE,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)}}TE.EXTENSION_NAME=GE;var G$=GE;class EE extends I1{constructor(...Z){super(...Z);this.extensionName=G$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createDispersion(){return new TE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[G$]){let Q=this.createDispersion();Z.materials[$].setExtension(G$,Q);let K=Y.extensions[G$];if(K.dispersion!==void 0)Q.setDispersion(K.dispersion)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(G$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[G$]={dispersion:Y.getDispersion()}}}),this}}EE.EXTENSION_NAME=G$;class kE extends s1{init(){this.extensionName=WE,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)}}kE.EXTENSION_NAME=WE;var W$=WE;class IE extends I1{constructor(...Z){super(...Z);this.extensionName=W$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createEmissiveStrength(){return new kE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[W$]){let Q=this.createEmissiveStrength();Z.materials[$].setExtension(W$,Q);let K=Y.extensions[W$];if(K.emissiveStrength!==void 0)Q.setEmissiveStrength(K.emissiveStrength)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(W$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[W$]={emissiveStrength:Y.getEmissiveStrength()}}}),this}}IE.EXTENSION_NAME=W$;class _E extends s1{init(){this.extensionName=HE,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)}}_E.EXTENSION_NAME=HE;var H$=HE;class m2 extends I1{constructor(...Z){super(...Z);this.extensionName=H$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIOR(){return new _E(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[H$]){let Q=this.createIOR();Z.materials[$].setExtension(H$,Q);let K=Y.extensions[H$];if(K.ior!==void 0)Q.setIOR(K.ior)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(H$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[H$]={ior:Y.getIOR()}}}),this}}m2.EXTENSION_NAME=H$;var{R:rD1,G:tD1}=Y9;class SE extends s1{init(){this.extensionName=VE,this.propertyType="Iridescence",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new T1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new T1(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:rD1})}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:tD1})}}SE.EXTENSION_NAME=VE;var V$=VE;class vE extends I1{constructor(...Z){super(...Z);this.extensionName=V$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIridescence(){return new SE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[V$]){let K=this.createIridescence();Z.materials[Q].setExtension(V$,K);let G=$.extensions[V$];if(G.iridescenceFactor!==void 0)K.setIridescenceFactor(G.iridescenceFactor);if(G.iridescenceIor!==void 0)K.setIridescenceIOR(G.iridescenceIor);if(G.iridescenceThicknessMinimum!==void 0)K.setIridescenceThicknessMinimum(G.iridescenceThicknessMinimum);if(G.iridescenceThicknessMaximum!==void 0)K.setIridescenceThicknessMaximum(G.iridescenceThicknessMaximum);if(G.iridescenceTexture!==void 0){let W=G.iridescenceTexture,H=Z.textures[Y[W.index].source];K.setIridescenceTexture(H),Z.setTextureInfo(K.getIridescenceTextureInfo(),W)}if(G.iridescenceThicknessTexture!==void 0){let W=G.iridescenceThicknessTexture,H=Z.textures[Y[W.index].source];K.setIridescenceThicknessTexture(H),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(V$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[V$]={};if(Y.getIridescenceFactor()>0)K.iridescenceFactor=Y.getIridescenceFactor();if(Y.getIridescenceIOR()!==1.3)K.iridescenceIor=Y.getIridescenceIOR();if(Y.getIridescenceThicknessMinimum()!==100)K.iridescenceThicknessMinimum=Y.getIridescenceThicknessMinimum();if(Y.getIridescenceThicknessMaximum()!==400)K.iridescenceThicknessMaximum=Y.getIridescenceThicknessMaximum();if(Y.getIridescenceTexture()){let G=Y.getIridescenceTexture(),W=Y.getIridescenceTextureInfo();K.iridescenceTexture=Z.createTextureInfoDef(G,W)}if(Y.getIridescenceThicknessTexture()){let G=Y.getIridescenceThicknessTexture(),W=Y.getIridescenceThicknessTextureInfo();K.iridescenceThicknessTexture=Z.createTextureInfoDef(G,W)}}}),this}}vE.EXTENSION_NAME=V$;var{R:Cr,G:Tr,B:Er,A:kr}=Y9;class AE extends s1{init(){this.extensionName=zE,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new T1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new T1(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:Cr|Tr|Er|kr,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:Cr|Tr|Er|kr})}}AE.EXTENSION_NAME=zE;var z$=zE;class u2 extends I1{constructor(...Z){super(...Z);this.extensionName=z$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createPBRSpecularGlossiness(){return new AE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[z$]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(z$,K);let G=$.extensions[z$];if(G.diffuseFactor!==void 0)K.setDiffuseFactor(G.diffuseFactor);if(G.specularFactor!==void 0)K.setSpecularFactor(G.specularFactor);if(G.glossinessFactor!==void 0)K.setGlossinessFactor(G.glossinessFactor);if(G.diffuseTexture!==void 0){let W=G.diffuseTexture,H=Z.textures[Y[W.index].source];K.setDiffuseTexture(H),Z.setTextureInfo(K.getDiffuseTextureInfo(),W)}if(G.specularGlossinessTexture!==void 0){let W=G.specularGlossinessTexture,H=Z.textures[Y[W.index].source];K.setSpecularGlossinessTexture(H),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(z$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[z$]={diffuseFactor:Y.getDiffuseFactor(),specularFactor:Y.getSpecularFactor(),glossinessFactor:Y.getGlossinessFactor()};if(Y.getDiffuseTexture()){let G=Y.getDiffuseTexture(),W=Y.getDiffuseTextureInfo();K.diffuseTexture=Z.createTextureInfoDef(G,W)}if(Y.getSpecularGlossinessTexture()){let G=Y.getSpecularGlossinessTexture(),W=Y.getSpecularGlossinessTextureInfo();K.specularGlossinessTexture=Z.createTextureInfoDef(G,W)}}}),this}}u2.EXTENSION_NAME=z$;var{R:eD1,G:ZC1,B:JC1,A:XC1}=Y9;class xE extends s1{init(){this.extensionName=FE,this.propertyType="Sheen",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new T1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new T1(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:eD1|ZC1|JC1,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:XC1})}}xE.EXTENSION_NAME=FE;var F$=FE;class hE extends I1{constructor(...Z){super(...Z);this.extensionName=F$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSheen(){return new xE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[F$]){let K=this.createSheen();Z.materials[Q].setExtension(F$,K);let G=$.extensions[F$];if(G.sheenColorFactor!==void 0)K.setSheenColorFactor(G.sheenColorFactor);if(G.sheenRoughnessFactor!==void 0)K.setSheenRoughnessFactor(G.sheenRoughnessFactor);if(G.sheenColorTexture!==void 0){let W=G.sheenColorTexture,H=Z.textures[Y[W.index].source];K.setSheenColorTexture(H),Z.setTextureInfo(K.getSheenColorTextureInfo(),W)}if(G.sheenRoughnessTexture!==void 0){let W=G.sheenRoughnessTexture,H=Z.textures[Y[W.index].source];K.setSheenRoughnessTexture(H),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(F$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[F$]={sheenColorFactor:Y.getSheenColorFactor(),sheenRoughnessFactor:Y.getSheenRoughnessFactor()};if(Y.getSheenColorTexture()){let G=Y.getSheenColorTexture(),W=Y.getSheenColorTextureInfo();K.sheenColorTexture=Z.createTextureInfoDef(G,W)}if(Y.getSheenRoughnessTexture()){let G=Y.getSheenRoughnessTexture(),W=Y.getSheenRoughnessTextureInfo();K.sheenRoughnessTexture=Z.createTextureInfoDef(G,W)}}}),this}}hE.EXTENSION_NAME=F$;var{R:YC1,G:$C1,B:QC1,A:KC1}=Y9;class fE extends s1{init(){this.extensionName=qE,this.propertyType="Specular",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new T1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new T1(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:KC1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:YC1|$C1|QC1,isColor:!0})}}fE.EXTENSION_NAME=qE;var q$=qE;class d2 extends I1{constructor(...Z){super(...Z);this.extensionName=q$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSpecular(){return new fE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[q$]){let K=this.createSpecular();Z.materials[Q].setExtension(q$,K);let G=$.extensions[q$];if(G.specularFactor!==void 0)K.setSpecularFactor(G.specularFactor);if(G.specularColorFactor!==void 0)K.setSpecularColorFactor(G.specularColorFactor);if(G.specularTexture!==void 0){let W=G.specularTexture,H=Z.textures[Y[W.index].source];K.setSpecularTexture(H),Z.setTextureInfo(K.getSpecularTextureInfo(),W)}if(G.specularColorTexture!==void 0){let W=G.specularColorTexture,H=Z.textures[Y[W.index].source];K.setSpecularColorTexture(H),Z.setTextureInfo(K.getSpecularColorTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(q$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[q$]={};if(Y.getSpecularFactor()!==1)K.specularFactor=Y.getSpecularFactor();if(!z8.eq(Y.getSpecularColorFactor(),[1,1,1]))K.specularColorFactor=Y.getSpecularColorFactor();if(Y.getSpecularTexture()){let G=Y.getSpecularTexture(),W=Y.getSpecularTextureInfo();K.specularTexture=Z.createTextureInfoDef(G,W)}if(Y.getSpecularColorTexture()){let G=Y.getSpecularColorTexture(),W=Y.getSpecularColorTextureInfo();K.specularColorTexture=Z.createTextureInfoDef(G,W)}}}),this}}d2.EXTENSION_NAME=q$;var{R:GC1}=Y9;class yE extends s1{init(){this.extensionName=UE,this.propertyType="Transmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new T1(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:GC1})}}yE.EXTENSION_NAME=UE;var U$=UE;class bE extends I1{constructor(...Z){super(...Z);this.extensionName=U$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createTransmission(){return new yE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[U$]){let K=this.createTransmission();Z.materials[Q].setExtension(U$,K);let G=$.extensions[U$];if(G.transmissionFactor!==void 0)K.setTransmissionFactor(G.transmissionFactor);if(G.transmissionTexture!==void 0){let W=G.transmissionTexture,H=Z.textures[Y[W.index].source];K.setTransmissionTexture(H),Z.setTextureInfo(K.getTransmissionTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(U$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[U$]={transmissionFactor:Y.getTransmissionFactor()};if(Y.getTransmissionTexture()){let G=Y.getTransmissionTexture(),W=Y.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(G,W)}}}),this}}bE.EXTENSION_NAME=U$;class gE extends s1{init(){this.extensionName=LE,this.propertyType="Unlit",this.parentTypes=[s.MATERIAL]}}gE.EXTENSION_NAME=LE;var GG=LE;class c2 extends I1{constructor(...Z){super(...Z);this.extensionName=GG,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createUnlit(){return new gE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((X,Y)=>{if(X.extensions&&X.extensions[GG])Z.materials[Y].setExtension(GG,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(GG)){let Y=Z.materialIndexMap.get(X),$=J.json.materials[Y];$.extensions=$.extensions||{},$.extensions[GG]={}}}),this}}c2.EXTENSION_NAME=GG;class mE extends s1{init(){this.extensionName=w$,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new E0})}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")}}mE.EXTENSION_NAME=w$;class uE extends s1{init(){this.extensionName=w$,this.propertyType="MappingList",this.parentTypes=[s.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new E0})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}uE.EXTENSION_NAME=w$;class f2 extends s1{init(){this.extensionName=w$,this.propertyType="Variant",this.parentTypes=["MappingList"]}}f2.EXTENSION_NAME=w$;var v7=w$;class dE extends I1{constructor(...Z){super(...Z);this.extensionName=v7}createMappingList(){return new uE(this.document.getGraph())}createVariant(Z=""){return new f2(this.document.getGraph(),Z)}createMapping(){return new mE(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof f2)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[v7])return this;let $=(J.json.extensions[v7].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,G)=>{let W=Z.meshes[G];(K.primitives||[]).forEach((V,F)=>{if(!V.extensions||!V.extensions[v7])return;let z=this.createMappingList(),q=V.extensions[v7];for(let U of q.mappings){let B=this.createMapping();if(U.material!==void 0)B.setMaterial(Z.materials[U.material]);for(let L of U.variants||[])B.addVariant($[L]);z.addMapping(B)}W.listPrimitives()[F].setExtension(v7,z)})}),this}write(Z){let J=Z.jsonDoc,X=this.listVariants();if(!X.length)return this;let Y=[],$=new Map;for(let Q of X)$.set(Q,Y.length),Y.push(Z.createPropertyDef(Q));for(let Q of this.document.getRoot().listMeshes()){let K=Z.meshIndexMap.get(Q);Q.listPrimitives().forEach((G,W)=>{let H=G.getExtension(v7);if(!H)return;let V=Z.jsonDoc.json.meshes[K].primitives[W],F=H.listMappings().map((z)=>{let q=Z.createPropertyDef(z),U=z.getMaterial();if(U)q.material=Z.materialIndexMap.get(U);return q.variants=z.listVariants().map((B)=>$.get(B)),q});V.extensions=V.extensions||{},V.extensions[v7]={mappings:F}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[v7]={variants:Y},this}}dE.EXTENSION_NAME=v7;var{G:WC1}=Y9;class cE extends s1{init(){this.extensionName=BE,this.propertyType="Volume",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new T1(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:WC1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}cE.EXTENSION_NAME=BE;var L$=BE;class lE extends I1{constructor(...Z){super(...Z);this.extensionName=L$,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createVolume(){return new cE(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[L$]){let K=this.createVolume();Z.materials[Q].setExtension(L$,K);let G=$.extensions[L$];if(G.thicknessFactor!==void 0)K.setThicknessFactor(G.thicknessFactor);if(G.attenuationDistance!==void 0)K.setAttenuationDistance(G.attenuationDistance);if(G.attenuationColor!==void 0)K.setAttenuationColor(G.attenuationColor);if(G.thicknessTexture!==void 0){let W=G.thicknessTexture,H=Z.textures[Y[W.index].source];K.setThicknessTexture(H),Z.setTextureInfo(K.getThicknessTextureInfo(),W)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(L$);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[L$]={};if(Y.getThicknessFactor()>0)K.thicknessFactor=Y.getThicknessFactor();if(Number.isFinite(Y.getAttenuationDistance()))K.attenuationDistance=Y.getAttenuationDistance();if(!z8.eq(Y.getAttenuationColor(),[1,1,1]))K.attenuationColor=Y.getAttenuationColor();if(Y.getThicknessTexture()){let G=Y.getThicknessTexture(),W=Y.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(G,W)}}}),this}}lE.EXTENSION_NAME=L$;var fr=PD1;class HV extends I1{constructor(...Z){super(...Z);this.extensionName=fr}read(Z){return this}write(Z){return this}}HV.EXTENSION_NAME=fr;var $V=DD1;class yr{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=A2(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=A2(Z).dataFormatDescriptor[0];if(X.colorModel===Ur)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===Lr)return(X.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=A2(Z),X=this.getChannels(Z)>3,Y=0;for(let $=0;$<J.levels.length;$++){let Q=J.levels[$];if(Q.uncompressedByteLength)Y+=Q.uncompressedByteLength;else{let K=Math.max(1,Math.floor(J.pixelWidth/Math.pow(2,$))),G=Math.max(1,Math.floor(J.pixelHeight/Math.pow(2,$))),W=X?16:8;Y+=K/4*(G/4)*W}}return Y}}class pE extends I1{constructor(...Z){super(...Z);this.extensionName=$V,this.prereadTypes=[s.TEXTURE]}static register(){h4.registerFormat("image/ktx2",new yr)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[$V]){let X=J.extensions[$V];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 Y=Z.imageIndexMap.get(X);J.json.textures.forEach(($)=>{if($.source===Y)$.extensions=$.extensions||{},$.extensions[$V]={source:$.source},delete $.source})}}),this}}pE.EXTENSION_NAME=$V;class iE extends s1{init(){this.extensionName=wE,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)}}iE.EXTENSION_NAME=wE;var B$=wE;class nE extends I1{constructor(...Z){super(...Z);this.extensionName=B$}createTransform(){return new iE(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[B$])continue;let Y=this.createTransform(),$=X.extensions[B$];if($.offset!==void 0)Y.setOffset($.offset);if($.rotation!==void 0)Y.setRotation($.rotation);if($.scale!==void 0)Y.setScale($.scale);if($.texCoord!==void 0)Y.setTexCoord($.texCoord);J.setExtension(B$,Y)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,Y]of J){let $=X.getExtension(B$);if(!$)continue;Y.extensions=Y.extensions||{};let Q={},K=z8.eq;if(!K($.getOffset(),[0,0]))Q.offset=$.getOffset();if($.getRotation()!==0)Q.rotation=$.getRotation();if(!K($.getScale(),[1,1]))Q.scale=$.getScale();if($.getTexCoord()!=null)Q.texCoord=$.getTexCoord();Y.extensions[B$]=Q}return this}}nE.EXTENSION_NAME=B$;var HC1=[s.ROOT,s.SCENE,s.NODE,s.MESH,s.MATERIAL,s.TEXTURE,s.ANIMATION];class aE extends s1{init(){this.extensionName=x2,this.propertyType="Packet",this.parentTypes=HC1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",AZ({},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=AZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=tT(this.get("context")),J=tT(this.get("properties"));return AZ({"@context":Z},J)}fromJSONLD(Z){Z=tT(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(`${x2}: Missing context for term, "${Z}".`)}}aE.EXTENSION_NAME=x2;function tT(Z){return JSON.parse(JSON.stringify(Z))}var vZ=x2;class sE extends I1{constructor(...Z){super(...Z);this.extensionName=vZ}createPacket(){return new aE(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[vZ];if(!X||!X.packets)return this;let Y=Z.jsonDoc.json,$=this.document.getRoot(),Q=X.packets.map((W)=>this.createPacket().fromJSONLD(W)),K=[[Y.asset],Y.scenes,Y.nodes,Y.meshes,Y.materials,Y.images,Y.animations],G=[[$],$.listScenes(),$.listNodes(),$.listMeshes(),$.listMaterials(),$.listTextures(),$.listAnimations()];for(let W=0;W<K.length;W++){let H=K[W]||[];for(let V=0;V<H.length;V++){let F=H[V];if(F.extensions&&F.extensions[vZ]){let z=F.extensions[vZ];G[W][V].setExtension(vZ,Q[z.packet])}}}return this}write(Z){let{json:J}=Z.jsonDoc,X=[];for(let Y of this.properties){X.push(Y.toJSONLD());for(let $ of Y.listParents()){let Q;switch($.propertyType){case s.ROOT:Q=J.asset;break;case s.SCENE:Q=J.scenes[Z.sceneIndexMap.get($)];break;case s.NODE:Q=J.nodes[Z.nodeIndexMap.get($)];break;case s.MESH:Q=J.meshes[Z.meshIndexMap.get($)];break;case s.MATERIAL:Q=J.materials[Z.materialIndexMap.get($)];break;case s.TEXTURE:Q=J.images[Z.imageIndexMap.get($)];break;case s.ANIMATION:Q=J.animations[Z.animationIndexMap.get($)];break;default:Q=null,this.document.getLogger().warn(`[${vZ}]: Unsupported parent property, "${$.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[vZ]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[vZ]={packets:X};return this}}sE.EXTENSION_NAME=vZ;var VC1=[WV,OE,RE,PE,CE,EE,IE,m2,vE,u2,d2,hE,bE,c2,dE,lE,HV,pE,nE,sE],vS6=[y2,GV,b2,g2,...VC1];var zC1=r(zT(),1);function FG(){return FG=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},FG.apply(null,arguments)}var{POINTS:br,LINES:l2,LINE_STRIP:FC1,LINE_LOOP:qC1,TRIANGLES:p2,TRIANGLE_STRIP:UC1,TRIANGLE_FAN:LC1}=C8.Mode;function $X(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function A7(Z,J){let X=FG({},Z);for(let Y in J)if(J[Y]!==void 0)X[Y]=J[Y];return X}function $t(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case C8.Mode.POINTS:return J?J.getCount():X.getCount();case C8.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case C8.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case C8.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case C8.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case C8.Mode.TRIANGLE_STRIP:case C8.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw new Error("Unexpected mode: "+Z.getMode())}}var BC1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function eE(Z){return BC1.format(Z)}function wC1(Z,J,X=2){let Y=Z>J?"–":"+",$="%";return Y+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function o2(Z,J){return`${eE(Z)} → ${eE(J)} (${wC1(Z,J)})`}function Kk(Z){let J=[];for(let X of Z.listAttributes())J.push(X);for(let X of Z.listTargets())for(let Y of X.listAttributes())J.push(Y);return Array.from(new Set(J))}function jC1(Z,J,X){Z.swap(J,X);for(let Y of Z.listTargets())Y.swap(J,X)}function OC1(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 xZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function MC1(Z,J=Z){let X=Gk(Z,J);for(let Y=0;Y<X.length;Y++)X[Y]=Y;return X}function Gk(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function RC1(Z){return Z.listParents().some((J)=>J.propertyType!==a.ROOT)}function Qt(Z){for(let J in Z)return!1;return!0}function Kt(Z){let J=_6.fromGraph(Z.getGraph()),X=Z.getMaterial(),Y=J.getRoot().listMaterials().indexOf(X),$=PC1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((W)=>{let H=Z.getAttribute(W),V=H.getElementSize(),F=H.getComponentType();return`${W}:${V}:${F}`}).join("+"),G=Z.listTargets().map((W)=>{return W.listSemantics().sort().map((H)=>{let V=Z.getAttribute(H),F=V.getElementSize(),z=V.getComponentType();return`${H}:${F}:${z}`}).join("+")}).join("~");return`${Y}|${$}|${Q}|${K}|${G}`}function NC1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var PC1={[br]:br,[l2]:l2,[FC1]:l2,[qC1]:l2,[p2]:p2,[UC1]:p2,[LC1]:p2},VG="center",gr={pivot:"center"};function Gt(Z=gr){let J=A7(gr,Z);return $X(VG,(X)=>{let Y=X.getLogger(),$=X.getRoot(),Q=$.listAnimations().length>0||$.listSkins().length>0;X.getRoot().listScenes().forEach((K,G)=>{Y.debug(`${VG}: Scene ${G+1} / ${$.listScenes().length}.`);let W;if(typeof J.pivot==="string"){let V=$T(K);if(W=[(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")W[1]=V.max[1];if(J.pivot==="below")W[1]=V.min[1]}else W=J.pivot;Y.debug(`${VG}: Pivot "${W.join(", ")}".`);let H=[-1*W[0],-1*W[1],-1*W[2]];if(Q){Y.debug(`${VG}: Model contains animation or skin. Adding a wrapper node.`);let V=X.createNode("Pivot").setTranslation(H);K.listChildren().forEach((F)=>V.addChild(F)),K.addChild(V)}else Y.debug(`${VG}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((V)=>{let F=V.getTranslation();V.setTranslation([F[0]+H[0],F[1]+H[1],F[2]+H[2]])})}),Y.debug(`${VG}: Complete.`)})}function DC1(Z){let J=new Set,X=Z,Y;while(Y=X.getParentNode()){if(J.has(Y))throw new Error("Circular dependency in scene graph.");J.add(Y),X=Y}return X.listParents().filter(($)=>$ instanceof sK)}function CC1(Z){let J=DC1(Z),X=Z.getParentNode();if(!X)return Z;Z.setMatrix(Z.getWorldMatrix()),X.removeChild(Z);for(let Y of J)Y.addChild(Z);return Z}var qG=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 TC1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],G=J[5],W=J[6],H=J[7],V=J[8],F=J[9],z=J[10],q=J[11],U=J[12],B=J[13],L=J[14],w=J[15],O=X*G-Y*K,M=X*W-$*K,R=X*H-Q*K,D=Y*W-$*G,N=Y*H-Q*G,C=$*H-Q*W,T=V*B-F*U,E=V*L-z*U,A=V*w-q*U,S=F*L-z*B,x=F*w-q*B,I=z*w-q*L,_=O*I-M*x+R*S+D*A-N*E+C*T;if(!_)return null;return _=1/_,Z[0]=(G*I-W*x+H*S)*_,Z[1]=($*x-Y*I-Q*S)*_,Z[2]=(B*C-L*N+w*D)*_,Z[3]=(z*N-F*C-q*D)*_,Z[4]=(W*A-K*I-H*E)*_,Z[5]=(X*I-$*A+Q*E)*_,Z[6]=(L*R-U*C-w*M)*_,Z[7]=(V*C-z*R+q*M)*_,Z[8]=(K*x-G*A+H*T)*_,Z[9]=(Y*A-X*x-Q*T)*_,Z[10]=(U*N-B*R+w*O)*_,Z[11]=(F*R-V*N-q*O)*_,Z[12]=(G*E-K*S-W*T)*_,Z[13]=(X*S-Y*E+$*T)*_,Z[14]=(B*M-U*D-L*O)*_,Z[15]=(V*D-F*M+z*O)*_,Z}function EC1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],G=Z[6],W=Z[7],H=Z[8],V=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,O=J*G-Y*Q,M=J*W-$*Q,R=X*G-Y*K,D=X*W-$*K,N=Y*W-$*G,C=H*U-V*q,T=H*B-F*q,E=H*L-z*q,A=V*B-F*U,S=V*L-z*U,x=F*L-z*B;return w*x-O*S+M*A+R*E-D*T+N*C}function Wt(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],G=J[4],W=J[5],H=J[6],V=J[7],F=J[8],z=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],O=J[15],M=X[0],R=X[1],D=X[2],N=X[3];return Z[0]=M*Y+R*G+D*F+N*B,Z[1]=M*$+R*W+D*z+N*L,Z[2]=M*Q+R*H+D*q+N*w,Z[3]=M*K+R*V+D*U+N*O,M=X[4],R=X[5],D=X[6],N=X[7],Z[4]=M*Y+R*G+D*F+N*B,Z[5]=M*$+R*W+D*z+N*L,Z[6]=M*Q+R*H+D*q+N*w,Z[7]=M*K+R*V+D*U+N*O,M=X[8],R=X[9],D=X[10],N=X[11],Z[8]=M*Y+R*G+D*F+N*B,Z[9]=M*$+R*W+D*z+N*L,Z[10]=M*Q+R*H+D*q+N*w,Z[11]=M*K+R*V+D*U+N*O,M=X[12],R=X[13],D=X[14],N=X[15],Z[12]=M*Y+R*G+D*F+N*B,Z[13]=M*$+R*W+D*z+N*L,Z[14]=M*Q+R*H+D*q+N*w,Z[15]=M*K+R*V+D*U+N*O,Z}function kC1(){var Z=new qG(9);if(qG!=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 IC1(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 _C1(Z,J){if(Z===J){var X=J[1],Y=J[2],$=J[5];Z[1]=J[3],Z[2]=J[6],Z[3]=X,Z[5]=J[7],Z[6]=Y,Z[7]=$}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 SC1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],G=J[5],W=J[6],H=J[7],V=J[8],F=V*K-G*H,z=-V*Q+G*W,q=H*Q-K*W,U=X*F+Y*z+$*q;if(!U)return null;return U=1/U,Z[0]=F*U,Z[1]=(-V*Y+$*H)*U,Z[2]=(G*Y-$*K)*U,Z[3]=z*U,Z[4]=(V*X-$*W)*U,Z[5]=(-G*X+$*Q)*U,Z[6]=q*U,Z[7]=(-H*X+Y*W)*U,Z[8]=(K*X-Y*Q)*U,Z}function r2(){var Z=new qG(3);if(qG!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function vC1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function Ht(Z,J){var X=J[0],Y=J[1],$=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 AC1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}function xC1(Z,J,X){var Y=J[0],$=J[1],Q=J[2];return Z[0]=Y*X[0]+$*X[3]+Q*X[6],Z[1]=Y*X[1]+$*X[4]+Q*X[7],Z[2]=Y*X[2]+$*X[5]+Q*X[8],Z}var hC1=vC1;(function(){var Z=r2();return function(J,X,Y,$,Q,K){var G,W;if(!X)X=3;if(!Y)Y=0;if($)W=Math.min($*X+Y,J.length);else W=J.length;for(G=Y;G<W;G+=X)Z[0]=J[G],Z[1]=J[G+1],Z[2]=J[G+2],Q(Z,Z,K),J[G]=Z[0],J[G+1]=Z[1],J[G+2]=Z[2];return J}})();var XX="dedup",oE={keepUniqueNames:!1,propertyTypes:[a.ACCESSOR,a.MESH,a.TEXTURE,a.MATERIAL,a.SKIN]};function Vt(Z=oE){let J=A7(oE,Z),X=new Set(J.propertyTypes);for(let Y of J.propertyTypes)if(!oE.propertyTypes.includes(Y))throw new Error(`${XX}: Unsupported deduplication on type "${Y}".`);return $X(XX,(Y)=>{let $=Y.getLogger();if(X.has(a.ACCESSOR))fC1(Y);if(X.has(a.TEXTURE))bC1(Y,J);if(X.has(a.MATERIAL))gC1(Y,J);if(X.has(a.MESH))yC1(Y,J);if(X.has(a.SKIN))mC1(Y,J);$.debug(`${XX}: Complete.`)})}function fC1(Z){let J=Z.getLogger(),X=new Map,Y=new Map,$=new Map,Q=new Map,K=Z.getRoot().listMeshes();K.forEach((F)=>{F.listPrimitives().forEach((z)=>{z.listAttributes().forEach((q)=>G(q,Y)),G(z.getIndices(),X)})});for(let F of Z.getRoot().listAnimations())for(let z of F.listSamplers())G(z.getInput(),$),G(z.getOutput(),Q);function G(F,z){if(!F)return;let q=[F.getCount(),F.getType(),F.getComponentType(),F.getNormalized(),F.getSparse()].join(":"),U=z.get(q);if(!U)z.set(q,U=new Set);U.add(F)}function W(F,z){for(let q=0;q<F.length;q++){let U=F[q],B=o0.toView(U.getArray());if(z.has(U))continue;for(let L=q+1;L<F.length;L++){let w=F[L];if(z.has(w))continue;if(o0.equals(B,o0.toView(w.getArray())))z.set(w,U)}}}let H=0,V=new Map;for(let F of[Y,X,$,Q])for(let z of F.values())H+=z.size,W(Array.from(z),V);J.debug(`${XX}: Merged ${V.size} of ${H} accessors.`),K.forEach((F)=>{F.listPrimitives().forEach((z)=>{z.listAttributes().forEach((U)=>{if(V.has(U))z.swap(U,V.get(U))});let q=z.getIndices();if(q&&V.has(q))z.swap(q,V.get(q))})});for(let F of Z.getRoot().listAnimations())for(let z of F.listSamplers()){let q=z.getInput(),U=z.getOutput();if(q&&V.has(q))z.swap(q,V.get(q));if(U&&V.has(U))z.swap(U,V.get(U))}Array.from(V.keys()).forEach((F)=>F.dispose())}function yC1(Z,J){let X=Z.getLogger(),Y=Z.getRoot(),$=new Map;Y.listAccessors().forEach((G,W)=>$.set(G,W)),Y.listMaterials().forEach((G,W)=>$.set(G,W));let Q=Y.listMeshes().length,K=new Map;for(let G of Y.listMeshes()){let W=[];for(let V of G.listPrimitives())W.push(zt(V,$));let H="";if(J.keepUniqueNames)H+=G.getName()+";";if(H+=W.join(";"),K.has(H)){let V=K.get(H);G.listParents().forEach((F)=>{if(F.propertyType!==a.ROOT)F.swap(G,V)}),G.dispose()}else K.set(H,G)}X.debug(`${XX}: Merged ${Q-K.size} of ${Q} meshes.`)}function bC1(Z,J){let X=Z.getLogger(),Y=Z.getRoot(),$=Y.listTextures(),Q=new Map;for(let K=0;K<$.length;K++){let G=$[K],W=G.getImage();if(Q.has(G))continue;for(let H=K+1;H<$.length;H++){let V=$[H],F=V.getImage();if(Q.has(V))continue;if(G.getMimeType()!==V.getMimeType())continue;if(J.keepUniqueNames&&G.getName()!==V.getName())continue;let z=G.getSize(),q=V.getSize();if(!z||!q)continue;if(z[0]!==q[0])continue;if(z[1]!==q[1])continue;if(!W||!F)continue;if(o0.equals(W,F))Q.set(V,G)}}X.debug(`${XX}: Merged ${Q.size} of ${Y.listTextures().length} textures.`),Array.from(Q.entries()).forEach(([K,G])=>{K.listParents().forEach((W)=>{if(!(W instanceof tY))W.swap(K,G)}),K.dispose()})}function gC1(Z,J){let X=Z.getLogger(),$=Z.getRoot().listMaterials(),Q=new Map,K=new Map,G=new Set;if(!J.keepUniqueNames)G.add("name");for(let W=0;W<$.length;W++){let H=$[W];if(Q.has(H))continue;if(mr(H,K))continue;for(let V=W+1;V<$.length;V++){let F=$[V];if(Q.has(F))continue;if(mr(F,K))continue;if(H.equals(F,G))Q.set(F,H)}}X.debug(`${XX}: Merged ${Q.size} of ${$.length} materials.`),Array.from(Q.entries()).forEach(([W,H])=>{W.listParents().forEach((V)=>{if(!(V instanceof tY))V.swap(W,H)}),W.dispose()})}function mC1(Z,J){let X=Z.getLogger(),$=Z.getRoot().listSkins(),Q=new Map,K=new Set(["joints"]);if(!J.keepUniqueNames)K.add("name");for(let G=0;G<$.length;G++){let W=$[G];if(Q.has(W))continue;for(let H=G+1;H<$.length;H++){let V=$[H];if(Q.has(V))continue;if(W.equals(V,K)&&OC1(W.listJoints(),V.listJoints()))Q.set(V,W)}}X.debug(`${XX}: Merged ${Q.size} of ${$.length} skins.`),Array.from(Q.entries()).forEach(([G,W])=>{G.listParents().forEach((H)=>{if(!(H instanceof tY))H.swap(G,W)}),G.dispose()})}function zt(Z,J){let X=[];for(let Y of Z.listSemantics()){let $=Z.getAttribute(Y);X.push(Y+":"+J.get($))}if(Z instanceof C8){let Y=Z.getIndices();if(Y)X.push("indices:"+J.get(Y));let $=Z.getMaterial();if($)X.push("material:"+J.get($));X.push("mode:"+Z.getMode());for(let Q of Z.listTargets())X.push("target:"+zt(Q,J))}return X.join(",")}function mr(Z,J){if(J.has(Z))return J.get(Z);let X=Z.getGraph(),Y=new Set,$=X.listParentEdges(Z);while($.length>0){let Q=$.pop();if(Q.getAttributes().modifyChild===!0)return J.set(Z,!0),!0;let K=Q.getChild();if(Y.has(K))continue;for(let G of X.listChildEdges(K))$.push(G)}return J.set(Z,!1),!1}function Ft(){var Z=new qG(4);if(qG!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function uC1(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 dC1(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 cC1(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 lC1(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 pC1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return Math.hypot(J,X,Y,$)}var qt=dC1,iC1=cC1,Ut=pC1;(function(){var Z=Ft();return function(J,X,Y,$,Q,K){var G,W;if(!X)X=4;if(!Y)Y=0;if($)W=Math.min($*X+Y,J.length);else W=J.length;for(G=Y;G<W;G+=X)Z[0]=J[G],Z[1]=J[G+1],Z[2]=J[G+2],Z[3]=J[G+3],Q(Z,Z,K),J[G]=Z[0],J[G+1]=Z[1],J[G+2]=Z[2],J[G+3]=Z[3];return J}})();var nC1=/color|emissive|diffuse/i;function aC1(Z){return Z.getGraph().listParentEdges(Z).some(($)=>{return $.getAttributes().isColor||nC1.test($.getName())})?"srgb":null}function sC1(Z){let J=Z.getGraph(),X=new Set,Y=new Set;function $(Q){let K=new Set;for(let G of J.listChildEdges(Q))if(G.getChild()instanceof rY)K.add(G.getName()+"Info");for(let G of J.listChildEdges(Q)){let W=G.getChild();if(X.has(W))continue;if(X.add(W),W instanceof E5&&K.has(G.getName()))Y.add(W);else if(W instanceof aK)$(W)}}return $(Z),Array.from(Y)}function oC1(Z){let X=_6.fromGraph(Z.getGraph()).getRoot(),Y=Z.getGraph().listParentEdges(Z).filter(($)=>$.getParent()!==X).map(($)=>$.getName());return Array.from(new Set(Y))}var zG="prune",Zk=0.011764705882352941,ur={propertyTypes:[a.NODE,a.SKIN,a.MESH,a.CAMERA,a.PRIMITIVE,a.PRIMITIVE_TARGET,a.ANIMATION,a.MATERIAL,a.TEXTURE,a.ACCESSOR,a.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function t2(Z=ur){let J=A7(ur,Z),X=new Set(J.propertyTypes),Y=J.keepExtras;return $X(zG,async($)=>{let Q=$.getLogger(),K=$.getRoot(),G=$.getGraph(),W=new Lt,H=(V)=>W.dispose(V.target);if(G.addEventListener("node:dispose",H),X.has(a.MESH))for(let V of K.listMeshes()){if(V.listPrimitives().length>0)continue;V.dispose()}if(X.has(a.NODE)){if(!J.keepLeaves)for(let V of K.listScenes())Bt(G,V,Y);for(let V of K.listNodes())m9(V,Y)}if(X.has(a.SKIN))for(let V of K.listSkins())m9(V,Y);if(X.has(a.MESH))for(let V of K.listMeshes())m9(V,Y);if(X.has(a.CAMERA))for(let V of K.listCameras())m9(V,Y);if(X.has(a.PRIMITIVE))dr(G,a.PRIMITIVE,Y);if(X.has(a.PRIMITIVE_TARGET))dr(G,a.PRIMITIVE_TARGET,Y);if(!J.keepAttributes&&X.has(a.ACCESSOR)){let V=new Map;for(let F of K.listMeshes())for(let z of F.listPrimitives()){let q=z.getMaterial();if(!q)continue;let U=wt($,z,q),B=tC1(z,U);cr(z,B),z.listTargets().forEach((L)=>cr(L,B)),V.has(q)?V.get(q).add(z):V.set(q,new Set([z]))}for(let[F,z]of V)eC1(F,Array.from(z))}if(!J.keepIndices&&X.has(a.ACCESSOR))for(let V of K.listMeshes())for(let F of V.listPrimitives())rC1(F);if(X.has(a.ANIMATION))for(let V of K.listAnimations()){for(let F of V.listChannels())if(!F.getTargetNode())F.dispose();if(!V.listChannels().length){let F=V.listSamplers();m9(V,Y),F.forEach((z)=>m9(z,Y))}else V.listSamplers().forEach((F)=>m9(F,Y))}if(X.has(a.MATERIAL))K.listMaterials().forEach((V)=>m9(V,Y));if(X.has(a.TEXTURE)){if(K.listTextures().forEach((V)=>m9(V,Y)),!J.keepSolidTextures)await ZT1($)}if(X.has(a.ACCESSOR))K.listAccessors().forEach((V)=>m9(V,Y));if(X.has(a.BUFFER))K.listBuffers().forEach((V)=>m9(V,Y));if(G.removeEventListener("node:dispose",H),!W.empty()){let V=W.entries().map(([F,z])=>`${F} (${z})`).join(", ");Q.info(`${zG}: Removed types... ${V}`)}else Q.debug(`${zG}: No unused properties found.`);Q.debug(`${zG}: Complete.`)})}class Lt{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 m9(Z,J){let X=Z.listParents().filter(($)=>!($ instanceof tY||$ instanceof sY)),Y=J&&!Qt(Z.getExtras());if(!X.length&&!Y)Z.dispose()}function dr(Z,J,X){for(let Y of Z.listEdges()){let $=Y.getParent();if($.propertyType===J)m9($,X)}}function Bt(Z,J,X){if(J.listChildren().forEach((K)=>Bt(Z,K,X)),J instanceof sK)return;let Y=Z.listParentEdges(J).some((K)=>{let G=K.getParent().propertyType;return G!==a.ROOT&&G!==a.SCENE&&G!==a.NODE}),$=Z.listChildren(J).length===0,Q=X&&!Qt(J.getExtras());if($&&!Y&&!Q)J.dispose()}function cr(Z,J){for(let X of J)Z.setAttribute(X,null)}function rC1(Z){let J=Z.getIndices(),X=J&&J.getArray(),Y=Z.listAttributes()[0];if(!X||!Y)return;if(J.getCount()!==Y.getCount())return;for(let $=0,Q=X.length;$<Q;$++)if($!==X[$])return;Z.setIndices(null)}function tC1(Z,J){let X=[];for(let Y of Z.listSemantics())if(Y==="NORMAL"&&!J.has(Y))X.push(Y);else if(Y==="TANGENT"&&!J.has(Y))X.push(Y);else if(Y.startsWith("TEXCOORD_")&&!J.has(Y))X.push(Y);else if(Y.startsWith("COLOR_")&&Y!=="COLOR_0")X.push(Y);return X}function wt(Z,J,X,Y=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let H of Q)if(H.getChild()instanceof rY)K.add(H.getName());for(let H of Q){let V=H.getName(),F=H.getChild();if(F instanceof E5){if(K.has(V.replace(/Info$/,"")))Y.add(`TEXCOORD_${F.getTexCoord()}`)}if(F instanceof rY&&V.match(/normalTexture/i))Y.add("TANGENT");if(F instanceof aK)wt(Z,J,F,Y)}let G=X instanceof D7&&!X.getExtension("KHR_materials_unlit"),W=J.getMode()===C8.Mode.POINTS;if(G&&!W)Y.add("NORMAL");return Y}function eC1(Z,J){let X=sC1(Z),Y=new Set(X.map((W)=>W.getTexCoord())),$=Array.from(Y).sort(),Q=new Map($.map((W,H)=>[W,H])),K=new Map($.map((W,H)=>[`TEXCOORD_${W}`,`TEXCOORD_${H}`]));for(let W of X){let H=W.getTexCoord();W.setTexCoord(Q.get(H))}for(let W of J){let H=W.listSemantics().filter((V)=>V.startsWith("TEXCOORD_")).sort();G(W,H),W.listTargets().forEach((V)=>G(V,H))}function G(W,H){for(let V of H){let F=W.getAttribute(V);if(!F)continue;let z=K.get(V);if(z===V)continue;W.setAttribute(z,F),W.setAttribute(V,null)}}}async function ZT1(Z){let J=Z.getRoot(),X=Z.getGraph(),Y=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var G;let W=await XT1(K);if(!W)return;if(aC1(K)==="srgb")QT.convertSRGBToLinear(W,W);let H=K.getName()||K.getURI(),V=(G=K.getSize())==null?void 0:G.join("x"),F=oC1(K);for(let z of X.listParentEdges(K)){let q=z.getParent();if(q!==J&&JT1(q,W,z.getName(),Y))z.dispose()}if(K.listParents().length===1)K.dispose(),Y.debug(`${zG}: Removed solid-color texture "${H}" (${V}px ${F.join(", ")})`)});await Promise.all(Q)}function JT1(Z,J,X,Y){if(Z instanceof D7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(iC1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(hC1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=Zk;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return Ut(qt(Ft(),J,[0.5,0.5,1,1]))<=Zk}return Y.warn(`${zG}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function XT1(Z){let J=await YT1(Z);if(!J)return null;let X=[1/0,1/0,1/0,1/0],Y=[-1/0,-1/0,-1/0,-1/0],$=[0,0,0,0],[Q,K]=J.shape;for(let G=0;G<Q;G++){for(let W=0;W<K;W++)for(let H=0;H<4;H++)X[H]=Math.min(X[H],J.get(G,W,H)),Y[H]=Math.max(Y[H],J.get(G,W,H));if(Ut(qt($,Y,X))/255>Zk)return null}return lC1($,uC1($,Y,X),0.00196078431372549)}async function YT1(Z){try{return await Xr(Z.getImage(),Z.getMimeType())}catch(J){return null}}var JX=4294967295;class jt{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of Kk(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),Y=Z.getElementSize()*Z.getComponentSize(),$=o0.padNumber(Y);return this.attributes.push({u8:X,byteStride:Y,paddedByteStride:$}),$}hash(Z){let J=0;for(let{u8:X,byteStride:Y,paddedByteStride:$}of this.attributes){for(let Q=0;Q<$;Q++)if(Q<Y)this.u8[J+Q]=X[Z*Y+Q];else this.u8[J+Q]=0;J+=$}return $T1(0,this.u32)}equal(Z,J){for(let{u8:X,byteStride:Y}of this.attributes)for(let $=0;$<Y;$++)if(X[Z*Y+$]!==X[J*Y+$])return!1;return!0}}function $T1(Z,J){for(let $=0,Q=J.length;$<Q;$++){let K=J[$];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 QT1(Z,J,X,Y,$=JX){let Q=J-1,G=X.hash(Y)&Q;for(let W=0;W<=Q;W++){let H=Z[G];if(H===$||X.equal(H,Y))return G;G=G+W+1&Q}throw new Error("Hash table full.")}var w6;(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"})(w6||(w6={}));function YX(Z,J){let X=Z.getAttribute("POSITION"),Y=Z.getIndices();switch(J){case w6.RENDER:return Y?Y.getCount():X.getCount();case w6.RENDER_CACHED:return Y?new Set(Y.getArray()).size:X.getCount();case w6.UPLOAD_NAIVE:case w6.UPLOAD:return X.getCount();case w6.DISTINCT:case w6.DISTINCT_POSITION:return KT1(J);case w6.UNUSED:return Y?X.getCount()-new Set(Y.getArray()).size:0;default:return GT1(J)}}function KT1(Z){throw new Error(`Not implemented: ${Z}`)}function GT1(Z){throw new Error(`Unexpected value: ${Z}`)}function zV(Z,J,X){let Y=_6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=WT1(Z);let $=Z.getIndices(),Q=$?$.getArray():null,K=YX(Z,w6.RENDER),G=Y.createAccessor(),W=K,H=Gk(W,X);for(let F=0;F<W;F++)H[F]=J[Q?Q[F]:F];Z.setIndices(G.setArray(H));let V=Kk(Z);for(let F of Z.listAttributes()){let z=xZ(Y,F);Jk(F,$,J,z,X),Z.swap(F,z)}for(let F of Z.listTargets())for(let z of F.listAttributes()){let q=xZ(Y,z);Jk(z,$,J,q,X),F.swap(z,q)}if($&&$.listParents().length===1)$.dispose();for(let F of V)if(F.listParents().length===1)F.dispose();return Z}function Jk(Z,J,X,Y,$){let Q=Z.getElementSize(),K=Z.getArray(),G=J?J.getArray():null,W=J?J.getCount():Z.getCount(),H=new K.constructor($*Q),V=new Uint8Array($);for(let F=0;F<W;F++){let z=G?G[F]:F,q=X[z];if(V[q])continue;for(let U=0;U<Q;U++)H[q*Q+U]=K[z*Q+U];V[q]=1}return Y.setArray(H)}function WT1(Z){let J=YX(Z,w6.UPLOAD),X=Z.getIndices(),Y=X?X.getArray():null;if(!X||!Y)return[MC1(J,1e6),J];let $=new Uint32Array(J).fill(JX),Q=0;for(let K=0;K<Y.length;K++){let G=Y[K];if($[G]===JX)$[G]=Q++}return[$,Q]}var Xk="weld",n2={overwrite:!0,cleanup:!0};function Wk(Z=n2){let J=A7(n2,Z);return $X(Xk,async(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes()){for(let Q of $.listPrimitives())if(e2(Q,J),YX(Q,w6.RENDER)===0)Q.dispose();if($.listPrimitives().length===0)$.dispose()}if(J.cleanup)await X.transform(t2({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Vt({propertyTypes:[a.ACCESSOR]}));Y.debug(`${Xk}: Complete.`)})}function e2(Z,J=n2){let X=Z.getGraph(),$=_6.fromGraph(X).getLogger(),Q=FG({},n2,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===C8.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),G=Z.getIndices(),W=G==null?void 0:G.getArray(),H=G?G.getCount():K,V=new jt(Z),F=NC1(K+K/4),z=new Uint32Array(F).fill(JX),q=new Uint32Array(K).fill(JX),U=0;for(let B=0;B<H;B++){let L=W?W[B]:B;if(q[L]!==JX)continue;let w=QT1(z,F,V,L,JX),O=z[w];if(O===JX)z[w]=L,q[L]=U++;else q[L]=q[O]}$.debug(`${Xk}: ${o2(K,U)} vertices.`),zV(Z,q,U)}var{FLOAT:HT1}=x0.ComponentType;function Ot(Z,J){let X=Z.getAttribute("POSITION");if(X)lr(J,X);let Y=Z.getAttribute("NORMAL");if(Y)pr(J,Y);let $=Z.getAttribute("TANGENT");if($)ir(J,$);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)lr(J,K);let G=Q.getAttribute("NORMAL");if(G)pr(J,G);let W=Q.getAttribute("TANGENT");if(W)ir(J,W)}if(EC1(J)<0)VT1(Z)}function lr(Z,J){let X=J.getComponentType(),Y=J.getNormalized(),$=J.getArray(),Q=X===HT1?$:new Float32Array($.length),K=r2();for(let G=0,W=J.getCount();G<W;G++){if(Y)K[0]=i0.decodeNormalizedInt($[G*3],X),K[1]=i0.decodeNormalizedInt($[G*3+1],X),K[2]=i0.decodeNormalizedInt($[G*3+2],X);else K[0]=$[G*3],K[1]=$[G*3+1],K[2]=$[G*3+2];AC1(K,K,Z),Q[G*3]=K[0],Q[G*3+1]=K[1],Q[G*3+2]=K[2]}J.setArray(Q).setNormalized(!1)}function pr(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=kC1();IC1(Q,Z),SC1(Q,Q),_C1(Q,Q);let K=r2();for(let G=0,W=J.getCount();G<W;G++){if(Y)K[0]=i0.decodeNormalizedInt(X[G*3],$),K[1]=i0.decodeNormalizedInt(X[G*3+1],$),K[2]=i0.decodeNormalizedInt(X[G*3+2],$);else K[0]=X[G*3],K[1]=X[G*3+1],K[2]=X[G*3+2];if(xC1(K,K,Q),Ht(K,K),Y)X[G*3]=i0.decodeNormalizedInt(K[0],$),X[G*3+1]=i0.decodeNormalizedInt(K[1],$),X[G*3+2]=i0.decodeNormalizedInt(K[2],$);else X[G*3]=K[0],X[G*3+1]=K[1],X[G*3+2]=K[2]}}function ir(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=r2();for(let K=0,G=J.getCount();K<G;K++){if(Y)Q[0]=i0.decodeNormalizedInt(X[K*4],$),Q[1]=i0.decodeNormalizedInt(X[K*4+1],$),Q[2]=i0.decodeNormalizedInt(X[K*4+2],$);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],Ht(Q,Q),Y)X[K*4]=i0.decodeNormalizedInt(Q[0],$),X[K*4+1]=i0.decodeNormalizedInt(Q[1],$),X[K*4+2]=i0.decodeNormalizedInt(Q[2],$);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function VT1(Z){if(Z.getMode()!==C8.Mode.TRIANGLES)return;if(!Z.getIndices())e2(Z);let J=Z.getIndices();for(let X=0,Y=J.getCount();X<Y;X+=3){let $=J.getScalar(X),Q=J.getScalar(X+2);J.setScalar(X,Q),J.setScalar(X+2,$)}}function zT1(Z,J){for(let X of Z.listPrimitives()){let Y=FT1(X,Z);if(X!==Y)Z.removePrimitive(X).addPrimitive(Y)}for(let X of Z.listPrimitives())zV(X),Ot(X,J)}function FT1(Z,J){if(Z.listParents().some((Y)=>Y instanceof uH&&Y!==J))Z=Z.clone();for(let Y of Z.listTargets())if(Y.listParents().some((Q)=>Q instanceof C8&&Q!==Z))Z.removeTarget(Y).addTarget(Y.clone());return Z}var nr=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function Mt(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!i0.eq(X,nr))zT1(J,X);for(let Y of Z.listChildren()){let $=Y.getMatrix();Wt($,$,X),Y.setMatrix($)}return Z.setMatrix(nr)}var{LINES:qT1,LINE_STRIP:UT1,LINE_LOOP:LT1,TRIANGLES:BT1,TRIANGLE_STRIP:wT1,TRIANGLE_FAN:jT1}=C8.Mode;function OT1(Z){let J=Z.getGraph(),X=_6.fromGraph(J);if(!Z.getIndices())e2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=$t(Z),G=new iJ[Y.getComponentType()](Q*2),W=Z.getMode();if(W===UT1)for(let V=0;V<Q;V++)G[V*2]=$[V],G[V*2+1]=$[V+1];else if(W===LT1)for(let V=0;V<Q;V++)if(V<Q-1)G[V*2]=$[V],G[V*2+1]=$[V+1];else G[V*2]=$[V],G[V*2+1]=$[0];else throw new Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(qT1);let H=X.getRoot();if(Y.listParents().some((V)=>V!==H&&V!==Z))Z.setIndices(xZ(X,Y).setArray(G));else Y.setArray(G)}function Rt(Z){let J=Z.getGraph(),X=_6.fromGraph(J);if(!Z.getIndices())e2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=$t(Z),G=new iJ[Y.getComponentType()](Q*3),W=Z.getMode();if(W===wT1)for(let V=0,F=$.length;V<F-2;V++)if(V%2)G[V*3]=$[V+1],G[V*3+1]=$[V],G[V*3+2]=$[V+2];else G[V*3]=$[V],G[V*3+1]=$[V+1],G[V*3+2]=$[V+2];else if(W===jT1)for(let V=0;V<Q;V++)G[V*3]=$[0],G[V*3+1]=$[V+1],G[V*3+2]=$[V+2];else throw new Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(BT1);let H=X.getRoot();if(Y.listParents().some((V)=>V!==H&&V!==Z))Z.setIndices(xZ(X,Y).setArray(G));else Y.setArray(G)}var ar="dequantize",a2={pattern:/^((?!JOINTS_).)*$/};function Nt(Z=a2){let J=A7(a2,Z);return $X(ar,(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes())for(let Q of $.listPrimitives())MT1(Q,J);X.createExtension(HV).dispose(),Y.debug(`${ar}: Complete.`)})}function MT1(Z,J=a2){let X=A7(a2,J);for(let Y of Z.listSemantics())if(X.pattern.test(Y))Yk(Z.getAttribute(Y));for(let Y of Z.listTargets())for(let $ of Y.listSemantics())if(X.pattern.test($))Yk(Y.getAttribute($))}function Yk(Z){let J=Z.getArray();if(!J)return;let X=s2(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function s2(Z,J,X){let Y=new Float32Array(Z.length);for(let $=0,Q=Z.length;$<Q;$++)if(X)Y[$]=i0.decodeNormalizedInt(Z[$],J);else Y[$]=Z[$];return Y}var{TEXTURE_INFO:Pt,ROOT:bS6}=a;function Dt(Z){let J=new _6().setLogger(Z.getLogger()),X=Hk(J,Z);return RT1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function RT1(Z,J,X){X||(X=Hk(Z,J));for(let Y of J.getRoot().listExtensionsUsed()){let $=Z.createExtension(Y.constructor);if(Y.isRequired())$.setRequired(!0)}return NT1(Z,J,PT1(J),X)}function NT1(Z,J,X,Y){Y||(Y=Hk(Z,J));let $=new Map;for(let Q of X)if(!$.has(Q)&&Q.propertyType!==Pt)$.set(Q,Y(Q));for(let[Q,K]of $.entries())K.copy(Q,Y);return $}function Hk(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return(Y)=>{if(Y.propertyType===Pt)return Y;let $=X.get(Y);if(!$)$=new Y.constructor(Z.getGraph()),X.set(Y,$);return $}}function PT1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}var rE="flatten",sr={cleanup:!0};function Ct(Z=sr){let J=A7(sr,Z);return $X(rE,async(X)=>{let Y=X.getRoot(),$=X.getLogger(),Q=new Set;for(let H of Y.listSkins())for(let V of H.listJoints())Q.add(V);let K=new Set;for(let H of Y.listAnimations())for(let V of H.listChannels()){let F=V.getTargetNode();if(F&&V.getTargetPath()!=="weights")K.add(F)}let G=new Set,W=new Set;for(let H of Y.listScenes())H.traverse((V)=>{let F=V.getParentNode();if(!F)return;if(Q.has(F)||G.has(F))G.add(V);if(K.has(F)||W.has(F))W.add(V)});for(let H of Y.listScenes())H.traverse((V)=>{if(K.has(V))return;if(G.has(V))return;if(W.has(V))return;CC1(V)});if(K.size)$.debug(`${rE}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(t2({propertyTypes:[a.NODE],keepLeaves:!1}));$.debug(`${rE}: Complete.`)})}function Tt(Z){return $T(Z)}var DT1={skipValidation:!1},or=4294967295,{LINE_STRIP:CT1,LINE_LOOP:TT1,TRIANGLE_STRIP:ET1,TRIANGLE_FAN:kT1}=C8.Mode;function IT1(Z,J={}){let X=A7(DT1,J),Y=Z[0],$=_6.fromGraph(Y.getGraph());if(!X.skipValidation&&new Set(Z.map(Kt)).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 CT1:case TT1:OT1(q);break;case ET1:case kT1:Rt(q);break}let Q=[],K=new Uint32Array(Z.length),G=0,W=0;for(let q=0;q<Z.length;q++){let U=Z[q],B=U.getIndices(),L=U.getAttribute("POSITION").getCount(),w=B?B.getArray():null,O=B?B.getCount():L,M=new Uint32Array(L).fill(or);for(let R=0;R<O;R++){let D=w?w[R]:R;if(M[D]===or)M[D]=G++,K[q]++}Q.push(M),W+=O}let H=$.createPrimitive().setMode(Y.getMode()).setMaterial(Y.getMaterial());for(let q of Y.listSemantics()){let U=Y.getAttribute(q),B=iJ[U.getComponentType()],L=xZ($,U).setArray(new B(G*U.getElementSize()));H.setAttribute(q,L)}let V=Y.getIndices(),F=V?xZ($,V).setArray(Gk(W,G)):null;H.setIndices(F);let z=0;for(let q=0;q<Q.length;q++){let U=Z[q],B=U.getIndices(),L=B?B.getCount():-1,w=Q[q];if(B&&F)ST1(B,w,F,z),z+=L;for(let O of H.listSemantics()){let M=U.getAttribute(O),R=H.getAttribute(O);_T1(M,B,w,R)}}return H}function _T1(Z,J,X,Y){let $=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),G=Z.getArray(),W=Y.getArray(),H=new Uint8Array(Z.getCount());for(let V=0,F=J?J.getCount():K;V<F;V++){let z=Q?Q[V]:V,q=X[z];if(H[q])continue;for(let U=0;U<$;U++)W[q*$+U]=G[z*$+U];H[q]=1}}function ST1(Z,J,X,Y){let $=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let G=0;G<$;G++){let W=Q[G],H=J[W];K[Y+G]=H}}var $k="join",{ROOT:vT1,NODE:AT1,MESH:xT1,PRIMITIVE:hT1,ACCESSOR:fT1}=a,tE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],rr={keepMeshes:!1,keepNamed:!1,cleanup:!0};function Et(Z=rr){let J=A7(rr,Z);return $X($k,async(X)=>{let Y=X.getRoot(),$=X.getLogger();for(let Q of Y.listScenes())tr(X,Q,J),Q.traverse((K)=>tr(X,K,J));if(J.cleanup)await X.transform(t2({propertyTypes:[AT1,xT1,hT1,fT1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));$.debug(`${$k}: Complete.`)})}function tr(Z,J,X){let Y=Z.getLogger(),$={},Q=J.listChildren();for(let W=0;W<Q.length;W++){let H=Q[W];if(H.listParents().some((z)=>z instanceof sY))continue;let F=H.getMesh();if(!F)continue;if(H.getExtension("EXT_mesh_gpu_instancing"))continue;if(H.getSkin())continue;for(let z of F.listPrimitives()){if(z.listTargets().length>0)continue;let q=z.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;zV(z),bT1(z);let U=Kt(z),B=F.getName()||H.getName();if(X.keepMeshes||X.keepNamed&&B)U+=`|${W}`;if(!(U in $))$[U]={prims:[],primMeshes:[],primNodes:[],dstNode:H,dstMesh:void 0};let L=$[U];L.prims.push(z),L.primNodes.push(H)}}let K=Object.values($).filter(({prims:W})=>W.length>1),G=new Set(K.flatMap((W)=>W.primNodes));for(let W of G){let H=W.getMesh();if(H.listParents().some((F)=>{return F.propertyType!==vT1&&W!==F}))W.setMesh(H.clone())}for(let W of K){let{dstNode:H,primNodes:V}=W;W.dstMesh=H.getMesh(),W.primMeshes=V.map((F)=>F.getMesh())}for(let W of K){let{prims:H,primNodes:V,primMeshes:F,dstNode:z,dstMesh:q}=W,U=z.getMatrix();for(let w=0;w<H.length;w++){let O=V[w],M=F[w],R=H[w];if(M.removePrimitive(R),RC1(R))R=H[w]=yT1(H[w]);if(O!==z)Wt(tE,TC1(tE,U),O.getMatrix()),Ot(R,tE)}let B=IT1(H),L=B.listAttributes()[0].getCount();q.addPrimitive(B),Y.debug(`${$k}: Joined Primitives (${H.length}) containing ${eE(L)} vertices under Node "${z.getName()}".`)}}function yT1(Z){let J=Z.clone();for(let Y of J.listSemantics())J.setAttribute(Y,J.getAttribute(Y).clone());let X=J.getIndices();if(X)J.setIndices(X.clone());return J}function bT1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)Yk(X)}}var{TRANSLATION:gS6,ROTATION:mS6,SCALE:uS6,WEIGHTS:dS6}=sY.TargetPath;var gT1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var cS6=FG({level:"high"},gT1);var mT1="unweld";function uT1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let Y=Z.getGraph(),$=_6.fromGraph(Y),Q=$.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let W of Z.listAttributes())if(Z.swap(W,er($,W,X,J)),W.listParents().length===1)W.dispose();for(let W of Z.listTargets())for(let H of W.listAttributes())if(W.swap(H,er($,H,X,J)),H.listParents().length===1)H.dispose();let G=Z.getAttribute("POSITION").getCount();if(Q.debug(`${mT1}: ${o2(K,G)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function er(Z,J,X,Y){if(Y.has(J)&&Y.get(J).has(X))return Y.get(J).get(X);let $=J.getArray(),K=new $.constructor(X.getCount()*J.getElementSize()),G=X.getArray(),W=J.getElementSize();for(let V=0,F=X.getCount();V<F;V++)for(let z=0;z<W;z++)K[V*W+z]=$[G[V]*W+z];if(!Y.has(J))Y.set(J,new Map);let H=xZ(Z,J).setArray(K);return Y.get(J).set(X,H),H}var Zt;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Zt||(Zt={}));var dT1=0.000001;function cT1(Z,J,X,Y=0.0001){let $=J.length/Z.length,Q=new Array($).fill(0),K=new Array($).fill(0),G=new Array($).fill(0),W=new Array($).fill(0),H=Z.length-1,V=1;for(let F=1;F<H;++F){let z=Z[V-1],q=Z[F],U=Z[F+1],B=(q-z)/(U-z),L=!1;if(q!==U&&(F!==1||q!==Z[0])){if(VV(J,V-1,W),VV(J,F,K),VV(J,F+1,G),X==="slerp"){let w=iT1(Q,W,G,B),O=Xt(W,K)+Xt(K,G);L=!i2(K,w,Y)||O+Number.EPSILON>=Math.PI}else if(X==="lerp"){let w=pT1(Q,W,G,B);L=!i2(K,w,Y)}else if(X==="step")L=!i2(K,W)||!i2(K,G)}if(L){if(F!==V)Z[V]=Z[F],Jt(J,V,VV(J,F,Q));V++}}if(H>0)Z[V]=Z[H],Jt(J,V,VV(J,H,Q)),V++;return V}function VV(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)X[Y]=Z[J*$+Y];return X}function Jt(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)Z[J*$+Y]=X[Y]}function i2(Z,J,X=0){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>X)return!1;return!0}function lT1(Z,J,X){return Z*(1-X)+J*X}function pT1(Z,J,X,Y){for(let $=0;$<J.length;$++)Z[$]=lT1(J[$],X[$],Y);return Z}function iT1(Z,J,X,Y){let $=J[0],Q=J[1],K=J[2],G=J[3],W=X[0],H=X[1],V=X[2],F=X[3],z,q,U,B,L;if(q=$*W+Q*H+K*V+G*F,q<0)q=-q,W=-W,H=-H,V=-V,F=-F;if(1-q>dT1)z=Math.acos(q),U=Math.sin(z),B=Math.sin((1-Y)*z)/U,L=Math.sin(Y*z)/U;else B=1-Y,L=Y;return Z[0]=B*$+L*W,Z[1]=B*Q+L*H,Z[2]=B*K+L*V,Z[3]=B*G+L*F,Z}function Xt(Z,J){let X=nT1(Z,J);return Math.acos(2*X*X-1)}function nT1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var lS6=new Float32Array(0),pS6={ready:Promise.resolve(),resample:cT1,tolerance:0.0001,cleanup:!0};var j$="simplify",{POINTS:kt,LINES:aT1,LINE_STRIP:sT1,LINE_LOOP:oT1,TRIANGLES:rT1,TRIANGLE_STRIP:It,TRIANGLE_FAN:_t}=C8.Mode,St={ratio:0,error:0.0001,lockBorder:!1,cleanup:!0};function vt(Z){let J=A7(St,Z),X=J.simplifier;if(!X)throw new Error(`${j$}: simplifier dependency required — install "meshoptimizer".`);return $X(j$,async(Y)=>{let $=Y.getLogger();await X.ready,await Y.transform(Wk({overwrite:!1,cleanup:J.cleanup}));let Q=0;for(let K of Y.getRoot().listMeshes()){for(let G of K.listPrimitives()){let W=G.getMode();if(W===rT1||W===It||W===_t){if(Yt(G,J),YX(G,w6.RENDER)===0)G.dispose()}else if(G.getMode()===kt&&!!X.simplifyPoints){if(Yt(G,J),YX(G,w6.RENDER)===0)G.dispose()}else Q++}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)$.warn(`${j$}: Skipping simplification of ${Q} primitives: Unsupported draw mode.`);if(J.cleanup)await Y.transform(t2({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Vt({propertyTypes:[a.ACCESSOR]}));$.debug(`${j$}: Complete.`)})}function Yt(Z,J){let X=FG({},St,J),Y=X.simplifier,$=Z.getGraph(),Q=_6.fromGraph($),K=Q.getLogger();switch(Z.getMode()){case kt:return tT1(Q,Z,X);case aT1:case sT1:case oT1:return K.warn(`${j$}: Skipping primitive simplification: Unsupported draw mode.`),Z;case It:case _t:Rt(Z);break}let G=YX(Z,w6.UPLOAD),W=YX(Z,w6.RENDER);if(W<G/2)zV(Z);let H=Z.getAttribute("POSITION"),V=Z.getIndices(),F=H.getArray(),z=V.getArray();if(!(F instanceof Float32Array))F=s2(F,H.getComponentType(),H.getNormalized());if(!(z instanceof Uint32Array))z=new Uint32Array(z);let q=Math.floor(X.ratio*W/3)*3,U=X.lockBorder?["LockBorder"]:[],[B,L]=Y.simplify(z,F,3,q,X.error,U);if(Z.setIndices(xZ(Q,V).setArray(B)),V.listParents().length===1)V.dispose();zV(Z);let w=YX(Z,w6.UPLOAD);if(w<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${j$}: ${o2(G,w)} vertices, error: ${L.toFixed(4)}.`),Z}function tT1(Z,J,X){let Y=X.simplifier,$=Z.getLogger();if(J.getIndices())uT1(J);let K=J.getAttribute("POSITION"),G=J.getAttribute("COLOR_0"),W=K.getCount(),H=K.getArray(),V=G?G.getArray():void 0,F=G?G.getComponentSize():void 0;if(!(H instanceof Float32Array))H=s2(H,K.getComponentType(),K.getNormalized());if(V&&!(V instanceof Float32Array))V=s2(V,K.getComponentType(),K.getNormalized());Y.useExperimentalFeatures=!0;let z=Math.floor(X.ratio*W),q=Y.simplifyPoints(H,3,z,V,F);Y.useExperimentalFeatures=!1;let[U,B]=Y.compactMesh(q);$.debug(`${j$}: ${o2(K.getCount(),B)} vertices.`);for(let L of Kk(J)){let w=xZ(Z,L);if(Jk(L,null,U,w,B),jC1(J,L,w),L.listParents().length===1)L.dispose()}return J}var Qk;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(Qk||(Qk={}));var iS6={resizeFilter:Qk.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var gt=r(bt(),1);var UG={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DIRECTORIES:[(()=>{try{return $9.dirname(m.resolve("@hytopia.com/assets"))}catch{return null}})(),$9.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 S5{static instance=new S5;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)c.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J.getRoot().listAnimations().map((Y)=>Y.getName())}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)c.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)c.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){c.error(`ModelRegistry.getTrimesh(): Model ${Z} not found!`);return}let Y=X.vertices;if(J!==1){Y=new Float32Array(Y.length);for(let $=0;$<Y.length;$++)Y[$]=X.vertices[$]*J}return{vertices:Y,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)c.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=$9.normalize(Z);for(let X of UG.DIRECTORIES){let Y=$9.normalize(X);if(J.startsWith(Y))return $9.relative(Y,J).replace(/\\/g,"/")}return $9.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of UG.DIRECTORIES){let X=$9.resolve(process.cwd(),J);if(!QX.existsSync(X))continue;let Y=await mB("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let $ of Y)Z.push($9.join(X,$))}return Z}async _loadModelData(Z){let J=await new VT().read(Z),X=Tt(J.getRoot().listScenes()[0]),Y=J.getRoot().listNodes().map((Q)=>Q.getName()),$=this._absoluteModelPathToModelUri(Z);this._modelUriDocuments.set($,J),this._modelUriBoundingBoxes.set($,{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($,await this._buildTrimesh($))}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)}${UG.CHECKSUM_EXT}`;if(!QX.existsSync(J))return!1;let X=this._calculateChecksum(Z),Y=QX.readFileSync(J,"utf8");return X===Y}_calculateChecksum(Z){if(!QX.existsSync(Z))return"";let J=QX.readFileSync(Z);return YE1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=$9.basename(Z),X=J.replace(/\.[^/.]+$/,""),Y=$9.dirname(Z),$=$9.join(Y,UG.OPTIMIZED_DIR,X);return $9.join($,J)}async _buildTrimesh(Z,J=1,X=0.001){let Y=this._modelUriDocuments.get(Z);if(!Y)c.fatalError(`ModelRegistry._buildTrimesh(): Model ${Z} not found!`);let $=Dt(Y);$.setLogger(new k5(gH.WARN)),await $.transform(Gt({pivot:"center"}),Ct(),Et(),Wk(),vt({simplifier:gt.MeshoptSimplifier,ratio:J,error:X}),Nt());for(let H of $.getRoot().listScenes())for(let V of H.listChildren())Mt(V);let Q=$.getRoot().listMeshes()[0];if(!Q){c.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root mesh!`);return}let K=Q.listPrimitives()[0];if(!K){c.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root primitive!`);return}let G=K.getAttribute("POSITION"),W=K.getIndices();if(!G||!W){c.error(`ModelRegistry._buildTrimesh(): Model ${Z} missing required geometry data!`);return}return{vertices:G.getArray(),indices:W.getArray()}}async _optimizeModel(Z,J){let X=$9.dirname(J);QX.rmSync(X,{recursive:!0,force:!0}),QX.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let Y of UG.OPTIMIZER_RUNS){let $=J.replace(/(\.[^/.]+)$/,`${Y.suffix}$1`),{stderr:Q}=await gi("npx",["@gltf-transform/cli","optimize",Z,$,...Y.options]);if(Q)return c.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return QX.writeFileSync(`${J}${UG.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var hZ=r(KH(),1);var BV;(($)=>{$.DYNAMIC="dynamic";$.FIXED="fixed";$.KINEMATIC_POSITION="kinematic_position";$.KINEMATIC_VELOCITY="kinematic_velocity"})(BV||={});var Uk=0.001,mt="dynamic";class O$ extends O0{_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??=mt,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:Y}=this.rotation;return{x:-2*(Z*X+Y*J),y:-2*(J*X-Y*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:Y,principalAngularInertiaLocalFrame:$}=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"]:hZ.default.RigidBodyType.Dynamic,["fixed"]:hZ.default.RigidBodyType.Fixed,["kinematic_position"]:hZ.default.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:hZ.default.RigidBodyType.KinematicVelocityBased}[Z];if(X===void 0)return c.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 c.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 Q9({...Z,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(Z)}createAndAddChildColliders(Z){let J=[];return Z.forEach((X)=>{let Y=this.createAndAddChildCollider(X);if(Y)J.push(Y)}),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 c.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 c.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 c.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,Y])=>{if(X in Z)Y(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 Q9(Z);return this._colliders.add(J),J}_createAndAddPendingChildColliders(Z){let J=[];return Z.forEach((X)=>{let Y=this._createAndAddPendingChildCollider(X);if(Y)J.push(Y)}),J}_createRigidBodyDesc(Z){let J=Z.type??mt;return{["dynamic"]:()=>hZ.default.RigidBodyDesc.dynamic(),["fixed"]:()=>hZ.default.RigidBodyDesc.fixed(),["kinematic_position"]:()=>hZ.default.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>hZ.default.RigidBodyDesc.kinematicVelocityBased()}[J]()}_requireCreated(Z){if(!this._rigidBody||!this._simulation)c.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)c.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)c.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)c.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)c.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)c.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)<Uk&&Math.abs(Z.y)<Uk&&Math.abs(Z.z)<Uk}}var Lk;(($)=>{$[$.Average=0]="Average";$[$.Min=1]="Min";$[$.Multiply=2]="Multiply";$[$.Max=3]="Max"})(Lk||={});var wV;((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"})(wV||={});class Q9 extends O0{_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 Y=S5.instance.getBoundingBox(Z),$=Y.max.x-Y.min.x,Q=Y.max.y-Y.min.y,K=Y.max.z-Y.min.z,G=Math.max($,K),W=Math.min($,K),H=G/W,V=G/Q,F=G*J/2,z=(O)=>Math.max(0.01,O),q=()=>({shape:"block",halfExtents:{x:z($*J/2),y:z(Q*J/2),z:z(K*J/2)}}),U=()=>({shape:"round-cylinder",radius:z(F),halfHeight:z(Q*J/2),borderRadius:z(F*0.1)}),B=()=>{let O=S5.instance.getTrimesh(Z,J);if(!O)return;return{shape:"trimesh",vertices:O.vertices,indices:O.indices}},L=()=>({shape:"wedge",extents:{x:$*J,y:Q*J,z:K*J}}),w=()=>({shape:"capsule",radius:z(F),halfHeight:z(Q*J/2-F)});if(X)switch(X){case"block":return q();case"capsule":return w();case"round-cylinder":return U();case"trimesh":{let O=B();if(!O){c.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return O}case"wedge":return L();default:c.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(H>2)return q();if(V>1.5)return U();return w()}get bounciness(){if(!this._requireNotRemoved("bounciness"))return 0;return this._collider?this._collider.restitution():this._colliderDesc.restitution}get bouncinessCombineRule(){if(!this._requireNotRemoved("bouncinessCombineRule"))return 0;return this._collider?this._collider.restitutionCombineRule():this._colliderDesc.restitutionCombineRule}get collisionGroups(){if(!this._requireNotRemoved("collisionGroups"))return{belongsTo:[],collidesWith:[]};return this._collider?T4.decodeRawCollisionGroups(this._collider.collisionGroups()):T4.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=T4.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 c.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 c.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")c.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 c.error("Collider.combineVoxelStates(): Other collider is not simulated!");if(this.shape!=="voxels")return c.error("Collider.combineVoxelStates(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return c.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|p8.default.ActiveEvents.COLLISION_EVENTS:J&~p8.default.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|p8.default.ActiveEvents.CONTACT_FORCE_EVENTS:J&~p8.default.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 c.error("Collider.propagateVoxelChange(): Other collider is not simulated!");if(this.shape!=="voxels")return c.error("Collider.propagateVoxelChange(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return c.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":{c.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"voxels":{c.error("Collider.setScale(): Voxels colliders cannot be scaled!");return}case"wedge":{c.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:c.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,Y])=>{if(Z[X]!==void 0)Y.call(this,Z[X])})}_autoAddToSimulation(Z){if(Z.simulation)this.addToSimulation(Z.simulation,Z.parentRigidBody)}_buildWedgeConvexHullVertices(Z){let{x:J,y:X,z:Y}=Z,$=J/2,Q=Y/2,K=X/2;return new Float32Array([-$,0-K,-Q,$,0-K,-Q,$,0-K,Q,-$,0-K,Q,-$,X-K,-Q,$,X-K,-Q])}_createColliderDesc(Z){let{shape:J,flags:X}=Z;switch(J){case"ball":{if(!Z.radius)c.fatalError("Ball collider must have a radius!");return p8.default.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)c.fatalError("Block collider must have halfExtents!");return p8.default.ColliderDesc.cuboid(Z.halfExtents.x,Z.halfExtents.y,Z.halfExtents.z)}case"capsule":{if(!Z.halfHeight||!Z.radius)c.fatalError("Capsule collider must have halfHeight and radius!");return p8.default.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)c.fatalError("Cone collider must have radius and halfHeight!");return p8.default.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)c.fatalError("Cylinder collider must have radius and halfHeight!");return p8.default.ColliderDesc.cylinder(Z.halfHeight,Z.radius)}case"round-cylinder":{if(!Z.radius||!Z.halfHeight||!Z.borderRadius)c.fatalError("Round cylinder collider must have radius, halfHeight, and borderRadius!");return p8.default.ColliderDesc.roundCylinder(Z.halfHeight,Z.radius,Z.borderRadius)}case"trimesh":{if(!Z.indices||!Z.vertices)c.fatalError("Trimesh collider must have vertices and indices!");return p8.default.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)c.fatalError("Voxels collider must have coordinates and size!");return p8.default.ColliderDesc.voxels(this._coordinatesToInt32Array(Z.coordinates),Z.size)}case"wedge":{if(!Z.extents)c.fatalError("Wedge collider must have extents!");let Y=this._buildWedgeConvexHullVertices(Z.extents),$=p8.default.ColliderDesc.convexHull(Y);if(!$)throw c.fatalError("Failed to create convex hull for wedge collider!"),new Error("Convex hull creation failed");return $}default:c.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)c.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)c.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)c.error(`Collider._requireNotRemoved(): Collider is removed, invoked method: ${Z}()`);return!this.isRemoved}_setActiveCollisionTypes(){(this._collider??this._colliderDesc).setActiveCollisionTypes(p8.default.ActiveCollisionTypes.DYNAMIC_DYNAMIC|p8.default.ActiveCollisionTypes.DYNAMIC_KINEMATIC|p8.default.ActiveCollisionTypes.DYNAMIC_FIXED|p8.default.ActiveCollisionTypes.KINEMATIC_KINEMATIC|p8.default.ActiveCollisionTypes.KINEMATIC_FIXED)}_coordinatesToInt32Array(Z){let J=new Int32Array(Z.length*3);for(let X=0;X<Z.length;X++){let Y=Z[X],$=X*3;J[$]=Math.floor(Y.x),J[$+1]=Math.floor(Y.y),J[$+2]=Math.floor(Y.z)}return J}}var $E1={shape:"voxels"},Bk;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(Bk||={});class K9 extends O0{_id;_blockTypeRegistry;_customColliderOptions;_halfExtents;_isLiquid;_name;_textureUri;constructor(Z,J={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(J.id<0)c.fatalError("BlockType.constructor(): BlockType id not set.");super();this._id=J.id,this._blockTypeRegistry=Z,this._customColliderOptions=J.customColliderOptions,this._halfExtents=J.halfExtents??{x:0.5,y:0.5,z:0.5},this._isLiquid=J.isLiquid??!1,this._name=J.name,this._textureUri=J.textureUri}get id(){return this._id}get blockTypeRegistry(){return this._blockTypeRegistry}get colliderOptions(){return{...this._customColliderOptions,...$E1}}get halfExtents(){return this._halfExtents}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}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 Q9({...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(T4.isDefaultCollisionGroups(J.collisionGroups))J.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return J}serialize(){return P0.serializeBlockType(this,this._blockTypeRegistry.world.tickAllocator)}}var wk;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(wk||={});class jV extends O0{_blockTypes=new Map;_world;constructor(Z){super();this._world=Z}get world(){return this._world}getAllBlockTypes(Z=!1){return Z?this._world.tickAllocator.getArray(this._blockTypes.values()):Array.from(this._blockTypes.values())}getBlockType(Z){let J=this._blockTypes.get(Z);if(!J)c.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends K9{constructor(Y,$){super(Y,$)}}(this,Z);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,this._world.tickAllocator)}}var aI={};zK(aI,{worldSchema:()=>nI,worldPacketDefinition:()=>A60,vectorSchema:()=>W1,vectorBooleanSchema:()=>Xh1,uiSchema:()=>pI,uiPacketDefinition:()=>S60,uiDatasSchema:()=>iI,uiDatasPacketDefinition:()=>v60,uiDataSendPacketDefinition:()=>B60,uiDataSchema:()=>dV,syncResponseSchema:()=>lI,syncResponsePacketDefinition:()=>_60,syncRequestSchema:()=>jI,syncRequestPacketDefinition:()=>L60,stateRequestSchema:()=>wI,stateRequestPacketDefinition:()=>U60,sceneUIsSchema:()=>cI,sceneUIsPacketDefinition:()=>I60,sceneUISchema:()=>dI,rgbColorSchema:()=>h6,registeredPackets:()=>cw,quaternionSchema:()=>_I,playersSchema:()=>uI,playersPacketDefinition:()=>k60,playerSchema:()=>mI,physicsDebugRenderSchema:()=>gI,physicsDebugRenderPacketDefinition:()=>T60,physicsDebugRaycastsSchema:()=>bI,physicsDebugRaycastsPacketDefinition:()=>E60,physicsDebugRaycastSchema:()=>yI,particleEmittersSchema:()=>fI,particleEmittersPacketDefinition:()=>C60,particleEmitterSchema:()=>hI,outboundPackets:()=>dw,modelNodeOverrideSchema:()=>II,lightsSchema:()=>xI,lightsPacketDefinition:()=>D60,lightSchema:()=>AI,isValidPacket:()=>$h1,inputSchema:()=>BI,inputPacketDefinition:()=>q60,inboundPackets:()=>uw,hexColorSchema:()=>UI,heartbeatSchema:()=>qI,heartbeatPacketDefinition:()=>V60,entitySchema:()=>SI,entitiesSchema:()=>vI,entitiesPacketDefinition:()=>P60,definePacket:()=>I0,debugConfigSchema:()=>LI,debugConfigPacketDefinition:()=>F60,createPacket:()=>ix1,connectionSchema:()=>FI,connectionPacketDefinition:()=>H60,chunksSchema:()=>kI,chunksPacketDefinition:()=>N60,chunkSchema:()=>EI,chatMessagesSchema:()=>TI,chatMessagesPacketDefinition:()=>R60,chatMessageSendPacketDefinition:()=>z60,chatMessageSchema:()=>uV,cameraSchema:()=>CI,cameraPacketDefinition:()=>M60,blocksSchema:()=>NI,blocksPacketDefinition:()=>j60,blockTypesSchema:()=>DI,blockTypesPacketDefinition:()=>O60,blockTypeSchema:()=>PI,blockSchema:()=>RI,bidirectionalPackets:()=>mw,audiosSchema:()=>MI,audiosPacketDefinition:()=>w60,audioSchema:()=>OI,PacketId:()=>S1});var mw={};zK(mw,{heartbeatPacketDefinition:()=>V60,connectionPacketDefinition:()=>H60});var VI=r(G60(),1);class zI extends VI.default{static instance=new VI.default}var S1;((E)=>{E[E.SYNC_REQUEST=0]="SYNC_REQUEST";E[E.INPUT=1]="INPUT";E[E.STATE_REQUEST=2]="STATE_REQUEST";E[E.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";E[E.UI_DATA_SEND=4]="UI_DATA_SEND";E[E.SYNC_RESPONSE=32]="SYNC_RESPONSE";E[E.AUDIOS=33]="AUDIOS";E[E.BLOCKS=34]="BLOCKS";E[E.BLOCK_TYPES=35]="BLOCK_TYPES";E[E.CHAT_MESSAGES=36]="CHAT_MESSAGES";E[E.CHUNKS=37]="CHUNKS";E[E.ENTITIES=38]="ENTITIES";E[E.WORLD=39]="WORLD";E[E.CAMERA=40]="CAMERA";E[E.UI=41]="UI";E[E.UI_DATAS=42]="UI_DATAS";E[E.SCENE_UIS=43]="SCENE_UIS";E[E.LIGHTS=44]="LIGHTS";E[E.PLAYERS=45]="PLAYERS";E[E.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";E[E.CONNECTION=116]="CONNECTION";E[E.HEARTBEAT=117]="HEARTBEAT";E[E.DEBUG_CONFIG=128]="DEBUG_CONFIG";E[E.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";E[E.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(S1||={});function ix1(Z,J,X,Y){if(!Z.validate(J))throw new Error(`Invalid payload for packet with id ${Z.id}. Error: ${zI.instance.errorsText(Z.validate.errors)}`);let $=Y??[];if($[0]=Z.id,$[1]=J,typeof X==="number")$.push(X);return $}function I0(Z,J){return{id:Z,schema:J,validate:zI.instance.compile(J)}}var nx1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},W60={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},ax1={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},sx1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},ox1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},rx1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},tx1={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},ex1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:sx1,ic:{type:"array",items:ax1},d:W60,s:rx1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},Zh1={type:"object",properties:{i:{type:"string"},d:W60},required:["i","d"],additionalProperties:!1},Jh1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:tx1},required:["l","s"],additionalProperties:!1},FI={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},c:{...Zh1,nullable:!0},ca:{...nx1,nullable:!0},d:{type:"array",items:{...Jh1},nullable:!0},pa:{...ox1,nullable:!0},t:{type:"array",items:{...ex1},nullable:!0}},additionalProperties:!1};var H60=I0(116,FI);var qI={type:"null",nullable:!0};var V60=I0(117,qI);var uw={};zK(uw,{uiDataSendPacketDefinition:()=>B60,syncRequestPacketDefinition:()=>L60,stateRequestPacketDefinition:()=>U60,inputPacketDefinition:()=>q60,debugConfigPacketDefinition:()=>F60,chatMessageSendPacketDefinition:()=>z60});var UI={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var uV={type:"object",properties:{m:{type:"string"},c:{...UI,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var z60=I0(3,uV);var LI={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var F60=I0(128,LI);var BI={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 q60=I0(1,BI);var wI={type:"object",properties:{},additionalProperties:!1};var U60=I0(2,wI);var jI={type:"null",nullable:!0};var L60=I0(0,jI);var dV={type:"object",properties:{},additionalProperties:!0};var B60=I0(4,dV);var dw={};zK(dw,{worldPacketDefinition:()=>A60,uiPacketDefinition:()=>S60,uiDatasPacketDefinition:()=>v60,syncResponsePacketDefinition:()=>_60,sceneUIsPacketDefinition:()=>I60,playersPacketDefinition:()=>k60,physicsDebugRenderPacketDefinition:()=>T60,physicsDebugRaycastsPacketDefinition:()=>E60,particleEmittersPacketDefinition:()=>C60,lightsPacketDefinition:()=>D60,entitiesPacketDefinition:()=>P60,chunksPacketDefinition:()=>N60,chatMessagesPacketDefinition:()=>R60,cameraPacketDefinition:()=>M60,blocksPacketDefinition:()=>j60,blockTypesPacketDefinition:()=>O60,audiosPacketDefinition:()=>w60});var W1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var OI={type:"object",properties:{i:{type:"number"},a:{type:"string",nullable:!0},cd:{type:"number",nullable:!0},d:{type:"number",nullable:!0},de:{type:"number",nullable:!0},di:{type:"number",minimum:0,nullable:!0},e:{type:"number",nullable:!0},l:{type:"boolean",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pl:{type:"boolean",nullable:!0},pr:{type:"number",minimum:0,nullable:!0},r:{type:"boolean",nullable:!0},rd:{type:"number",nullable:!0},s:{type:"number",nullable:!0},v:{type:"number",minimum:0,maximum:1,nullable:!0}},required:["i"],additionalProperties:!1};var MI={type:"array",items:{...OI}};var w60=I0(33,MI);var RI={type:"object",properties:{i:{type:"number"},c:W1},required:["i","c"],additionalProperties:!1};var NI={type:"array",items:{...RI}};var j60=I0(34,NI);var PI={type:"object",properties:{i:{type:"number"},l:{type:"boolean",nullable:!0},n:{type:"string",nullable:!0},t:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var DI={type:"array",items:{...PI}};var O60=I0(35,DI);var CI={type:"object",properties:{m:{type:"number",nullable:!0},e:{type:"number",nullable:!0},et:{type:"number",nullable:!0},fo:{type:"number",nullable:!0},ffo:{type:"number",nullable:!0},fv:{type:"number",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pt:{...W1,nullable:!0},pl:{...W1,nullable:!0},s:{type:"array",items:{type:"string"},nullable:!0},sa:{type:"number",nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var TI={type:"array",items:{...uV}};var EI={type:"object",properties:{c:W1,b:{type:"array",items:{type:"number",minimum:0,maximum:255},minItems:4096,maxItems:4096,nullable:!0},rm:{type:"boolean",nullable:!0}},required:["c"],additionalProperties:!1};var kI={type:"array",items:{...EI}};var h6={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 II={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:{...h6,nullable:!0}},required:["n"],additionalProperties:!1};var _I={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var SI={type:"object",properties:{i:{type:"number"},al:{type:"array",items:{type:"string"},nullable:!0},ao:{type:"array",items:{type:"string"},nullable:!0},ap:{type:"number",nullable:!0},as:{type:"array",items:{type:"string"},nullable:!0},bh:{...W1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...II},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{..._I,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...h6,nullable:!0}},required:["i"],additionalProperties:!1};var vI={type:"array",items:{...SI}};var AI={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...h6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",minimum:0,maximum:1,nullable:!0},rm:{type:"boolean",nullable:!0},t:{type:"number",nullable:!0},te:{type:"number",nullable:!0},tp:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var xI={type:"array",items:{...AI}};var hI={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},b:{type:"number",nullable:!0},ce:{...h6,nullable:!0},cev:{...h6,nullable:!0},cs:{...h6,nullable:!0},csv:{...h6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...W1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...W1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pv:{...W1,nullable:!0},r:{type:"number",nullable:!0},rv:{type:"number",nullable:!0},rm:{type:"boolean",nullable:!0},se:{type:"number",nullable:!0},sev:{type:"number",nullable:!0},ss:{type:"number",nullable:!0},ssv:{type:"number",nullable:!0},t:{type:"boolean",nullable:!0},tu:{type:"string",nullable:!0},v:{...W1,nullable:!0},vv:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var fI={type:"array",items:{...hI}};var yI={type:"object",properties:{o:{...W1},d:{...W1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var bI={type:"array",items:{...yI}};var gI={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var mI={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 uI={type:"array",items:{...mI}};var dI={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"object",nullable:!0},t:{type:"string",nullable:!0},v:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var cI={type:"array",items:{...dI}};var lI={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var pI={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var iI={type:"array",items:{...dV}};var Xh1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var nI={type:"object",properties:{i:{type:"number"},ac:{...h6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...h6,nullable:!0},di:{type:"number",nullable:!0},dp:{...W1,nullable:!0},fc:{...h6,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 M60=I0(40,CI);var R60=I0(36,TI);var N60=I0(37,kI);var P60=I0(38,vI);var D60=I0(44,xI);var C60=I0(46,fI);var T60=I0(192,gI);var E60=I0(193,bI);var k60=I0(45,uI);var I60=I0(43,cI);var _60=I0(32,lI);var S60=I0(41,pI);var v60=I0(42,iI);var A60=I0(39,nI);var cw=new Map,Yh1={...mw,...uw,...dw};for(let Z of Object.values(Yh1))if("id"in Z&&"schema"in Z){let J=Z;if(cw.has(J.id))throw new Error(`Packet with id ${J.id} is already registered.`);cw.set(J.id,J)}function $h1(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=cw.get(Z[0]);return!!J&&J.validate(Z[1])}var Y0=aI;var $50=r(X50(),1);import T$ from"fs";import Y50 from"path";var lV="./dev/persistence";class f7{static instance=new f7;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;constructor(){try{this._creativeGateway=new $50.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(`
415
415
  `))}}get isGatewayAvailable(){return!!this._creativeGateway}async getData(Z){if(!this._creativeGateway&&process.env.NODE_ENV==="production")return c.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 c.warning("PlatformGateway.setData(): Cannot set data with an error property.");if(!this._creativeGateway&&process.env.NODE_ENV==="production")return c.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(!T$.existsSync(lV))return;let J=Y50.join(lV,`${Z}.json`);return JSON.parse(T$.readFileSync(J,"utf8"))}catch(J){c.warning(`PlatformGateway._readDevDataLocally(): Failed to read data for key "${Z}": ${J}`)}}_writeDevDataLocally(Z,J){try{if(!T$.existsSync(lV))T$.mkdirSync(lV,{recursive:!0});let X=Y50.join(lV,`${Z}.json`),Y={};if(T$.existsSync(X))Y=JSON.parse(T$.readFileSync(X,"utf8"));let $={...Y,...J};T$.writeFileSync(X,JSON.stringify($,null,2),"utf8")}catch(X){c.warning(`PlatformGateway._writeDevDataLocally(): Failed to write data for key "${Z}": ${X}`)}}}class E${static instance=new E$;constructor(){}async getGlobalData(Z){let J=await f7.instance.getData(Z);if(!J||J.error){if(J?.error)c.warning(`PersistenceManager.getGlobalData(): ${J.error.message}`);return}return J}async getPlayerData(Z){let J=await f7.instance.getData(this._getPlayerKey(Z));if(!J||J.error){if(J?.error)c.warning(`PersistenceManager.getPlayerData(): ${J.error.message}`);return}return J}async setGlobalData(Z,J){let X=await f7.instance.setData(Z,J);if(!X||X.error){if(X?.error)c.warning(`PersistenceManager.setGlobalData(): ${X.error.message}`);return}return X}async setPlayerData(Z,J){let X=await f7.instance.setData(this._getPlayerKey(Z),J);if(!X||X.error){if(X?.error)c.warning(`PersistenceManager.setPlayerData(): ${X.error.message}`);return}return X}_getPlayerKey(Z){return`player-${Z.id}`}}var Q50;((Y)=>{Y[Y.FIRST_PERSON=0]="FIRST_PERSON";Y[Y.THIRD_PERSON=1]="THIRD_PERSON";Y[Y.SPECTATOR=2]="SPECTATOR"})(Q50||={});var oI;((B)=>{B.LOOK_AT_ENTITY="PLAYER_CAMERA.LOOK_AT_ENTITY";B.LOOK_AT_POSITION="PLAYER_CAMERA.LOOK_AT_POSITION";B.SET_ATTACHED_TO_ENTITY="PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY";B.SET_ATTACHED_TO_POSITION="PLAYER_CAMERA.SET_ATTACHED_TO_POSITION";B.SET_FILM_OFFSET="PLAYER_CAMERA.SET_FILM_OFFSET";B.SET_FORWARD_OFFSET="PLAYER_CAMERA.SET_FORWARD_OFFSET";B.SET_FOV="PLAYER_CAMERA.SET_FOV";B.SET_MODEL_HIDDEN_NODES="PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES";B.SET_MODEL_SHOWN_NODES="PLAYER_CAMERA.SET_MODEL_SHOWN_NODES";B.SET_MODE="PLAYER_CAMERA.SET_MODE";B.SET_OFFSET="PLAYER_CAMERA.SET_OFFSET";B.SET_SHOULDER_ANGLE="PLAYER_CAMERA.SET_SHOULDER_ANGLE";B.SET_TRACKED_ENTITY="PLAYER_CAMERA.SET_TRACKED_ENTITY";B.SET_TRACKED_POSITION="PLAYER_CAMERA.SET_TRACKED_POSITION";B.SET_ZOOM="PLAYER_CAMERA.SET_ZOOM"})(oI||={});class pV extends O0{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),Y=Math.sin(Z),$=Math.cos(J),Q=Math.sin(J);return{x:Y*$,y:X*Q,z:-Y*Q,w:X*$}}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 c.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(){if(!this.player.world)c.fatalError("PlayerCamera.serialize(): PlayerCamera player is not in a world and cannot be serialized!");return P0.serializePlayerCamera(this,this.player.world.tickAllocator)}_requirePlayerWorld(Z){if(!this.player.world)c.error(`PlayerCamera._requirePlayerWorld(): Player ${this.player.id} is not in a world, invoked method: ${Z}()`);return!!this.player.world}}var pw;(($)=>{$.DATA="PLAYER_UI.DATA";$.LOAD="PLAYER_UI.LOAD";$.LOCK_POINTER="PLAYER_UI.LOCK_POINTER";$.SEND_DATA="PLAYER_UI.SEND_DATA"})(pw||={});class iV extends O0{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 K50=["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"],nV;((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"})(nV||={});class CG extends O0{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-${CG._devNextPlayerId++}`,this.username=J?.user.username??this.id,this.profilePictureUrl=J?.user.profilePictureURL??void 0,this.camera=new pV(this),this.connection=Z,this.ui=new iV(this),Z.onPacket(Y0.PacketId.CHAT_MESSAGE_SEND,this._onChatMessageSendPacket),Z.onPacket(Y0.PacketId.DEBUG_CONFIG,this._onDebugConfigPacket),Z.onPacket(Y0.PacketId.INPUT,this._onInputPacket),Z.onPacket(Y0.PacketId.SYNC_REQUEST,this._onSyncRequestPacket),Z.onPacket(Y0.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 E$.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},E$.instance.setPlayerData(this,Z).catch((J)=>{}),this._persistedData}serialize(){if(!this._world)c.fatalError("Player.serialize(): Player is not in a world and cannot be serialized!");return P0.serializePlayer(this,this._world.tickAllocator)}_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(K50.forEach((X)=>{let Y=X;if(J[Y]!==void 0)this._input[Y]=Boolean(J[Y])}),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 rI;((X)=>{X.BROADCAST_MESSAGE="CHAT.BROADCAST_MESSAGE";X.PLAYER_MESSAGE="CHAT.PLAYER_MESSAGE"})(rI||={});class aV extends O0{_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[Y];if(Q){Q(J,$,X);return}this._sendBroadcastMessage(J,X)})}_sendBroadcastMessage(Z,J,X){this.emitWithWorld(this._world,"CHAT.BROADCAST_MESSAGE",{player:Z,message:J,color:X})}}var G9=16,tI=G9-1,Ih1=G9**3;class W9{_blocks;_chunkLattice;_originCoordinate;constructor(Z,J){this._blocks=new Uint8Array(Ih1),this._chunkLattice=Z,this._originCoordinate=J}get blocks(){return this._blocks}get chunkLattice(){return this._chunkLattice}get originCoordinate(){return this._originCoordinate}static blockIndexToLocalCoordinate(Z){return{x:Z%G9,y:(Z/G9|0)%G9,z:Z/(G9*G9)|0}}static globalCoordinateToLocalCoordinate(Z){return{x:Z.x&G9-1,y:Z.y&G9-1,z:Z.z&G9-1}}static globalCoordinateToOriginCoordinate(Z){return{x:Z.x&~(G9-1),y:Z.y&~(G9-1),z:Z.z&~(G9-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 c.error("Chunk.setBlock(): Block local coordinate is out of bounds");let X=this._getIndex(Z);this._blocks[X]=J}serialize(){return P0.serializeChunk(this,this._chunkLattice.world.tickAllocator)}_getIndex(Z){return Z.x+(Z.y<<4)+(Z.z<<8)}_isValidLocalCoordinate(Z){return Z.x>=0&&Z.x<=tI&&Z.y>=0&&Z.y<=tI&&Z.z>=0&&Z.z<=tI}}var eI;((Y)=>{Y.ADD_CHUNK="CHUNK_LATTICE.ADD_CHUNK";Y.REMOVE_CHUNK="CHUNK_LATTICE.REMOVE_CHUNK";Y.SET_BLOCK="CHUNK_LATTICE.SET_BLOCK"})(eI||={});class sV extends O0{_blockTypeColliders=new Map;_blockTypeCounts=new Map;_chunks=new Map;_rigidBody;_world;constructor(Z){super();this._world=Z}get chunkCount(){return this._chunks.size}get world(){return this._world}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(W9.globalCoordinateToOriginCoordinate(Z));if(!J)return 0;return J.getBlockId(W9.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(W9.globalCoordinateToOriginCoordinate(Z)))}getOrCreateBlockTypeCollider(Z,J){let X=this._blockTypeColliders.get(Z);if(X)return X;let $=this._world.blockTypeRegistry.getBlockType(Z).createCollider(J);return this._blockTypeColliders.set(Z,$),$}getOrCreateChunk(Z){let J=W9.globalCoordinateToOriginCoordinate(Z),X=this._chunks.get(this._getChunkKey(J));if(X)return X;return X=new W9(this,J),this._chunks.set(this._getChunkKey(J),X),this.emitWithWorld(this._world,"CHUNK_LATTICE.ADD_CHUNK",{chunkLattice:this,chunk:X}),X}getAllChunks(Z=!1){return Z?this._world.tickAllocator.getArray(this._chunks.values()):Array.from(this._chunks.values())}hasBlock(Z){let J=this.getChunk(W9.globalCoordinateToOriginCoordinate(Z));if(!J)return!1;return J.hasBlock(W9.globalCoordinateToLocalCoordinate(Z))}hasChunk(Z){let J=W9.globalCoordinateToOriginCoordinate(Z);return this._chunks.has(this._getChunkKey(J))}setBlock(Z,J){let X=W9.globalCoordinateToLocalCoordinate(Z),Y=this.getOrCreateChunk(Z),$=Y.getBlockId(X);if($===J)return;if(Y.setBlock(X,J),!this._rigidBody)this._rigidBody=new O$({type:"fixed"}),this._rigidBody.addToSimulation(this._world.simulation);if($!==0){let Q=Math.max(0,(this._blockTypeCounts.get($)??0)-1),K=this.getBlockTypeCollider($);if(K)if(Q===0)this._world.simulation.colliderMap.removeColliderBlockType(K),K.removeFromSimulation(),this._blockTypeColliders.delete($);else K.setVoxel(Z,!1),this._propagateVoxelChange(K,Z);this._blockTypeCounts.set($,Q)}if(J!==0){let Q=(this._blockTypeCounts.get(J)??0)+1,K=this.getOrCreateBlockTypeCollider(J,[Z]);if(Q===1){let G=this._world.blockTypeRegistry.getBlockType(J);K.addToSimulation(this._world.simulation,this._rigidBody),this._world.simulation.colliderMap.setColliderBlockType(K,G),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:Y,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 oV{_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)c.error("ColliderMap._requireSimulatedCollider(): Collider is not in the simulation.");return!!Z.rawCollider}}var G50={type:"dynamic",softCcdPrediction:1},W50=0.015625,H50=Math.cos(0.026),rV;((R)=>{R.BLOCK_COLLISION="ENTITY.BLOCK_COLLISION";R.BLOCK_CONTACT_FORCE="ENTITY.BLOCK_CONTACT_FORCE";R.DESPAWN="ENTITY.DESPAWN";R.ENTITY_COLLISION="ENTITY.ENTITY_COLLISION";R.ENTITY_CONTACT_FORCE="ENTITY.ENTITY_CONTACT_FORCE";R.SET_MODEL_ANIMATIONS_PLAYBACK_RATE="ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE";R.SET_MODEL_HIDDEN_NODES="ENTITY.SET_MODEL_HIDDEN_NODES";R.SET_MODEL_SCALE="ENTITY.SET_MODEL_SCALE";R.SET_MODEL_SHOWN_NODES="ENTITY.SET_MODEL_SHOWN_NODES";R.SET_MODEL_TEXTURE_URI="ENTITY.SET_MODEL_TEXTURE_URI";R.SET_OPACITY="ENTITY.SET_OPACITY";R.SET_PARENT="ENTITY.SET_PARENT";R.SET_TINT_COLOR="ENTITY.SET_TINT_COLOR";R.SPAWN="ENTITY.SPAWN";R.START_MODEL_LOOPED_ANIMATIONS="ENTITY.START_MODEL_LOOPED_ANIMATIONS";R.START_MODEL_ONESHOT_ANIMATIONS="ENTITY.START_MODEL_ONESHOT_ANIMATIONS";R.STOP_MODEL_ANIMATIONS="ENTITY.STOP_MODEL_ANIMATIONS";R.TICK="ENTITY.TICK";R.UPDATE_POSITION="ENTITY.UPDATE_POSITION";R.UPDATE_ROTATION="ENTITY.UPDATE_ROTATION"})(rV||={});class i8 extends O${_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)c.fatalError("Entity.constructor(): Entity data must include a blockTextureUri or modelUri, but not both.");if(J&&!Z.blockHalfExtents)c.fatalError("Entity.constructor(): Block entity must have blockHalfExtents!");if(Z.parent&&!Z.parent.isSpawned)c.fatalError("Entity.constructor(): Parent entity must be spawned before child entity!");if(Z.parent?.modelUri&&Z.parentNodeName&&!S5.instance.modelHasNode(Z.parent.modelUri,Z.parentNodeName))c.fatalError(`Entity.constructor(): Parent node name ${Z.parentNodeName} not found in parent model ${Z.parent.modelUri}!`);super(Z.rigidBodyOptions??G50);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((Y)=>this._modelHiddenNodes.add(Y.toLowerCase())),Z.modelLoopedAnimations?.forEach((Y)=>this._modelLoopedAnimations.add(Y)),Z.modelShownNodes?.forEach((Y)=>this._modelShownNodes.add(Y.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=W50,this._rotationUpdateThreshold=H50,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?S5.instance.getDepth(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.z*2}get height(){return this.isModelEntity?S5.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?S5.instance.getWidth(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.x*2}get world(){return this._world}spawn(Z,J,X){if(this.isSpawned)return c.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 Q9(Q9.optionsFromBlockHalfExtents(this._blockHalfExtents)));if(this._modelUri&&this.numColliders===0&&this._modelPreferredShape!=="none")this.addChildColliderToSimulation(new Q9(Q9.optionsFromModelUri(this._modelUri,this._modelScale,this._modelPreferredShape)));if(this.colliders.forEach((Y)=>{if(this.hasListeners("ENTITY.BLOCK_COLLISION")||this.hasListeners("ENTITY.ENTITY_COLLISION"))Y.enableCollisionEvents(!0);if(this.hasListeners("ENTITY.BLOCK_CONTACT_FORCE")||this.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))Y.enableContactForceEvents(!0);if(T4.isDefaultCollisionGroups(Y.collisionGroups)){let $=this.isEnvironmental?[8]:[Y.isSensor?4:2],Q=this.isEnvironmental?[65535&~8&~1]:[65535];Y.setCollisionGroups({belongsTo:$,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((Y)=>{Z.simulation.colliderMap.setColliderEntity(Y,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,Y){if(!this._requireSpawned("setParent"))return;if(Z&&!Z.isSpawned)return c.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(($)=>$.setEnabled(!Z)),this.setType(!Z?this._lastParentlessType:"kinematic_velocity"),this.setPosition(X??{x:0,y:0,z:0}),this.setRotation(Y??{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(){if(!this._world)c.fatalError("Entity.serialize(): Entity is not in a world and cannot be serialized!");return P0.serializeEntity(this,this._world.tickAllocator)}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;let X=this._world.tickAllocator.getObject();X.entity=this,X.rotation=J,this.emitWithWorld(this._world,"ENTITY.UPDATE_ROTATION",X)}if(this._positionExceedsThreshold(Z,this._lastUpdatedPosition)){this._lastUpdatedPosition=Z;let X=this._world.tickAllocator.getObject();X.entity=this,X.position=Z,this.emitWithWorld(this._world,"ENTITY.UPDATE_POSITION",X)}}_positionExceedsThreshold(Z,J){let X=Z.x-J.x,Y=Z.y-J.y,$=Z.z-J.z;return X*X+Y*Y+$*$>this._positionUpdateThresholdSq}_requireSpawned(Z){if(!this.isSpawned)c.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),Y=[];for(let $ of Z)for(let Q of $)if(!X.has(Q))Y.push(Q);if(Y.length>0)this.stopModelAnimations(Y)}}class y1 extends _Y{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 P3({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 Y=Z.linearVelocity;Z.setLinearVelocity({x:Y.x*this.swimGravity,y:Y.y*this.swimGravity,z:Y.z*this.swimGravity})}if(this._liquidContactCount+=X?1:-1,this._liquidContactCount>0)Z.setGravityScale(this.swimGravity),Z.stopAllModelLoopedAnimations(this.swimLoopedAnimations),this._swimUpwardCooldownAt=performance.now()+y1.SWIM_UPWARD_COOLDOWN_MS;else Z.setGravityScale(1),Z.stopModelAnimations(this.swimLoopedAnimations)})}spawn(Z){if(!Z.isSpawned)return c.error("DefaultPlayerEntityController.spawn(): Entity is not spawned!");Z.createAndAddChildCollider({shape:"cylinder",radius:y1.GROUND_SENSOR_RADIUS_SCALE*(Z.height/y1.BASE_ENTITY_HEIGHT),halfHeight:y1.GROUND_SENSOR_HEIGHT_SCALE*(Z.height/y1.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 K9)||!J.isLiquid){if(X&&this._groundContactCount===0&&Z.linearVelocity.y<-1)if(Z.linearVelocity.y<y1.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 i8))return;if(X&&this.sticksToPlatforms)this._platform=J;else if(J===this._platform&&!X)this._platform=void 0}}),Z.createAndAddChildCollider({shape:"capsule",halfHeight:y1.WALL_COLLIDER_HEIGHT_SCALE*(Z.height/y1.BASE_ENTITY_HEIGHT),radius:y1.WALL_COLLIDER_RADIUS_SCALE*(Z.height/y1.BASE_ENTITY_HEIGHT),collisionGroups:{belongsTo:[4],collidesWith:[1,2,8]},friction:0,frictionCombineRule:1,tag:"wallCollider"})}tickWithPlayerInput(Z,J,X,Y){if(!Z.isSpawned||!Z.world)return;if(super.tickWithPlayerInput(Z,J,X,Y),Z.parent)return;let{w:$,a:Q,s:K,d:G,c:W,sp:H,sh:V,ml:F}=J,{yaw:z}=X,q=Z.linearVelocity;this._reusableTargetVelocities.x=0,this._reusableTargetVelocities.y=0,this._reusableTargetVelocities.z=0,this._isActivelyMoving=!!($||Q||K||G);let U=V,B=Q&&G&&!$&&!K||$&&K&&!Q&&!G,L=U&&this.canRun(this)||!U&&this.canWalk(this);if(this.isSwimming&&!this._isFullySubmerged)this._isFullySubmerged=!0,this._justSubmergedUntil=performance.now()+y1.WATER_ENTRY_SINKING_MS;else if(!this.isSwimming)this._isFullySubmerged=!1,this._justSubmergedUntil=0;if(this.isGrounded&&!this.isSwimming&&this._isActivelyMoving&&!B&&L){let N=U?this.runLoopedAnimations:this.walkLoopedAnimations;Z.stopAllModelLoopedAnimations(N),Z.startModelLoopedAnimations(N),this._stepAudio?.setPlaybackRate(U?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 w;if(this.applyDirectionalMovementRotations&&L){if($&&Q&&!G&&!K)w=y1.MOVEMENT_ROTATIONS.wa;else if($&&G&&!Q&&!K)w=y1.MOVEMENT_ROTATIONS.wd;else if(K&&Q&&!$&&!G)w=y1.MOVEMENT_ROTATIONS.sa;else if(K&&G&&!$&&!Q)w=y1.MOVEMENT_ROTATIONS.sd;else if(K&&!$&&!Q&&!G||Q&&K&&G&&!$)w=y1.MOVEMENT_ROTATIONS.s;else if(Q&&!$&&!K&&!G)w=y1.MOVEMENT_ROTATIONS.a;else if(G&&!$&&!Q&&!K)w=y1.MOVEMENT_ROTATIONS.d}if(F)Z.startModelOneshotAnimations(this.interactOneshotAnimations),J.ml=!this.autoCancelMouseLeftClick;if(L){let N=!this.isSwimming?U?this.runVelocity:this.walkVelocity:U?this.swimFastVelocity:this.swimSlowVelocity,C=Math.sin(z),T=Math.cos(z);if($)this._reusableTargetVelocities.x-=N*C,this._reusableTargetVelocities.z-=N*T;if(K)this._reusableTargetVelocities.x+=N*C,this._reusableTargetVelocities.z+=N*T;if(Q)this._reusableTargetVelocities.x-=N*T,this._reusableTargetVelocities.z+=N*C;if(G)this._reusableTargetVelocities.x+=N*T,this._reusableTargetVelocities.z-=N*C;let E=Math.sqrt(this._reusableTargetVelocities.x*this._reusableTargetVelocities.x+this._reusableTargetVelocities.z*this._reusableTargetVelocities.z);if(E>N){let A=N/E;this._reusableTargetVelocities.x*=A,this._reusableTargetVelocities.z*=A}}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(W)this._reusableTargetVelocities.y=-this.swimUpwardVelocity;else if(performance.now()<this._justSubmergedUntil)this._reusableTargetVelocities.y=-this.swimUpwardVelocity*y1.WATER_ENTRY_SINKING_FACTOR;else if(!H)this._reusableTargetVelocities.y=-q.y*y1.SWIMMING_DRAG_FACTOR}if(H&&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 O=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 N=Math.sqrt(this._externalVelocity.x*this._externalVelocity.x+this._magnitudeYTracker*this._magnitudeYTracker+this._externalVelocity.z*this._externalVelocity.z);if(N>0.01){let T=Math.max(0,N-y1.EXTERNAL_IMPULSE_DECAY_RATE)/N;this._externalVelocity.x*=T,this._magnitudeYTracker*=T,this._externalVelocity.z*=T}else this._externalVelocity.x=0,this._externalVelocity.y=0,this._magnitudeYTracker=0,this._externalVelocity.z=0}}let M=this._reusableTargetVelocities.x+this._externalVelocity.x-q.x+O.x,R=this._reusableTargetVelocities.y+this._externalVelocity.y+O.y,D=this._reusableTargetVelocities.z+this._externalVelocity.z-q.z+O.z;if(this._externalVelocity.y=0,M!==0||R!==0||D!==0){let N=Z.mass;this._reusableImpulse.x=M*N,this._reusableImpulse.y=R*N,this._reusableImpulse.z=D*N,this._internalApplyImpulse(this._reusableImpulse)}if(z!==void 0&&(this.faceForwardOnStop||this.isActivelyMoving)){let C=(w!==void 0?z+w:z)*0.5;Z.setRotation({x:0,y:Math.sin(C),z:0,w:Math.cos(C)})}}}var Z_;((G)=>{G.LOAD="SCENE_UI.LOAD";G.SET_ATTACHED_TO_ENTITY="SCENE_UI.SET_ATTACHED_TO_ENTITY";G.SET_OFFSET="SCENE_UI.SET_OFFSET";G.SET_POSITION="SCENE_UI.SET_POSITION";G.SET_STATE="SCENE_UI.SET_STATE";G.SET_VIEW_DISTANCE="SCENE_UI.SET_VIEW_DISTANCE";G.UNLOAD="SCENE_UI.UNLOAD"})(Z_||={});class tV extends O0{_id;_attachedToEntity;_offset;_position;_state={};_templateId;_viewDistance;_world;constructor(Z){if(!!Z.attachedToEntity===!!Z.position)c.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 c.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 c.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(){if(!this._world)c.fatalError("SceneUI.serialize(): SceneUI is not in a world and cannot be serialized!");return P0.serializeSceneUI(this,this._world.tickAllocator)}}var V50=0.010000000000000002,z50=Math.cos(0.026);class y7 extends i8{player;nametagSceneUI;constructor(Z){super(Z);this._positionUpdateThresholdSq=V50,this._rotationUpdateThreshold=z50,this.player=Z.player,this.nametagSceneUI=new tV({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:Y})=>{this.nametagSceneUI.setState({chat:Y})})}tick(Z){if(!this.isSpawned||!this.world)return;if(!this.controller)return c.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 J_ extends y7{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 y1)}}class eV{_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)c.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 c.error(`EntityManager.unregisterEntity(): Entity ${Z.name} is not assigned an id!`);if(this._entities.delete(Z.id),!Z.isEnvironmental)this._activeEntities.delete(Z)}getAllEntities(Z=!1){return Z?this._world.tickAllocator.getArray(this._entities.values()):Array.from(this._entities.values())}getAllPlayerEntities(){let Z=[];return this._entities.forEach((J)=>{if(J instanceof y7)Z.push(J)}),Z}getPlayerEntitiesByPlayer(Z){let J=[];return this._entities.forEach((X)=>{if(X instanceof y7&&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()}}var x31=r(KH(),1);import{gzipSync as oQ6}from"zlib";var nf1=r(K90(),1),af1=r(G_(),1),sf1=r(H_(),1),$j=r(Xj(),1),B_=r(q90(),1);var Q5=r(w40(),1),pm6=Q5.default.v1,im6=Q5.default.v1ToV6,nm6=Q5.default.v3,j40=Q5.default.v4,am6=Q5.default.v5,sm6=Q5.default.v6,om6=Q5.default.v6ToV1,rm6=Q5.default.v7,tm6=Q5.default.NIL,em6=Q5.default.MAX,Zu6=Q5.default.version,Ju6=Q5.default.validate,Xu6=Q5.default.stringify,Yu6=Q5.default.parse;var D_;try{D_=new TextDecoder}catch(Z){}var J0,z9,b=0;var k_=[],A$=k_,Vz=0,v1={},Q1,pZ,V9=0,l9=0,n8,iZ,y5=[],J1,O40={useRecords:!1,mapsAsObjects:!0};class Fj{}var I_=new Fj;I_.name="MessagePack 0xC1";var BX=!1,E40=2,C_,T_,E_;try{new Function("")}catch(Z){E40=1/0}class nZ{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 b40(()=>{return zj(),this?this.unpack(Z,J):nZ.prototype.unpack.call(O40,Z,J)});if(!Z.buffer&&Z.constructor===ArrayBuffer)Z=typeof Buffer!=="undefined"?Buffer.from(Z):new Uint8Array(Z);if(typeof J==="object")z9=J.end||Z.length,b=J.start||0;else b=0,z9=J>-1?J:Z.length;Vz=0,l9=0,pZ=null,A$=k_,n8=null,J0=Z;try{J1=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 nZ){if(v1=this,this.structures)return Q1=this.structures,Hj(J);else if(!Q1||Q1.length>0)Q1=[]}else if(v1=O40,!Q1||Q1.length>0)Q1=[];return Hj(J)}unpackMultiple(Z,J){let X,Y=0;try{BX=!0;let $=Z.length,Q=this?this.unpack(Z,$):qj.unpack(Z,$);if(J){if(J(Q,Y,b)===!1)return;while(b<$)if(Y=b,J(Hj(),Y,b)===!1)return}else{X=[Q];while(b<$)Y=b,X.push(Hj());return X}}catch($){throw $.lastPosition=Y,$.values=X,$}finally{BX=!1,zj()}}_mergeStructures(Z,J){if(T_)Z=T_.call(this,Z);if(Z=Z||[],Object.isFrozen(Z))Z=Z.map((X)=>X.slice(0));for(let X=0,Y=Z.length;X<Y;X++){let $=Z[X];if($){if($.isShared=!0,X>=32)$.highByte=X-32>>5}}Z.sharedLength=Z.length;for(let X in J||[])if(X>=0){let Y=Z[X],$=J[X];if($){if(Y)(Z.restoreStructures||(Z.restoreStructures=[]))[X]=Y;Z[X]=$}}return this.structures=Z}decode(Z,J){return this.unpack(Z,J)}}function Hj(Z){try{if(!v1.trusted&&!BX){let X=Q1.sharedLength||0;if(X<Q1.length)Q1.length=X}let J;if(v1.randomAccessStructure&&J0[b]<64&&J0[b]>=32&&C_){if(J=C_(J0,b,z9,v1),J0=null,!(Z&&Z.lazy)&&J)J=J.toJSON();b=z9}else J=I8();if(n8)b=n8.postBundlePosition,n8=null;if(BX)Q1.restoreStructures=null;if(b==z9){if(Q1&&Q1.restoreStructures)M40();if(Q1=null,J0=null,iZ)iZ=null}else if(b>z9)throw new Error("Unexpected end of MessagePack data");else if(!BX){let X;try{X=JSON.stringify(J,(Y,$)=>typeof $==="bigint"?`${$}n`:$).slice(0,100)}catch(Y){X="(JSON view not available "+Y+")"}throw new Error("Data read, but end of buffer not reached "+X)}return J}catch(J){if(Q1&&Q1.restoreStructures)M40();if(zj(),J instanceof RangeError||J.message.startsWith("Unexpected end of buffer")||b>z9)J.incomplete=!0;throw J}}function M40(){for(let Z in Q1.restoreStructures)Q1[Z]=Q1.restoreStructures[Z];Q1.restoreStructures=null}function I8(){let Z=J0[b++];if(Z<160)if(Z<128)if(Z<64)return Z;else{let J=Q1[Z&63]||v1.getStructures&&k40()[Z&63];if(J){if(!J.read)J.read=__(J,Z&63);return J.read()}else return Z}else if(Z<144)if(Z-=128,v1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let Y=f40();if(Y==="__proto__")Y="__proto_";J[Y]=I8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(I8(),I8());return J}else{Z-=144;let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=I8();if(v1.freezeData)return Object.freeze(J);return J}else if(Z<192){let J=Z-160;if(l9>=b)return pZ.slice(b-V9,(b+=J)-V9);if(l9==0&&z9<140){let X=J<16?S_(J):h40(J);if(X!=null)return X}return Vj(J)}else{let J;switch(Z){case 192:return null;case 193:if(n8)if(J=I8(),J>0)return n8[1].slice(n8.position1,n8.position1+=J);else return n8[0].slice(n8.position0,n8.position0-=J);return I_;case 194:return!1;case 195:return!0;case 196:if(J=J0[b++],J===void 0)throw new Error("Unexpected end of buffer");return P_(J);case 197:return J=J1.getUint16(b),b+=2,P_(J);case 198:return J=J1.getUint32(b),b+=4,P_(J);case 199:return v$(J0[b++]);case 200:return J=J1.getUint16(b),b+=2,v$(J);case 201:return J=J1.getUint32(b),b+=4,v$(J);case 202:if(J=J1.getFloat32(b),v1.useFloat32>2){let X=h$[(J0[b]&127)<<1|J0[b+1]>>7];return b+=4,(X*J+(J>0?0.5:-0.5)>>0)/X}return b+=4,J;case 203:return J=J1.getFloat64(b),b+=8,J;case 204:return J0[b++];case 205:return J=J1.getUint16(b),b+=2,J;case 206:return J=J1.getUint32(b),b+=4,J;case 207:if(v1.int64AsType==="number")J=J1.getUint32(b)*4294967296,J+=J1.getUint32(b+4);else if(v1.int64AsType==="string")J=J1.getBigUint64(b).toString();else if(v1.int64AsType==="auto"){if(J=J1.getBigUint64(b),J<=BigInt(2)<<BigInt(52))J=Number(J)}else J=J1.getBigUint64(b);return b+=8,J;case 208:return J1.getInt8(b++);case 209:return J=J1.getInt16(b),b+=2,J;case 210:return J=J1.getInt32(b),b+=4,J;case 211:if(v1.int64AsType==="number")J=J1.getInt32(b)*4294967296,J+=J1.getUint32(b+4);else if(v1.int64AsType==="string")J=J1.getBigInt64(b).toString();else if(v1.int64AsType==="auto"){if(J=J1.getBigInt64(b),J>=BigInt(-2)<<BigInt(52)&&J<=BigInt(2)<<BigInt(52))J=Number(J)}else J=J1.getBigInt64(b);return b+=8,J;case 212:if(J=J0[b++],J==114)return T40(J0[b++]&63);else{let X=y5[J];if(X)if(X.read)return b++,X.read(I8());else if(X.noBuffer)return b++,X();else return X(J0.subarray(b,++b));else throw new Error("Unknown extension "+J)}case 213:if(J=J0[b],J==114)return b++,T40(J0[b++]&63,J0[b++]);else return v$(2);case 214:return v$(4);case 215:return v$(8);case 216:return v$(16);case 217:if(J=J0[b++],l9>=b)return pZ.slice(b-V9,(b+=J)-V9);return I40(J);case 218:if(J=J1.getUint16(b),b+=2,l9>=b)return pZ.slice(b-V9,(b+=J)-V9);return _40(J);case 219:if(J=J1.getUint32(b),b+=4,l9>=b)return pZ.slice(b-V9,(b+=J)-V9);return S40(J);case 220:return J=J1.getUint16(b),b+=2,N40(J);case 221:return J=J1.getUint32(b),b+=4,N40(J);case 222:return J=J1.getUint16(b),b+=2,P40(J);case 223:return J=J1.getUint32(b),b+=4,P40(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 Db1=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function __(Z,J){function X(){if(X.count++>E40){let $=Z.read=new Function("r","return function(){return "+(v1.freezeData?"Object.freeze":"")+"({"+Z.map((Q)=>Q==="__proto__"?"__proto_:r()":Db1.test(Q)?Q+":r()":"["+JSON.stringify(Q)+"]:r()").join(",")+"})}")(I8);if(Z.highByte===0)Z.read=R40(J,Z.read);return $()}let Y={};for(let $=0,Q=Z.length;$<Q;$++){let K=Z[$];if(K==="__proto__")K="__proto_";Y[K]=I8()}if(v1.freezeData)return Object.freeze(Y);return Y}if(X.count=0,Z.highByte===0)return R40(J,X);return X}var R40=(Z,J)=>{return function(){let X=J0[b++];if(X===0)return J();let Y=Z<32?-(Z+(X<<5)):Z+(X<<5),$=Q1[Y]||k40()[Y];if(!$)throw new Error("Record id is not defined for "+Y);if(!$.read)$.read=__($,Z);return $.read()}};function k40(){let Z=b40(()=>{return J0=null,v1.getStructures()});return Q1=v1._mergeStructures(Z,Q1)}var Vj=x$,I40=x$,_40=x$,S40=x$,v40=!1;function A40(Z){v40=!0,Vj=J(1),I40=J(2),_40=J(3),S40=J(5);function J(X){return function Y($){let Q=A$[Vz++];if(Q==null){if(n8)return x$($);let G=J0.byteOffset,W=Z(b-X+G,z9+G,J0.buffer);if(typeof W=="string")Q=W,A$=k_;else if(A$=W,Vz=1,l9=1,Q=A$[0],Q===void 0)throw new Error("Unexpected end of buffer")}let K=Q.length;if(K<=$)return b+=$,Q;return pZ=Q,V9=b,l9=b+K,b+=$,Q.slice(0,$)}}}function x$(Z){let J;if(Z<16){if(J=S_(Z))return J}if(Z>64&&D_)return D_.decode(J0.subarray(b,b+=Z));let X=b+Z,Y=[];J="";while(b<X){let $=J0[b++];if(($&128)===0)Y.push($);else if(($&224)===192){let Q=J0[b++]&63;Y.push(($&31)<<6|Q)}else if(($&240)===224){let Q=J0[b++]&63,K=J0[b++]&63;Y.push(($&31)<<12|Q<<6|K)}else if(($&248)===240){let Q=J0[b++]&63,K=J0[b++]&63,G=J0[b++]&63,W=($&7)<<18|Q<<12|K<<6|G;if(W>65535)W-=65536,Y.push(W>>>10&1023|55296),W=56320|W&1023;Y.push(W)}else Y.push($);if(Y.length>=4096)J+=Y6.apply(String,Y),Y.length=0}if(Y.length>0)J+=Y6.apply(String,Y);return J}function x40(Z,J,X){let Y=J0;J0=Z,b=J;try{return x$(X)}finally{J0=Y}}function N40(Z){let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=I8();if(v1.freezeData)return Object.freeze(J);return J}function P40(Z){if(v1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let Y=f40();if(Y==="__proto__")Y="__proto_";J[Y]=I8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(I8(),I8());return J}}var Y6=String.fromCharCode;function h40(Z){let J=b,X=new Array(Z);for(let Y=0;Y<Z;Y++){let $=J0[b++];if(($&128)>0){b=J;return}X[Y]=$}return Y6.apply(String,X)}function S_(Z){if(Z<4)if(Z<2)if(Z===0)return"";else{let J=J0[b++];if((J&128)>1){b-=1;return}return Y6(J)}else{let J=J0[b++],X=J0[b++];if((J&128)>0||(X&128)>0){b-=2;return}if(Z<3)return Y6(J,X);let Y=J0[b++];if((Y&128)>0){b-=3;return}return Y6(J,X,Y)}else{let J=J0[b++],X=J0[b++],Y=J0[b++],$=J0[b++];if((J&128)>0||(X&128)>0||(Y&128)>0||($&128)>0){b-=4;return}if(Z<6)if(Z===4)return Y6(J,X,Y,$);else{let Q=J0[b++];if((Q&128)>0){b-=5;return}return Y6(J,X,Y,$,Q)}else if(Z<8){let Q=J0[b++],K=J0[b++];if((Q&128)>0||(K&128)>0){b-=6;return}if(Z<7)return Y6(J,X,Y,$,Q,K);let G=J0[b++];if((G&128)>0){b-=7;return}return Y6(J,X,Y,$,Q,K,G)}else{let Q=J0[b++],K=J0[b++],G=J0[b++],W=J0[b++];if((Q&128)>0||(K&128)>0||(G&128)>0||(W&128)>0){b-=8;return}if(Z<10)if(Z===8)return Y6(J,X,Y,$,Q,K,G,W);else{let H=J0[b++];if((H&128)>0){b-=9;return}return Y6(J,X,Y,$,Q,K,G,W,H)}else if(Z<12){let H=J0[b++],V=J0[b++];if((H&128)>0||(V&128)>0){b-=10;return}if(Z<11)return Y6(J,X,Y,$,Q,K,G,W,H,V);let F=J0[b++];if((F&128)>0){b-=11;return}return Y6(J,X,Y,$,Q,K,G,W,H,V,F)}else{let H=J0[b++],V=J0[b++],F=J0[b++],z=J0[b++];if((H&128)>0||(V&128)>0||(F&128)>0||(z&128)>0){b-=12;return}if(Z<14)if(Z===12)return Y6(J,X,Y,$,Q,K,G,W,H,V,F,z);else{let q=J0[b++];if((q&128)>0){b-=13;return}return Y6(J,X,Y,$,Q,K,G,W,H,V,F,z,q)}else{let q=J0[b++],U=J0[b++];if((q&128)>0||(U&128)>0){b-=14;return}if(Z<15)return Y6(J,X,Y,$,Q,K,G,W,H,V,F,z,q,U);let B=J0[b++];if((B&128)>0){b-=15;return}return Y6(J,X,Y,$,Q,K,G,W,H,V,F,z,q,U,B)}}}}}function D40(){let Z=J0[b++],J;if(Z<192)J=Z-160;else switch(Z){case 217:J=J0[b++];break;case 218:J=J1.getUint16(b),b+=2;break;case 219:J=J1.getUint32(b),b+=4;break;default:throw new Error("Expected string")}return x$(J)}function P_(Z){return v1.copyBuffers?Uint8Array.prototype.slice.call(J0,b,b+=Z):J0.subarray(b,b+=Z)}function v$(Z){let J=J0[b++];if(y5[J]){let X;return y5[J](J0.subarray(b,X=b+=Z),(Y)=>{b=Y;try{return I8()}finally{b=X}})}else throw new Error("Unknown extension type "+J)}var C40=new Array(4096);function f40(){let Z=J0[b++];if(Z>=160&&Z<192){if(Z=Z-160,l9>=b)return pZ.slice(b-V9,(b+=Z)-V9);else if(!(l9==0&&z9<180))return Vj(Z)}else return b--,y40(I8());let J=(Z<<5^(Z>1?J1.getUint16(b):Z>0?J0[b]:0))&4095,X=C40[J],Y=b,$=b+Z-3,Q,K=0;if(X&&X.bytes==Z){while(Y<$){if(Q=J1.getUint32(Y),Q!=X[K++]){Y=1879048192;break}Y+=4}$+=3;while(Y<$)if(Q=J0[Y++],Q!=X[K++]){Y=1879048192;break}if(Y===$)return b=Y,X.string;$-=3,Y=b}X=[],C40[J]=X,X.bytes=Z;while(Y<$)Q=J1.getUint32(Y),X.push(Q),Y+=4;$+=3;while(Y<$)Q=J0[Y++],X.push(Q);let G=Z<16?S_(Z):h40(Z);if(G!=null)return X.string=G;return X.string=Vj(Z)}function y40(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(v1.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 T40=(Z,J)=>{let X=I8().map(y40),Y=Z;if(J!==void 0)Z=Z<32?-((J<<5)+Z):(J<<5)+Z,X.highByte=J;let $=Q1[Z];if($&&($.isShared||BX))(Q1.restoreStructures||(Q1.restoreStructures=[]))[Z]=$;return Q1[Z]=X,X.read=__(X,Y),X.read()};y5[0]=()=>{};y5[0].noBuffer=!0;y5[66]=(Z)=>{let J=Z.length,X=BigInt(Z[0]&128?Z[0]-256:Z[0]);for(let Y=1;Y<J;Y++)X<<=BigInt(8),X+=BigInt(Z[Y]);return X};var Cb1={Error,TypeError,ReferenceError};y5[101]=()=>{let Z=I8();return(Cb1[Z[0]]||Error)(Z[1],{cause:Z[2]})};y5[105]=(Z)=>{if(v1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=J1.getUint32(b-4);if(!iZ)iZ=new Map;let X=J0[b],Y;if(X>=144&&X<160||X==220||X==221)Y=[];else if(X>=128&&X<144||X==222||X==223)Y=new Map;else if((X>=199&&X<=201||X>=212&&X<=216)&&J0[b+1]===115)Y=new Set;else Y={};let $={target:Y};iZ.set(J,$);let Q=I8();if(!$.used)return $.target=Q;else Object.assign(Y,Q);if(Y instanceof Map)for(let[K,G]of Q.entries())Y.set(K,G);if(Y instanceof Set)for(let K of Array.from(Q))Y.add(K);return Y};y5[112]=(Z)=>{if(v1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=J1.getUint32(b-4),X=iZ.get(J);return X.used=!0,X.target};y5[115]=()=>new Set(I8());var v_=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((Z)=>Z+"Array"),Tb1=typeof globalThis==="object"?globalThis:window;y5[116]=(Z)=>{let J=Z[0],X=Uint8Array.prototype.slice.call(Z,1).buffer,Y=v_[J];if(!Y){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 Tb1[Y](X)};y5[120]=()=>{let Z=I8();return new RegExp(Z[0],Z[1])};var Eb1=[];y5[98]=(Z)=>{let J=(Z[0]<<24)+(Z[1]<<16)+(Z[2]<<8)+Z[3],X=b;return b+=J-Z.length,n8=Eb1,n8=[D40(),D40()],n8.position0=0,n8.position1=0,n8.postBundlePosition=b,b=X,I8()};y5[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 b40(Z){if(E_)E_();let J=z9,X=b,Y=Vz,$=V9,Q=l9,K=pZ,G=A$,W=iZ,H=n8,V=new Uint8Array(J0.slice(0,z9)),F=Q1,z=Q1.slice(0,Q1.length),q=v1,U=BX,B=Z();return z9=J,b=X,Vz=Y,V9=$,l9=Q,pZ=K,A$=G,iZ=W,n8=H,J0=V,BX=U,Q1=F,Q1.splice(0,Q1.length,...z),v1=q,J1=new DataView(J0.buffer,J0.byteOffset,J0.byteLength),B}function zj(){J0=null,iZ=null,Q1=null}var h$=new Array(147);for(let Z=0;Z<256;Z++)h$[Z]=+("1e"+Math.floor(45.15-Z*0.30103));var qj=new nZ({useRecords:!1}),kb1=qj.unpack,Ib1=qj.unpackMultiple,_b1=qj.unpack,zz={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Sb1=new Float32Array(1),Qu6=new Uint8Array(Sb1.buffer,0,4);function g40(Z,J,X){C_=Z,T_=J,E_=X}var Lj;try{Lj=new TextEncoder}catch(Z){}var h_,d40,qz=typeof Buffer!=="undefined",Uj=qz?function(Z){return Buffer.allocUnsafeSlow(Z)}:Uint8Array,c40=qz?Buffer:Uint8Array,m40=qz?4294967296:2144337920,p,Fz,b1,d=0,K5,J8=null,l40,vb1=21760,Ab1=/[\u0080-\uFFFF]/,g7=Symbol("record-id");class f$ extends nZ{constructor(Z){super(Z);this.offset=0;let J,X,Y,$,Q,K=c40.prototype.utf8Write?function(I,_){return p.utf8Write(I,_,p.byteLength-_)}:Lj&&Lj.encodeInto?function(I,_){return Lj.encodeInto(I,p.subarray(_)).written}:!1,G=this;if(!Z)Z={};let W=Z&&Z.sequential,H=Z.structures||Z.saveStructures,V=Z.maxSharedStructures;if(V==null)V=H?32:0;if(V>8160)throw new Error("Maximum maxSharedStructure is 8160");if(Z.structuredClone&&Z.moreTypes==null)this.moreTypes=!0;let F=Z.maxOwnStructures;if(F==null)F=H?32:64;if(!this.structures&&Z.useRecords!=!1)this.structures=[];let z=V>32||F+V>64,q=V+64,U=V+F+64;if(U>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let B=[],L=0,w=0;this.pack=this.encode=function(I,_){if(!p)p=new Uj(8192),b1=p.dataView||(p.dataView=new DataView(p.buffer,0,8192)),d=0;if(K5=p.length-10,K5-d<2048)p=new Uj(p.length),b1=p.dataView||(p.dataView=new DataView(p.buffer,0,p.length)),K5=p.length-10,d=0;else d=d+7&2147483640;if(X=d,_&mb1)d+=_&255;if(Q=G.structuredClone?new Map:null,G.bundleStrings&&typeof I!=="string")J8=[],J8.size=1/0;else J8=null;if($=G.structures,$){if($.uninitialized)$=G._mergeStructures(G.getStructures());let u=$.sharedLength||0;if(u>V)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+$.sharedLength);if(!$.transitions){$.transitions=Object.create(null);for(let n=0;n<u;n++){let o=$[n];if(!o)continue;let Q0,G0=$.transitions;for(let S0=0,v0=o.length;S0<v0;S0++){let r0=o[S0];if(Q0=G0[r0],!Q0)Q0=G0[r0]=Object.create(null);G0=Q0}G0[g7]=n+64}this.lastNamedStructuresLength=u}if(!W)$.nextId=u+64}if(Y)Y=!1;let y;try{if(G.randomAccessStructure&&I&&I.constructor&&I.constructor===Object)x(I);else R(I);let u=J8;if(J8)u40(X,R,0);if(Q&&Q.idsToInsert){let n=Q.idsToInsert.sort((S0,v0)=>S0.offset>v0.offset?1:-1),o=n.length,Q0=-1;while(u&&o>0){let S0=n[--o].offset+X;if(S0<u.stringsPosition+X&&Q0===-1)Q0=0;if(S0>u.position+X){if(Q0>=0)Q0+=6}else{if(Q0>=0)b1.setUint32(u.position+X,b1.getUint32(u.position+X)+Q0),Q0=-1;u=u.previous,o++}}if(Q0>=0&&u)b1.setUint32(u.position+X,b1.getUint32(u.position+X)+Q0);if(d+=n.length*6,d>K5)E(d);G.offset=d;let G0=hb1(p.subarray(X,d),n);return Q=null,G0}if(G.offset=d,_&bb1)return p.start=X,p.end=d,p;return p.subarray(X,d)}catch(u){throw y=u,u}finally{if($){if(O(),Y&&G.saveStructures){let u=$.sharedLength||0,n=p.subarray(X,d),o=p40($,G);if(!y){if(G.saveStructures(o,o.isCompatible)===!1)return G.pack(I,_);if(G.lastNamedStructuresLength=u,p.length>1073741824)p=null;return n}}}if(p.length>1073741824)p=null;if(_&gb1)d=X}};let O=()=>{if(w<10)w++;let I=$.sharedLength||0;if($.length>I&&!W)$.length=I;if(L>1e4){if($.transitions=null,w=0,L=0,B.length>0)B=[]}else if(B.length>0&&!W){for(let _=0,y=B.length;_<y;_++)B[_][g7]=0;B=[]}},M=(I)=>{var _=I.length;if(_<16)p[d++]=144|_;else if(_<65536)p[d++]=220,p[d++]=_>>8,p[d++]=_&255;else p[d++]=221,b1.setUint32(d,_),d+=4;for(let y=0;y<_;y++)R(I[y])},R=(I)=>{if(d>K5)p=E(d);var _=typeof I,y;if(_==="string"){let u=I.length;if(J8&&u>=4&&u<4096){if((J8.size+=u)>vb1){let G0,S0=(J8[0]?J8[0].length*3+J8[1].length:0)+10;if(d+S0>K5)p=E(d+S0);let v0;if(J8.position)v0=J8,p[d]=200,d+=3,p[d++]=98,G0=d-X,d+=4,u40(X,R,0),b1.setUint16(G0+X-3,d-X-G0);else p[d++]=214,p[d++]=98,G0=d-X,d+=4;J8=["",""],J8.previous=v0,J8.size=0,J8.position=G0}let Q0=Ab1.test(I);J8[Q0?0:1]+=I,p[d++]=193,R(Q0?-u:u);return}let n;if(u<32)n=1;else if(u<256)n=2;else if(u<65536)n=3;else n=5;let o=u*3;if(d+o>K5)p=E(d+o);if(u<64||!K){let Q0,G0,S0,v0=d+n;for(Q0=0;Q0<u;Q0++)if(G0=I.charCodeAt(Q0),G0<128)p[v0++]=G0;else if(G0<2048)p[v0++]=G0>>6|192,p[v0++]=G0&63|128;else if((G0&64512)===55296&&((S0=I.charCodeAt(Q0+1))&64512)===56320)G0=65536+((G0&1023)<<10)+(S0&1023),Q0++,p[v0++]=G0>>18|240,p[v0++]=G0>>12&63|128,p[v0++]=G0>>6&63|128,p[v0++]=G0&63|128;else p[v0++]=G0>>12|224,p[v0++]=G0>>6&63|128,p[v0++]=G0&63|128;y=v0-d-n}else y=K(I,d+n);if(y<32)p[d++]=160|y;else if(y<256){if(n<2)p.copyWithin(d+2,d+1,d+1+y);p[d++]=217,p[d++]=y}else if(y<65536){if(n<3)p.copyWithin(d+3,d+2,d+2+y);p[d++]=218,p[d++]=y>>8,p[d++]=y&255}else{if(n<5)p.copyWithin(d+5,d+3,d+3+y);p[d++]=219,b1.setUint32(d,y),d+=4}d+=y}else if(_==="number")if(I>>>0===I)if(I<32||I<128&&this.useRecords===!1||I<64&&!this.randomAccessStructure)p[d++]=I;else if(I<256)p[d++]=204,p[d++]=I;else if(I<65536)p[d++]=205,p[d++]=I>>8,p[d++]=I&255;else p[d++]=206,b1.setUint32(d,I),d+=4;else if(I>>0===I)if(I>=-32)p[d++]=256+I;else if(I>=-128)p[d++]=208,p[d++]=I+256;else if(I>=-32768)p[d++]=209,b1.setInt16(d,I),d+=2;else p[d++]=210,b1.setInt32(d,I),d+=4;else{let u;if((u=this.useFloat32)>0&&I<4294967296&&I>=-2147483648){p[d++]=202,b1.setFloat32(d,I);let n;if(u<4||(n=I*h$[(p[d]&127)<<1|p[d+1]>>7])>>0===n){d+=4;return}else d--}p[d++]=203,b1.setFloat64(d,I),d+=8}else if(_==="object"||_==="function")if(!I)p[d++]=192;else{if(Q){let n=Q.get(I);if(n){if(!n.id){let o=Q.idsToInsert||(Q.idsToInsert=[]);n.id=o.push(n)}p[d++]=214,p[d++]=112,b1.setUint32(d,n.id),d+=4;return}else Q.set(I,{offset:d-X})}let u=I.constructor;if(u===Object)T(I);else if(u===Array)M(I);else if(u===Map)if(this.mapAsEmptyObject)p[d++]=128;else{if(y=I.size,y<16)p[d++]=128|y;else if(y<65536)p[d++]=222,p[d++]=y>>8,p[d++]=y&255;else p[d++]=223,b1.setUint32(d,y),d+=4;for(let[n,o]of I)R(n),R(o)}else{for(let n=0,o=h_.length;n<o;n++){let Q0=d40[n];if(I instanceof Q0){let G0=h_[n];if(G0.write){if(G0.type)p[d++]=212,p[d++]=G0.type,p[d++]=0;let r1=G0.write.call(this,I);if(r1===I)if(Array.isArray(I))M(I);else T(I);else R(r1);return}let S0=p,v0=b1,r0=d;p=null;let A8;try{A8=G0.pack.call(this,I,(r1)=>{if(p=S0,S0=null,d+=r1,d>K5)E(d);return{target:p,targetView:b1,position:d-r1}},R)}finally{if(S0)p=S0,b1=v0,d=r0,K5=p.length-10}if(A8){if(A8.length+d>K5)E(A8.length+d);d=xb1(A8,p,d,G0.type)}return}}if(Array.isArray(I))M(I);else{if(I.toJSON){let n=I.toJSON();if(n!==I)return R(n)}if(_==="function")return R(this.writeFunction&&this.writeFunction(I));T(I)}}}else if(_==="boolean")p[d++]=I?195:194;else if(_==="bigint"){if(I<9223372036854776000&&I>=-9223372036854776000)p[d++]=211,b1.setBigInt64(d,I);else if(I<18446744073709552000&&I>0)p[d++]=207,b1.setBigUint64(d,I);else if(this.largeBigIntToFloat)p[d++]=203,b1.setFloat64(d,Number(I));else if(this.largeBigIntToString)return R(I.toString());else if((this.useBigIntExtension||this.moreTypes)&&I<BigInt(2)**BigInt(1023)&&I>-(BigInt(2)**BigInt(1023))){p[d++]=199,d++,p[d++]=66;let u=[],n;do{let o=I&BigInt(255);n=(o&BigInt(128))===(I<BigInt(0)?BigInt(128):BigInt(0)),u.push(o),I>>=BigInt(8)}while(!((I===BigInt(0)||I===BigInt(-1))&&n));p[d-2]=u.length;for(let o=u.length;o>0;)p[d++]=Number(u[--o]);return}else throw new RangeError(I+" 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");d+=8}else if(_==="undefined")if(this.encodeUndefinedAsNil)p[d++]=192;else p[d++]=212,p[d++]=0,p[d++]=0;else throw new Error("Unknown type: "+_)},D=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?(I)=>{let _;if(this.skipValues){_=[];for(let n in I)if((typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(n))&&!this.skipValues.includes(I[n]))_.push(n)}else _=Object.keys(I);let y=_.length;if(y<16)p[d++]=128|y;else if(y<65536)p[d++]=222,p[d++]=y>>8,p[d++]=y&255;else p[d++]=223,b1.setUint32(d,y),d+=4;let u;if(this.coercibleKeyAsNumber)for(let n=0;n<y;n++){u=_[n];let o=Number(u);R(isNaN(o)?u:o),R(I[u])}else for(let n=0;n<y;n++)R(u=_[n]),R(I[u])}:(I)=>{p[d++]=222;let _=d-X;d+=2;let y=0;for(let u in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(u))R(u),R(I[u]),y++;if(y>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');p[_+++X]=y>>8,p[_+X]=y&255},N=this.useRecords===!1?D:Z.progressiveRecords&&!z?(I)=>{let _,y=$.transitions||($.transitions=Object.create(null)),u=d++-X,n;for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o)){if(_=y[o],_)y=_;else{let Q0=Object.keys(I),G0=y;y=$.transitions;let S0=0;for(let v0=0,r0=Q0.length;v0<r0;v0++){let A8=Q0[v0];if(_=y[A8],!_)_=y[A8]=Object.create(null),S0++;y=_}if(u+X+1==d)d--,A(y,Q0,S0);else S(y,Q0,u,S0);n=!0,y=G0[o]}R(I[o])}if(!n){let o=y[g7];if(o)p[u+X]=o;else S(y,Object.keys(I),u,0)}}:(I)=>{let _,y=$.transitions||($.transitions=Object.create(null)),u=0;for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o)){if(_=y[o],!_)_=y[o]=Object.create(null),u++;y=_}let n=y[g7];if(n)if(n>=96&&z)p[d++]=((n-=96)&31)+96,p[d++]=n>>5;else p[d++]=n;else A(y,y.__keys__||Object.keys(I),u);for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o))R(I[o])},C=typeof this.useRecords=="function"&&this.useRecords,T=C?(I)=>{C(I)?N(I):D(I)}:N,E=(I)=>{let _;if(I>16777216){if(I-X>m40)throw new Error("Packed buffer would be larger than maximum buffer size");_=Math.min(m40,Math.round(Math.max((I-X)*(I>67108864?1.25:2),4194304)/4096)*4096)}else _=(Math.max(I-X<<2,p.length-1)>>12)+1<<12;let y=new Uj(_);if(b1=y.dataView||(y.dataView=new DataView(y.buffer,0,_)),I=Math.min(I,p.length),p.copy)p.copy(y,0,X,I);else y.set(p.slice(X,I));return d-=X,X=0,K5=y.length-10,p=y},A=(I,_,y)=>{let u=$.nextId;if(!u)u=64;if(u<q&&this.shouldShareStructure&&!this.shouldShareStructure(_)){if(u=$.nextOwnId,!(u<U))u=q;$.nextOwnId=u+1}else{if(u>=U)u=q;$.nextId=u+1}let n=_.highByte=u>=96&&z?u-96>>5:-1;if(I[g7]=u,I.__keys__=_,$[u-64]=_,u<q)if(_.isShared=!0,$.sharedLength=u-63,Y=!0,n>=0)p[d++]=(u&31)+96,p[d++]=n;else p[d++]=u;else{if(n>=0)p[d++]=213,p[d++]=114,p[d++]=(u&31)+96,p[d++]=n;else p[d++]=212,p[d++]=114,p[d++]=u;if(y)L+=w*y;if(B.length>=F)B.shift()[g7]=0;B.push(I),R(_)}},S=(I,_,y,u)=>{let n=p,o=d,Q0=K5,G0=X;if(p=Fz,d=0,X=0,!p)Fz=p=new Uj(8192);K5=p.length-10,A(I,_,u),Fz=p;let S0=d;if(p=n,d=o,K5=Q0,X=G0,S0>1){let v0=d+S0-1;if(v0>K5)E(v0);let r0=y+X;p.copyWithin(r0+S0,r0+1,d),p.set(Fz.slice(0,S0),r0),d=v0}else p[y+X]=Fz[0]},x=(I)=>{let _=l40(I,p,X,d,$,E,(y,u,n)=>{if(n)return Y=!0;d=u;let o=p;if(R(y),O(),o!==p)return{position:d,targetView:b1,target:p};return d},this);if(_===0)return T(I);d=_}}useBuffer(Z){p=Z,p.dataView||(p.dataView=new DataView(p.buffer,p.byteOffset,p.byteLength)),d=0}set position(Z){d=Z}get position(){return d}clearSharedData(){if(this.structures)this.structures=[];if(this.typedStructs)this.typedStructs=[]}}d40=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Fj];h_=[{pack(Z,J,X){let Y=Z.getTime()/1000;if((this.useTimestamp32||Z.getMilliseconds()===0)&&Y>=0&&Y<4294967296){let{target:$,targetView:Q,position:K}=J(6);$[K++]=214,$[K++]=255,Q.setUint32(K,Y)}else if(Y>0&&Y<4294967296){let{target:$,targetView:Q,position:K}=J(10);$[K++]=215,$[K++]=255,Q.setUint32(K,Z.getMilliseconds()*4000000+(Y/1000/4294967296>>0)),Q.setUint32(K+4,Y)}else if(isNaN(Y)){if(this.onInvalidDate)return J(0),X(this.onInvalidDate());let{target:$,targetView:Q,position:K}=J(3);$[K++]=212,$[K++]=255,$[K++]=255}else{let{target:$,targetView:Q,position:K}=J(15);$[K++]=199,$[K++]=12,$[K++]=255,Q.setUint32(K,Z.getMilliseconds()*1e6),Q.setBigInt64(K+4,BigInt(Math.floor(Y)))}}},{pack(Z,J,X){if(this.setAsEmptyObject)return J(0),X({});let Y=Array.from(Z),{target:$,position:Q}=J(this.moreTypes?3:0);if(this.moreTypes)$[Q++]=212,$[Q++]=115,$[Q++]=0;X(Y)}},{pack(Z,J,X){let{target:Y,position:$}=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:Y,position:$}=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)A_(Z,16,J);else x_(qz?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let X=Z.constructor;if(X!==c40&&this.moreTypes)A_(Z,v_.indexOf(X.name),J);else x_(Z,J)}},{pack(Z,J){if(this.moreTypes)A_(Z,17,J);else x_(qz?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let{target:X,position:Y}=J(1);X[Y]=193}}];function A_(Z,J,X,Y){let $=Z.byteLength;if($+1<256){var{target:Q,position:K}=X(4+$);Q[K++]=199,Q[K++]=$+1}else if($+1<65536){var{target:Q,position:K}=X(5+$);Q[K++]=200,Q[K++]=$+1>>8,Q[K++]=$+1&255}else{var{target:Q,position:K,targetView:G}=X(7+$);Q[K++]=201,G.setUint32(K,$+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 x_(Z,J){let X=Z.byteLength;var Y,$;if(X<256){var{target:Y,position:$}=J(X+2);Y[$++]=196,Y[$++]=X}else if(X<65536){var{target:Y,position:$}=J(X+3);Y[$++]=197,Y[$++]=X>>8,Y[$++]=X&255}else{var{target:Y,position:$,targetView:Q}=J(X+5);Y[$++]=198,Q.setUint32($,X),$+=4}Y.set(Z,$)}function xb1(Z,J,X,Y){let $=Z.length;switch($){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($<256)J[X++]=199,J[X++]=$;else if($<65536)J[X++]=200,J[X++]=$>>8,J[X++]=$&255;else J[X++]=201,J[X++]=$>>24,J[X++]=$>>16&255,J[X++]=$>>8&255,J[X++]=$&255}return J[X++]=Y,J.set(Z,X),X+=$,X}function hb1(Z,J){let X,Y=J.length*6,$=Z.length-Y;while(X=J.pop()){let{offset:Q,id:K}=X;Z.copyWithin(Q+Y,Q,$),Y-=6;let G=Q+Y;Z[G++]=214,Z[G++]=105,Z[G++]=K>>24,Z[G++]=K>>16&255,Z[G++]=K>>8&255,Z[G++]=K&255,$=Q}return Z}function u40(Z,J,X){if(J8.length>0){b1.setUint32(J8.position+Z,d+X-J8.position-Z),J8.stringsPosition=d-Z;let Y=J8;J8=null,J(Y[0]),J(Y[1])}}function p40(Z,J){return Z.isCompatible=(X)=>{let Y=!X||(J.lastNamedStructuresLength||0)===X.length;if(!Y)J._mergeStructures(X);return Y},Z}function i40(Z,J){l40=Z,p40=J}var n40=new f$({useRecords:!1}),fb1=n40.pack,yb1=n40.pack;var bb1=512,gb1=1024,mb1=2048;var f_=3,xG=0,Uz=2,Bj=1,b_=16,s40=["num","object","string","ascii"];s40[b_]="date";var db1=[!1,!0,!0,!1,!1,!0,!0,!1],o40;try{new Function(""),o40=!0}catch(Z){}var y$,cb1=typeof Buffer!=="undefined",wj,m7;try{wj=new TextEncoder}catch(Z){}var lb1=cb1?function(Z,J,X){return Z.utf8Write(J,X,Z.byteLength-X)}:wj&&wj.encodeInto?function(Z,J,X){return wj.encodeInto(J,Z.subarray(X)).written}:!1,Uu6=Symbol("type"),Lu6=Symbol("parent");i40(r40,sb1);function r40(Z,J,X,Y,$,Q,K,G){let W=G.typedStructs||(G.typedStructs=[]),H=J.dataView,V=(W.lastStringStart||100)+Y,F=J.length-10,z=Y;if(Y>F)J=Q(Y),H=J.dataView,Y-=X,z-=X,V-=X,X=0,F=J.length-10;let q,U=V,B=W.transitions||(W.transitions=Object.create(null)),L=W.nextId||W.length,w=L<15?1:L<240?2:L<61440?3:L<15728640?4:0;if(w===0)return 0;Y+=w;let O=[],M,R=0;for(let N in Z){let C=Z[N],T=B[N];if(!T)B[N]=T={key:N,parent:B,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};if(Y>F)J=Q(Y),H=J.dataView,Y-=X,z-=X,V-=X,U-=X,X=0,F=J.length-10;switch(typeof C){case"number":let E=C;if(L<200||!T.num64){if(E>>0===E&&E<536870912&&E>-520093696){if(E<246&&E>=0&&(T.num8&&!(L>200&&T.num32)||E<32&&!T.num32))B=T.num8||b5(T,xG,1),J[Y++]=E;else B=T.num32||b5(T,xG,4),H.setUint32(Y,E,!0),Y+=4;break}else if(E<4294967296&&E>=-2147483648){if(H.setFloat32(Y,E,!0),db1[J[Y+3]>>>5]){let I;if((I=E*h$[(J[Y+3]&127)<<1|J[Y+2]>>7])>>0===I){B=T.num32||b5(T,xG,4),Y+=4;break}}}}B=T.num64||b5(T,xG,8),H.setFloat64(Y,E,!0),Y+=8;break;case"string":let A=C.length;if(q=U-V,(A<<2)+U>F)J=Q((A<<2)+U),H=J.dataView,Y-=X,z-=X,V-=X,U-=X,X=0,F=J.length-10;if(A>65280+q>>2){O.push(N,C,Y-z);break}let S,x=U;if(A<64){let I,_,y;for(I=0;I<A;I++)if(_=C.charCodeAt(I),_<128)J[U++]=_;else if(_<2048)S=!0,J[U++]=_>>6|192,J[U++]=_&63|128;else if((_&64512)===55296&&((y=C.charCodeAt(I+1))&64512)===56320)S=!0,_=65536+((_&1023)<<10)+(y&1023),I++,J[U++]=_>>18|240,J[U++]=_>>12&63|128,J[U++]=_>>6&63|128,J[U++]=_&63|128;else S=!0,J[U++]=_>>12|224,J[U++]=_>>6&63|128,J[U++]=_&63|128}else U+=lb1(J,C,U),S=U-x>A;if(q<160||q<246&&(T.ascii8||T.string8)){if(S){if(!(B=T.string8))if(W.length>10&&(B=T.ascii8))B.__type=Uz,T.ascii8=null,T.string8=B,K(null,0,!0);else B=b5(T,Uz,1)}else if(q===0&&!M){M=!0,B=T.ascii0||b5(T,f_,0);break}else if(!(B=T.ascii8)&&!(W.length>10&&(B=T.string8)))B=b5(T,f_,1);J[Y++]=q}else B=T.string16||b5(T,Uz,2),H.setUint16(Y,q,!0),Y+=2;break;case"object":if(C){if(C.constructor===Date)B=T.date64||b5(T,b_,8),H.setFloat64(Y,C.getTime(),!0),Y+=8;else O.push(N,C,R);break}else if(T=a40(T,Y,H,-10),T)B=T,Y=y$;else O.push(N,C,R);break;case"boolean":B=T.num8||T.ascii8||b5(T,xG,1),J[Y++]=C?249:248;break;case"undefined":if(T=a40(T,Y,H,-9),T)B=T,Y=y$;else O.push(N,C,R);break;default:O.push(N,C,R)}R++}for(let N=0,C=O.length;N<C;){let T=O[N++],E=O[N++],A=O[N++],S=B[T];if(!S)B[T]=S={key:T,parent:B,enumerationOffset:A-R,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null};let x;if(E){let I;if(q=U-V,q<65280)if(B=S.object16,B)I=2;else if(B=S.object32)I=4;else B=b5(S,Bj,2),I=2;else B=S.object32||b5(S,Bj,4),I=4;if(x=K(E,U),typeof x==="object")U=x.position,H=x.targetView,J=x.target,V-=X,Y-=X,z-=X,X=0;else U=x;if(I===2)H.setUint16(Y,q,!0),Y+=2;else H.setUint32(Y,q,!0),Y+=4}else B=S.object16||b5(S,Bj,2),H.setInt16(Y,E===null?-10:-9,!0),Y+=2;R++}let D=B[g7];if(D==null){D=G.typedStructs.length;let N=[],C=B,T,E;while((E=C.__type)!==void 0){let A=C.__size;C=C.__parent,T=C.key;let S=[E,A,T];if(C.enumerationOffset)S.push(C.enumerationOffset);N.push(S),C=C.parent}N.reverse(),B[g7]=D,G.typedStructs[D]=N,K(null,0,!0)}switch(w){case 1:if(D>=16)return 0;J[z]=D+32;break;case 2:if(D>=256)return 0;J[z]=56,J[z+1]=D;break;case 3:if(D>=65536)return 0;J[z]=57,H.setUint16(z+1,D,!0);break;case 4:if(D>=16777216)return 0;H.setUint32(z,(D<<8)+58,!0);break}if(Y<V){if(V===U)return Y;J.copyWithin(Y,V,U),U+=Y-V,W.lastStringStart=Y-z}else if(Y>V){if(V===U)return Y;return W.lastStringStart=Y-z,r40(Z,J,X,z,$,Q,K,G)}return U}function a40(Z,J,X,Y){let $;if($=Z.ascii8||Z.num8)return X.setInt8(J,Y,!0),y$=J+1,$;if($=Z.string16||Z.object16)return X.setInt16(J,Y,!0),y$=J+2,$;if($=Z.num32)return X.setUint32(J,3758096640+Y,!0),y$=J+4,$;if($=Z.num64)return X.setFloat64(J,NaN,!0),X.setInt8(J,Y),y$=J+8,$;y$=J;return}function b5(Z,J,X){let Y=s40[J]+(X<<3),$=Z[Y]||(Z[Y]=Object.create(null));return $.__type=J,$.__size=X,$.__parent=Z,$}function pb1(Z){if(!(Z instanceof Map))return Z;let J=Z.get("typed")||[];if(Object.isFrozen(J))J=J.map(($)=>$.slice(0));let X=Z.get("named"),Y=Object.create(null);for(let $=0,Q=J.length;$<Q;$++){let K=J[$],G=Y;for(let[W,H,V]of K){let F=G[V];if(!F)G[V]=F={key:V,parent:G,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};G=b5(F,W,H)}G[g7]=$}return J.transitions=Y,this.typedStructs=J,this.lastTypedStructuresLength=J.length,X}var y_=Symbol.for("source");function ib1(Z,J,X,Y){let $=Z[J++]-32;if($>=24)switch($){case 24:$=Z[J++];break;case 25:$=Z[J++]+(Z[J++]<<8);break;case 26:$=Z[J++]+(Z[J++]<<8)+(Z[J++]<<16);break;case 27:$=Z[J++]+(Z[J++]<<8)+(Z[J++]<<16)+(Z[J++]<<24);break}let Q=Y.typedStructs&&Y.typedStructs[$];if(!Q){if(Z=Uint8Array.prototype.slice.call(Z,J,X),X-=J,J=0,!Y.getStructures)throw new Error(`Reference to shared structure ${$} without getStructures method`);if(Y._mergeStructures(Y.getStructures()),!Y.typedStructs)throw new Error("Could not find any shared typed structures");if(Y.lastTypedStructuresLength=Y.typedStructs.length,Q=Y.typedStructs[$],!Q)throw new Error("Could not find typed structure "+$)}var{construct:K,fullConstruct:G}=Q;if(!K){K=Q.construct=function q(){},G=Q.fullConstruct=function q(){},G.prototype=Y.structPrototype??{};var W=K.prototype=Y.structPrototype?Object.create(Y.structPrototype):{};let V=[],F=0,z;for(let q=0,U=Q.length;q<U;q++){let B=Q[q],[L,w,O,M]=B;if(O==="__proto__")O="__proto_";let R={key:O,offset:F};if(M)V.splice(q+M,0,R);else V.push(R);let D;switch(w){case 0:D=()=>0;break;case 1:D=(C,T)=>{let E=C.bytes[T+R.offset];return E>=246?AG(E):E};break;case 2:D=(C,T)=>{let E=C.bytes,S=(E.dataView||(E.dataView=new DataView(E.buffer,E.byteOffset,E.byteLength))).getUint16(T+R.offset,!0);return S>=65280?AG(S&255):S};break;case 4:D=(C,T)=>{let E=C.bytes,S=(E.dataView||(E.dataView=new DataView(E.buffer,E.byteOffset,E.byteLength))).getUint32(T+R.offset,!0);return S>=4294967040?AG(S&255):S};break}R.getRef=D,F+=w;let N;switch(L){case f_:if(z&&!z.next)z.next=R;z=R,R.multiGetCount=0,N=function(C){let{bytes:T,position:E}=C,A=F+E,S=D(C,E);if(typeof S!=="number")return S;let x,I=R.next;while(I){if(x=I.getRef(C,E),typeof x==="number")break;else x=null;I=I.next}if(x==null)x=C.bytesEnd-A;if(C.srcString)return C.srcString.slice(S,x);return x40(T,S+A,x-S)};break;case Uz:case Bj:if(z&&!z.next)z.next=R;z=R,N=function(C){let T=C.position,E=F+T,A=D(C,T);if(typeof A!=="number")return A;let S=C.bytes,x,I=R.next;while(I){if(x=I.getRef(C,T),typeof x==="number")break;else x=null;I=I.next}if(x==null)x=C.bytesEnd-E;if(L===Uz)return S.toString("utf8",A+E,x+E);else{m7=C;try{return Y.unpack(S,{start:A+E,end:x+E})}finally{m7=null}}};break;case xG:switch(w){case 4:N=function(C){let T=C.bytes,E=T.dataView||(T.dataView=new DataView(T.buffer,T.byteOffset,T.byteLength)),A=C.position+R.offset,S=E.getInt32(A,!0);if(S<536870912){if(S>-520093696)return S;if(S>-536870912)return AG(S&255)}let x=E.getFloat32(A,!0),I=h$[(T[A+3]&127)<<1|T[A+2]>>7];return(I*x+(x>0?0.5:-0.5)>>0)/I};break;case 8:N=function(C){let T=C.bytes,A=(T.dataView||(T.dataView=new DataView(T.buffer,T.byteOffset,T.byteLength))).getFloat64(C.position+R.offset,!0);if(isNaN(A)){let S=T[C.position+R.offset];if(S>=246)return AG(S)}return A};break;case 1:N=function(C){let E=C.bytes[C.position+R.offset];return E<246?E:AG(E)};break}break;case b_:N=function(C){let T=C.bytes,E=T.dataView||(T.dataView=new DataView(T.buffer,T.byteOffset,T.byteLength));return new Date(E.getFloat64(C.position+R.offset,!0))};break}R.get=N}if(o40){let q=[],U=[],B=0,L;for(let O of V){if(Y.alwaysLazyProperty&&Y.alwaysLazyProperty(O.key)){L=!0;continue}Object.defineProperty(W,O.key,{get:nb1(O.get),enumerable:!0});let M="v"+B++;U.push(M),q.push("o["+JSON.stringify(O.key)+"]="+M+"(s)")}if(L)q.push("__proto__:this");let w=new Function(...U,"var c=this;return function(s){var o=new c();"+q.join(";")+";return o;}").apply(G,V.map((O)=>O.get));Object.defineProperty(W,"toJSON",{value(O){return w.call(this,this[y_])}})}else Object.defineProperty(W,"toJSON",{value(q){let U={};for(let B=0,L=V.length;B<L;B++){let w=V[B].key;U[w]=this[w]}return U}})}var H=new K;return H[y_]={bytes:Z,position:J,srcString:"",bytesEnd:X},H}function AG(Z){switch(Z){case 246:return null;case 247:return;case 248:return!1;case 249:return!0}throw new Error("Unknown constant")}function nb1(Z){return function(){return Z(this[y_])}}function ab1(){if(m7)m7.bytes=Uint8Array.prototype.slice.call(m7.bytes,m7.position,m7.bytesEnd),m7.position=0,m7.bytesEnd=m7.bytes.length}function sb1(Z,J){if(J.typedStructs){let Y=new Map;Y.set("named",Z),Y.set("typed",J.typedStructs),Z=Y}let X=J.lastTypedStructuresLength||0;return Z.isCompatible=(Y)=>{let $=!0;if(Y instanceof Map){if((Y.get("named")||[]).length!==(J.lastNamedStructuresLength||0))$=!1;if((Y.get("typed")||[]).length!==X)$=!1}else if(Y instanceof Array||Array.isArray(Y)){if(Y.length!==(J.lastNamedStructuresLength||0))$=!1}if(!$)J._mergeStructures(Y);return $},J.lastTypedStructuresLength=J.typedStructs&&J.typedStructs.length,Z}g40(ib1,pb1,ab1);var tb1=process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED!==void 0&&process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase()==="true";if(!tb1){let Z;try{if(Z=m("msgpackr-extract"),Z)A40(Z.extractStrings)}catch(J){}}var DO=r(SK0(),1);import po1 from"http";import io1 from"https";import PO from"fs";import no1 from"path";import ao1 from"url";var vK0=`-----BEGIN CERTIFICATE-----
416
416
  MIIDRjCCAi6gAwIBAgIFOTEzNTIwDQYJKoZIhvcNAQELBQAwWDEQMA4GA1UEAxMH
417
417
  SFlUT1BJQTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNV
@@ -457,7 +457,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
457
457
  xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
458
458
  6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
459
459
  0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
460
- -----END RSA PRIVATE KEY-----`;var av=process.env.PORT??8080,sv="0.8.2",ov;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(ov||={});class FW extends O0{static instance=new FW;_webserver=DO.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:sv,runtime:"Bun"in globalThis?"bun":("Deno"in globalThis)?"deno":"node"})}),this._webserver.use(DO.default.static("assets"));try{this._webserver.use(DO.default.static(no1.dirname(m.resolve("@hytopia.com/assets"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?po1.createServer(this._webserver):io1.createServer({key:PO.existsSync("assets/certs/localhost.key")?PO.readFileSync("assets/certs/localhost.key"):AK0,cert:PO.existsSync("assets/certs/localhost.crt")?PO.readFileSync("assets/certs/localhost.crt"):vK0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else c.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(av,this._onStarted),console.info(`WebServer.start(): Server running on port ${av}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return c.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let Y=ao1.parse(Z.url??"",!0).query,$=Y.connectionId?.toString(),Q=Y.sessionToken?.toString()??"";if($&&a7.instance.isValidConnectionId($))Z.connectionId=$;else{let K=await f7.instance.getPlayerSession(Q);if(K?.error){let G=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
460
+ -----END RSA PRIVATE KEY-----`;var av=process.env.PORT??8080,sv="0.8.3",ov;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(ov||={});class FW extends O0{static instance=new FW;_webserver=DO.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:sv,runtime:"Bun"in globalThis?"bun":("Deno"in globalThis)?"deno":"node"})}),this._webserver.use(DO.default.static("assets"));try{this._webserver.use(DO.default.static(no1.dirname(m.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?po1.createServer(this._webserver):io1.createServer({key:PO.existsSync("assets/certs/localhost.key")?PO.readFileSync("assets/certs/localhost.key"):AK0,cert:PO.existsSync("assets/certs/localhost.crt")?PO.readFileSync("assets/certs/localhost.crt"):vK0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else c.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(av,this._onStarted),console.info(`WebServer.start(): Server running on port ${av}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return c.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let Y=ao1.parse(Z.url??"",!0).query,$=Y.connectionId?.toString(),Q=Y.sessionToken?.toString()??"";if($&&a7.instance.isValidConnectionId($))Z.connectionId=$;else{let K=await f7.instance.getPlayerSession(Q);if(K?.error){let G=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
461
461
  Content-Type: text/plain\r
462
462
  Content-Length: ${G.length}\r
463
463
  Connection: close\r