hytopia 0.10.42 → 0.10.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/server.mjs CHANGED
@@ -396,7 +396,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
396
396
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
397
397
  if (condition) { yield value; }`)};import{Buffer as Tq1}from"node:buffer";import{StringDecoder as Cq1}from"node:string_decoder";var VF=(Z,J,X)=>{if(X)return;if(Z)return{transform:fq1.bind(void 0,new TextEncoder)};let Y=new Cq1(J);return{transform:kq1.bind(void 0,Y),final:Eq1.bind(void 0,Y)}},fq1=function*(Z,J){if(Tq1.isBuffer(J))yield s7(J);else if(typeof J==="string")yield Z.encode(J);else yield J},kq1=function*(Z,J){yield _8(J)?Z.write(J):J},Eq1=function*(Z){let J=Z.end();if(J!=="")yield J};import{callbackify as py}from"node:util";var QM=py(async(Z,J,X,Y)=>{J.currentIterable=Z(...X);try{for await(let $ of J.currentIterable)Y.push($)}finally{delete J.currentIterable}}),HF=async function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:Y=_q1}=J[X];for await(let $ of Y(Z))yield*HF($,J,X+1)},iy=async function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*Iq1(X,Number(J),Z)},Iq1=async function*(Z,J,X){if(Z===void 0)return;for await(let Y of Z())yield*HF(Y,X,J+1)},gy=py(async({currentIterable:Z},J)=>{if(Z!==void 0){await(J?Z.throw(J):Z.return());return}if(J)throw J}),_q1=function*(Z){yield Z};var KM=(Z,J,X,Y)=>{try{for(let $ of Z(...J))X.push($);Y()}catch($){Y($)}},dy=(Z,J)=>[...J.flatMap((X)=>[...NY(X,Z,0)]),...eW(Z)],NY=function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:Y=Sq1}=J[X];for(let $ of Y(Z))yield*NY($,J,X+1)},eW=function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*hq1(X,Number(J),Z)},hq1=function*(Z,J,X){if(Z===void 0)return;for(let Y of Z())yield*NY(Y,X,J+1)},Sq1=function*(Z){yield Z};var WM=({value:Z,value:{transform:J,final:X,writableObjectMode:Y,readableObjectMode:$},optionName:Q},{encoding:K})=>{let W={},G=ny(Z,K,Q),z=RY(J),v=RY(X),H=z?QM.bind(void 0,HF,W):KM.bind(void 0,NY),V=z||v?QM.bind(void 0,iy,W):KM.bind(void 0,eW),q=z||v?gy.bind(void 0,W):void 0;return{stream:new bq1({writableObjectMode:Y,writableHighWaterMark:ay(Y),readableObjectMode:$,readableHighWaterMark:ay($),transform(w,c,U){H([w,G,0],this,U)},flush(w){V([G],this,w)},destroy:q})}},qF=(Z,J,X,Y)=>{let $=J.filter(({type:K})=>K==="generator"),Q=Y?$.reverse():$;for(let{value:K,optionName:W}of Q){let G=ny(K,X,W);Z=dy(G,Z)}return Z},ny=({transform:Z,final:J,binary:X,writableObjectMode:Y,readableObjectMode:$,preserveNewlines:Q},K,W)=>{let G={};return[{transform:uy(Y,W)},VF(X,K,Y),vF(X,Q,Y,G),{transform:Z,final:J},{transform:ly($,W)},my({binary:X,preserveNewlines:Q,readableObjectMode:$,state:G})].filter(Boolean)};var sy=(Z,J)=>{for(let X of Aq1(Z))mq1(Z,X,J)},Aq1=(Z)=>new Set(Object.entries(Z).filter(([,{direction:J}])=>J==="input").map(([J])=>Number(J))),mq1=(Z,J,X)=>{let{stdioItems:Y}=Z[J],$=Y.filter(({contents:W})=>W!==void 0);if($.length===0)return;if(J!==0){let[{type:W,optionName:G}]=$;throw TypeError(`Only the \`stdin\` option, not \`${G}\`, can be ${kJ[W]} with synchronous methods.`)}let K=$.map(({contents:W})=>W).map((W)=>uq1(W,Y));X.input=gW(K)},uq1=(Z,J)=>{let X=qF(Z,J,"utf8",!0);return lq1(X),gW(X)},lq1=(Z)=>{let J=Z.find((X)=>typeof X!=="string"&&!_8(X));if(J!==void 0)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${J}.`)};import{writeFileSync as gq1,appendFileSync as dq1}from"node:fs";var FF=({stdioItems:Z,encoding:J,verboseInfo:X,fdNumber:Y})=>Y!=="all"&&lQ(X,Y)&&!E5.has(J)&&yq1(Y)&&(Z.some(({type:$,value:Q})=>$==="native"&&pq1.has(Q))||Z.every(({type:$})=>z4.has($))),yq1=(Z)=>Z===1||Z===2,pq1=new Set(["pipe","overlapped"]),oy=async(Z,J,X,Y)=>{for await(let $ of Z)if(!iq1(J))ty($,X,Y)},ry=(Z,J,X)=>{for(let Y of Z)ty(Y,J,X)},iq1=(Z)=>Z._readableState.pipes.length>0,ty=(Z,J,X)=>{let Y=Nq(Z);t9({type:"output",verboseMessage:Y,fdNumber:J,verboseInfo:X})};var ey=({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((G,z)=>aq1({result:G,fileDescriptors:Z,fdNumber:z,state:Q,outputFiles:K,isMaxBuffer:Y,verboseInfo:$},X)),...Q}},aq1=({result:Z,fileDescriptors:J,fdNumber:X,state:Y,outputFiles:$,isMaxBuffer:Q,verboseInfo:K},{buffer:W,encoding:G,lines:z,stripFinalNewline:v,maxBuffer:H})=>{if(Z===null)return;let V=Zy(Z,Q,H),q=s7(V),{stdioItems:F,objectMode:w}=J[X],c=nq1([q],F,G,Y),{serializedResult:U,finalResult:j=U}=sq1({chunks:c,objectMode:w,encoding:G,lines:z,stripFinalNewline:v,fdNumber:X});oq1({serializedResult:U,fdNumber:X,state:Y,verboseInfo:K,encoding:G,stdioItems:F,objectMode:w});let B=W[X]?j:void 0;try{if(Y.error===void 0)rq1(U,F,$);return B}catch(L){return Y.error=L,B}},nq1=(Z,J,X,Y)=>{try{return qF(Z,J,X,!1)}catch($){return Y.error=$,Z}},sq1=({chunks:Z,objectMode:J,encoding:X,lines:Y,stripFinalNewline:$,fdNumber:Q})=>{if(J)return{serializedResult:Z};if(X==="buffer")return{serializedResult:gW(Z)};let K=Fm(Z,X);if(Y[Q])return{serializedResult:K,finalResult:$M(K,!$[Q],J)};return{serializedResult:K}},oq1=({serializedResult:Z,fdNumber:J,state:X,verboseInfo:Y,encoding:$,stdioItems:Q,objectMode:K})=>{if(!FF({stdioItems:Q,encoding:$,verboseInfo:Y,fdNumber:J}))return;let W=$M(Z,!1,K);try{ry(W,J,Y)}catch(G){X.error??=G}},rq1=(Z,J,X)=>{for(let{path:Y,append:$}of J.filter(({type:Q})=>GF.has(Q))){let Q=typeof Y==="string"?Y:Y.toString();if($||X.has(Q))dq1(Y,Z);else X.add(Q),gq1(Y,Z)}};var Zp=([,Z,J],X)=>{if(!X.all)return;if(Z===void 0)return J;if(J===void 0)return Z;if(Array.isArray(Z))return Array.isArray(J)?[...Z,...J]:[...Z,e7(J,X,"all")];if(Array.isArray(J))return[e7(Z,X,"all"),...J];if(_8(Z)&&_8(J))return qD([Z,J]);return`${Z}${J}`};import{once as GM}from"node:events";var Jp=async(Z,J)=>{let[X,Y]=await tq1(Z);return J.isForcefullyTerminated??=!1,[X,Y]},tq1=async(Z)=>{let[J,X]=await Promise.allSettled([GM(Z,"spawn"),GM(Z,"exit")]);if(J.status==="rejected")return[];return X.status==="rejected"?Xp(Z):X.value},Xp=async(Z)=>{try{return await GM(Z,"exit")}catch{return Xp(Z)}},Yp=async(Z)=>{let[J,X]=await Z;if(!eq1(J,X)&&zM(J,X))throw new e9;return[J,X]},eq1=(Z,J)=>Z===void 0&&J===void 0,zM=(Z,J)=>Z!==0||J!==null;var $p=({error:Z,status:J,signal:X,output:Y},{maxBuffer:$})=>{let Q=ZF1(Z,J,X),K=Q?.code==="ETIMEDOUT",W=el(Q,Y,$);return{resultError:Q,exitCode:J,signal:X,timedOut:K,isMaxBuffer:W}},ZF1=(Z,J,X)=>{if(Z!==void 0)return Z;return zM(J,X)?new e9:void 0};var Qp=(Z,J,X)=>{let{file:Y,commandArguments:$,command:Q,escapedCommand:K,startTime:W,verboseInfo:G,options:z,fileDescriptors:v}=XF1(Z,J,X),H=QF1({file:Y,commandArguments:$,options:z,command:Q,escapedCommand:K,verboseInfo:G,fileDescriptors:v,startTime:W});return oQ(H,G,z)},XF1=(Z,J,X)=>{let{command:Y,escapedCommand:$,startTime:Q,verboseInfo:K}=Oq(Z,J,X),W=YF1(X),{file:G,commandArguments:z,options:v}=oq(Z,J,W);$F1(v);let H=hy(v,K);return{file:G,commandArguments:z,command:Y,escapedCommand:$,startTime:Q,verboseInfo:K,options:v,fileDescriptors:H}},YF1=(Z)=>Z.node&&!Z.ipc?{...Z,ipc:!1}:Z,$F1=({ipc:Z,ipcInput:J,detached:X,cancelSignal:Y})=>{if(J)wF("ipcInput");if(Z)wF("ipc: true");if(X)wF("detached: true");if(Y)wF("cancelSignal")},wF=(Z)=>{throw TypeError(`The "${Z}" option cannot be used with synchronous methods.`)},QF1=({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,verboseInfo:Q,fileDescriptors:K,startTime:W})=>{let G=KF1({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,fileDescriptors:K,startTime:W});if(G.failed)return G;let{resultError:z,exitCode:v,signal:H,timedOut:V,isMaxBuffer:q}=$p(G,X),{output:F,error:w=z}=ey({fileDescriptors:K,syncResult:G,options:X,isMaxBuffer:q,verboseInfo:Q}),c=F.map((j,B)=>e7(j,X,B)),U=e7(Zp(F,X),X,"all");return GF1({error:w,exitCode:v,signal:H,timedOut:V,isMaxBuffer:q,stdio:c,all:U,options:X,command:Y,escapedCommand:$,startTime:W})},KF1=({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,fileDescriptors:Q,startTime:K})=>{try{sy(Q,X);let W=WF1(X);return JF1(Z,J,W)}catch(W){return sQ({error:W,command:Y,escapedCommand:$,fileDescriptors:Q,options:X,startTime:K,isSync:!0})}},WF1=({encoding:Z,maxBuffer:J,...X})=>({...X,encoding:"buffer",maxBuffer:$F(J)}),GF1=({error:Z,exitCode:J,signal:X,timedOut:Y,isMaxBuffer:$,stdio:Q,all:K,options:W,command:G,escapedCommand:z,startTime:v})=>Z===void 0?QF({command:G,escapedCommand:z,stdio:Q,all:K,ipcOutput:[],options:W,startTime:v}):tW({error:Z,command:G,escapedCommand:z,timedOut:Y,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:$,isForcefullyTerminated:!1,exitCode:J,signal:X,stdio:Q,all:K,ipcOutput:[],options:W,startTime:v,isSync:!0});import{setMaxListeners as sw1}from"node:events";import{spawn as ow1}from"node:child_process";import vp from"node:process";import{once as vM,on as zF1}from"node:events";var Kp=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y},{reference:$=!0,filter:Q}={})=>{return iQ({methodName:"getOneMessage",isSubprocess:X,ipc:Y,isConnected:iq(Z)}),vF1({anyProcess:Z,channel:J,isSubprocess:X,filter:Q,reference:$})},vF1=async({anyProcess:Z,channel:J,isSubprocess:X,filter:Y,reference:$})=>{uq(J,$);let Q=fJ(Z,J,X),K=new AbortController;try{return await Promise.race([VF1(Q,Y,K),HF1(Q,X,K),qF1(Q,X,K)])}catch(W){throw gQ(Z),W}finally{K.abort(),lq(J,$)}},VF1=async(Z,J,{signal:X})=>{if(J===void 0){let[Y]=await vM(Z,"message",{signal:X});return Y}for await(let[Y]of zF1(Z,"message",{signal:X}))if(J(Y))return Y},HF1=async(Z,J,{signal:X})=>{await vM(Z,"disconnect",{signal:X}),gu(J)},qF1=async(Z,J,{signal:X})=>{let[Y]=await vM(Z,"strict:error",{signal:X});throw bq(Y,J)};import{once as Gp,on as FF1}from"node:events";var zp=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y},{reference:$=!0}={})=>VM({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y,shouldAwait:!X,reference:$}),VM=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y,shouldAwait:$,reference:Q})=>{iQ({methodName:"getEachMessage",isSubprocess:X,ipc:Y,isConnected:iq(Z)}),uq(J,Q);let K=fJ(Z,J,X),W=new AbortController,G={};return wF1(Z,K,W),cF1({ipcEmitter:K,isSubprocess:X,controller:W,state:G}),UF1({anyProcess:Z,channel:J,ipcEmitter:K,isSubprocess:X,shouldAwait:$,controller:W,state:G,reference:Q})},wF1=async(Z,J,X)=>{try{await Gp(J,"disconnect",{signal:X.signal}),X.abort()}catch{}},cF1=async({ipcEmitter:Z,isSubprocess:J,controller:X,state:Y})=>{try{let[$]=await Gp(Z,"strict:error",{signal:X.signal});Y.error=bq($,J),X.abort()}catch{}},UF1=async function*({anyProcess:Z,channel:J,ipcEmitter:X,isSubprocess:Y,shouldAwait:$,controller:Q,state:K,reference:W}){try{for await(let[G]of FF1(X,"message",{signal:Q.signal}))Wp(K),yield G}catch{Wp(K)}finally{if(Q.abort(),lq(J,W),!Y)gQ(Z);if($)await Z}},Wp=({error:Z})=>{if(Z)throw Z};var Vp=(Z,{ipc:J})=>{Object.assign(Z,qp(Z,!1,J))},Hp=()=>{let Z=vp,J=!0,X=vp.channel!==void 0;return{...qp(Z,!0,X),getCancelSignal:xl.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:!0,ipc:X})}},qp=(Z,J,X)=>({sendMessage:nq.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getOneMessage:Kp.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getEachMessage:zp.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X})});import{ChildProcess as xF1}from"node:child_process";import{PassThrough as jF1,Readable as BF1,Writable as LF1,Duplex as DF1}from"node:stream";var Fp=({error:Z,command:J,escapedCommand:X,fileDescriptors:Y,options:$,startTime:Q,verboseInfo:K})=>{JM(Y);let W=new xF1;MF1(W,Y),Object.assign(W,{readable:RF1,writable:NF1,duplex:PF1});let G=sQ({error:Z,command:J,escapedCommand:X,fileDescriptors:Y,options:$,startTime:Q,isSync:!1}),z=OF1(G,K,$);return{subprocess:W,promise:z}},MF1=(Z,J)=>{let X=ZG(),Y=ZG(),$=ZG(),Q=Array.from({length:J.length-3},ZG),K=ZG(),W=[X,Y,$,...Q];Object.assign(Z,{stdin:X,stdout:Y,stderr:$,all:K,stdio:W})},ZG=()=>{let Z=new jF1;return Z.end(),Z},RF1=()=>new BF1({read(){}}),NF1=()=>new LF1({write(){}}),PF1=()=>new DF1({read(){},write(){}}),OF1=async(Z,J,X)=>oQ(Z,J,X);import{createReadStream as wp,createWriteStream as cp}from"node:fs";import{Buffer as TF1}from"node:buffer";import{Readable as JG,Writable as CF1,Duplex as fF1}from"node:stream";var xp=(Z,J)=>zF(kF1,Z,J,!1),XG=({type:Z,optionName:J})=>{throw TypeError(`The \`${J}\` option cannot be ${kJ[Z]}.`)},Up={fileNumber:XG,generator:WM,asyncGenerator:WM,nodeStream:({value:Z})=>({stream:Z}),webTransform({value:{transform:Z,writableObjectMode:J,readableObjectMode:X}}){let Y=J||X;return{stream:fF1.fromWeb(Z,{objectMode:Y})}},duplex:({value:{transform:Z}})=>({stream:Z}),native(){}},kF1={input:{...Up,fileUrl:({value:Z})=>({stream:wp(Z)}),filePath:({value:{file:Z}})=>({stream:wp(Z)}),webStream:({value:Z})=>({stream:JG.fromWeb(Z)}),iterable:({value:Z})=>({stream:JG.from(Z)}),asyncIterable:({value:Z})=>({stream:JG.from(Z)}),string:({value:Z})=>({stream:JG.from(Z)}),uint8Array:({value:Z})=>({stream:JG.from(TF1.from(Z))})},output:{...Up,fileUrl:({value:Z})=>({stream:cp(Z)}),filePath:({value:{file:Z,append:J}})=>({stream:cp(Z,J?{flags:"a"}:{})}),webStream:({value:Z})=>({stream:CF1.fromWeb(Z)}),iterable:XG,asyncIterable:XG,string:XG,uint8Array:XG}};import{on as EF1,once as jp}from"node:events";import{PassThrough as IF1,getDefaultHighWaterMark as _F1}from"node:stream";import{finished as Dp}from"node:stream/promises";function PY(Z){if(!Array.isArray(Z))throw TypeError(`Expected an array, got \`${typeof Z}\`.`);for(let $ of Z)HM($);let J=Z.some(({readableObjectMode:$})=>$),X=hF1(Z,J),Y=new Mp({objectMode:J,writableHighWaterMark:X,readableHighWaterMark:X});for(let $ of Z)Y.add($);return Y}var hF1=(Z,J)=>{if(Z.length===0)return _F1(J);let X=Z.filter(({readableObjectMode:Y})=>Y===J).map(({readableHighWaterMark:Y})=>Y);return Math.max(...X)};class Mp extends IF1{#Z=new Set([]);#J=new Set([]);#Y=new Set([]);#X;#$=Symbol("unpipe");#v=new WeakMap;add(Z){if(HM(Z),this.#Z.has(Z))return;this.#Z.add(Z),this.#X??=SF1(this,this.#Z,this.#$);let J=mF1({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(HM(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 SF1=async(Z,J,X)=>{cF(Z,Bp);let Y=new AbortController;try{await Promise.race([bF1(Z,Y),AF1(Z,J,X,Y)])}finally{Y.abort(),cF(Z,-Bp)}},bF1=async(Z,{signal:J})=>{try{await Dp(Z,{signal:J,cleanup:!0})}catch(X){throw Rp(Z,X),X}},AF1=async(Z,J,X,{signal:Y})=>{for await(let[$]of EF1(Z,"unpipe",{signal:Y}))if(J.has($))$.emit(X)},HM=(Z)=>{if(typeof Z?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof Z}\`.`)},mF1=async({passThroughStream:Z,stream:J,streams:X,ended:Y,aborted:$,onFinished:Q,unpipeEvent:K})=>{cF(Z,Lp);let W=new AbortController;try{await Promise.race([uF1(Q,J,W),lF1({passThroughStream:Z,stream:J,streams:X,ended:Y,aborted:$,controller:W}),yF1({stream:J,streams:X,ended:Y,aborted:$,unpipeEvent:K,controller:W})])}finally{W.abort(),cF(Z,-Lp)}if(X.size>0&&X.size===Y.size+$.size)if(Y.size===0&&$.size>0)qM(Z);else pF1(Z)},uF1=async(Z,J,{signal:X})=>{try{if(await Z,!X.aborted)qM(J)}catch(Y){if(!X.aborted)Rp(J,Y)}},lF1=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(Np(K))$.add(J);else Pp(Z,K)}},yF1=async({stream:Z,streams:J,ended:X,aborted:Y,unpipeEvent:$,controller:{signal:Q}})=>{if(await jp(Z,$,{signal:Q}),!Z.readable)return jp(Q,"abort",{signal:Q});J.delete(Z),X.delete(Z),Y.delete(Z)},pF1=(Z)=>{if(Z.writable)Z.end()},Rp=(Z,J)=>{if(Np(J))qM(Z);else Pp(Z,J)},Np=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",qM=(Z)=>{if(Z.readable||Z.writable)Z.destroy()},Pp=(Z,J)=>{if(!Z.destroyed)Z.once("error",iF1),Z.destroy(J)},iF1=()=>{},cF=(Z,J)=>{let X=Z.getMaxListeners();if(X!==0&&X!==Number.POSITIVE_INFINITY)Z.setMaxListeners(X+J)},Bp=2,Lp=1;import{finished as Op}from"node:stream/promises";var tQ=(Z,J)=>{Z.pipe(J),gF1(Z,J),dF1(Z,J)},gF1=async(Z,J)=>{if(V9(Z)||V9(J))return;try{await Op(Z,{cleanup:!0,readable:!0,writable:!1})}catch{}FM(J)},FM=(Z)=>{if(Z.writable)Z.end()},dF1=async(Z,J)=>{if(V9(Z)||V9(J))return;try{await Op(J,{cleanup:!0,readable:!1,writable:!0})}catch{}wM(Z)},wM=(Z)=>{if(Z.readable)Z.destroy()};var Tp=(Z,J,X)=>{let Y=new Map;for(let[$,{stdioItems:Q,direction:K}]of Object.entries(J)){for(let{stream:W}of Q.filter(({type:G})=>z4.has(G)))aF1(Z,W,K,$);for(let{stream:W}of Q.filter(({type:G})=>!z4.has(G)))sF1({subprocess:Z,stream:W,direction:K,fdNumber:$,pipeGroups:Y,controller:X})}for(let[$,Q]of Y.entries()){let K=Q.length===1?Q[0]:PY(Q);tQ(K,$)}},aF1=(Z,J,X,Y)=>{if(X==="output")tQ(Z.stdio[Y],J);else tQ(J,Z.stdio[Y]);let $=nF1[Y];if($!==void 0)Z[$]=J;Z.stdio[Y]=J},nF1=["stdin","stdout","stderr"],sF1=({subprocess:Z,stream:J,direction:X,fdNumber:Y,pipeGroups:$,controller:Q})=>{if(J===void 0)return;oF1(J,Q);let[K,W]=X==="output"?[J,Z.stdio[Y]]:[Z.stdio[Y],J],G=$.get(K)??[];$.set(K,[...G,W])},oF1=(Z,{signal:J})=>{if(V9(Z))DY(Z,rF1,J)},rF1=2;import{addAbortListener as Zw1}from"node:events";var OY=[];OY.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")OY.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")OY.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var UF=(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",cM=Symbol.for("signal-exit emitter"),UM=globalThis,tF1=Object.defineProperty.bind(Object);class Cp{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(UM[cM])return UM[cM];tF1(UM,cM,{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 jM{}var eF1=(Z)=>{return{onExit(J,X){return Z.onExit(J,X)},load(){return Z.load()},unload(){return Z.unload()}}};class fp extends jM{onExit(){return()=>{}}load(){}unload(){}}class kp extends jM{#Z=xM.platform==="win32"?"SIGINT":"SIGHUP";#J=new Cp;#Y;#X;#$;#v={};#H=!1;constructor(Z){super();this.#Y=Z,this.#v={};for(let J of OY)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(!UF(this.#Y))return()=>{};if(this.#H===!1)this.load();let X=J?.alwaysLast?"afterExit":"exit";return this.#J.on(X,Z),()=>{if(this.#J.removeListener(X,Z),this.#J.listeners.exit.length===0&&this.#J.listeners.afterExit.length===0)this.unload()}}load(){if(this.#H)return;this.#H=!0,this.#J.count+=1;for(let Z of OY)try{let J=this.#v[Z];if(J)this.#Y.on(Z,J)}catch(J){}this.#Y.emit=(Z,...J)=>{return this.#G(Z,...J)},this.#Y.reallyExit=(Z)=>{return this.#W(Z)}}unload(){if(!this.#H)return;this.#H=!1,OY.forEach((Z)=>{let J=this.#v[Z];if(!J)throw 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}#W(Z){if(!UF(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)}#G(Z,...J){let X=this.#X;if(Z==="exit"&&UF(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 xM=globalThis.process,{onExit:Ep,load:kL6,unload:EL6}=eF1(UF(xM)?new kp(xM):new fp);var Ip=(Z,{cleanup:J,detached:X},{signal:Y})=>{if(!J||X)return;let $=Ep(()=>{Z.kill()});Zw1(Y,()=>{$()})};var hp=({source:Z,sourcePromise:J,boundOptions:X,createNested:Y},...$)=>{let Q=Pq(),{destination:K,destinationStream:W,destinationError:G,from:z,unpipeSignal:v}=Jw1(X,Y,$),{sourceStream:H,sourceError:V}=Yw1(Z,z),{options:q,fileDescriptors:F}=J7.get(Z);return{sourcePromise:J,sourceStream:H,sourceOptions:q,sourceError:V,destination:K,destinationStream:W,destinationError:G,unpipeSignal:v,fileDescriptors:F,startTime:Q}},Jw1=(Z,J,X)=>{try{let{destination:Y,pipeOptions:{from:$,to:Q,unpipeSignal:K}={}}=Xw1(Z,J,...X),W=mq(Y,Q);return{destination:Y,destinationStream:W,from:$,unpipeSignal:K}}catch(Y){return{destinationError:Y}}},Xw1=(Z,J,X,...Y)=>{if(Array.isArray(X))return{destination:J(_p,Z)(X,...Y),pipeOptions:Z};if(typeof X==="string"||X instanceof URL||VD(X)){if(Object.keys(Z).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[$,Q,K]=cq(X,...Y);return{destination:J(_p)($,Q,K),pipeOptions:K}}if(J7.has(X)){if(Object.keys(Z).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:X,pipeOptions:Y[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${X}`)},_p=({options:Z})=>({options:{...Z,stdin:"pipe",piped:!0}}),Yw1=(Z,J)=>{try{return{sourceStream:dQ(Z,J)}}catch(X){return{sourceError:X}}};var bp=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y,fileDescriptors:$,sourceOptions:Q,startTime:K})=>{let W=$w1({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y});if(W!==void 0)throw BM({error:W,fileDescriptors:$,sourceOptions:Q,startTime:K})},$w1=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y})=>{if(J!==void 0&&Y!==void 0)return Y;if(Y!==void 0)return wM(Z),Y;if(J!==void 0)return FM(X),J},BM=({error:Z,fileDescriptors:J,sourceOptions:X,startTime:Y})=>sQ({error:Z,command:Sp,escapedCommand:Sp,fileDescriptors:J,options:X,startTime:Y,isSync:!1}),Sp="source.pipe(destination)";var Ap=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 Qw1}from"node:stream/promises";var mp=(Z,J,X)=>{let Y=xF.has(J)?Ww1(Z,J):Kw1(Z,J);return DY(Z,zw1,X.signal),DY(J,vw1,X.signal),Gw1(J),Y},Kw1=(Z,J)=>{let X=PY([Z]);return tQ(X,J),xF.set(J,X),X},Ww1=(Z,J)=>{let X=xF.get(J);return X.add(Z),X},Gw1=async(Z)=>{try{await Qw1(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}xF.delete(Z)},xF=new WeakMap,zw1=2,vw1=1;import{aborted as Vw1}from"node:util";var up=(Z,J)=>Z===void 0?[]:[Hw1(Z,J)],Hw1=async(Z,{sourceStream:J,mergedStream:X,fileDescriptors:Y,sourceOptions:$,startTime:Q})=>{await Vw1(Z,J),await X.remove(J);let K=Error("Pipe canceled by `unpipeSignal` option.");throw BM({error:K,fileDescriptors:Y,sourceOptions:$,startTime:Q})};var jF=(Z,...J)=>{if(c8(J[0]))return jF.bind(void 0,{...Z,boundOptions:{...Z.boundOptions,...J[0]}});let{destination:X,...Y}=hp(Z,...J),$=qw1({...Y,destination:X});return $.pipe=jF.bind(void 0,{...Z,source:X,sourcePromise:$,boundOptions:{}}),$},qw1=async({sourcePromise:Z,sourceStream:J,sourceOptions:X,sourceError:Y,destination:$,destinationStream:Q,destinationError:K,unpipeSignal:W,fileDescriptors:G,startTime:z})=>{let v=Fw1(Z,$);bp({sourceStream:J,sourceError:Y,destinationStream:Q,destinationError:K,fileDescriptors:G,sourceOptions:X,startTime:z});let H=new AbortController;try{let V=mp(J,Q,H);return await Promise.race([Ap(v),...up(W,{sourceStream:J,mergedStream:V,sourceOptions:X,fileDescriptors:G,startTime:z})])}finally{H.abort()}},Fw1=(Z,J)=>Promise.allSettled([Z,J]);import{setImmediate as Lw1}from"node:timers/promises";import{on as ww1}from"node:events";import{getDefaultHighWaterMark as cw1}from"node:stream";var BF=({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:Y,encoding:$,preserveNewlines:Q})=>{let K=new AbortController;return Uw1(J,K),yp({stream:Z,controller:K,binary:X,shouldEncode:!Z.readableObjectMode&&Y,encoding:$,shouldSplit:!Z.readableObjectMode,preserveNewlines:Q})},Uw1=async(Z,J)=>{try{await Z}catch{}finally{J.abort()}},LM=({stream:Z,onStreamEnd:J,lines:X,encoding:Y,stripFinalNewline:$,allMixed:Q})=>{let K=new AbortController;xw1(J,K,Z);let W=Z.readableObjectMode&&!Q;return yp({stream:Z,controller:K,binary:Y==="buffer",shouldEncode:!W,encoding:Y,shouldSplit:!W&&X,preserveNewlines:!$})},xw1=async(Z,J,X)=>{try{await Z}catch{X.destroy()}finally{J.abort()}},yp=({stream:Z,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K})=>{let W=ww1(Z,"data",{signal:J.signal,highWaterMark:lp,highWatermark:lp});return jw1({onStdoutChunk:W,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K})},DM=cw1(!0),lp=DM,jw1=async function*({onStdoutChunk:Z,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K}){let W=Bw1({binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K});try{for await(let[G]of Z)yield*NY(G,W,0)}catch(G){if(!J.signal.aborted)throw G}finally{yield*eW(W)}},Bw1=({binary:Z,shouldEncode:J,encoding:X,shouldSplit:Y,preserveNewlines:$})=>[VF(Z,X,!J),vF(Z,$,!Y,{})].filter(Boolean);var pp=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,buffer:$,maxBuffer:Q,lines:K,allMixed:W,stripFinalNewline:G,verboseInfo:z,streamInfo:v})=>{let H=Dw1({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,allMixed:W,verboseInfo:z,streamInfo:v});if(!$){await Promise.all([Mw1(Z),H]);return}let V=XM(G,X),q=LM({stream:Z,onStreamEnd:J,lines:K,encoding:Y,stripFinalNewline:V,allMixed:W}),[F]=await Promise.all([Rw1({stream:Z,iterable:q,fdNumber:X,encoding:Y,maxBuffer:Q,lines:K}),H]);return F},Dw1=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,allMixed:$,verboseInfo:Q,streamInfo:{fileDescriptors:K}})=>{if(!FF({stdioItems:K[X]?.stdioItems,encoding:Y,verboseInfo:Q,fdNumber:X}))return;let W=LM({stream:Z,onStreamEnd:J,lines:!0,encoding:Y,stripFinalNewline:!0,allMixed:$});await oy(W,Z,X,Q)},Mw1=async(Z)=>{if(await Lw1(),Z.readableFlowing===null)Z.resume()},Rw1=async({stream:Z,stream:{readableObjectMode:J},iterable:X,fdNumber:Y,encoding:$,maxBuffer:Q,lines:K})=>{try{if(J||K)return await ZF(X,{maxBuffer:Q});if($==="buffer")return new Uint8Array(await JF(X,{maxBuffer:Q}));return await YF(X,{maxBuffer:Q})}catch(W){return ip(ol({error:W,stream:Z,readableObjectMode:J,lines:K,encoding:$,fdNumber:Y}))}},MM=async(Z)=>{try{return await Z}catch(J){return ip(J)}},ip=({bufferedData:Z})=>Hm(Z)?new Uint8Array(Z):Z;import{finished as Nw1}from"node:stream/promises";var YG=async(Z,J,X,{isSameDirection:Y,stopOnExit:$=!1}={})=>{let Q=Pw1(Z,X),K=new AbortController;try{await Promise.race([...$?[X.exitPromise]:[],Nw1(Z,{cleanup:!0,signal:K.signal})])}catch(W){if(!Q.stdinCleanedUp)Cw1(W,J,X,Y)}finally{K.abort()}},Pw1=(Z,{originalStreams:[J],subprocess:X})=>{let Y={stdinCleanedUp:!1};if(Z===J)Ow1(Z,X,Y);return Y},Ow1=(Z,J,X)=>{let{_destroy:Y}=Z;Z._destroy=(...$)=>{Tw1(J,X),Y.call(Z,...$)}},Tw1=({exitCode:Z,signalCode:J},X)=>{if(Z!==null||J!==null)X.stdinCleanedUp=!0},Cw1=(Z,J,X,Y)=>{if(!fw1(Z,J,X,Y))throw Z},fw1=(Z,J,X,Y=!0)=>{if(X.propagating)return gp(Z)||LF(Z);return X.propagating=!0,RM(X,J)===Y?gp(Z):LF(Z)},RM=({fileDescriptors:Z},J)=>J!=="all"&&Z[J].direction==="input",LF=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",gp=(Z)=>Z?.code==="EPIPE";var dp=({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>Z.stdio.map((G,z)=>NM({stream:G,fdNumber:z,encoding:J,buffer:X[z],maxBuffer:Y[z],lines:$[z],allMixed:!1,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})),NM=async({stream:Z,fdNumber:J,encoding:X,buffer:Y,maxBuffer:$,lines:Q,allMixed:K,stripFinalNewline:W,verboseInfo:G,streamInfo:z})=>{if(!Z)return;let v=YG(Z,J,z);if(RM(z,J)){await v;return}let[H]=await Promise.all([pp({stream:Z,onStreamEnd:v,fdNumber:J,encoding:X,buffer:Y,maxBuffer:$,lines:Q,allMixed:K,stripFinalNewline:W,verboseInfo:G,streamInfo:z}),v]);return H};var ap=({stdout:Z,stderr:J},{all:X})=>X&&(Z||J)?PY([Z,J].filter(Boolean)):void 0,np=({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>NM({...kw1(Z,X),fdNumber:"all",encoding:J,maxBuffer:Y[1]+Y[2],lines:$[1]||$[2],allMixed:Ew1(Z),stripFinalNewline:Q,verboseInfo:K,streamInfo:W}),kw1=({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}},Ew1=({all:Z,stdout:J,stderr:X})=>Z&&J&&X&&J.readableObjectMode!==X.readableObjectMode;import{once as Iw1}from"node:events";var sp=(Z)=>lQ(Z,"ipc"),op=(Z,J)=>{let X=Nq(Z);t9({type:"ipc",verboseMessage:X,fdNumber:"ipc",verboseInfo:J})};var rp=async({subprocess:Z,buffer:J,maxBuffer:X,ipc:Y,ipcOutput:$,verboseInfo:Q})=>{if(!Y)return $;let K=sp(Q),W=o7(J,"ipc"),G=o7(X,"ipc");for await(let z of VM({anyProcess:Z,channel:Z.channel,isSubprocess:!1,ipc:Y,shouldAwait:!1,reference:!0})){if(W)rl(Z,$,G),$.push(z);if(K)op(z,Q)}return $},tp=async(Z,J)=>{return await Promise.allSettled([Z]),J};var ep=async({subprocess:Z,options:{encoding:J,buffer:X,maxBuffer:Y,lines:$,timeoutDuration:Q,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,stripFinalNewline:z,ipc:v,ipcInput:H},context:V,verboseInfo:q,fileDescriptors:F,originalStreams:w,onInternalError:c,controller:U})=>{let j=Jp(Z,V),B={originalStreams:w,fileDescriptors:F,subprocess:Z,exitPromise:j,propagating:!1},L=dp({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:z,verboseInfo:q,streamInfo:B}),R=np({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:z,verboseInfo:q,streamInfo:B}),M=[],N=rp({subprocess:Z,buffer:X,maxBuffer:Y,ipc:v,ipcOutput:M,verboseInfo:q}),P=_w1(w,Z,B),O=hw1(F,B);try{return await Promise.race([Promise.all([{},Yp(j),Promise.all(L),R,N,Tl(Z,H),...P,...O]),c,Sw1(Z,U),...Ml(Z,Q,V,U),...iu({subprocess:Z,cancelSignal:K,gracefulCancel:W,context:V,controller:U}),...Ll({subprocess:Z,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,context:V,controller:U})])}catch(k){return V.terminationReason??="other",Promise.all([{error:k},j,Promise.all(L.map((E)=>MM(E))),MM(R),tp(N,M),Promise.allSettled(P),Promise.allSettled(O)])}},_w1=(Z,J,X)=>Z.map((Y,$)=>Y===J.stdio[$]?void 0:YG(Y,$,X)),hw1=(Z,J)=>Z.flatMap(({stdioItems:X},Y)=>X.filter(({value:$,stream:Q=$})=>q9(Q,{checkOpen:!1})&&!V9(Q)).map(({type:$,value:Q,stream:K=Q})=>YG(K,Y,J,{isSameDirection:z4.has($),stopOnExit:$==="native"}))),Sw1=async(Z,{signal:J})=>{let[X]=await Iw1(Z,"error",{signal:J});throw X};var Zi=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),$G=(Z,J,X)=>{let Y=Z[X];if(!Y.has(J))Y.set(J,[]);let $=Y.get(J),Q=Z7();return $.push(Q),{resolve:Q.resolve.bind(Q),promises:$}},eQ=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 bw1}from"node:stream";import{callbackify as Aw1}from"node:util";import{finished as Ji}from"node:stream/promises";var PM=async(Z)=>{if(Z===void 0)return;try{await OM(Z)}catch{}},Xi=async(Z)=>{if(Z===void 0)return;try{await TM(Z)}catch{}},OM=async(Z)=>{await Ji(Z,{cleanup:!0,readable:!1,writable:!0})},TM=async(Z)=>{await Ji(Z,{cleanup:!0,readable:!0,writable:!1})},DF=async(Z,J)=>{if(await Z,J)throw J},MF=(Z,J,X)=>{if(X&&!LF(X))Z.destroy(X);else if(J)Z.destroy()};var Yi=({subprocess:Z,concurrentStreams:J,encoding:X},{from:Y,binary:$=!0,preserveNewlines:Q=!0}={})=>{let K=$||E5.has(X),{subprocessStdout:W,waitReadableDestroy:G}=CM(Z,Y,J),{readableEncoding:z,readableObjectMode:v,readableHighWaterMark:H}=fM(W,K),{read:V,onStdoutDataDone:q}=kM({subprocessStdout:W,subprocess:Z,binary:K,encoding:X,preserveNewlines:Q}),F=new bw1({read:V,destroy:Aw1(IM.bind(void 0,{subprocessStdout:W,subprocess:Z,waitReadableDestroy:G})),highWaterMark:H,objectMode:v,encoding:z});return EM({subprocessStdout:W,onStdoutDataDone:q,readable:F,subprocess:Z}),F},CM=(Z,J,X)=>{let Y=dQ(Z,J),$=$G(X,Y,"readableDestroy");return{subprocessStdout:Y,waitReadableDestroy:$}},fM=({readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X},Y)=>Y?{readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X}:{readableEncoding:Z,readableObjectMode:!0,readableHighWaterMark:DM},kM=({subprocessStdout:Z,subprocess:J,binary:X,encoding:Y,preserveNewlines:$})=>{let Q=Z7(),K=BF({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:!X,encoding:Y,preserveNewlines:$});return{read(){mw1(this,K,Q)},onStdoutDataDone:Q}},mw1=async(Z,J,X)=>{try{let{value:Y,done:$}=await J.next();if($)X.resolve();else Z.push(Y)}catch{}},EM=async({subprocessStdout:Z,onStdoutDataDone:J,readable:X,subprocess:Y,subprocessStdin:$})=>{try{if(await TM(Z),await Y,await PM($),await J,X.readable)X.push(null)}catch(Q){await PM($),$i(X,Q)}},IM=async({subprocessStdout:Z,subprocess:J,waitReadableDestroy:X},Y)=>{if(await eQ(X,J))$i(Z,Y),await DF(J,Y)},$i=(Z,J)=>{MF(Z,Z.readable,J)};import{Writable as uw1}from"node:stream";import{callbackify as Qi}from"node:util";var Ki=({subprocess:Z,concurrentStreams:J},{to:X}={})=>{let{subprocessStdin:Y,waitWritableFinal:$,waitWritableDestroy:Q}=_M(Z,X,J),K=new uw1({...hM(Y,Z,$),destroy:Qi(bM.bind(void 0,{subprocessStdin:Y,subprocess:Z,waitWritableFinal:$,waitWritableDestroy:Q})),highWaterMark:Y.writableHighWaterMark,objectMode:Y.writableObjectMode});return SM(Y,K),K},_M=(Z,J,X)=>{let Y=mq(Z,J),$=$G(X,Y,"writableFinal"),Q=$G(X,Y,"writableDestroy");return{subprocessStdin:Y,waitWritableFinal:$,waitWritableDestroy:Q}},hM=(Z,J,X)=>({write:lw1.bind(void 0,Z),final:Qi(yw1.bind(void 0,Z,J,X))}),lw1=(Z,J,X,Y)=>{if(Z.write(J,X))Y();else Z.once("drain",Y)},yw1=async(Z,J,X)=>{if(await eQ(X,J)){if(Z.writable)Z.end();await J}},SM=async(Z,J,X)=>{try{if(await OM(Z),J.writable)J.end()}catch(Y){await Xi(X),Wi(J,Y)}},bM=async({subprocessStdin:Z,subprocess:J,waitWritableFinal:X,waitWritableDestroy:Y},$)=>{if(await eQ(X,J),await eQ(Y,J))Wi(Z,$),await DF(J,$)},Wi=(Z,J)=>{MF(Z,Z.writable,J)};import{Duplex as pw1}from"node:stream";import{callbackify as iw1}from"node:util";var Gi=({subprocess:Z,concurrentStreams:J,encoding:X},{from:Y,to:$,binary:Q=!0,preserveNewlines:K=!0}={})=>{let W=Q||E5.has(X),{subprocessStdout:G,waitReadableDestroy:z}=CM(Z,Y,J),{subprocessStdin:v,waitWritableFinal:H,waitWritableDestroy:V}=_M(Z,$,J),{readableEncoding:q,readableObjectMode:F,readableHighWaterMark:w}=fM(G,W),{read:c,onStdoutDataDone:U}=kM({subprocessStdout:G,subprocess:Z,binary:W,encoding:X,preserveNewlines:K}),j=new pw1({read:c,...hM(v,Z,H),destroy:iw1(gw1.bind(void 0,{subprocessStdout:G,subprocessStdin:v,subprocess:Z,waitReadableDestroy:z,waitWritableFinal:H,waitWritableDestroy:V})),readableHighWaterMark:w,writableHighWaterMark:v.writableHighWaterMark,readableObjectMode:F,writableObjectMode:v.writableObjectMode,encoding:q});return EM({subprocessStdout:G,onStdoutDataDone:U,readable:j,subprocess:Z,subprocessStdin:v}),SM(v,j,G),j},gw1=async({subprocessStdout:Z,subprocessStdin:J,subprocess:X,waitReadableDestroy:Y,waitWritableFinal:$,waitWritableDestroy:Q},K)=>{await Promise.all([IM({subprocessStdout:Z,subprocess:X,waitReadableDestroy:Y},K),bM({subprocessStdin:J,subprocess:X,waitWritableFinal:$,waitWritableDestroy:Q},K)])};var AM=(Z,J,{from:X,binary:Y=!1,preserveNewlines:$=!1}={})=>{let Q=Y||E5.has(J),K=dQ(Z,X),W=BF({subprocessStdout:K,subprocess:Z,binary:Q,shouldEncode:!0,encoding:J,preserveNewlines:$});return dw1(W,K,Z)},dw1=async function*(Z,J,X){try{yield*Z}finally{if(J.readable)J.destroy();await X}};var zi=(Z,{encoding:J})=>{let X=Zi();Z.readable=Yi.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.writable=Ki.bind(void 0,{subprocess:Z,concurrentStreams:X}),Z.duplex=Gi.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.iterable=AM.bind(void 0,Z,J),Z[Symbol.asyncIterator]=AM.bind(void 0,Z,J,{})};var vi=(Z,J)=>{for(let[X,Y]of nw1){let $=Y.value.bind(J);Reflect.defineProperty(Z,X,{...Y,value:$})}},aw1=(async()=>{})().constructor.prototype,nw1=["then","catch","finally"].map((Z)=>[Z,Reflect.getOwnPropertyDescriptor(aw1,Z)]);var Vi=(Z,J,X,Y)=>{let{file:$,commandArguments:Q,command:K,escapedCommand:W,startTime:G,verboseInfo:z,options:v,fileDescriptors:H}=rw1(Z,J,X),{subprocess:V,promise:q}=ew1({file:$,commandArguments:Q,options:v,startTime:G,verboseInfo:z,command:K,escapedCommand:W,fileDescriptors:H});return V.pipe=jF.bind(void 0,{source:V,sourcePromise:q,boundOptions:{},createNested:Y}),vi(V,q),J7.set(V,{options:v,fileDescriptors:H}),V},rw1=(Z,J,X)=>{let{command:Y,escapedCommand:$,startTime:Q,verboseInfo:K}=Oq(Z,J,X),{file:W,commandArguments:G,options:z}=oq(Z,J,X),v=tw1(z),H=xp(v,K);return{file:W,commandArguments:G,command:Y,escapedCommand:$,startTime:Q,verboseInfo:K,options:v,fileDescriptors:H}},tw1=({timeout:Z,signal:J,...X})=>{if(J!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...X,timeoutDuration:Z}},ew1=({file:Z,commandArguments:J,options:X,startTime:Y,verboseInfo:$,command:Q,escapedCommand:K,fileDescriptors:W})=>{let G;try{G=ow1(Z,J,X)}catch(F){return Fp({error:F,command:Q,escapedCommand:K,fileDescriptors:W,options:X,startTime:Y,verboseInfo:$})}let z=new AbortController;sw1(Number.POSITIVE_INFINITY,z.signal);let v=[...G.stdio];Tp(G,W,z),Ip(G,X,z);let H={},V=Z7();G.kill=yu.bind(void 0,{kill:G.kill.bind(G),options:X,onInternalError:V,context:H,controller:z}),G.all=ap(G,X),zi(G,X),Vp(G,X);let q=Zc1({subprocess:G,options:X,startTime:Y,verboseInfo:$,fileDescriptors:W,originalStreams:v,command:Q,escapedCommand:K,context:H,onInternalError:V,controller:z});return{subprocess:G,promise:q}},Zc1=async({subprocess:Z,options:J,startTime:X,verboseInfo:Y,fileDescriptors:$,originalStreams:Q,command:K,escapedCommand:W,context:G,onInternalError:z,controller:v})=>{let[H,[V,q],F,w,c]=await ep({subprocess:Z,options:J,context:G,verboseInfo:Y,fileDescriptors:$,originalStreams:Q,onInternalError:z,controller:v});v.abort(),z.resolve();let U=F.map((L,R)=>e7(L,J,R)),j=e7(w,J,"all"),B=Jc1({errorInfo:H,exitCode:V,signal:q,stdio:U,all:j,ipcOutput:c,context:G,options:J,command:K,escapedCommand:W,startTime:X});return oQ(B,Y,J)},Jc1=({errorInfo:Z,exitCode:J,signal:X,stdio:Y,all:$,ipcOutput:Q,context:K,options:W,command:G,escapedCommand:z,startTime:v})=>("error"in Z)?tW({error:Z.error,command:G,escapedCommand:z,timedOut:K.terminationReason==="timeout",isCanceled:K.terminationReason==="cancel"||K.terminationReason==="gracefulCancel",isGracefullyCanceled:K.terminationReason==="gracefulCancel",isMaxBuffer:Z.error instanceof r7,isForcefullyTerminated:K.isForcefullyTerminated,exitCode:J,signal:X,stdio:Y,all:$,ipcOutput:Q,options:W,startTime:v,isSync:!1}):QF({command:G,escapedCommand:z,stdio:Y,all:$,ipcOutput:Q,options:W,startTime:v});var RF=(Z,J)=>{let X=Object.fromEntries(Object.entries(J).map(([Y,$])=>[Y,Xc1(Y,Z[Y],$)]));return{...Z,...X}},Xc1=(Z,J,X)=>{if(Yc1.has(Z)&&c8(J)&&c8(X))return{...J,...X};return X},Yc1=new Set(["env",...UD]);var EJ=(Z,J,X,Y)=>{let $=(K,W,G)=>EJ(K,W,X,G),Q=(...K)=>$c1({mapArguments:Z,deepOptions:X,boundOptions:J,setBoundExeca:Y,createNested:$},...K);if(Y!==void 0)Y(Q,$,J);return Q},$c1=({mapArguments:Z,deepOptions:J={},boundOptions:X={},setBoundExeca:Y,createNested:$},Q,...K)=>{if(c8(Q))return $(Z,RF(X,Q),Y);let{file:W,commandArguments:G,options:z,isSync:v}=Qc1({mapArguments:Z,firstArgument:Q,nextArguments:K,deepOptions:J,boundOptions:X});return v?Qp(W,G,z):Vi(W,G,z,$)},Qc1=({mapArguments:Z,firstArgument:J,nextArguments:X,deepOptions:Y,boundOptions:$})=>{let Q=xm(J)?jm(J,X):[J,...X],[K,W,G]=cq(...Q),z=RF(RF(Y,$),G),{file:v=K,commandArguments:H=W,options:V=z,isSync:q=!1}=Z({file:K,commandArguments:W,options:z});return{file:v,commandArguments:H,options:V,isSync:q}};var Hi=({file:Z,commandArguments:J})=>Fi(Z,J),qi=({file:Z,commandArguments:J})=>({...Fi(Z,J),isSync:!0}),Fi=(Z,J)=>{if(J.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${Z} ${J}.`);let[X,...Y]=Kc1(Z);return{file:X,commandArguments:Y}},Kc1=(Z)=>{if(typeof Z!=="string")throw TypeError(`The command must be a string: ${String(Z)}.`);let J=Z.trim();if(J==="")return[];let X=[];for(let Y of J.split(Wc1)){let $=X.at(-1);if($&&$.endsWith("\\"))X[X.length-1]=`${$.slice(0,-1)} ${Y}`;else X.push(Y)}return X},Wc1=/ +/g;var wi=(Z,J,X)=>{Z.sync=J(Gc1,X),Z.s=Z.sync},ci=({options:Z})=>Ui(Z),Gc1=({options:Z})=>({...Ui(Z),isSync:!0}),Ui=(Z)=>({options:{...zc1(Z),...Z}}),zc1=({input:Z,inputFile:J,stdio:X})=>Z===void 0&&J===void 0&&X===void 0?{stdin:"inherit"}:{},xi={preferLocal:!0};var ji=EJ(()=>({})),BR6=EJ(()=>({isSync:!0})),LR6=EJ(Hi),DR6=EJ(qi),MR6=EJ(Nl),RR6=EJ(ci,{},xi,wi),{sendMessage:NR6,getOneMessage:PR6,getEachMessage:OR6,getCancelSignal:TR6}=Hp();var mi=t(ki(),1);var KG=(Z)=>{if(typeof Z!=="string")throw TypeError("invalid pattern");if(Z.length>65536)throw TypeError("pattern is too long")};var Uc1={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},WG=(Z)=>Z.replace(/[[\]\\-]/g,"\\$&"),xc1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ei=(Z)=>Z.join(""),Ii=(Z,J)=>{let X=J;if(Z.charAt(X)!=="[")throw Error("not in a brace expression");let Y=[],$=[],Q=X+1,K=!1,W=!1,G=!1,z=!1,v=X,H="";Z:while(Q<Z.length){let w=Z.charAt(Q);if((w==="!"||w==="^")&&Q===X+1){z=!0,Q++;continue}if(w==="]"&&K&&!G){v=Q+1;break}if(K=!0,w==="\\"){if(!G){G=!0,Q++;continue}}if(w==="["&&!G){for(let[c,[U,j,B]]of Object.entries(Uc1))if(Z.startsWith(c,Q)){if(H)return["$.",!1,Z.length-X,!0];if(Q+=c.length,B)$.push(U);else Y.push(U);W=W||j;continue Z}}if(G=!1,H){if(w>H)Y.push(WG(H)+"-"+WG(w));else if(w===H)Y.push(WG(w));H="",Q++;continue}if(Z.startsWith("-]",Q+1)){Y.push(WG(w+"-")),Q+=2;continue}if(Z.startsWith("-",Q+1)){H=w,Q+=2;continue}Y.push(WG(w)),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])&&!z){let w=Y[0].length===2?Y[0].slice(-1):Y[0];return[xc1(w),!1,v-X,!1]}let V="["+(z?"^":"")+Ei(Y)+"]",q="["+(z?"":"^")+Ei($)+"]";return[Y.length&&$.length?"("+V+"|"+q+")":Y.length?V:q,W,v-X,!0]};var F9=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/\[([^\/\\])\]/g,"$1"):Z.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var jc1=new Set(["!","?","+","*","@"]),_i=(Z)=>jc1.has(Z),Bc1="(?!(?:^|/)\\.\\.?(?:$|/))",NF="(?!\\.)",Lc1=new Set(["[","."]),Dc1=new Set(["..","."]),Mc1=new Set("().*{}+?[]^$\\!"),Rc1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),yM="[^/]",hi=yM+"*?",Si=yM+"+?";class Z6{type;#Z;#J;#Y=!1;#X=[];#$;#v;#H;#W=!1;#G;#z;#V=!1;constructor(Z,J,X={}){if(this.type=Z,Z)this.#J=!0;if(this.#$=J,this.#Z=this.#$?this.#$.#Z:this,this.#G=this.#Z===this?X:this.#Z.#G,this.#H=this.#Z===this?[]:this.#Z.#H,Z==="!"&&!this.#Z.#W)this.#H.push(this);this.#v=this.#$?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.#z!==void 0)return this.#z;if(!this.type)return this.#z=this.#X.map((Z)=>String(Z)).join("");else return this.#z=this.type+"("+this.#X.map((Z)=>String(Z)).join("|")+")"}#Q(){if(this!==this.#Z)throw Error("should only call on root");if(this.#W)return this;this.toString(),this.#W=!0;let Z;while(Z=this.#H.pop()){if(Z.type!=="!")continue;let J=Z,X=J.#$;while(X){for(let Y=J.#v+1;!X.type&&Y<X.#X.length;Y++)for(let $ of Z.#X){if(typeof $==="string")throw 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 Z6&&J.#$===this))throw Error("invalid part: "+J);this.#X.push(J)}}toJSON(){let Z=this.type===null?this.#X.slice().map((J)=>typeof J==="string"?J:J.toJSON()):[this.type,...this.#X.map((J)=>J.toJSON())];if(this.isStart()&&!this.type)Z.unshift([]);if(this.isEnd()&&(this===this.#Z||this.#Z.#W&&this.#$?.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 Z6&&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 Z6(this.type,Z);for(let X of this.#X)J.copyIn(X);return J}static#F(Z,J,X,Y){let $=!1,Q=!1,K=-1,W=!1;if(J.type===null){let V=X,q="";while(V<Z.length){let F=Z.charAt(V++);if($||F==="\\"){$=!$,q+=F;continue}if(Q){if(V===K+1){if(F==="^"||F==="!")W=!0}else if(F==="]"&&!(V===K+2&&W))Q=!1;q+=F;continue}else if(F==="["){Q=!0,K=V,W=!1,q+=F;continue}if(!Y.noext&&_i(F)&&Z.charAt(V)==="("){J.push(q),q="";let w=new Z6(F,J);V=Z6.#F(Z,w,V,Y),J.push(w);continue}q+=F}return J.push(q),V}let G=X+1,z=new Z6(null,J),v=[],H="";while(G<Z.length){let V=Z.charAt(G++);if($||V==="\\"){$=!$,H+=V;continue}if(Q){if(G===K+1){if(V==="^"||V==="!")W=!0}else if(V==="]"&&!(G===K+2&&W))Q=!1;H+=V;continue}else if(V==="["){Q=!0,K=G,W=!1,H+=V;continue}if(_i(V)&&Z.charAt(G)==="("){z.push(H),H="";let q=new Z6(V,z);z.push(q),G=Z6.#F(Z,q,G,Y);continue}if(V==="|"){z.push(H),H="",v.push(z),z=new Z6(null,J);continue}if(V===")"){if(H===""&&J.#X.length===0)J.#V=!0;return z.push(H),H="",J.push(...v,z),G}H+=V}return J.type=null,J.#J=void 0,J.#X=[Z.substring(X-1)],G}static fromGlob(Z,J={}){let X=new Z6(null,void 0,J);return Z6.#F(Z,X,0,J),X}toMMPattern(){if(this!==this.#Z)return this.#Z.toMMPattern();let Z=this.toString(),[J,X,Y,$]=this.toRegExpSource();if(!(Y||this.#J||this.#G.nocase&&!this.#G.nocaseMagicOnly&&Z.toUpperCase()!==Z.toLowerCase()))return X;let K=(this.#G.nocase?"i":"")+($?"u":"");return Object.assign(new RegExp(`^${J}$`,K),{_src:J,_glob:Z})}get options(){return this.#G}toRegExpSource(Z){let J=Z??!!this.#G.dot;if(this.#Z===this)this.#Q();if(!this.type){let W=this.isStart()&&this.isEnd(),G=this.#X.map((V)=>{let[q,F,w,c]=typeof V==="string"?Z6.#w(V,this.#J,W):V.toRegExpSource(Z);return this.#J=this.#J||w,this.#Y=this.#Y||c,q}).join(""),z="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&Dc1.has(this.#X[0]))){let q=Lc1,F=J&&q.has(G.charAt(0))||G.startsWith("\\.")&&q.has(G.charAt(2))||G.startsWith("\\.\\.")&&q.has(G.charAt(4)),w=!J&&!Z&&q.has(G.charAt(0));z=F?Bc1:w?NF:""}}}let v="";if(this.isEnd()&&this.#Z.#W&&this.#$?.type==="!")v="(?:$|\\/)";return[z+G+v,F9(G),this.#J=!!this.#J,this.#Y]}let X=this.type==="*"||this.type==="+",Y=this.type==="!"?"(?:(?!(?:":"(?:",$=this.#c(J);if(this.isStart()&&this.isEnd()&&!$&&this.type!=="!"){let W=this.toString();return this.#X=[W],this.type=null,this.#J=void 0,[W,F9(this.toString()),!1,!1]}let Q=!X||Z||J||!NF?"":this.#c(!0);if(Q===$)Q="";if(Q)$=`(?:${$})(?:${Q})*?`;let K="";if(this.type==="!"&&this.#V)K=(this.isStart()&&!J?NF:"")+Si;else{let W=this.type==="!"?"))"+(this.isStart()&&!J&&!Z?NF:"")+hi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&Q?")":this.type==="*"&&Q?")?":`)${this.type}`;K=Y+$+W}return[K,F9($),this.#J=!!this.#J,this.#Y]}#c(Z){return this.#X.map((J)=>{if(typeof J==="string")throw Error("string type in extglob ast??");let[X,Y,$,Q]=J.toRegExpSource(Z);return this.#Y=this.#Y||Q,X}).filter((J)=>!(this.isStart()&&this.isEnd())||!!J).join("|")}static#w(Z,J,X=!1){let Y=!1,$="",Q=!1;for(let K=0;K<Z.length;K++){let W=Z.charAt(K);if(Y){Y=!1,$+=(Mc1.has(W)?"\\":"")+W;continue}if(W==="\\"){if(K===Z.length-1)$+="\\\\";else Y=!0;continue}if(W==="["){let[G,z,v,H]=Ii(Z,K);if(v){$+=G,Q=Q||z,K+=v-1,J=J||H;continue}}if(W==="*"){if(X&&Z==="*")$+=Si;else $+=hi;J=!0;continue}if(W==="?"){$+=yM,J=!0;continue}$+=Rc1(W)}return[$,F9(Z),!!J,Q]}}var Z3=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/[?*()[\]]/g,"[$&]"):Z.replace(/[?*()[\]\\]/g,"\\$&")};var h6=(Z,J,X={})=>{if(KG(J),!X.nocomment&&J.charAt(0)==="#")return!1;return new V4(J,X).match(Z)},Nc1=/^\*+([^+@!?\*\[\(]*)$/,Pc1=(Z)=>(J)=>!J.startsWith(".")&&J.endsWith(Z),Oc1=(Z)=>(J)=>J.endsWith(Z),Tc1=(Z)=>{return Z=Z.toLowerCase(),(J)=>!J.startsWith(".")&&J.toLowerCase().endsWith(Z)},Cc1=(Z)=>{return Z=Z.toLowerCase(),(J)=>J.toLowerCase().endsWith(Z)},fc1=/^\*+\.\*+$/,kc1=(Z)=>!Z.startsWith(".")&&Z.includes("."),Ec1=(Z)=>Z!=="."&&Z!==".."&&Z.includes("."),Ic1=/^\.\*+$/,_c1=(Z)=>Z!=="."&&Z!==".."&&Z.startsWith("."),hc1=/^\*+$/,Sc1=(Z)=>Z.length!==0&&!Z.startsWith("."),bc1=(Z)=>Z.length!==0&&Z!=="."&&Z!=="..",Ac1=/^\?+([^+@!?\*\[\(]*)?$/,mc1=([Z,J=""])=>{let X=ui([Z]);if(!J)return X;return J=J.toLowerCase(),(Y)=>X(Y)&&Y.toLowerCase().endsWith(J)},uc1=([Z,J=""])=>{let X=li([Z]);if(!J)return X;return J=J.toLowerCase(),(Y)=>X(Y)&&Y.toLowerCase().endsWith(J)},lc1=([Z,J=""])=>{let X=li([Z]);return!J?X:(Y)=>X(Y)&&Y.endsWith(J)},yc1=([Z,J=""])=>{let X=ui([Z]);return!J?X:(Y)=>X(Y)&&Y.endsWith(J)},ui=([Z])=>{let J=Z.length;return(X)=>X.length===J&&!X.startsWith(".")},li=([Z])=>{let J=Z.length;return(X)=>X.length===J&&X!=="."&&X!==".."},yi=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",bi={win32:{sep:"\\"},posix:{sep:"/"}},pc1=yi==="win32"?bi.win32.sep:bi.posix.sep;h6.sep=pc1;var J6=Symbol("globstar **");h6.GLOBSTAR=J6;var ic1="[^/]",gc1=ic1+"*?",dc1="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ac1="(?:(?!(?:\\/|^)\\.).)*?",nc1=(Z,J={})=>(X)=>h6(X,Z,J);h6.filter=nc1;var v4=(Z,J={})=>Object.assign({},Z,J),sc1=(Z)=>{if(!Z||typeof Z!=="object"||!Object.keys(Z).length)return h6;let J=h6;return Object.assign((Y,$,Q={})=>J(Y,$,v4(Z,Q)),{Minimatch:class extends J.Minimatch{constructor($,Q={}){super($,v4(Z,Q))}static defaults($){return J.defaults(v4(Z,$)).Minimatch}},AST:class extends J.AST{constructor($,Q,K={}){super($,Q,v4(Z,K))}static fromGlob($,Q={}){return J.AST.fromGlob($,v4(Z,Q))}},unescape:(Y,$={})=>J.unescape(Y,v4(Z,$)),escape:(Y,$={})=>J.escape(Y,v4(Z,$)),filter:(Y,$={})=>J.filter(Y,v4(Z,$)),defaults:(Y)=>J.defaults(v4(Z,Y)),makeRe:(Y,$={})=>J.makeRe(Y,v4(Z,$)),braceExpand:(Y,$={})=>J.braceExpand(Y,v4(Z,$)),match:(Y,$,Q={})=>J.match(Y,$,v4(Z,Q)),sep:J.sep,GLOBSTAR:J6})};h6.defaults=sc1;var pi=(Z,J={})=>{if(KG(Z),J.nobrace||!/\{(?:(?!\{).)*\}/.test(Z))return[Z];return mi.default(Z)};h6.braceExpand=pi;var oc1=(Z,J={})=>new V4(Z,J).makeRe();h6.makeRe=oc1;var rc1=(Z,J,X={})=>{let Y=new V4(J,X);if(Z=Z.filter(($)=>Y.match($)),Y.options.nonull&&!Z.length)Z.push(J);return Z};h6.match=rc1;var Ai=/[?*]|[+@!]\(.*?\)|\[|\]/,tc1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class V4{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Z,J={}){if(KG(Z),J=J||{},this.options=J,this.pattern=Z,this.platform=J.platform||yi,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 W=$[0]===""&&$[1]===""&&($[2]==="?"||!Ai.test($[2]))&&!Ai.test($[3]),G=/^[a-z]:/i.test($[0]);if(W)return[...$.slice(0,4),...$.slice(4).map((z)=>this.parse(z))];else if(G)return[$[0],...$.slice(1).map((z)=>this.parse(z))]}return $.map((W)=>this.parse(W))});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],W=X[Y+2],G=X[Y+3];if(K!=="..")continue;if(!W||W==="."||W===".."||!G||G==="."||G==="..")continue;J=!0,X.splice(Y,1);let z=X.slice(0);z[Y]="**",Z.push(z),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 W=$===1&&X[$+1]==="**"?["."]:[];if(X.splice($-1,2,...W),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 F=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),w=!F&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&/^[a-z]:$/i.test(Z[3]),c=typeof J[0]==="string"&&/^[a-z]:$/i.test(J[0]),U=!c&&J[0]===""&&J[1]===""&&J[2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]),j=w?3:F?0:void 0,B=U?3:c?0:void 0;if(typeof j==="number"&&typeof B==="number"){let[L,R]=[Z[j],J[B]];if(L.toLowerCase()===R.toLowerCase()){if(J[B]=L,B>j)J=J.slice(B);else if(j>B)Z=Z.slice(j)}}}let{optimizationLevel:$=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,W=Z.length,G=J.length;Q<W&&K<G;Q++,K++){this.debug("matchOne loop");var z=J[K],v=Z[Q];if(this.debug(J,z,v),z===!1)return!1;if(z===J6){this.debug("GLOBSTAR",[J,z,v]);var H=Q,V=K+1;if(V===G){this.debug("** at the end");for(;Q<W;Q++)if(Z[Q]==="."||Z[Q]===".."||!Y.dot&&Z[Q].charAt(0)===".")return!1;return!0}while(H<W){var q=Z[H];if(this.debug(`
398
398
  globstar while`,Z,H,J,V,q),this.matchOne(Z.slice(H),J.slice(V),X))return this.debug("globstar found match!",H,W,q),!0;else{if(q==="."||q===".."||!Y.dot&&q.charAt(0)==="."){this.debug("dot detected!",Z,H,J,V);break}this.debug("globstar swallow a segment, and continue"),H++}}if(X){if(this.debug(`
399
- >>> no match, partial?`,Z,H,J,V),H===W)return!0}return!1}let F;if(typeof z==="string")F=v===z,this.debug("string match",z,v,F);else F=z.test(v),this.debug("pattern match",z,v,F);if(!F)return!1}if(Q===W&&K===G)return!0;else if(Q===W)return X;else if(K===G)return Q===W-1&&Z[Q]==="";else throw Error("wtf?")}braceExpand(){return pi(this.pattern,this.options)}parse(Z){KG(Z);let J=this.options;if(Z==="**")return J6;if(Z==="")return"";let X,Y=null;if(X=Z.match(hc1))Y=J.dot?bc1:Sc1;else if(X=Z.match(Nc1))Y=(J.nocase?J.dot?Cc1:Tc1:J.dot?Oc1:Pc1)(X[1]);else if(X=Z.match(Ac1))Y=(J.nocase?J.dot?uc1:mc1:J.dot?lc1:yc1)(X);else if(X=Z.match(fc1))Y=J.dot?Ec1:kc1;else if(X=Z.match(Ic1))Y=_c1;let $=Z6.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?gc1:J.dot?dc1:ac1,Y=new Set(J.nocase?["i"]:[]),$=Z.map((W)=>{let G=W.map((z)=>{if(z instanceof RegExp)for(let v of z.flags.split(""))Y.add(v);return typeof z==="string"?tc1(z):z===J6?J6:z._src});return G.forEach((z,v)=>{let H=G[v+1],V=G[v-1];if(z!==J6||V===J6)return;if(V===void 0)if(H!==void 0&&H!==J6)G[v+1]="(?:\\/|"+X+"\\/)?"+H;else G[v]=X;else if(H===void 0)G[v-1]=V+"(?:\\/|"+X+")?";else if(H!==J6)G[v-1]=V+"(?:\\/|\\/"+X+"\\/)"+H,G[v+1]=J6}),G.filter((z)=>z!==J6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if($="^"+Q+$+K+"$",this.negate)$="^(?!"+$+").+$";try{this.regexp=new RegExp($,[...Y].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit(Z){if(this.preserveMultipleSlashes)return Z.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Z))return["",...Z.split(/\/+/)];else return Z.split(/\/+/)}match(Z,J=this.partial){if(this.debug("match",Z,this.pattern),this.comment)return!1;if(this.empty)return Z==="";if(Z==="/"&&J)return!0;let X=this.options;if(this.isWindows)Z=Z.split("\\").join("/");let 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 W=$[K],G=Y;if(X.matchBase&&W.length===1)G=[Q];if(this.matchOne(G,W,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return h6.defaults(Z).Minimatch}}h6.AST=Z6;h6.Minimatch=V4;h6.escape=Z3;h6.unescape=F9;import{fileURLToPath as fU1}from"node:url";var J3=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,gi=new Set,pM=typeof process==="object"&&!!process?process:{},di=(Z,J,X,Y)=>{typeof pM.emitWarning==="function"?pM.emitWarning(Z,J,X,Y):console.error(`[${X}] ${J}: ${Z}`)},PF=globalThis.AbortController,ii=globalThis.AbortSignal;if(typeof PF>"u"){ii=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(Y,$){this._onabort.push($)}},PF=class{constructor(){J()}signal=new ii;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=pM.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,di("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 ec1=(Z)=>!gi.has(Z),aR6=Symbol("type"),IJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),ai=(Z)=>!IJ(Z)?null:Z<=Math.pow(2,8)?Uint8Array:Z<=Math.pow(2,16)?Uint16Array:Z<=Math.pow(2,32)?Uint32Array:Z<=Number.MAX_SAFE_INTEGER?GG:null;class GG extends Array{constructor(Z){super(Z);this.fill(0)}}class X3{heap;length;static#Z=!1;static create(Z){let J=ai(Z);if(!J)return[];X3.#Z=!0;let X=new X3(Z,J);return X3.#Z=!1,X}constructor(Z,J){if(!X3.#Z)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new J(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}}class zG{#Z;#J;#Y;#X;#$;#v;#H;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#z;#V;#Q;#F;#c;#w;#x;#O;#j;#T;#D;#L;#B;#N;#U;#f;static unsafeExposeInternals(Z){return{starts:Z.#D,ttls:Z.#L,sizes:Z.#T,keyMap:Z.#z,keyList:Z.#V,valList:Z.#Q,next:Z.#F,prev:Z.#c,get head(){return Z.#w},get tail(){return Z.#x},free:Z.#O,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,Y,$)=>Z.#h(J,X,Y,$),moveToTail:(J)=>Z.#A(J),indexes:(J)=>Z.#P(J),rindexes:(J)=>Z.#C(J),isStale:(J)=>Z.#R(J)}}get max(){return this.#Z}get maxSize(){return this.#J}get calculatedSize(){return this.#G}get size(){return this.#W}get fetchMethod(){return this.#v}get memoMethod(){return this.#H}get dispose(){return this.#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:W,dispose:G,onInsert:z,disposeAfter:v,noDisposeOnSet:H,noUpdateTTL:V,maxSize:q=0,maxEntrySize:F=0,sizeCalculation:w,fetchMethod:c,memoMethod:U,noDeleteOnFetchRejection:j,noDeleteOnStaleGet:B,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:R,ignoreFetchAbort:M}=Z;if(J!==0&&!IJ(J))throw TypeError("max option must be a nonnegative integer");let N=J?ai(J):Array;if(!N)throw Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=F||this.#J,this.sizeCalculation=w,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(U!==void 0&&typeof U!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#H=U,c!==void 0&&typeof c!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#v=c,this.#N=!!c,this.#z=new Map,this.#V=Array(J).fill(void 0),this.#Q=Array(J).fill(void 0),this.#F=new N(J),this.#c=new N(J),this.#w=0,this.#x=0,this.#O=X3.create(J),this.#W=0,this.#G=0,typeof G==="function")this.#Y=G;if(typeof z==="function")this.#X=z;if(typeof v==="function")this.#$=v,this.#j=[];else this.#$=void 0,this.#j=void 0;if(this.#B=!!this.#Y,this.#f=!!this.#X,this.#U=!!this.#$,this.noDisposeOnSet=!!H,this.noUpdateTTL=!!V,this.noDeleteOnFetchRejection=!!j,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!IJ(this.#J))throw TypeError("maxSize must be a positive integer if specified")}if(!IJ(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#u()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!B,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=IJ(Y)||Y===0?Y:1,this.ttlAutopurge=!!$,this.ttl=X||0,this.ttl){if(!IJ(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(ec1("LRU_CACHE_UNBOUNDED"))gi.add("LRU_CACHE_UNBOUNDED"),di("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",zG)}}getRemainingTTL(Z){return this.#z.has(Z)?1/0:0}#K(){let Z=new GG(this.#Z),J=new GG(this.#Z);this.#L=Z,this.#D=J,this.#k=($,Q,K=J3.now())=>{if(J[$]=Q!==0?K:0,Z[$]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#R($))this.#E(this.#V[$],"expire")},Q+1);if(W.unref)W.unref()}},this.#I=($)=>{J[$]=Z[$]!==0?J3.now():0},this.#M=($,Q)=>{if(Z[Q]){let K=Z[Q],W=J[Q];if(!K||!W)return;$.ttl=K,$.start=W,$.now=X||Y();let G=$.now-W;$.remainingTTL=K-G}};let X=0,Y=()=>{let $=J3.now();if(this.ttlResolution>0){X=$;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return $};this.getRemainingTTL=($)=>{let Q=this.#z.get($);if(Q===void 0)return 0;let K=Z[Q],W=J[Q];if(!K||!W)return 1/0;let G=(X||Y())-W;return K-G},this.#R=($)=>{let Q=J[$],K=Z[$];return!!K&&!!Q&&(X||Y())-Q>K}}#I=()=>{};#M=()=>{};#k=()=>{};#R=()=>!1;#u(){let Z=new GG(this.#Z);this.#G=0,this.#T=Z,this.#_=(J)=>{this.#G-=Z[J],Z[J]=0},this.#l=(J,X,Y,$)=>{if(this.#q(X))return 0;if(!IJ(Y))if($){if(typeof $!=="function")throw TypeError("sizeCalculation must be a function");if(Y=$(X,J),!IJ(Y))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return Y},this.#S=(J,X,Y)=>{if(Z[J]=X,this.#J){let $=this.#J-Z[J];while(this.#G>$)this.#b(!0)}if(this.#G+=Z[J],Y)Y.entrySize=X,Y.totalCalculatedSize=this.#G}}#_=(Z)=>{};#S=(Z,J,X)=>{};#l=(Z,J,X,Y)=>{if(X||Y)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#x;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#w)break;else J=this.#c[J]}}*#C({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#w;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#x)break;else J=this.#F[J]}}#y(Z){return Z!==void 0&&this.#z.get(this.#V[Z])===Z}*entries(){for(let Z of this.#P())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#C())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*keys(){for(let Z of this.#P()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#C()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#P())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#C())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,J={}){for(let X of this.#P()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;if(Z($,this.#V[X],this))return this.get(this.#V[X],J)}}forEach(Z,J=this){for(let X of this.#P()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#V[X],this)}}rforEach(Z,J=this){for(let X of this.#C()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#V[X],this)}}purgeStale(){let Z=!1;for(let J of this.#C({allowStale:!0}))if(this.#R(J))this.#E(this.#V[J],"expire"),Z=!0;return Z}info(Z){let J=this.#z.get(Z);if(J===void 0)return;let X=this.#Q[J],Y=this.#q(X)?X.__staleWhileFetching:X;if(Y===void 0)return;let $={value:Y};if(this.#L&&this.#D){let Q=this.#L[J],K=this.#D[J];if(Q&&K){let W=Q-(J3.now()-K);$.ttl=W,$.start=Date.now()}}if(this.#T)$.size=this.#T[J];return $}dump(){let Z=[];for(let J of this.#P({allowStale:!0})){let X=this.#V[J],Y=this.#Q[J],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0||X===void 0)continue;let Q={value:$};if(this.#L&&this.#D){Q.ttl=this.#L[J];let K=J3.now()-this.#D[J];Q.start=Math.floor(Date.now()-K)}if(this.#T)Q.size=this.#T[J];Z.unshift([X,Q])}return Z}load(Z){this.clear();for(let[J,X]of Z){if(X.start){let Y=Date.now()-X.start;X.start=J3.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:W}=X,{noUpdateTTL:G=this.noUpdateTTL}=X,z=this.#l(Z,J,X.size||0,K);if(this.maxEntrySize&&z>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#E(Z,"set"),this}let v=this.#W===0?void 0:this.#z.get(Z);if(v===void 0){if(v=this.#W===0?this.#x:this.#O.length!==0?this.#O.pop():this.#W===this.#Z?this.#b(!1):this.#W,this.#V[v]=Z,this.#Q[v]=J,this.#z.set(Z,v),this.#F[this.#x]=v,this.#c[v]=this.#x,this.#x=v,this.#W++,this.#S(v,z,W),W)W.set="add";if(G=!1,this.#f)this.#X?.(J,Z,"add")}else{this.#A(v);let H=this.#Q[v];if(J!==H){if(this.#N&&this.#q(H)){H.__abortController.abort(Error("replaced"));let{__staleWhileFetching:V}=H;if(V!==void 0&&!Q){if(this.#B)this.#Y?.(V,Z,"set");if(this.#U)this.#j?.push([V,Z,"set"])}}else if(!Q){if(this.#B)this.#Y?.(H,Z,"set");if(this.#U)this.#j?.push([H,Z,"set"])}if(this.#_(v),this.#S(v,z,W),this.#Q[v]=J,W){W.set="replace";let V=H&&this.#q(H)?H.__staleWhileFetching:H;if(V!==void 0)W.oldValue=V}}else if(W)W.set="update";if(this.#f)this.onInsert?.(J,Z,J===H?"update":"replace")}if(Y!==0&&!this.#L)this.#K();if(this.#L){if(!G)this.#k(v,Y,$);if(W)this.#M(W,v)}if(!Q&&this.#U&&this.#j){let H=this.#j,V;while(V=H?.shift())this.#$?.(...V)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#w];if(this.#b(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#U&&this.#j){let Z=this.#j,J;while(J=Z?.shift())this.#$?.(...J)}}}#b(Z){let J=this.#w,X=this.#V[J],Y=this.#Q[J];if(this.#N&&this.#q(Y))Y.__abortController.abort(Error("evicted"));else if(this.#B||this.#U){if(this.#B)this.#Y?.(Y,X,"evict");if(this.#U)this.#j?.push([Y,X,"evict"])}if(this.#_(J),Z)this.#V[J]=void 0,this.#Q[J]=void 0,this.#O.push(J);if(this.#W===1)this.#w=this.#x=0,this.#O.length=0;else this.#w=this.#F[J];return this.#z.delete(X),this.#W--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:Y}=J,$=this.#z.get(Z);if($!==void 0){let Q=this.#Q[$];if(this.#q(Q)&&Q.__staleWhileFetching===void 0)return!1;if(!this.#R($)){if(X)this.#I($);if(Y)Y.has="hit",this.#M(Y,$);return!0}else if(Y)Y.has="stale",this.#M(Y,$)}else if(Y)Y.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,Y=this.#z.get(Z);if(Y===void 0||!X&&this.#R(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 PF,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:Y},G=(F,w=!1)=>{let{aborted:c}=Q.signal,U=X.ignoreFetchAbort&&F!==void 0;if(X.status)if(c&&!w){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,U)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(c&&!U&&!w)return v(Q.signal.reason);let j=V;if(this.#Q[J]===V)if(F===void 0)if(j.__staleWhileFetching)this.#Q[J]=j.__staleWhileFetching;else this.#E(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,F,W.options)}return F},z=(F)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=F;return v(F)},v=(F)=>{let{aborted:w}=Q.signal,c=w&&X.allowStaleOnFetchAbort,U=c||X.allowStaleOnFetchRejection,j=U||X.noDeleteOnFetchRejection,B=V;if(this.#Q[J]===V){if(!j||B.__staleWhileFetching===void 0)this.#E(Z,"fetch");else if(!c)this.#Q[J]=B.__staleWhileFetching}if(U){if(X.status&&B.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return B.__staleWhileFetching}else if(B.__returned===B)throw F},H=(F,w)=>{let c=this.#v?.(Z,$,W);if(c&&c instanceof Promise)c.then((U)=>F(U===void 0?void 0:U),w);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(F(void 0),X.allowStaleOnFetchAbort)F=(U)=>G(U,!0)}})};if(X.status)X.status.fetchDispatched=!0;let V=new Promise(H).then(G,z),q=Object.assign(V,{__abortController:Q,__staleWhileFetching:$,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#z.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#N)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof PF}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:W=0,sizeCalculation:G=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:v=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:H=this.allowStaleOnFetchRejection,ignoreFetchAbort:V=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:F,forceRefresh:w=!1,status:c,signal:U}=J;if(!this.#N){if(c)c.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,status:c})}let j={allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:z,noDeleteOnFetchRejection:v,allowStaleOnFetchRejection:H,allowStaleOnFetchAbort:q,ignoreFetchAbort:V,status:c,signal:U},B=this.#z.get(Z);if(B===void 0){if(c)c.fetch="miss";let L=this.#h(Z,B,j,F);return L.__returned=L}else{let L=this.#Q[B];if(this.#q(L)){let O=X&&L.__staleWhileFetching!==void 0;if(c){if(c.fetch="inflight",O)c.returnedStale=!0}return O?L.__staleWhileFetching:L.__returned=L}let R=this.#R(B);if(!w&&!R){if(c)c.fetch="hit";if(this.#A(B),Y)this.#I(B);if(c)this.#M(c,B);return L}let M=this.#h(Z,B,j,F),P=M.__staleWhileFetching!==void 0&&X;if(c){if(c.fetch=R?"stale":"refresh",P&&R)c.returnedStale=!0}return P?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#H;if(!X)throw Error("no memoMethod provided to constructor");let{context:Y,forceRefresh:$,...Q}=J,K=this.get(Z,Q);if(!$&&K!==void 0)return K;let W=X(Z,K,{options:Q,context:Y});return this.set(Z,W,Q),W}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:Y=this.updateAgeOnGet,noDeleteOnStaleGet:$=this.noDeleteOnStaleGet,status:Q}=J,K=this.#z.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#M(Q,K);if(this.#R(K)){if(Q)Q.get="stale";if(!G){if(!$)this.#E(Z,"expire");if(Q&&X)Q.returnedStale=!0;return X?W:void 0}else{if(Q&&X&&W.__staleWhileFetching!==void 0)Q.returnedStale=!0;return X?W.__staleWhileFetching:void 0}}else{if(Q)Q.get="hit";if(G)return W.__staleWhileFetching;if(this.#A(K),Y)this.#I(K);return W}}else if(Q)Q.get="miss"}#p(Z,J){this.#c[J]=Z,this.#F[Z]=J}#A(Z){if(Z!==this.#x){if(Z===this.#w)this.#w=this.#F[Z];else this.#p(this.#c[Z],this.#F[Z]);this.#p(this.#x,Z),this.#x=Z}}delete(Z){return this.#E(Z,"delete")}#E(Z,J){let X=!1;if(this.#W!==0){let Y=this.#z.get(Z);if(Y!==void 0)if(X=!0,this.#W===1)this.#m(J);else{this.#_(Y);let $=this.#Q[Y];if(this.#q($))$.__abortController.abort(Error("deleted"));else if(this.#B||this.#U){if(this.#B)this.#Y?.($,Z,J);if(this.#U)this.#j?.push([$,Z,J])}if(this.#z.delete(Z),this.#V[Y]=void 0,this.#Q[Y]=void 0,Y===this.#x)this.#x=this.#c[Y];else if(Y===this.#w)this.#w=this.#F[Y];else{let Q=this.#c[Y];this.#F[Q]=this.#F[Y];let K=this.#F[Y];this.#c[K]=this.#c[Y]}this.#W--,this.#O.push(Y)}}if(this.#U&&this.#j?.length){let Y=this.#j,$;while($=Y?.shift())this.#$?.(...$)}return X}clear(){return this.#m("delete")}#m(Z){for(let J of this.#C({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(Error("deleted"));else{let Y=this.#V[J];if(this.#B)this.#Y?.(X,Y,Z);if(this.#U)this.#j?.push([X,Y,Z])}}if(this.#z.clear(),this.#Q.fill(void 0),this.#V.fill(void 0),this.#L&&this.#D)this.#L.fill(0),this.#D.fill(0);if(this.#T)this.#T.fill(0);if(this.#w=0,this.#x=0,this.#O.length=0,this.#G=0,this.#W=0,this.#U&&this.#j){let J=this.#j,X;while(X=J?.shift())this.#$?.(...X)}}}import{posix as vU1,win32 as eM}from"node:path";import{fileURLToPath as VU1}from"node:url";import{lstatSync as HU1,readdir as qU1,readdirSync as FU1,readlinkSync as wU1,realpathSync as cU1}from"fs";import*as UU1 from"node:fs";import{lstat as jU1,readdir as BU1,readlink as LU1,realpath as DU1}from"node:fs/promises";import{EventEmitter as sM}from"node:events";import ti from"node:stream";import{StringDecoder as ZU1}from"node:string_decoder";var ni=typeof process==="object"&&process?process:{stdout:null,stderr:null},JU1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof CY||Z instanceof ti||XU1(Z)||YU1(Z)),XU1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof sM&&typeof Z.pipe==="function"&&Z.pipe!==ti.Writable.prototype.pipe,YU1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof sM&&typeof Z.write==="function"&&typeof Z.end==="function",ZZ=Symbol("EOF"),JZ=Symbol("maybeEmitEnd"),_J=Symbol("emittedEnd"),OF=Symbol("emittingEnd"),vG=Symbol("emittedError"),TF=Symbol("closed"),si=Symbol("read"),CF=Symbol("flush"),oi=Symbol("flushChunk"),w9=Symbol("encoding"),Y3=Symbol("decoder"),y8=Symbol("flowing"),VG=Symbol("paused"),$3=Symbol("resume"),p8=Symbol("buffer"),S6=Symbol("pipes"),i8=Symbol("bufferLength"),iM=Symbol("bufferPush"),fF=Symbol("bufferShift"),w6=Symbol("objectMode"),U8=Symbol("destroyed"),gM=Symbol("error"),dM=Symbol("emitData"),ri=Symbol("emitEnd"),aM=Symbol("emitEnd2"),Y7=Symbol("async"),nM=Symbol("abort"),kF=Symbol("aborted"),HG=Symbol("signal"),TY=Symbol("dataListeners"),I5=Symbol("discarded"),qG=(Z)=>Promise.resolve().then(Z),$U1=(Z)=>Z(),QU1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",KU1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,WU1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class oM{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[$3](),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 ei extends oM{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 GU1=(Z)=>!!Z.objectMode,zU1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class CY extends sM{[y8]=!1;[VG]=!1;[S6]=[];[p8]=[];[w6];[w9];[Y7];[Y3];[ZZ]=!1;[_J]=!1;[OF]=!1;[TF]=!1;[vG]=null;[i8]=0;[U8]=!1;[HG];[kF]=!1;[TY]=0;[I5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(GU1(J))this[w6]=!0,this[w9]=null;else if(zU1(J))this[w9]=J.encoding,this[w6]=!1;else this[w6]=!1,this[w9]=null;if(this[Y7]=!!J.async,this[Y3]=this[w9]?new ZU1(this[w9]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[p8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[S6]});let{signal:X}=J;if(X)if(this[HG]=X,X.aborted)this[nM]();else X.addEventListener("abort",()=>this[nM]())}get bufferLength(){return this[i8]}get encoding(){return this[w9]}set encoding(Z){throw Error("Encoding must be set at instantiation time")}setEncoding(Z){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[w6]}set objectMode(Z){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[Y7]}set["async"](Z){this[Y7]=this[Y7]||!!Z}[nM](){this[kF]=!0,this.emit("abort",this[HG]?.reason),this.destroy(this[HG]?.reason)}get aborted(){return this[kF]}set aborted(Z){}write(Z,J,X){if(this[kF])return!1;if(this[ZZ])throw Error("write after end");if(this[U8])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof J==="function")X=J,J="utf8";if(!J)J="utf8";let Y=this[Y7]?qG:$U1;if(!this[w6]&&!Buffer.isBuffer(Z)){if(WU1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(KU1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[w6]){if(this[y8]&&this[i8]!==0)this[CF](!0);if(this[y8])this.emit("data",Z);else this[iM](Z);if(this[i8]!==0)this.emit("readable");if(X)Y(X);return this[y8]}if(!Z.length){if(this[i8]!==0)this.emit("readable");if(X)Y(X);return this[y8]}if(typeof Z==="string"&&!(J===this[w9]&&!this[Y3]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[w9])Z=this[Y3].write(Z);if(this[y8]&&this[i8]!==0)this[CF](!0);if(this[y8])this.emit("data",Z);else this[iM](Z);if(this[i8]!==0)this.emit("readable");if(X)Y(X);return this[y8]}read(Z){if(this[U8])return null;if(this[I5]=!1,this[i8]===0||Z===0||Z&&Z>this[i8])return this[JZ](),null;if(this[w6])Z=null;if(this[p8].length>1&&!this[w6])this[p8]=[this[w9]?this[p8].join(""):Buffer.concat(this[p8],this[i8])];let J=this[si](Z||null,this[p8][0]);return this[JZ](),J}[si](Z,J){if(this[w6])this[fF]();else{let X=J;if(Z===X.length||Z===null)this[fF]();else if(typeof X==="string")this[p8][0]=X.slice(Z),J=X.slice(0,Z),this[i8]-=Z;else this[p8][0]=X.subarray(Z),J=X.subarray(0,Z),this[i8]-=Z}if(this.emit("data",J),!this[p8].length&&!this[ZZ])this.emit("drain");return J}end(Z,J,X){if(typeof Z==="function")X=Z,Z=void 0;if(typeof J==="function")X=J,J="utf8";if(Z!==void 0)this.write(Z,J);if(X)this.once("end",X);if(this[ZZ]=!0,this.writable=!1,this[y8]||!this[VG])this[JZ]();return this}[$3](){if(this[U8])return;if(!this[TY]&&!this[S6].length)this[I5]=!0;if(this[VG]=!1,this[y8]=!0,this.emit("resume"),this[p8].length)this[CF]();else if(this[ZZ])this[JZ]();else this.emit("drain")}resume(){return this[$3]()}pause(){this[y8]=!1,this[VG]=!0,this[I5]=!1}get destroyed(){return this[U8]}get flowing(){return this[y8]}get paused(){return this[VG]}[iM](Z){if(this[w6])this[i8]+=1;else this[i8]+=Z.length;this[p8].push(Z)}[fF](){if(this[w6])this[i8]-=1;else this[i8]-=this[p8][0].length;return this[p8].shift()}[CF](Z=!1){do;while(this[oi](this[fF]())&&this[p8].length);if(!Z&&!this[p8].length&&!this[ZZ])this.emit("drain")}[oi](Z){return this.emit("data",Z),this[y8]}pipe(Z,J){if(this[U8])return Z;this[I5]=!1;let X=this[_J];if(J=J||{},Z===ni.stdout||Z===ni.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 oM(this,Z,J):new ei(this,Z,J)),this[Y7])qG(()=>this[$3]());else this[$3]();return Z}unpipe(Z){let J=this[S6].find((X)=>X.dest===Z);if(J){if(this[S6].length===1){if(this[y8]&&this[TY]===0)this[y8]=!1;this[S6]=[]}else this[S6].splice(this[S6].indexOf(J),1);J.unpipe()}}addListener(Z,J){return this.on(Z,J)}on(Z,J){let X=super.on(Z,J);if(Z==="data"){if(this[I5]=!1,this[TY]++,!this[S6].length&&!this[y8])this[$3]()}else if(Z==="readable"&&this[i8]!==0)super.emit("readable");else if(QU1(Z)&&this[_J])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[vG]){let Y=J;if(this[Y7])qG(()=>Y.call(this,this[vG]));else Y.call(this,this[vG])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[TY]=this.listeners("data").length,this[TY]===0&&!this[I5]&&!this[S6].length)this[y8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[TY]=0,!this[I5]&&!this[S6].length)this[y8]=!1}return J}get emittedEnd(){return this[_J]}[JZ](){if(!this[OF]&&!this[_J]&&!this[U8]&&this[p8].length===0&&this[ZZ]){if(this[OF]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[TF])this.emit("close");this[OF]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==U8&&this[U8])return!1;else if(Z==="data")return!this[w6]&&!X?!1:this[Y7]?(qG(()=>this[dM](X)),!0):this[dM](X);else if(Z==="end")return this[ri]();else if(Z==="close"){if(this[TF]=!0,!this[_J]&&!this[U8])return!1;let $=super.emit("close");return this.removeAllListeners("close"),$}else if(Z==="error"){this[vG]=X,super.emit(gM,X);let $=!this[HG]||this.listeners("error").length?super.emit("error",X):!1;return this[JZ](),$}else if(Z==="resume"){let $=super.emit("resume");return this[JZ](),$}else if(Z==="finish"||Z==="prefinish"){let $=super.emit(Z);return this.removeAllListeners(Z),$}let Y=super.emit(Z,...J);return this[JZ](),Y}[dM](Z){for(let X of this[S6])if(X.dest.write(Z)===!1)this.pause();let J=this[I5]?!1:super.emit("data",Z);return this[JZ](),J}[ri](){if(this[_J])return!1;return this[_J]=!0,this.readable=!1,this[Y7]?(qG(()=>this[aM]()),!0):this[aM]()}[aM](){if(this[Y3]){let J=this[Y3].end();if(J){for(let X of this[S6])X.dest.write(J);if(!this[I5])super.emit("data",J)}}for(let J of this[S6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[w6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[w6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[w6])throw Error("cannot concat in objectMode");let Z=await this.collect();return this[w9]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(U8,()=>J(Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[I5]=!1;let Z=!1,J=async()=>{return this.pause(),Z=!0,{value:void 0,done:!0}};return{next:()=>{if(Z)return J();let Y=this.read();if(Y!==null)return Promise.resolve({done:!1,value:Y});if(this[ZZ])return J();let $,Q,K=(v)=>{this.off("data",W),this.off("end",G),this.off(U8,z),J(),Q(v)},W=(v)=>{this.off("error",K),this.off("end",G),this.off(U8,z),this.pause(),$({value:v,done:!!this[ZZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(U8,z),J(),$({done:!0,value:void 0})},z=()=>K(Error("stream destroyed"));return new Promise((v,H)=>{Q=H,$=v,this.once(U8,z),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[I5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(gM,J),this.off(U8,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(gM,J),this.once(U8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[U8]){if(Z)this.emit("error",Z);else this.emit(U8);return this}this[U8]=!0,this[I5]=!0,this[p8].length=0,this[i8]=0;let J=this;if(typeof J.close==="function"&&!this[TF])J.close();if(Z)this.emit("error",Z);else this.emit(U8);return this}static get isStream(){return JU1}}var xU1=cU1.native,wG={lstatSync:HU1,readdir:qU1,readdirSync:FU1,readlinkSync:wU1,realpathSync:xU1,promises:{lstat:jU1,readdir:BU1,readlink:LU1,realpath:DU1}},$g=(Z)=>!Z||Z===wG||Z===UU1?wG:{...wG,...Z,promises:{...wG.promises,...Z.promises||{}}},Qg=/^\\\\\?\\([a-z]:)\\?$/i,MU1=(Z)=>Z.replace(/\//g,"\\").replace(Qg,"$1\\"),RU1=/[\\\/]/,q4=0,Kg=1,Wg=2,$7=4,Gg=6,zg=8,fY=10,vg=12,H4=15,FG=~H4,rM=16,Zg=32,cG=64,c9=128,EF=256,_F=512,Jg=cG|c9|_F,NU1=1023,tM=(Z)=>Z.isFile()?zg:Z.isDirectory()?$7:Z.isSymbolicLink()?fY:Z.isCharacterDevice()?Wg:Z.isBlockDevice()?Gg:Z.isSocket()?vg:Z.isFIFO()?Kg:q4,Xg=new Map,UG=(Z)=>{let J=Xg.get(Z);if(J)return J;let X=Z.normalize("NFKD");return Xg.set(Z,X),X},Yg=new Map,IF=(Z)=>{let J=Yg.get(Z);if(J)return J;let X=UG(Z.toLowerCase());return Yg.set(Z,X),X};class ZR extends zG{constructor(){super({max:256})}}class Vg extends zG{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var Hg=Symbol("PathScurry setAsCwd");class b6{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}#H;get rdev(){return this.#H}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#z;get size(){return this.#z}#V;get blocks(){return this.#V}#Q;get atimeMs(){return this.#Q}#F;get mtimeMs(){return this.#F}#c;get ctimeMs(){return this.#c}#w;get birthtimeMs(){return this.#w}#x;get atime(){return this.#x}#O;get mtime(){return this.#O}#j;get ctime(){return this.#j}#T;get birthtime(){return this.#T}#D;#L;#B;#N;#U;#f;#K;#I;#M;#k;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=q4,X,Y,$,Q,K){if(this.name=Z,this.#D=$?IF(Z):UG(Z),this.#K=J&NU1,this.nocase=$,this.roots=Y,this.root=X||this,this.#I=Q,this.#B=K.fullpath,this.#U=K.relative,this.#f=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=$g(K.fs)}depth(){if(this.#L!==void 0)return this.#L;if(!this.parent)return this.#L=0;return this.#L=this.parent.depth()+1}childrenCache(){return this.#I}resolve(Z){if(!Z)return this;let J=this.getRootString(Z),Y=Z.substring(J.length).split(this.splitSep);return J?this.getRoot(J).#R(Y):this.#R(Y)}#R(Z){let J=this;for(let X of Z)J=J.child(X);return J}children(){let Z=this.#I.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#I.set(this,J),this.#K&=~rM,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),Y=this.nocase?IF(Z):UG(Z);for(let W of X)if(W.#D===Y)return W;let $=this.parent?this.sep:"",Q=this.#B?this.#B+$+Z:void 0,K=this.newChild(Z,q4,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=c9;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#U!==void 0)return this.#U;let Z=this.name,J=this.parent;if(!J)return this.#U=this.name;let X=J.relative();return X+(!X||!J.parent?"":this.sep)+Z}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#f!==void 0)return this.#f;let Z=this.name,J=this.parent;if(!J)return this.#f=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#B!==void 0)return this.#B;let Z=this.name,J=this.parent;if(!J)return this.#B=this.name;let Y=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#B=Y}fullpathPosix(){if(this.#N!==void 0)return this.#N;if(this.sep==="/")return this.#N=this.fullpath();if(!this.parent){let Y=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(Y))return this.#N=`//?/${Y}`;else return this.#N=Y}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#N=X}isUnknown(){return(this.#K&H4)===q4}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&H4)===zg}isDirectory(){return(this.#K&H4)===$7}isCharacterDevice(){return(this.#K&H4)===Wg}isBlockDevice(){return(this.#K&H4)===Gg}isFIFO(){return(this.#K&H4)===Kg}isSocket(){return(this.#K&H4)===vg}isSymbolicLink(){return(this.#K&fY)===fY}lstatCached(){return this.#K&Zg?this:void 0}readlinkCached(){return this.#M}realpathCached(){return this.#k}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#M)return!0;if(!this.parent)return!1;let Z=this.#K&H4;return!(Z!==q4&&Z!==fY||this.#K&EF||this.#K&c9)}calledReaddir(){return!!(this.#K&rM)}isENOENT(){return!!(this.#K&c9)}isNamed(Z){return!this.nocase?this.#D===UG(Z):this.#D===IF(Z)}async readlink(){let Z=this.#M;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=await this.#Z.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(J);if(X)return this.#M=X}catch(J){this.#b(J.code);return}}readlinkSync(){let Z=this.#M;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=this.#Z.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(J);if(X)return this.#M=X}catch(J){this.#b(J.code);return}}#u(Z){this.#K|=rM;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#_()}}#_(){if(this.#K&c9)return;this.#K=(this.#K|c9)&FG,this.#S()}#S(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#_()}#l(){this.#K|=_F,this.#P()}#P(){if(this.#K&cG)return;let Z=this.#K;if((Z&H4)===$7)Z&=FG;this.#K=Z|cG,this.#S()}#C(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#P();else if(Z==="ENOENT")this.#_();else this.children().provisional=0}#y(Z=""){if(Z==="ENOTDIR")this.parent.#P();else if(Z==="ENOENT")this.#_()}#b(Z=""){let J=this.#K;if(J|=EF,Z==="ENOENT")J|=c9;if(Z==="EINVAL"||Z==="UNKNOWN")J&=FG;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#P()}#h(Z,J){return this.#p(Z,J)||this.#q(Z,J)}#q(Z,J){let X=tM(Z),Y=this.newChild(Z.name,X,{parent:this}),$=Y.#K&H4;if($!==$7&&$!==fY&&$!==q4)Y.#K|=cG;return J.unshift(Y),J.provisional++,Y}#p(Z,J){for(let X=J.provisional;X<J.length;X++){let Y=J[X];if((this.nocase?IF(Z.name):UG(Z.name))!==Y.#D)continue;return this.#A(Z,Y,X,J)}}#A(Z,J,X,Y){let $=J.name;if(J.#K=J.#K&FG|tM(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&c9)===0)try{return this.#E(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#y(Z.code)}}lstatSync(){if((this.#K&c9)===0)try{return this.#E(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#y(Z.code)}}#E(Z){let{atime:J,atimeMs:X,birthtime:Y,birthtimeMs:$,blksize:Q,blocks:K,ctime:W,ctimeMs:G,dev:z,gid:v,ino:H,mode:V,mtime:q,mtimeMs:F,nlink:w,rdev:c,size:U,uid:j}=Z;this.#x=J,this.#Q=X,this.#T=Y,this.#w=$,this.#W=Q,this.#V=K,this.#j=W,this.#c=G,this.#J=z,this.#v=v,this.#G=H,this.#Y=V,this.#O=q,this.#F=F,this.#X=w,this.#H=c,this.#z=U,this.#$=j;let B=tM(Z);if(this.#K=this.#K&FG|B|Zg,B!==q4&&B!==$7&&B!==fY)this.#K|=cG}#m=[];#g=!1;#d(Z){this.#g=!1;let J=this.#m.slice();this.#m.length=0,J.forEach((X)=>X(null,Z))}readdirCB(Z,J=!1){if(!this.canReaddir()){if(J)Z(null,[]);else queueMicrotask(()=>Z(null,[]));return}let X=this.children();if(this.calledReaddir()){let $=X.slice(0,X.provisional);if(J)Z(null,$);else queueMicrotask(()=>Z(null,$));return}if(this.#m.push(Z),this.#g)return;this.#g=!0;let Y=this.fullpath();this.#Z.readdir(Y,{withFileTypes:!0},($,Q)=>{if($)this.#C($.code),X.provisional=0;else{for(let K of Q)this.#h(K,X);this.#u(X)}this.#d(X.slice(0,X.provisional));return})}#i;async readdir(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();if(this.#i)await this.#i;else{let X=()=>{};this.#i=new Promise((Y)=>X=Y);try{for(let Y of await this.#Z.promises.readdir(J,{withFileTypes:!0}))this.#h(Y,Z);this.#u(Z)}catch(Y){this.#C(Y.code),Z.provisional=0}this.#i=void 0,X()}return Z.slice(0,Z.provisional)}readdirSync(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();try{for(let X of this.#Z.readdirSync(J,{withFileTypes:!0}))this.#h(X,Z);this.#u(Z)}catch(X){this.#C(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&Jg)return!1;let Z=H4&this.#K;if(!(Z===q4||Z===$7||Z===fY))return!1;return!0}shouldWalk(Z,J){return(this.#K&$7)===$7&&!(this.#K&Jg)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#k)return this.#k;if((_F|EF|c9)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}realpathSync(){if(this.#k)return this.#k;if((_F|EF|c9)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}[Hg](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.#U=X.join(this.sep),Y.#f=X.join("/"),Y=Y.parent,X.push("..");Y=Z;while(Y&&Y.parent&&!J.has(Y))Y.#U=void 0,Y.#f=void 0,Y=Y.parent}}class hF extends b6{sep="\\";splitSep=RU1;constructor(Z,J=q4,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}newChild(Z,J=q4,X={}){return new hF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return eM.parse(Z).root}getRoot(Z){if(Z=MU1(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 xG(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(Qg,"$1\\"),Z===J}}class SF extends b6{splitSep="/";sep="/";constructor(Z,J=q4,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=q4,X={}){return new SF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class JR{root;rootPath;roots;cwd;#Z;#J;#Y;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:Y,childrenCacheSize:$=16384,fs:Q=wG}={}){if(this.#X=$g(Q),Z instanceof URL||Z.startsWith("file://"))Z=VU1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new ZR,this.#J=new ZR,this.#Y=new Vg($);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if(Y===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=Y,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let G=this.root,z=W.length-1,v=J.sep,H=this.rootPath,V=!1;for(let q of W){let F=z--;G=G.child(q,{relative:Array(F).fill("..").join(v),relativePosix:Array(F).fill("..").join("/"),fullpath:H+=(V?"":v)+q}),V=!0}this.cwd=G}depth(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.depth()}childrenCache(){return this.#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 b6))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 b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0}=J;if(!Z.canReaddir())return[];else if(X)return Z.readdirSync();else return Z.readdirSync().map((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 b6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.readlink();return J?X:X?.fullpath()}readlinkSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z.withFileTypes,Z=this.cwd;let X=Z.readlinkSync();return J?X:X?.fullpath()}async realpath(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.realpath();return J?X:X?.fullpath()}realpathSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z.withFileTypes,Z=this.cwd;let X=Z.realpathSync();return J?X:X?.fullpath()}async walk(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let W=new Set,G=(v,H)=>{W.add(v),v.readdirCB((V,q)=>{if(V)return H(V);let F=q.length;if(!F)return H();let w=()=>{if(--F===0)H()};for(let c of q){if(!$||$(c))K.push(X?c:c.fullpath());if(Y&&c.isSymbolicLink())c.realpath().then((U)=>U?.isUnknown()?U.lstat():U).then((U)=>U?.shouldWalk(W,Q)?G(U,w):w());else if(c.shouldWalk(W,Q))G(c,w);else w()}},!0)},z=Z;return new Promise((v,H)=>{G(z,(V)=>{if(V)return H(V);v(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let W=new Set([Z]);for(let G of W){let z=G.readdirSync();for(let v of z){if(!$||$(v))K.push(X?v:v.fullpath());let H=v;if(v.isSymbolicLink()){if(!(Y&&(H=v.realpathSync())))continue;if(H.isUnknown())H.lstatSync()}if(H.shouldWalk(W,Q))W.add(H)}}return K}[Symbol.asyncIterator](){return this.iterate()}iterate(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;return this.stream(Z,J)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J;if(!$||$(Z))yield X?Z:Z.fullpath();let K=new Set([Z]);for(let W of K){let G=W.readdirSync();for(let z of G){if(!$||$(z))yield X?z:z.fullpath();let v=z;if(z.isSymbolicLink()){if(!(Y&&(v=z.realpathSync())))continue;if(v.isUnknown())v.lstatSync()}if(v.shouldWalk(K,Q))K.add(v)}}}stream(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new CY({objectMode:!0});if(!$||$(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=(w,c,U=!1)=>{if(w)return K.emit("error",w);if(Y&&!U){let j=[];for(let B of c)if(B.isSymbolicLink())j.push(B.realpath().then((L)=>L?.isUnknown()?L.lstat():L));if(j.length){Promise.all(j).then(()=>q(null,c,!0));return}}for(let j of c)if(j&&(!$||$(j))){if(!K.write(X?j:j.fullpath()))H=!0}z--;for(let j of c){let B=j.realpathCached()||j;if(B.shouldWalk(W,Q))G.push(B)}if(H&&!K.flowing)K.once("drain",v);else if(!F)v()},F=!0;V.readdirCB(q,!0),F=!1}};return v(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new CY({objectMode:!0}),W=new Set;if(!$||$(Z))K.write(X?Z:Z.fullpath());let G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=V.readdirSync();for(let F of q)if(!$||$(F)){if(!K.write(X?F:F.fullpath()))H=!0}z--;for(let F of q){let w=F;if(F.isSymbolicLink()){if(!(Y&&(w=F.realpathSync())))continue;if(w.isUnknown())w.lstatSync()}if(w.shouldWalk(W,Q))G.push(w)}}if(H&&!K.flowing)K.once("drain",v)};return v(),K}chdir(Z=this.cwd){let J=this.cwd;this.cwd=typeof Z==="string"?this.cwd.resolve(Z):Z,this.cwd[Hg](J)}}class xG extends JR{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,eM,"\\",{...J,nocase:X});this.nocase=X;for(let Y=this.cwd;Y;Y=Y.parent)Y.nocase=this.nocase}parseRootPath(Z){return eM.parse(Z).root.toUpperCase()}newRoot(Z){return new hF(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class jG extends JR{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,vU1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new SF(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class bF extends jG{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var QN6=process.platform==="win32"?hF:SF,qg=process.platform==="win32"?xG:process.platform==="darwin"?bF:jG;var PU1=(Z)=>Z.length>=1,OU1=(Z)=>Z.length>=1;class Q3{#Z;#J;#Y;length;#X;#$;#v;#H;#W;#G;#z=!0;constructor(Z,J,X,Y){if(!PU1(Z))throw TypeError("empty pattern list");if(!OU1(J))throw TypeError("empty glob list");if(J.length!==Z.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw TypeError("index out of range");if(this.#Z=Z,this.#J=J,this.#Y=X,this.#X=Y,this.#Y===0){if(this.isUNC()){let[$,Q,K,W,...G]=this.#Z,[z,v,H,V,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let F=[$,Q,K,W,""].join("/"),w=[z,v,H,V,""].join("/");this.#Z=[F,...G],this.#J=[w,...q],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[$,...Q]=this.#Z,[K,...W]=this.#J;if(Q[0]==="")Q.shift(),W.shift();let G=$+"/",z=K+"/";this.#Z=[G,...Q],this.#J=[z,...W],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]===J6}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 Q3(this.#Z,this.#J,this.#Y+1,this.#X),this.#$.#G=this.#G,this.#$.#W=this.#W,this.#$.#H=this.#H,this.#$}isUNC(){let Z=this.#Z;return this.#W!==void 0?this.#W:this.#W=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.#H!==void 0?this.#H:this.#H=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.#G!==void 0?this.#G:this.#G=Z[0]===""&&Z.length>1||this.isDrive()||this.isUNC()}root(){let Z=this.#Z[0];return typeof Z==="string"&&this.isAbsolute()&&this.#Y===0?Z:""}checkFollowGlobstar(){return!(this.#Y===0||!this.isGlobstar()||!this.#z)}markFollowGlobstar(){if(this.#Y===0||!this.isGlobstar()||!this.#z)return!1;return this.#z=!1,!0}}var TU1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class BG{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:Y,noglobstar:$,platform:Q=TU1}){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 V4(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let Y=J.set[X],$=J.globParts[X];if(!Y||!$)throw Error("invalid pattern object");while(Y[0]==="."&&$[0]===".")Y.shift(),$.shift();let Q=new Q3(Y,$,0,this.platform),K=new V4(Q.globString(),this.mmopts),W=$[$.length-1]==="**",G=Q.isAbsolute();if(G)this.absolute.push(K);else this.relative.push(K);if(W)if(G)this.absoluteChildren.push(K);else this.relativeChildren.push(K)}}ignored(Z){let J=Z.fullpath(),X=`${J}/`,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 XR{store;constructor(Z=new Map){this.store=Z}copy(){return new XR(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 Fg{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 wg{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 Error("attempting to walk unknown path");return J}entries(){return this.keys().map((Z)=>[Z,this.store.get(Z)])}keys(){return[...this.store.keys()].filter((Z)=>Z.canReaddir())}}class LG{hasWalkedCache;matches=new Fg;subwalks=new wg;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new XR}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 W,G,z=!1;while(typeof(W=$.pattern())==="string"&&(G=$.rest()))Y=Y.resolve(W),$=G,z=!0;if(W=$.pattern(),G=$.rest(),z){if(this.hasWalkedCache.hasWalked(Y,$))continue;this.hasWalkedCache.storeWalked(Y,$)}if(typeof W==="string"){let v=W===".."||W===""||W===".";this.matches.add(Y.resolve(W),K,v);continue}else if(W===J6){if(!Y.isSymbolicLink()||this.follow||$.checkFollowGlobstar())this.subwalks.add(Y,$);let v=G?.pattern(),H=G?.rest();if(!G||(v===""||v===".")&&!H)this.matches.add(Y,K,v===""||v===".");else if(v===".."){let V=Y.parent||Y;if(!H)this.matches.add(V,K,!0);else if(!this.hasWalkedCache.hasWalked(V,H))this.subwalks.add(V,H)}}else if(W instanceof RegExp)this.subwalks.add(Y,$)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new LG(this.opts,this.hasWalkedCache)}filterEntries(Z,J){let X=this.subwalks.get(Z),Y=this.child();for(let $ of J)for(let Q of X){let K=Q.isAbsolute(),W=Q.pattern(),G=Q.rest();if(W===J6)Y.testGlobstar($,Q,G,K);else if(W instanceof RegExp)Y.testRegExp($,W,G,K);else Y.testString($,W,G,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 CU1=(Z,J)=>typeof Z==="string"?new BG([Z],J):Array.isArray(Z)?new BG(Z,J):Z;class YR{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#J;#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=CU1(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#X(Z){return this.seen.has(Z)||!!this.#J?.ignored?.(Z)}#$(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 LG(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,W,G]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,W,G).then(()=>Q())}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let W=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,W,X,Q);else K.readdirCB((G,z)=>this.walkCB3(K,z,X,Q),!0)}Q()}walkCB3(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,W,G).then(()=>Q())}for(let[K,W]of X.subwalks.entries())$++,this.walkCB2(K,W,X.child(),Q);Q()}walkCBSync(Z,J,X){if(this.signal?.aborted)X();this.walkCB2Sync(Z,J,new LG(this.opts),X)}walkCB2Sync(Z,J,X,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,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let W=K.readdirSync();this.walkCB3Sync(K,W,X,Q)}Q()}walkCB3Sync(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let[K,W]of X.subwalks.entries())$++,this.walkCB2Sync(K,W,X.child(),Q);Q()}}class AF extends YR{matches=new Set;constructor(Z,J,X){super(Z,J,X)}matchEmit(Z){this.matches.add(Z)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Z,J)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)J(this.signal.reason);else Z(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class mF extends YR{results;constructor(Z,J,X){super(Z,J,X);this.results=new CY({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 kU1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Q7{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Z,J){if(!J)throw TypeError("glob options required");if(this.withFileTypes=!!J.withFileTypes,this.signal=J.signal,this.follow=!!J.follow,this.dot=!!J.dot,this.dotRelative=!!J.dotRelative,this.nodir=!!J.nodir,this.mark=!!J.mark,!J.cwd)this.cwd="";else if(J.cwd instanceof URL||J.cwd.startsWith("file://"))J.cwd=fU1(J.cwd);if(this.cwd=J.cwd||"",this.root=J.root,this.magicalBraces=!!J.magicalBraces,this.nobrace=!!J.nobrace,this.noext=!!J.noext,this.realpath=!!J.realpath,this.absolute=J.absolute,this.includeChildMatches=J.includeChildMatches!==!1,this.noglobstar=!!J.noglobstar,this.matchBase=!!J.matchBase,this.maxDepth=typeof J.maxDepth==="number"?J.maxDepth:1/0,this.stat=!!J.stat,this.ignore=J.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof Z==="string")Z=[Z];if(this.windowsPathsNoEscape=!!J.windowsPathsNoEscape||J.allowWindowsEscape===!1,this.windowsPathsNoEscape)Z=Z.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(J.noglobstar)throw TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||kU1,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?xG:J.platform==="darwin"?bF:J.platform?jG:qg;this.scurry=new W(this.cwd,{nocase:J.nocase,fs:J.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",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((W)=>new V4(W,Y)),[Q,K]=$.reduce((W,G)=>{return W[0].push(...G.set),W[1].push(...G.globParts),W},[[],[]]);this.patterns=Q.map((W,G)=>{let z=K[G];if(!z)throw Error("invalid pattern object");return new Q3(W,z,0,this.platform)})}async walk(){return[...await new AF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new AF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new mF(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 mF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var $R=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new V4(X,J).hasMagic())return!0;return!1};function lF(Z,J={}){return new Q7(Z,J).streamSync()}function Ug(Z,J={}){return new Q7(Z,J).stream()}function xg(Z,J={}){return new Q7(Z,J).walkSync()}async function cg(Z,J={}){return new Q7(Z,J).walk()}function yF(Z,J={}){return new Q7(Z,J).iterateSync()}function jg(Z,J={}){return new Q7(Z,J).iterate()}var EU1=lF,IU1=Object.assign(Ug,{sync:lF}),_U1=yF,hU1=Object.assign(jg,{sync:yF}),SU1=Object.assign(xg,{stream:lF,iterate:yF}),uF=Object.assign(cg,{glob:cg,globSync:xg,sync:SU1,globStream:Ug,stream:IU1,globStreamSync:lF,streamSync:EU1,globIterate:jg,iterate:hU1,globIterateSync:yF,iterateSync:_U1,Glob:Q7,hasMagic:$R,escape:Z3,unescape:F9});uF.glob=uF;class QR{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 XZ{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 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 pF extends QR{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 XZ(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 DG(){return DG=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},DG.apply(this,arguments)}class U9{constructor(Z){if(this.list=[],Z)for(let J of Z)this.list.push(J)}add(Z){this.list.push(Z)}remove(Z){let J=this.list.indexOf(Z);if(J>=0)this.list.splice(J,1)}removeChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);for(let X of J)this.remove(X);return J}listRefsByChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);return J}values(){return this.list}}class w1{constructor(Z){if(this.set=new Set,this.map=new Map,Z)for(let J of Z)this.add(J)}add(Z){let J=Z.getChild();this.removeChild(J),this.set.add(Z),this.map.set(J,Z)}remove(Z){this.set.delete(Z),this.map.delete(Z.getChild())}removeChild(Z){let J=this.map.get(Z)||null;if(J)this.remove(J);return J}getRefByChild(Z){return this.map.get(Z)||null}values(){return Array.from(this.set)}}class A6{constructor(Z){if(this.map={},Z)Object.assign(this.map,Z)}set(Z,J){this.map[Z]=J}delete(Z){delete this.map[Z]}get(Z){return this.map[Z]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}}var H1=Symbol("attributes"),hJ=Symbol("immutableKeys");class iF extends QR{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[H1]=void 0,this[hJ]=void 0,this.graph=Z,this[hJ]=new Set,this[H1]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let Y=Z[X];if(Y instanceof iF){let $=this.graph._createEdge(X,this,Y);this[hJ].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[H1]){let Y=this[H1][X];if(Y instanceof XZ){let $=Y;if($.getChild()===Z)this.setRef(X,J,$.getAttributes())}else if(Y instanceof U9)for(let $ of Y.listRefsByChild(Z)){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if(Y instanceof w1){let $=Y.getRefByChild(Z);if($){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if(Y instanceof A6)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[H1][Z]}set(Z,J){return this[H1][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[H1][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[hJ].has(Z))throw Error(`Cannot overwrite immutable attribute, "${Z}".`);let Y=this[H1][Z];if(Y)Y.dispose();if(!J)return this;let $=this.graph._createEdge(Z,this,J,X);return this[H1][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 U9)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[H1][Z];if(J instanceof U9||J instanceof w1)return J;throw Error(`Expected RefList or RefSet for attribute "${Z}"`)}listRefMapKeys(Z){return this.assertRefMap(Z).keys()}listRefMapValues(Z){return this.assertRefMap(Z).values().map((J)=>J.getChild())}getRefMap(Z,J){let 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,DG({},Y,{key:J}));return $.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[H1][Z];if(J instanceof A6)return J;throw Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(DG({},Z,{target:this})),this.graph.dispatchEvent(DG({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[H1][J]===Z){if(this[H1][J]=null,this[hJ].has(J))Z.getChild().dispose()}else if(this[H1][J]instanceof U9)this[H1][J].remove(Z);else if(this[H1][J]instanceof w1)this[H1][J].remove(Z);else if(this[H1][J]instanceof A6){let X=this[H1][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 Pg="v4.2.1",EY="@glb.bin",i;(function(Z){Z.ACCESSOR="Accessor",Z.ANIMATION="Animation",Z.ANIMATION_CHANNEL="AnimationChannel",Z.ANIMATION_SAMPLER="AnimationSampler",Z.BUFFER="Buffer",Z.CAMERA="Camera",Z.MATERIAL="Material",Z.MESH="Mesh",Z.PRIMITIVE="Primitive",Z.PRIMITIVE_TARGET="PrimitiveTarget",Z.NODE="Node",Z.ROOT="Root",Z.SCENE="Scene",Z.SKIN="Skin",Z.TEXTURE="Texture",Z.TEXTURE_INFO="TextureInfo"})(i||(i={}));var oF;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(oF||(oF={}));var h5;(function(Z){Z.ARRAY_BUFFER="ARRAY_BUFFER",Z.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",Z.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",Z.OTHER="OTHER",Z.SPARSE="SPARSE"})(h5||(h5={}));var v5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(v5||(v5={}));var YZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(YZ||(YZ={}));var bJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array};class E0{static createBufferFromDataURI(Z){if(typeof Buffer>"u"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let 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 Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class VR{static hexToFactor(Z,J){Z=Math.floor(Z);let X=J;return X[0]=(Z>>16&255)/255,X[1]=(Z>>8&255)/255,X[2]=(Z&255)/255,this.convertSRGBToLinear(J,J)}static factorToHex(Z){let J=[...Z],[X,Y,$]=this.convertLinearToSRGB(Z,J);return X*255<<16^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 Og{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),bU1(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 TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class eF{match(Z){return Z.length>=8&&Z[0]===137&&Z[1]===80&&Z[2]===78&&Z[3]===71&&Z[4]===13&&Z[5]===10&&Z[6]===26&&Z[7]===10}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset);if(E0.decodeText(Z.slice(12,16))===eF.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}}eF.PNG_FRIED_CHUNK_NAME="CgBI";class _5{static registerFormat(Z,J){this.impls[Z]=J}static getMimeType(Z){for(let J in this.impls)if(this.impls[J].match(Z))return J;return null}static getSize(Z,J){if(!this.impls[J])return null;return this.impls[J].getSize(Z)}static getChannels(Z,J){if(!this.impls[J])return null;return this.impls[J].getChannels(Z)}static getVRAMByteLength(Z,J){if(!this.impls[J])return null;if(this.impls[J].getVRAMByteLength)return this.impls[J].getVRAMByteLength(Z);let X=0,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}`}}_5.impls={"image/jpeg":new Og,"image/png":new eF};function bU1(Z,J){if(J>Z.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw TypeError("Invalid JPG, marker table corrupted");return Z}class $Z{static basename(Z){let J=Z.split(/[\\/]/).pop();return J.substring(0,J.lastIndexOf("."))}static extension(Z){if(Z.startsWith("data:image/")){let J=Z.match(/data:(image\/\w+)/)[1];return _5.mimeTypeToExtension(J)}else if(Z.startsWith("data:model/gltf+json"))return"gltf";else if(Z.startsWith("data:model/gltf-binary"))return"glb";else if(Z.startsWith("data:application/"))return"bin";return Z.split(/[\\/]/).pop().split(/[.]/).pop()}}var WR=typeof Float32Array<"u"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function AU1(){var Z=new WR(3);if(WR!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function KR(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function mU1(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=AU1();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();function NG(Z){let J=Tg(),X=Z.propertyType===i.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=uU1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))GR(K.min,J),GR(K.max,J)});return J}function uU1(Z,J){let X=Tg();for(let Y of Z.listPrimitives()){let $=Y.getAttribute("POSITION"),Q=Y.getIndices();if(!$)continue;let K=[0,0,0],W=[0,0,0];for(let G=0,z=Q?Q.getCount():$.getCount();G<z;G++){let v=Q?Q.getScalar(G):G;K=$.getElement(v,K),W=mU1(W,K,J),GR(W,X)}}return X}function GR(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 Tg(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}var Bg="https://null.example";class F4{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return $Z.basename(new URL(Z,Bg).pathname)}static extension(Z){return $Z.extension(new URL(Z,Bg).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)}}F4.DEFAULT_INIT={};F4.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;function Lg(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function kY(Z){if(Lg(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Lg(X)===!1)return!1;if(Object.hasOwn(X,"isPrototypeOf")===!1)return!1;return!0}var zR,MG;(function(Z){Z[Z.SILENT=4]="SILENT",Z[Z.ERROR=3]="ERROR",Z[Z.WARN=2]="WARN",Z[Z.INFO=1]="INFO",Z[Z.DEBUG=0]="DEBUG"})(MG||(MG={}));class z5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=z5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=z5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=z5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=z5.Verbosity.ERROR)console.error(Z)}}zR=z5;z5.Verbosity=MG;z5.DEFAULT_INSTANCE=new zR(zR.Verbosity.INFO);function lU1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],w=Z[14],c=Z[15],U=J*K-X*Q,j=J*W-Y*Q,B=J*G-$*Q,L=X*W-Y*K,R=X*G-$*K,M=Y*G-$*W,N=z*F-v*q,P=z*w-H*q,O=z*c-V*q,k=v*w-H*F,E=v*c-V*F,S=H*c-V*w;return U*S-j*E+B*k+L*O-R*P+M*N}function yU1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],w=J[12],c=J[13],U=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*Y+L*W+R*H+M*w,Z[1]=B*$+L*G+R*V+M*c,Z[2]=B*Q+L*z+R*q+M*U,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*Y+L*W+R*H+M*w,Z[5]=B*$+L*G+R*V+M*c,Z[6]=B*Q+L*z+R*q+M*U,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*Y+L*W+R*H+M*w,Z[9]=B*$+L*G+R*V+M*c,Z[10]=B*Q+L*z+R*q+M*U,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*Y+L*W+R*H+M*w,Z[13]=B*$+L*G+R*V+M*c,Z[14]=B*Q+L*z+R*q+M*U,Z[15]=B*K+L*v+R*F+M*j,Z}function pU1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],z=J[9],v=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,z,v),Z}function iU1(Z,J){var X=new WR(3);pU1(X,J);var Y=1/X[0],$=1/X[1],Q=1/X[2],K=J[0]*Y,W=J[1]*$,G=J[2]*Q,z=J[4]*Y,v=J[5]*$,H=J[6]*Q,V=J[8]*Y,q=J[9]*$,F=J[10]*Q,w=K+v+F,c=0;if(w>0)c=Math.sqrt(w+1)*2,Z[3]=0.25*c,Z[0]=(H-q)/c,Z[1]=(V-G)/c,Z[2]=(W-z)/c;else if(K>v&&K>F)c=Math.sqrt(1+K-v-F)*2,Z[3]=(H-q)/c,Z[0]=0.25*c,Z[1]=(W+z)/c,Z[2]=(V+G)/c;else if(v>F)c=Math.sqrt(1+v-K-F)*2,Z[3]=(V-G)/c,Z[0]=(W+z)/c,Z[1]=0.25*c,Z[2]=(H+q)/c;else c=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/c,Z[0]=(V+G)/c,Z[1]=(H+q)/c,Z[2]=0.25*c;return Z}class I0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let 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 Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(I0.clamp(Z,0,1)*65535);case 5121:return Math.round(I0.clamp(Z,0,1)*255);case 5122:return Math.round(I0.clamp(Z,-1,1)*32767);case 5120:return Math.round(I0.clamp(Z,-1,1)*127);default:throw Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=KR([Z[0],Z[1],Z[2]]),Q=KR([Z[4],Z[5],Z[6]]),K=KR([Z[8],Z[9],Z[10]]);if(lU1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),z=1/$,v=1/Q,H=1/K;G[0]*=z,G[1]*=z,G[2]*=z,G[4]*=v,G[5]*=v,G[6]*=v,G[8]*=H,G[9]*=H,G[10]*=H,iU1(X,G),Y[0]=$,Y[1]=Q,Y[2]=K}static compose(Z,J,X,Y){let $=Y,Q=J[0],K=J[1],W=J[2],G=J[3],z=Q+Q,v=K+K,H=W+W,V=Q*z,q=Q*v,F=Q*H,w=K*v,c=K*H,U=W*H,j=G*z,B=G*v,L=G*H,R=X[0],M=X[1],N=X[2];return $[0]=(1-(w+U))*R,$[1]=(q+L)*R,$[2]=(F-B)*R,$[3]=0,$[4]=(q-L)*M,$[5]=(1-(V+U))*M,$[6]=(c+j)*M,$[7]=0,$[8]=(F+B)*N,$[9]=(c-j)*N,$[10]=(1-(V+w))*N,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function gU1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function dU1(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 aU1(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 W=Q.getChild(),G=K.getChild();if(W===G)continue;if(!W.equals(G))return!1}return!0}function Cg(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 fg(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!kY(Z)||!kY(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 W=X[K],G=Y[K];if(rF(W)&&rF(G)){if(!Cg(W,G))return!1}else if(kY(W)&&kY(G)){if(!fg(W,G))return!1}else if(W!==G)return!1}return!0}function rF(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Dg="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",nU1=999,sU1=6,Mg=new Set,oU1=function(){let J="";for(let X=0;X<sU1;X++)J+=Dg.charAt(Math.floor(Math.random()*Dg.length));return J},kg=function(){for(let J=0;J<nU1;J++){let X=oU1();if(!Mg.has(X))return Mg.add(X),X}return""},SJ=(Z)=>Z,rU1=new Set;class Zw extends iF{constructor(Z,J=""){super(Z);this[H1].name=J,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(Z,J){if(Array.isArray(J))J=J.slice();return super.set(Z,J)}getName(){return this.get("name")}setName(Z){return this.set("name",Z)}getExtras(){return this.get("extras")}setExtras(Z){return this.set("extras",Z)}clone(){return new this.constructor(this.graph).copy(this,SJ)}copy(Z,J=SJ){for(let X in this[H1]){let Y=this[H1][X];if(Y instanceof XZ){if(!this[hJ].has(X))Y.dispose()}else if(Y instanceof U9||Y instanceof w1)for(let $ of Y.values())$.dispose();else if(Y instanceof A6)for(let $ of Y.values())$.dispose()}for(let X in Z[H1]){let Y=this[H1][X],$=Z[H1][X];if($ instanceof XZ)if(this[hJ].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof w1||$ instanceof U9)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof A6)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(kY($))this[H1][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[H1][X]=$.slice();else this[H1][X]=$}return this}equals(Z,J=rU1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[H1]){if(J.has(X))continue;let Y=this[H1][X],$=Z[H1][X];if(Y instanceof XZ||$ instanceof XZ){if(!gU1(Y,$))return!1}else if(Y instanceof w1||$ instanceof w1||Y instanceof U9||$ instanceof U9){if(!dU1(Y,$))return!1}else if(Y instanceof A6||$ instanceof A6){if(!aU1(Y,$))return!1}else if(kY(Y)||kY($)){if(!fg(Y,$))return!1}else if(rF(Y)||rF($)){if(!Cg(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 U6 extends Zw{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new A6})}getExtension(Z){return this.getRefMap("extensions",Z)}setExtension(Z,J){if(J)J._validateParent(this);return this.setRefMap("extensions",Z,J)}listExtensions(){return this.listRefMapValues("extensions")}}class K0 extends U6{init(){this.propertyType=i.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:K0.Type.SCALAR,componentType:K0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case K0.Type.SCALAR:return 1;case K0.Type.VEC2:return 2;case K0.Type.VEC3:return 3;case K0.Type.VEC4:return 4;case K0.Type.MAT2:return 4;case K0.Type.MAT3:return 9;case K0.Type.MAT4:return 16;default:throw Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case K0.ComponentType.BYTE:return 1;case K0.ComponentType.UNSIGNED_BYTE:return 1;case K0.ComponentType.SHORT:return 2;case K0.ComponentType.UNSIGNED_SHORT:return 2;case K0.ComponentType.UNSIGNED_INT:return 4;case K0.ComponentType.FLOAT:return 4;default:throw Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),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 K0.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(Z){return this.set("normalized",Z)}getScalar(Z){let J=this.getElementSize(),X=this.getComponentType(),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?tU1(Z):K0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}K0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};K0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function tU1(Z){switch(Z.constructor){case Float32Array:return K0.ComponentType.FLOAT;case Uint32Array:return K0.ComponentType.UNSIGNED_INT;case Uint16Array:return K0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return K0.ComponentType.UNSIGNED_BYTE;case Int16Array:return K0.ComponentType.SHORT;case Int8Array:return K0.ComponentType.BYTE;default:throw Error("Unknown accessor componentType.")}}class HR extends U6{init(){this.propertyType=i.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new w1,samplers:new w1})}addChannel(Z){return this.addRef("channels",Z)}removeChannel(Z){return this.removeRef("channels",Z)}listChannels(){return this.listRefs("channels")}addSampler(Z){return this.addRef("samplers",Z)}removeSampler(Z){return this.removeRef("samplers",Z)}listSamplers(){return this.listRefs("samplers")}}class QZ extends U6{init(){this.propertyType=i.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(Z){return this.set("targetPath",Z)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(Z){return this.setRef("targetNode",Z)}getSampler(){return this.getRef("sampler")}setSampler(Z){return this.setRef("sampler",Z)}}QZ.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class AJ extends U6{init(){this.propertyType=i.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:AJ.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(Z){return this.set("interpolation",Z)}getInput(){return this.getRef("input")}setInput(Z){return this.setRef("input",Z,{usage:h5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:h5.OTHER})}}AJ.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class qR extends U6{init(){this.propertyType=i.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class IY extends U6{init(){this.propertyType=i.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:IY.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)}}IY.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class O1 extends Zw{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}O1.EXTENSION_NAME=void 0;class F1 extends U6{init(){this.propertyType=i.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:F1.WrapMode.REPEAT,wrapT:F1.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}getMagFilter(){return this.get("magFilter")}setMagFilter(Z){return this.set("magFilter",Z)}getMinFilter(){return this.get("minFilter")}setMinFilter(Z){return this.set("minFilter",Z)}getWrapS(){return this.get("wrapS")}setWrapS(Z){return this.set("wrapS",Z)}getWrapT(){return this.get("wrapT")}setWrapT(Z){return this.set("wrapT",Z)}}F1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};F1.MagFilter={NEAREST:9728,LINEAR:9729};F1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:gF,G:dF,B:aF,A:eU1}=v5;class K7 extends U6{init(){this.propertyType=i.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:K7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new F1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new F1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new F1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new F1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new F1(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(Z){return this.set("doubleSided",Z)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(Z){let J=this.get("baseColorFactor").slice();return J[3]=Z,this.set("baseColorFactor",J)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(Z){return this.set("alphaMode",Z)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(Z){return this.set("alphaCutoff",Z)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(Z){return this.set("baseColorFactor",Z)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(Z){return this.setRef("baseColorTexture",Z,{channels:gF|dF|aF|eU1,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:gF|dF|aF,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:gF|dF|aF})}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:gF})}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:dF|aF})}}K7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class PG extends U6{init(){this.propertyType=i.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new w1})}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 Jw extends U6{init(){this.propertyType=i.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new w1})}copy(Z,J=SJ){if(J===SJ)throw Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return I0.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),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())yU1(X,X,J.getMatrix());return X}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);for(let X of Z.listParents())if(X.propertyType===i.SCENE)X.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}getParentNode(){for(let Z of this.listParents())if(Z.propertyType===i.NODE)return Z;return null}getMesh(){return this.getRef("mesh")}setMesh(Z){return this.setRef("mesh",Z)}getCamera(){return this.getRef("camera")}setCamera(Z){return this.setRef("camera",Z)}getSkin(){return this.getRef("skin")}setSkin(Z){return this.setRef("skin",Z)}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}traverse(Z){Z(this);for(let J of this.listChildren())J.traverse(Z);return this}}class g1 extends U6{init(){this.propertyType=i.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:g1.Mode.TRIANGLES,material:null,indices:null,attributes:new A6,targets:new w1})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:h5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:h5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}getMode(){return this.get("mode")}setMode(Z){return this.set("mode",Z)}listTargets(){return this.listRefs("targets")}addTarget(Z){return this.addRef("targets",Z)}removeTarget(Z){return this.removeRef("targets",Z)}}g1.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class FR extends Zw{init(){this.propertyType=i.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:h5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function m6(){return m6=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},m6.apply(null,arguments)}class K3 extends U6{init(){this.propertyType=i.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new w1})}copy(Z,J=SJ){if(J===SJ)throw Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class wR extends U6{init(){this.propertyType=i.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new w1})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(Z){return this.setRef("skeleton",Z)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(Z){return this.setRef("inverseBindMatrices",Z,{usage:h5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class _Y extends U6{init(){this.propertyType=i.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||_5.extensionToMimeType($Z.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=_5.extensionToMimeType($Z.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",E0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return _5.getSize(Z,this.getMimeType())}}class W3 extends U6{init(){this.propertyType=i.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Pg}`,version:"2.0"},defaultScene:null,accessors:new w1,animations:new w1,buffers:new w1,cameras:new w1,materials:new w1,meshes:new w1,nodes:new w1,scenes:new w1,skins:new w1,textures:new w1})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw Error("Root cannot be cloned.")}copy(Z,J=SJ){if(J===SJ)throw Error("Root cannot be copied.");this.set("asset",m6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(m6({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let Y=Z.getExtension(X);this.setExtension(X,J(Y))}return this}_addChildOfRoot(Z){if(Z instanceof K3)this.addRef("scenes",Z);else if(Z instanceof Jw)this.addRef("nodes",Z);else if(Z instanceof IY)this.addRef("cameras",Z);else if(Z instanceof wR)this.addRef("skins",Z);else if(Z instanceof PG)this.addRef("meshes",Z);else if(Z instanceof K7)this.addRef("materials",Z);else if(Z instanceof _Y)this.addRef("textures",Z);else if(Z instanceof HR)this.addRef("animations",Z);else if(Z instanceof K0)this.addRef("accessors",Z);else if(Z instanceof qR)this.addRef("buffers",Z);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((Z)=>Z.isRequired())}_enableExtension(Z){return this._extensions.add(Z),this}_disableExtension(Z){return this._extensions.delete(Z),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(Z){return this.setRef("defaultScene",Z)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class c6{static fromGraph(Z){return c6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new pF,this._root=new W3(this._graph),this._logger=z5.DEFAULT_INSTANCE,c6._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find((Y)=>Y.extensionName===J)||new Z(this)}createScene(Z=""){return new K3(this._graph,Z)}createNode(Z=""){return new Jw(this._graph,Z)}createCamera(Z=""){return new IY(this._graph,Z)}createSkin(Z=""){return new wR(this._graph,Z)}createMesh(Z=""){return new PG(this._graph,Z)}createPrimitive(){return new g1(this._graph)}createPrimitiveTarget(Z=""){return new FR(this._graph,Z)}createMaterial(Z=""){return new K7(this._graph,Z)}createTexture(Z=""){return new _Y(this._graph,Z)}createAnimation(Z=""){return new HR(this._graph,Z)}createAnimationChannel(Z=""){return new QZ(this._graph,Z)}createAnimationSampler(Z=""){return new AJ(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new K0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new qR(this._graph,Z)}}c6._GRAPH_DOCUMENTS=new WeakMap;class T1{constructor(Z){this.extensionName="",this.prereadTypes=[],this.prewriteTypes=[],this.readDependencies=[],this.writeDependencies=[],this.document=void 0,this.required=!1,this.properties=new Set,this._listener=void 0,this.document=Z,Z.getRoot()._enableExtension(this),this._listener=(X)=>{let Y=X,$=Y.target;if($ instanceof O1&&$.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}}T1.EXTENSION_NAME=void 0;class Eg{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 Rg={logger:z5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},Zx1=new Set([i.BUFFER,i.TEXTURE,i.MATERIAL,i.MESH,i.PRIMITIVE,i.NODE,i.SCENE]);class Ig{static read(Z,J=Rg){let X=m6({},Rg,J),{json:Y}=Z,$=new c6().setLogger(X.logger);this.validate(Z,X);let Q=new Eg(Z),K=Y.asset,W=$.getRoot().getAsset();if(K.copyright)W.copyright=K.copyright;if(K.extras)W.extras=K.extras;if(Y.extras!==void 0)$.getRoot().setExtras(m6({},Y.extras));let G=Y.extensionsUsed||[],z=Y.extensionsRequired||[];X.extensions.sort((M,N)=>M.EXTENSION_NAME>N.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let N=$.createExtension(M).setRequired(z.includes(M.EXTENSION_NAME)),P=N.prereadTypes.filter((O)=>!Zx1.has(O));if(P.length)X.logger.warn(`Preread hooks for some types (${P.join()}), requested by extension ${N.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of N.readDependencies)N.install(O,X.dependencies[O])}let v=Y.buffers||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.BUFFER)).forEach((M)=>M.preread(Q,i.BUFFER)),Q.buffers=v.map((M)=>{let N=$.createBuffer(M.name);if(M.extras)N.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)N.setURI(M.uri);return N});let H=Y.bufferViews||[];Q.bufferViewBuffers=H.map((M,N)=>{if(!Q.bufferViews[N]){let P=Z.json.buffers[M.buffer],O=P.uri?Z.resources[P.uri]:Z.resources[EY],k=M.byteOffset||0;Q.bufferViews[N]=E0.toView(O,k,M.byteLength)}return Q.buffers[M.buffer]});let V=Y.accessors||[];Q.accessors=V.map((M)=>{let N=Q.bufferViewBuffers[M.bufferView],P=$.createAccessor(M.name,N).setType(M.type);if(M.extras)P.setExtras(M.extras);if(M.normalized!==void 0)P.setNormalized(M.normalized);if(M.bufferView===void 0)return P;return P.setArray(sF(M,Q)),P});let q=Y.images||[],F=Y.textures||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.TEXTURE)).forEach((M)=>M.preread(Q,i.TEXTURE)),Q.textures=q.map((M)=>{let N=$.createTexture(M.name);if(M.extras)N.setExtras(M.extras);if(M.bufferView!==void 0){let P=Y.bufferViews[M.bufferView],O=Z.json.buffers[P.buffer],k=O.uri?Z.resources[O.uri]:Z.resources[EY],E=P.byteOffset||0,S=P.byteLength,f=k.slice(E,E+S);N.setImage(f)}else if(M.uri!==void 0){if(N.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)N.setURI(M.uri)}if(M.mimeType!==void 0)N.setMimeType(M.mimeType);else if(M.uri){let P=$Z.extension(M.uri);N.setMimeType(_5.extensionToMimeType(P))}return N}),$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MATERIAL)).forEach((M)=>M.preread(Q,i.MATERIAL));let w=Y.materials||[];Q.materials=w.map((M)=>{let N=$.createMaterial(M.name);if(M.extras)N.setExtras(M.extras);if(M.alphaMode!==void 0)N.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)N.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)N.setDoubleSided(M.doubleSided);let P=M.pbrMetallicRoughness||{};if(P.baseColorFactor!==void 0)N.setBaseColorFactor(P.baseColorFactor);if(M.emissiveFactor!==void 0)N.setEmissiveFactor(M.emissiveFactor);if(P.metallicFactor!==void 0)N.setMetallicFactor(P.metallicFactor);if(P.roughnessFactor!==void 0)N.setRoughnessFactor(P.roughnessFactor);if(P.baseColorTexture!==void 0){let O=P.baseColorTexture,k=Q.textures[F[O.index].source];N.setBaseColorTexture(k),Q.setTextureInfo(N.getBaseColorTextureInfo(),O)}if(M.emissiveTexture!==void 0){let O=M.emissiveTexture,k=Q.textures[F[O.index].source];N.setEmissiveTexture(k),Q.setTextureInfo(N.getEmissiveTextureInfo(),O)}if(M.normalTexture!==void 0){let O=M.normalTexture,k=Q.textures[F[O.index].source];if(N.setNormalTexture(k),Q.setTextureInfo(N.getNormalTextureInfo(),O),M.normalTexture.scale!==void 0)N.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let O=M.occlusionTexture,k=Q.textures[F[O.index].source];if(N.setOcclusionTexture(k),Q.setTextureInfo(N.getOcclusionTextureInfo(),O),M.occlusionTexture.strength!==void 0)N.setOcclusionStrength(M.occlusionTexture.strength)}if(P.metallicRoughnessTexture!==void 0){let O=P.metallicRoughnessTexture,k=Q.textures[F[O.index].source];N.setMetallicRoughnessTexture(k),Q.setTextureInfo(N.getMetallicRoughnessTextureInfo(),O)}return N}),$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MESH)).forEach((M)=>M.preread(Q,i.MESH));let c=Y.meshes||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.PRIMITIVE)).forEach((M)=>M.preread(Q,i.PRIMITIVE)),Q.meshes=c.map((M)=>{let N=$.createMesh(M.name);if(M.extras)N.setExtras(M.extras);if(M.weights!==void 0)N.setWeights(M.weights);return(M.primitives||[]).forEach((O)=>{let k=$.createPrimitive();if(O.extras)k.setExtras(O.extras);if(O.material!==void 0)k.setMaterial(Q.materials[O.material]);if(O.mode!==void 0)k.setMode(O.mode);for(let[f,C]of Object.entries(O.attributes||{}))k.setAttribute(f,Q.accessors[C]);if(O.indices!==void 0)k.setIndices(Q.accessors[O.indices]);let E=M.extras&&M.extras.targetNames||[];(O.targets||[]).forEach((f,C)=>{let h=E[C]||C.toString(),_=$.createPrimitiveTarget(h);for(let[a,s]of Object.entries(f))_.setAttribute(a,Q.accessors[s]);k.addTarget(_)}),N.addPrimitive(k)}),N});let U=Y.cameras||[];Q.cameras=U.map((M)=>{let N=$.createCamera(M.name).setType(M.type);if(M.extras)N.setExtras(M.extras);if(M.type===IY.Type.PERSPECTIVE){let P=M.perspective;if(N.setYFov(P.yfov),N.setZNear(P.znear),P.zfar!==void 0)N.setZFar(P.zfar);if(P.aspectRatio!==void 0)N.setAspectRatio(P.aspectRatio)}else{let P=M.orthographic;N.setZNear(P.znear).setZFar(P.zfar).setXMag(P.xmag).setYMag(P.ymag)}return N});let j=Y.nodes||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.NODE)).forEach((M)=>M.preread(Q,i.NODE)),Q.nodes=j.map((M)=>{let N=$.createNode(M.name);if(M.extras)N.setExtras(M.extras);if(M.translation!==void 0)N.setTranslation(M.translation);if(M.rotation!==void 0)N.setRotation(M.rotation);if(M.scale!==void 0)N.setScale(M.scale);if(M.matrix!==void 0){let P=[0,0,0],O=[0,0,0,1],k=[1,1,1];I0.decompose(M.matrix,P,O,k),N.setTranslation(P),N.setRotation(O),N.setScale(k)}if(M.weights!==void 0)N.setWeights(M.weights);return N});let B=Y.skins||[];Q.skins=B.map((M)=>{let N=$.createSkin(M.name);if(M.extras)N.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)N.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)N.setSkeleton(Q.nodes[M.skeleton]);for(let P of M.joints)N.addJoint(Q.nodes[P]);return N}),j.map((M,N)=>{let P=Q.nodes[N];if((M.children||[]).forEach((k)=>P.addChild(Q.nodes[k])),M.mesh!==void 0)P.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)P.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)P.setSkin(Q.skins[M.skin])});let L=Y.animations||[];Q.animations=L.map((M)=>{let N=$.createAnimation(M.name);if(M.extras)N.setExtras(M.extras);let O=(M.samplers||[]).map((E)=>{let S=$.createAnimationSampler().setInput(Q.accessors[E.input]).setOutput(Q.accessors[E.output]).setInterpolation(E.interpolation||AJ.Interpolation.LINEAR);if(E.extras)S.setExtras(E.extras);return N.addSampler(S),S});return(M.channels||[]).forEach((E)=>{let S=$.createAnimationChannel().setSampler(O[E.sampler]).setTargetPath(E.target.path);if(E.target.node!==void 0)S.setTargetNode(Q.nodes[E.target.node]);if(E.extras)S.setExtras(E.extras);N.addChannel(S)}),N});let R=Y.scenes||[];if($.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.SCENE)).forEach((M)=>M.preread(Q,i.SCENE)),Q.scenes=R.map((M)=>{let N=$.createScene(M.name);if(M.extras)N.setExtras(M.extras);return(M.nodes||[]).map((O)=>Q.nodes[O]).forEach((O)=>N.addChild(O)),N}),Y.scene!==void 0)$.getRoot().setDefaultScene(Q.scenes[Y.scene]);return $.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),V.forEach((M,N)=>{let P=Q.accessors[N],O=!!M.sparse,k=!M.bufferView&&!P.getArray();if(O||k)P.setSparse(!0).setArray(Xx1(M,Q))}),$}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let Y of X.extensionsRequired)if(!J.extensions.find(($)=>$.EXTENSION_NAME===Y))throw 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 Jx1(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=bJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,z=new Q(Z.count*K),v=new DataView(Y.buffer,Y.byteOffset,Y.byteLength),H=$.byteStride;for(let V=0;V<Z.count;V++)for(let q=0;q<K;q++){let F=G+V*H+q*W,w;switch(Z.componentType){case K0.ComponentType.FLOAT:w=v.getFloat32(F,!0);break;case K0.ComponentType.UNSIGNED_INT:w=v.getUint32(F,!0);break;case K0.ComponentType.UNSIGNED_SHORT:w=v.getUint16(F,!0);break;case K0.ComponentType.UNSIGNED_BYTE:w=v.getUint8(F);break;case K0.ComponentType.SHORT:w=v.getInt16(F,!0);break;case K0.ComponentType.BYTE:w=v.getInt8(F);break;default:throw Error(`Unexpected componentType "${Z.componentType}".`)}z[V*K+q]=w}return z}function sF(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=bJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if($.byteStride!==void 0&&$.byteStride!==G)return Jx1(Z,J);let z=Y.byteOffset+(Z.byteOffset||0),v=Z.count*K*W;return new Q(Y.buffer.slice(z,z+v))}function Xx1(Z,J){let X=bJ[Z.componentType],Y=K0.getElementSize(Z.type),$;if(Z.bufferView!==void 0)$=sF(Z,J);else $=new X(Z.count*Y);let Q=Z.sparse;if(!Q)return $;let K=Q.count,W=m6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=m6({},Z,Q.values,{count:K}),z=sF(W,J),v=sF(G,J);for(let H=0;H<W.count;H++)for(let V=0;V<Y;V++)$[z[H]*Y+V]=v[H*Y+V];return $}var RG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(RG||(RG={}));class w4{constructor(Z,J,X){this._doc=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this._accessorUsageMap=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this._doc=Z,this.jsonDoc=J,this.options=X;let Y=Z.getRoot(),$=Y.listBuffers().length,Q=Y.listTextures().length;this.bufferURIGenerator=new vR($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new vR(Q>1,(K)=>Yx1(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===YZ.GLB)this.imageBufferViews.push(J),Z.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:J.byteLength});else{let Y=_5.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 Error($)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return h5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:Y}=X.getAttributes();if(Y)return Y;if(X.getParent().propertyType!==i.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return h5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}w4.BufferViewTarget=RG;w4.BufferViewUsage=h5;w4.USAGE_TO_TARGET={[h5.ARRAY_BUFFER]:RG.ARRAY_BUFFER,[h5.ELEMENT_ARRAY_BUFFER]:RG.ELEMENT_ARRAY_BUFFER};class vR{constructor(Z,J){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=Z,this.basename=J}createURI(Z,J){if(Z.getURI())return Z.getURI();else if(!this.multiple)return`${this.basename(Z)}.${J}`;else{let X=this.basename(Z);return this.counter[X]=this.counter[X]||1,`${X}_${this.counter[X]++}.${J}`}}}function Yx1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:nF}=w4,{UNSIGNED_INT:$x1,UNSIGNED_SHORT:Qx1,UNSIGNED_BYTE:Kx1}=K0.ComponentType,Wx1=new Set([i.ACCESSOR,i.BUFFER,i.MATERIAL,i.MESH]);class _g{static write(Z,J){let X=Z.getGraph(),Y=Z.getRoot(),$={asset:m6({generator:`glTF-Transform ${Pg}`},Y.getAsset()),extras:m6({},Y.getExtras())},Q={json:$,resources:{}},K=new w4(Z,Q,J),W=J.logger||z5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((c)=>c.EXTENSION_NAME)),z=Z.getRoot().listExtensionsUsed().filter((c)=>G.has(c.extensionName)).sort((c,U)=>c.extensionName>U.extensionName?1:-1),v=Z.getRoot().listExtensionsRequired().filter((c)=>G.has(c.extensionName)).sort((c,U)=>c.extensionName>U.extensionName?1:-1);if(z.length<Z.getRoot().listExtensionsUsed().length)W.warn("Some extensions were not registered for I/O, and will not be written.");for(let c of z){let U=c.prewriteTypes.filter((j)=>!Wx1.has(j));if(U.length)W.warn(`Prewrite hooks for some types (${U.join()}), requested by extension ${c.extensionName}, are unsupported. Please file an issue or a PR.`);for(let j of c.writeDependencies)c.install(j,J.dependencies[j])}function H(c,U,j,B){let L=[],R=0;for(let P of c){let O=K.createAccessorDef(P);O.bufferView=$.bufferViews.length;let k=P.getArray(),E=E0.pad(E0.toView(k));O.byteOffset=R,R+=E.byteLength,L.push(E),K.accessorIndexMap.set(P,$.accessors.length),$.accessors.push(O)}let M=E0.concat(L),N={buffer:U,byteOffset:j,byteLength:M.byteLength};if(B)N.target=B;return $.bufferViews.push(N),{buffers:L,byteLength:R}}function V(c,U,j){let B=c[0].getCount(),L=0;for(let O of c){let k=K.createAccessorDef(O);k.bufferView=$.bufferViews.length,k.byteOffset=L;let E=O.getElementSize(),S=O.getComponentSize();L+=E0.padNumber(E*S),K.accessorIndexMap.set(O,$.accessors.length),$.accessors.push(k)}let R=B*L,M=new ArrayBuffer(R),N=new DataView(M);for(let O=0;O<B;O++){let k=0;for(let E of c){let S=E.getElementSize(),f=E.getComponentSize(),C=E.getComponentType(),h=E.getArray();for(let _=0;_<S;_++){let a=O*L+k+_*f,s=h[O*S+_];switch(C){case K0.ComponentType.FLOAT:N.setFloat32(a,s,!0);break;case K0.ComponentType.BYTE:N.setInt8(a,s);break;case K0.ComponentType.SHORT:N.setInt16(a,s,!0);break;case K0.ComponentType.UNSIGNED_BYTE:N.setUint8(a,s);break;case K0.ComponentType.UNSIGNED_SHORT:N.setUint16(a,s,!0);break;case K0.ComponentType.UNSIGNED_INT:N.setUint32(a,s,!0);break;default:throw Error("Unexpected component type: "+C)}}k+=E0.padNumber(S*f)}}let P={buffer:U,byteOffset:j,byteLength:R,byteStride:L,target:w4.BufferViewTarget.ARRAY_BUFFER};return $.bufferViews.push(P),{byteLength:R,buffers:[new Uint8Array(M)]}}function q(c,U,j){let B=[],L=0,R=new Map,M=-1/0,N=!1;for(let C of c){let h=K.createAccessorDef(C);$.accessors.push(h),K.accessorIndexMap.set(C,$.accessors.length-1);let _=[],a=[],s=[],Z0=Array(C.getElementSize()).fill(0);for(let m0=0,P1=C.getCount();m0<P1;m0++){if(C.getElement(m0,s),I0.eq(s,Z0,0))continue;M=Math.max(m0,M),_.push(m0);for(let s0=0;s0<s.length;s0++)a.push(s[s0])}let o=_.length,M0={accessorDef:h,count:o};if(R.set(C,M0),o===0)continue;if(o>C.getCount()/2)N=!0;let R0=bJ[C.getComponentType()];M0.indices=_,M0.values=new R0(a)}if(!Number.isFinite(M))return{buffers:B,byteLength:L};if(N)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let P=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,O=M<255?Kx1:M<65535?Qx1:$x1,k={buffer:U,byteOffset:j+L,byteLength:0};for(let C of c){let h=R.get(C);if(h.count===0)continue;h.indicesByteOffset=k.byteLength;let _=E0.pad(E0.toView(new P(h.indices)));B.push(_),L+=_.byteLength,k.byteLength+=_.byteLength}$.bufferViews.push(k);let E=$.bufferViews.length-1,S={buffer:U,byteOffset:j+L,byteLength:0};for(let C of c){let h=R.get(C);if(h.count===0)continue;h.valuesByteOffset=S.byteLength;let _=E0.pad(E0.toView(h.values));B.push(_),L+=_.byteLength,S.byteLength+=_.byteLength}$.bufferViews.push(S);let f=$.bufferViews.length-1;for(let C of c){let h=R.get(C);if(h.count===0)continue;h.accessorDef.sparse={count:h.count,indices:{bufferView:E,byteOffset:h.indicesByteOffset,componentType:O},values:{bufferView:f,byteOffset:h.valuesByteOffset}}}return{buffers:B,byteLength:L}}if($.accessors=[],$.bufferViews=[],$.samplers=[],$.textures=[],$.images=Y.listTextures().map((c,U)=>{let j=K.createPropertyDef(c);if(c.getMimeType())j.mimeType=c.getMimeType();let B=c.getImage();if(B)K.createImageData(j,B,c);return K.imageIndexMap.set(c,U),j}),z.filter((c)=>c.prewriteTypes.includes(i.ACCESSOR)).forEach((c)=>c.prewrite(K,i.ACCESSOR)),Y.listAccessors().forEach((c)=>{let{accessorUsageGroupedByParent:U,accessorParents:j}=K;if(K.accessorIndexMap.has(c))return;let B=K.getAccessorUsage(c);if(K.addAccessorToUsageGroup(c,B),U.has(B)){let L=X.listParents(c).find((R)=>R.propertyType!==i.ROOT);j.set(c,L)}}),z.filter((c)=>c.prewriteTypes.includes(i.BUFFER)).forEach((c)=>c.prewrite(K,i.BUFFER)),(Y.listAccessors().length>0||K.otherBufferViews.size>0||Y.listTextures().length>0&&J.format===YZ.GLB)&&Y.listBuffers().length===0)throw Error("Buffer required for Document resources, but none was found.");if($.buffers=[],Y.listBuffers().forEach((c,U)=>{let j=K.createPropertyDef(c),B=K.accessorUsageGroupedByParent,L=c.listParents().filter((S)=>S instanceof K0),R=new Set(L.map((S)=>K.accessorParents.get(S))),M=new Map(Array.from(R).map((S,f)=>[S,f])),N={};for(let S of L){var P;if(K.accessorIndexMap.has(S))continue;let f=K.getAccessorUsage(S),C=f;if(B.has(f)){let h=K.accessorParents.get(S);C+=`:${M.get(h)}`}N[P=C]||(N[P]={usage:f,accessors:[]}),N[C].accessors.push(S)}let O=[],k=$.buffers.length,E=0;for(let{usage:S,accessors:f}of Object.values(N))if(S===nF.ARRAY_BUFFER&&J.vertexLayout===oF.INTERLEAVED){let C=V(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===nF.ARRAY_BUFFER)for(let C of f){let h=V([C],k,E);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else if(S===nF.SPARSE){let C=q(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===nF.ELEMENT_ARRAY_BUFFER){let C=w4.BufferViewTarget.ELEMENT_ARRAY_BUFFER,h=H(f,k,E,C);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else{let C=H(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}if(K.imageBufferViews.length&&U===0){for(let S=0;S<K.imageBufferViews.length;S++)if($.bufferViews[$.images[S].bufferView].byteOffset=E,E+=K.imageBufferViews[S].byteLength,O.push(K.imageBufferViews[S]),E%8){let f=8-E%8;E+=f,O.push(new Uint8Array(f))}}if(K.otherBufferViews.has(c))for(let S of K.otherBufferViews.get(c))$.bufferViews.push({buffer:k,byteOffset:E,byteLength:S.byteLength}),K.otherBufferViewsIndexMap.set(S,$.bufferViews.length-1),E+=S.byteLength,O.push(S);if(E){let S;if(J.format===YZ.GLB)S=EY;else S=K.bufferURIGenerator.createURI(c,"bin"),j.uri=S;j.byteLength=E,K.assignResourceURI(S,E0.concat(O),!0)}$.buffers.push(j),K.bufferIndexMap.set(c,U)}),Y.listAccessors().find((c)=>!c.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");z.filter((c)=>c.prewriteTypes.includes(i.MATERIAL)).forEach((c)=>c.prewrite(K,i.MATERIAL)),$.materials=Y.listMaterials().map((c,U)=>{let j=K.createPropertyDef(c);if(c.getAlphaMode()!==K7.AlphaMode.OPAQUE)j.alphaMode=c.getAlphaMode();if(c.getAlphaMode()===K7.AlphaMode.MASK)j.alphaCutoff=c.getAlphaCutoff();if(c.getDoubleSided())j.doubleSided=!0;if(j.pbrMetallicRoughness={},!I0.eq(c.getBaseColorFactor(),[1,1,1,1]))j.pbrMetallicRoughness.baseColorFactor=c.getBaseColorFactor();if(!I0.eq(c.getEmissiveFactor(),[0,0,0]))j.emissiveFactor=c.getEmissiveFactor();if(c.getRoughnessFactor()!==1)j.pbrMetallicRoughness.roughnessFactor=c.getRoughnessFactor();if(c.getMetallicFactor()!==1)j.pbrMetallicRoughness.metallicFactor=c.getMetallicFactor();if(c.getBaseColorTexture()){let B=c.getBaseColorTexture(),L=c.getBaseColorTextureInfo();j.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(B,L)}if(c.getEmissiveTexture()){let B=c.getEmissiveTexture(),L=c.getEmissiveTextureInfo();j.emissiveTexture=K.createTextureInfoDef(B,L)}if(c.getNormalTexture()){let B=c.getNormalTexture(),L=c.getNormalTextureInfo(),R=K.createTextureInfoDef(B,L);if(c.getNormalScale()!==1)R.scale=c.getNormalScale();j.normalTexture=R}if(c.getOcclusionTexture()){let B=c.getOcclusionTexture(),L=c.getOcclusionTextureInfo(),R=K.createTextureInfoDef(B,L);if(c.getOcclusionStrength()!==1)R.strength=c.getOcclusionStrength();j.occlusionTexture=R}if(c.getMetallicRoughnessTexture()){let B=c.getMetallicRoughnessTexture(),L=c.getMetallicRoughnessTextureInfo();j.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(B,L)}return K.materialIndexMap.set(c,U),j}),z.filter((c)=>c.prewriteTypes.includes(i.MESH)).forEach((c)=>c.prewrite(K,i.MESH)),$.meshes=Y.listMeshes().map((c,U)=>{let j=K.createPropertyDef(c),B=null;if(j.primitives=c.listPrimitives().map((L)=>{let R={attributes:{}};R.mode=L.getMode();let M=L.getMaterial();if(M)R.material=K.materialIndexMap.get(M);if(Object.keys(L.getExtras()).length)R.extras=L.getExtras();let N=L.getIndices();if(N)R.indices=K.accessorIndexMap.get(N);for(let P of L.listSemantics())R.attributes[P]=K.accessorIndexMap.get(L.getAttribute(P));for(let P of L.listTargets()){let O={};for(let k of P.listSemantics())O[k]=K.accessorIndexMap.get(P.getAttribute(k));R.targets=R.targets||[],R.targets.push(O)}if(L.listTargets().length&&!B)B=L.listTargets().map((P)=>P.getName());return R}),c.getWeights().length)j.weights=c.getWeights();if(B)j.extras=j.extras||{},j.extras.targetNames=B;return K.meshIndexMap.set(c,U),j}),$.cameras=Y.listCameras().map((c,U)=>{let j=K.createPropertyDef(c);if(j.type=c.getType(),j.type===IY.Type.PERSPECTIVE){j.perspective={znear:c.getZNear(),zfar:c.getZFar(),yfov:c.getYFov()};let B=c.getAspectRatio();if(B!==null)j.perspective.aspectRatio=B}else j.orthographic={znear:c.getZNear(),zfar:c.getZFar(),xmag:c.getXMag(),ymag:c.getYMag()};return K.cameraIndexMap.set(c,U),j}),$.nodes=Y.listNodes().map((c,U)=>{let j=K.createPropertyDef(c);if(!I0.eq(c.getTranslation(),[0,0,0]))j.translation=c.getTranslation();if(!I0.eq(c.getRotation(),[0,0,0,1]))j.rotation=c.getRotation();if(!I0.eq(c.getScale(),[1,1,1]))j.scale=c.getScale();if(c.getWeights().length)j.weights=c.getWeights();return K.nodeIndexMap.set(c,U),j}),$.skins=Y.listSkins().map((c,U)=>{let j=K.createPropertyDef(c),B=c.getInverseBindMatrices();if(B)j.inverseBindMatrices=K.accessorIndexMap.get(B);let L=c.getSkeleton();if(L)j.skeleton=K.nodeIndexMap.get(L);return j.joints=c.listJoints().map((R)=>K.nodeIndexMap.get(R)),K.skinIndexMap.set(c,U),j}),Y.listNodes().forEach((c,U)=>{let j=$.nodes[U],B=c.getMesh();if(B)j.mesh=K.meshIndexMap.get(B);let L=c.getCamera();if(L)j.camera=K.cameraIndexMap.get(L);let R=c.getSkin();if(R)j.skin=K.skinIndexMap.get(R);if(c.listChildren().length>0)j.children=c.listChildren().map((M)=>K.nodeIndexMap.get(M))}),$.animations=Y.listAnimations().map((c,U)=>{let j=K.createPropertyDef(c),B=new Map;return j.samplers=c.listSamplers().map((L,R)=>{let M=K.createPropertyDef(L);return M.input=K.accessorIndexMap.get(L.getInput()),M.output=K.accessorIndexMap.get(L.getOutput()),M.interpolation=L.getInterpolation(),B.set(L,R),M}),j.channels=c.listChannels().map((L)=>{let R=K.createPropertyDef(L);return R.sampler=B.get(L.getSampler()),R.target={node:K.nodeIndexMap.get(L.getTargetNode()),path:L.getTargetPath()},R}),K.animationIndexMap.set(c,U),j}),$.scenes=Y.listScenes().map((c,U)=>{let j=K.createPropertyDef(c);return j.nodes=c.listChildren().map((B)=>K.nodeIndexMap.get(B)),K.sceneIndexMap.set(c,U),j});let w=Y.getDefaultScene();if(w)$.scene=Y.listScenes().indexOf(w);return $.extensionsUsed=z.map((c)=>c.extensionName),$.extensionsRequired=v.map((c)=>c.extensionName),z.forEach((c)=>c.write(K)),Gx1($),Q}}function Gx1(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 tF;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(tF||(tF={}));class hg{constructor(){this._logger=z5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=oF.INTERLEAVED,this.lastReadBytes=0,this.lastWriteBytes=0}setLogger(Z){return this._logger=Z,this}registerExtensions(Z){for(let J of Z)this._extensions.add(J),J.register();return this}registerDependencies(Z){return Object.assign(this._dependencies,Z),this}setVertexLayout(Z){return this._vertexLayout=Z,this}async read(Z){return await this.readJSON(await this.readAsJSON(Z))}async readAsJSON(Z){let J=await this.readURI(Z,"view");this.lastReadBytes=J.byteLength;let X=Ng(J)?this._binaryToJSON(J):{json:JSON.parse(E0.decodeText(J)),resources:{}};return await this._readResourcesExternal(X,this.dirname(Z)),this._readResourcesInternal(X),X}async readJSON(Z){return Z=this._copyJSON(Z),this._readResourcesInternal(Z),Ig.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(E0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some((Y)=>zx1(J,Y)))throw Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some((Y)=>vx1(J,Y)))throw Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(E0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===YZ.GLB&&Z.getRoot().listBuffers().length>1)throw Error("GLB must have 0–1 buffers.");return _g.write(Z,{format:J.format||YZ.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:m6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:YZ.GLB}),Y=new Uint32Array([1179937895,2,12]),$=JSON.stringify(J),Q=E0.pad(E0.encodeText($),32),K=E0.toView(new Uint32Array([Q.byteLength,1313821514])),W=E0.concat([K,Q]);Y[Y.length-1]+=W.byteLength;let G=Object.values(X)[0];if(!G||!G.byteLength)return E0.concat([E0.toView(Y),W]);let z=E0.pad(G,0),v=E0.toView(new Uint32Array([z.byteLength,5130562])),H=E0.concat([v,z]);return Y[Y.length-1]+=H.byteLength,E0.concat([E0.toView(Y),W,H])}async _readResourcesExternal(Z,J){var X=this;let Y=Z.json.images||[],$=Z.json.buffers||[],Q=[...Y,...$].map(async function(K){let W=K.uri;if(!W||W.match(/data:/))return Promise.resolve();Z.resources[W]=await X.readURI(X.resolve(J,W),"view"),X.lastReadBytes+=Z.resources[W].byteLength});await Promise.all(Q)}_readResourcesInternal(Z){function J($){if(!$.uri)return;if($.uri in Z.resources){E0.assertView(Z.resources[$.uri]);return}if($.uri.match(/data:/)){let Q=`__${kg()}.${$Z.extension($.uri)}`;Z.resources[Q]=E0.createBufferFromDataURI($.uri),$.uri=Q}}(Z.json.images||[]).forEach(($)=>{if($.bufferView===void 0&&$.uri===void 0)throw 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:m6({},Z.json),resources:m6({},Z.resources)},J)Z.json.images=J.map((Y)=>m6({},Y));if(X)Z.json.buffers=X.map((Y)=>m6({},Y));return Z}_binaryToJSON(Z){if(!Ng(Z))throw Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==tF.JSON)throw Error("Missing required GLB JSON chunk.");let X=20,Y=J[0],$=E0.decodeText(E0.toView(Z,X,Y)),Q=JSON.parse($),K=X+Y;if(Z.byteLength<=K)return{json:Q,resources:{}};let W=new Uint32Array(Z.buffer,Z.byteOffset+K,2);if(W[1]!==tF.BIN)return{json:Q,resources:{}};let G=W[0],z=E0.toView(Z,K+8,G);return{json:Q,resources:{[EY]:z}}}}function zx1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function vx1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Ng(Z){if(Z.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let J=new Uint32Array(Z.buffer,Z.byteOffset,3);return J[0]===1179937895&&J[1]===2}class cR extends hg{constructor(Z=null,J=F4.DEFAULT_INIT){super();this._fetch=void 0,this._fetchConfig=void 0,this._init=void 0,this._fetchEnabled=!1,this._fetch=Z,this._fetchConfig=J,this._init=this.init()}async init(){if(this._init)return this._init;return Promise.all([import("fs"),import("path")]).then(([Z,J])=>{this._fs=Z.promises,this._path=J})}setAllowNetwork(Z){if(Z&&!this._fetch)throw Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),F4.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw Error("Network request blocked. Allow HTTP requests explicitly, if needed.");let X=await this._fetch(Z,this._fetchConfig);switch(J){case"view":return new Uint8Array(await X.arrayBuffer());case"text":return X.text()}}else switch(J){case"view":return this._fs.readFile(Z);case"text":return this._fs.readFile(Z,"utf8")}}resolve(Z,J){if(F4.isAbsoluteURL(Z)||F4.isAbsoluteURL(J))return F4.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(F4.isAbsoluteURL(Z))return F4.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:YZ.GLTF,basename:$Z.basename(Z)}),{_fs:Q,_path:K}=this,W=K.dirname(Z),G=JSON.stringify(Y,null,2);await Q.writeFile(Z,G),this.lastWriteBytes+=G.length;for(let z of Vx1(Object.keys($),10))await Promise.all(z.map(async function(v){if(F4.isAbsoluteURL(v)){if(F4.extension(v)==="bin")throw Error(`Cannot write buffer to path "${v}".`);return}let H=K.join(W,decodeURIComponent(v));await Q.mkdir(K.dirname(H),{recursive:!0}),await Q.writeFile(H,$[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 Vx1(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 En=t(UR(),1),In=t(wn(),1),$D1=t(kn(),1);async function QD1(Z,J){if(!(Z instanceof Uint8Array))throw Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:Y}=await In.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return En.default(new Uint8Array(X),[Y.width,Y.height,4],[4,4*Y.width|0,1],0)}async function _n(Z,J){return QD1(Z)}var Sn=163,bn=166;function KD1(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class x3{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 uP6=new Uint8Array([0]),p6=[171,75,84,88,32,50,48,187,13,10,26,10];function hn(Z){return new TextDecoder().decode(Z)}function Mw(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,p6.length);if(J[0]!==p6[0]||J[1]!==p6[1]||J[2]!==p6[2]||J[3]!==p6[3]||J[4]!==p6[4]||J[5]!==p6[5]||J[6]!==p6[6]||J[7]!==p6[7]||J[8]!==p6[8]||J[9]!==p6[9]||J[10]!==p6[10]||J[11]!==p6[11])throw Error("Missing KTX 2.0 identifier.");let X=KD1(),Y=17*Uint32Array.BYTES_PER_ELEMENT,$=new x3(Z,p6.length,Y,!0);X.vkFormat=$._nextUint32(),X.typeSize=$._nextUint32(),X.pixelWidth=$._nextUint32(),X.pixelHeight=$._nextUint32(),X.pixelDepth=$._nextUint32(),X.layerCount=$._nextUint32(),X.faceCount=$._nextUint32(),X.levelCount=$._nextUint32(),X.supercompressionScheme=$._nextUint32();let Q=$._nextUint32(),K=$._nextUint32(),W=$._nextUint32(),G=$._nextUint32(),z=$._nextUint64(),v=$._nextUint64(),H=Math.max(X.levelCount,1)*3*8,V=new x3(Z,p6.length+Y,H,!0);for(let O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+V._nextUint64(),V._nextUint64()),uncompressedByteLength:V._nextUint64()});let q=new x3(Z,Q,K,!0);q._skip(4);let F=q._nextUint16(),w=q._nextUint16(),c=q._nextUint16(),U=q._nextUint16(),j=q._nextUint8(),B=q._nextUint8(),L=q._nextUint8(),R=q._nextUint8(),M=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],N=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],O={vendorId:F,descriptorType:w,versionNumber:c,colorModel:j,colorPrimaries:B,transferFunction:L,flags:R,texelBlockDimension:M,bytesPlane:N,samples:[]},k=6,E=4,S=(U/4-k)/E;for(let O8=0;O8<S;O8++){let q6={bitOffset:q._nextUint16(),bitLength:q._nextUint8(),channelType:q._nextUint8(),samplePosition:[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(q6.channelType&64)q6.sampleLower=q._nextInt32(),q6.sampleUpper=q._nextInt32();else q6.sampleLower=q._nextUint32(),q6.sampleUpper=q._nextUint32();O.samples[O8]=q6}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(O);let f=new x3(Z,W,G,!0);while(f._offset<G){let O8=f._nextUint32(),q6=f._scan(O8),kH=hn(q6);if(X.keyValue[kH]=f._nextUint8Array(O8-q6.byteLength-1),kH.match(/^ktx/i)){let BA=hn(X.keyValue[kH]);X.keyValue[kH]=BA.substring(0,BA.lastIndexOf("\x00"))}let DG1=O8%4?4-O8%4:0;f._skip(DG1)}if(v<=0)return X;let C=new x3(Z,z,v,!0),h=C._nextUint16(),_=C._nextUint16(),a=C._nextUint32(),s=C._nextUint32(),Z0=C._nextUint32(),o=C._nextUint32(),M0=[];for(let O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)M0.push({imageFlags:C._nextUint32(),rgbSliceByteOffset:C._nextUint32(),rgbSliceByteLength:C._nextUint32(),alphaSliceByteOffset:C._nextUint32(),alphaSliceByteLength:C._nextUint32()});let R0=z+C._offset,m0=R0+a,P1=m0+s,s0=P1+Z0,j1=new Uint8Array(Z.buffer,Z.byteOffset+R0,a),K4=new Uint8Array(Z.buffer,Z.byteOffset+m0,s),NJ=new Uint8Array(Z.buffer,Z.byteOffset+P1,Z0),IQ=new Uint8Array(Z.buffer,Z.byteOffset+s0,o);return X.globalData={endpointCount:h,selectorCount:_,imageDescs:M0,endpointsData:j1,selectorsData:K4,tablesData:NJ,extendedData:IQ},X}var GZ="EXT_mesh_gpu_instancing",X6="EXT_meshopt_compression",bG="EXT_texture_webp",AG="EXT_texture_avif",s1="KHR_draco_mesh_compression",x4="KHR_lights_punctual",zZ="KHR_materials_anisotropy",vZ="KHR_materials_clearcoat",VZ="KHR_materials_diffuse_transmission",HZ="KHR_materials_dispersion",qZ="KHR_materials_emissive_strength",FZ="KHR_materials_ior",wZ="KHR_materials_iridescence",cZ="KHR_materials_pbrSpecularGlossiness",UZ="KHR_materials_sheen",xZ="KHR_materials_specular",jZ="KHR_materials_transmission",iJ="KHR_materials_unlit",BZ="KHR_materials_volume",x6="KHR_materials_variants",rn="KHR_mesh_quantization",mG="KHR_texture_basisu",LZ="KHR_texture_transform",j4="KHR_xmp_json_ld",iR="INSTANCE_ATTRIBUTE";class dR extends O1{init(){this.extensionName=GZ,this.propertyType="InstancedMesh",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:iR})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}dR.EXTENSION_NAME=GZ;class Pw extends T1{constructor(...Z){super(...Z);this.extensionName=GZ,this.provideTypes=[i.NODE],this.prewriteTypes=[i.ACCESSOR]}createInstancedMesh(){return new dR(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[GZ])return;let Q=Y.extensions[GZ],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[$].setExtension(GZ,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(iR);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,iR);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let Y=X.getExtension(GZ);if(Y){let $=Z.nodeIndexMap.get(X),Q=J.json.nodes[$],K={attributes:{}};Y.listSemantics().forEach((W)=>{let G=Y.getAttribute(W);K.attributes[W]=Z.accessorIndexMap.get(G)}),Q.extensions=Q.extensions||{},Q.extensions[GZ]=K}}),this}}Pw.EXTENSION_NAME=GZ;function DZ(){return DZ=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},DZ.apply(null,arguments)}var uG;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(uG||(uG={}));var j3;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(j3||(j3={}));var Y8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})(Y8||(Y8={}));function WD1(Z){if(!Z.extensions||!Z.extensions[X6])return!1;return!!Z.extensions[X6].fallback}var{BYTE:GD1,SHORT:An,FLOAT:zD1}=K0.ComponentType,{encodeNormalizedInt:mn,decodeNormalizedInt:gR}=I0;function vD1(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!==j3.ATTRIBUTES)return K;if($!==Y8.NONE){let W=Z.getNormalized()?VD1(Z):new Float32Array(K.array);switch($){case Y8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=zD1,K.normalized=!1,K.array=J.encodeFilterExp(W,Z.getCount(),K.byteStride,Q);break;case Y8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?An:GD1,K.normalized=!0,W=Z.getElementSize()===3?qD1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case Y8.QUATERNION:K.byteStride=8,K.componentType=An,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>gR(G,Z.getComponentType())),K.max=K.max.map((G)=>gR(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>mn(G,K.componentType)),K.max=K.max.map((G)=>mn(G,K.componentType))}else if(K.byteStride%4)K.array=HD1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function VD1(Z){let J=Z.getComponentType(),X=Z.getArray(),Y=new Float32Array(X.length);for(let $=0;$<X.length;$++)Y[$]=gR(X[$],J);return Y}function HD1(Z,J){let Y=E0.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 W=0;W<J;W++)Q[K*Y+W]=Z[K*J+W];return Q}function qD1(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 FD1(Z,J){if(J===w4.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some((Y)=>{return Y instanceof g1&&Y.getMode()===g1.Mode.TRIANGLES})?j3.TRIANGLES:j3.INDICES;return j3.ATTRIBUTES}function wD1(Z,J){let X=J.getGraph().listParentEdges(Z).filter((Y)=>!(Y.getParent()instanceof W3));for(let Y of X){let $=Y.getName(),Q=Y.getAttributes().key||"",K=Y.getParent().propertyType===i.PRIMITIVE_TARGET;if($==="indices")return{filter:Y8.NONE};if($==="attributes"){if(Q==="POSITION")return{filter:Y8.NONE};if(Q==="TEXCOORD_0")return{filter:Y8.NONE};if(Q.startsWith("JOINTS_"))return{filter:Y8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:Y8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:Y8.NONE}:{filter:Y8.OCTAHEDRAL,bits:8}}if($==="output"){let W=tn(Z);if(W==="rotation")return{filter:Y8.QUATERNION,bits:16};if(W==="translation")return{filter:Y8.EXPONENTIAL,bits:12};if(W==="scale")return{filter:Y8.EXPONENTIAL,bits:12};return{filter:Y8.NONE}}if($==="input")return{filter:Y8.NONE};if($==="inverseBindMatrices")return{filter:Y8.NONE}}return{filter:Y8.NONE}}function tn(Z){for(let J of Z.listParents()){if(!(J instanceof AJ))continue;for(let X of J.listParents()){if(!(X instanceof QZ))continue;return X.getTargetPath()}}return null}var un={method:uG.QUANTIZE};class yG extends T1{constructor(...Z){super(...Z);this.extensionName=X6,this.prereadTypes=[i.BUFFER,i.PRIMITIVE],this.prewriteTypes=[i.BUFFER,i.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=un,this._encoderFallbackBuffer=null,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={}}install(Z,J){if(Z==="meshopt.decoder")this._decoder=J;if(Z==="meshopt.encoder")this._encoder=J;return this}setEncoderOptions(Z){return this._encoderOptions=DZ({},un,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw Error(`[${X6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw Error(`[${X6}]: Missing WASM support.`)}if(J===i.BUFFER)this._prereadBuffers(Z);else if(J===i.PRIMITIVE)this._prereadPrimitives(Z);return this}_prereadBuffers(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[X6])return;let Q=Y.extensions[X6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,z=Q.byteStride,v=new Uint8Array(G*z),H=J.json.buffers[Q.buffer],V=H.uri?J.resources[H.uri]:J.resources[EY],q=E0.toView(V,K,W);this._decoder.decodeGltfBuffer(v,G,z,q,Q.mode,Q.filter),Z.bufferViews[$]=v})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y)=>{if(!Y.extensions||!Y.extensions[X6])return;let $=Y.extensions[X6],Q=Z.buffers[$.buffer],K=Z.buffers[Y.buffer],W=J.json.buffers[Y.buffer];if(WD1(W))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 K0)Y.swap(J,X);J.dispose()}return this}prewrite(Z,J){if(J===i.ACCESSOR)this._prewriteAccessors(Z);else if(J===i.BUFFER)this._prewriteBuffers(Z);return this}_prewriteAccessors(Z){let J=Z.jsonDoc.json,X=this._encoder,Y=this._encoderOptions,$=this.document.getGraph(),Q=this.document.createBuffer(),K=this.document.getRoot().listBuffers().indexOf(Q),W=1,G=new Map,z=(v)=>{for(let H of $.listParents(v)){if(H.propertyType===i.ROOT)continue;let V=G.get(v);if(V===void 0)G.set(v,V=W++);return V}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let v of this.document.getRoot().listAccessors()){if(tn(v)==="weights")continue;if(v.getSparse())continue;let H=Z.getAccessorUsage(v),V=Z.accessorUsageGroupedByParent.has(H)?z(v):null,q=FD1(v,H),F=Y.method===uG.FILTER?wD1(v,this.document):{filter:Y8.NONE},w=vD1(v,X,q,F),{array:c,byteStride:U}=w,j=v.getBuffer();if(!j)throw Error(`${X6}: Missing buffer for accessor.`);let B=this.document.getRoot().listBuffers().indexOf(j),L=[H,V,q,F.filter,U,B].join(":"),R=this._encoderBufferViews[L],M=this._encoderBufferViewData[L],N=this._encoderBufferViewAccessors[L];if(!R||!M)N=this._encoderBufferViewAccessors[L]=[],M=this._encoderBufferViewData[L]=[],R=this._encoderBufferViews[L]={buffer:K,target:w4.USAGE_TO_TARGET[H],byteOffset:0,byteLength:0,byteStride:H===w4.BufferViewUsage.ARRAY_BUFFER?U:void 0,extensions:{[X6]:{buffer:B,byteOffset:0,byteLength:0,mode:q,filter:F.filter!==Y8.NONE?F.filter:void 0,byteStride:U,count:0}}};let P=Z.createAccessorDef(v);if(P.componentType=w.componentType,P.normalized=w.normalized,P.byteOffset=R.byteLength,P.min&&w.min)P.min=w.min;if(P.max&&w.max)P.max=w.max;Z.accessorIndexMap.set(v,J.accessors.length),J.accessors.push(P),N.push(P),M.push(new Uint8Array(c.buffer,c.byteOffset,c.byteLength)),R.byteLength+=c.byteLength,R.extensions.EXT_meshopt_compression.count+=v.getCount()}}_prewriteBuffers(Z){let J=this._encoder;for(let X in this._encoderBufferViews){let Y=this._encoderBufferViews[X],$=this._encoderBufferViewData[X],Q=this.document.getRoot().listBuffers()[Y.extensions[X6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:z}=Y.extensions[X6],v=E0.concat($),H=J.encodeGltfBuffer(v,W,G,z),V=E0.pad(H);Y.extensions[X6].byteLength=H.byteLength,$.length=0,$.push(V),K.push(V),Z.otherBufferViews.set(Q,K)}}write(Z){let J=0;for(let Q in this._encoderBufferViews){let K=this._encoderBufferViews[Q],W=this._encoderBufferViewData[Q][0],G=Z.otherBufferViewsIndexMap.get(W),z=this._encoderBufferViewAccessors[Q];for(let q of z)q.bufferView=G;let v=Z.jsonDoc.json.bufferViews[G],H=v.byteOffset||0;Object.assign(v,K),v.byteOffset=J;let V=v.extensions[X6];V.byteOffset=H,J+=E0.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,Y=Z.bufferIndexMap.get(X),$=Z.jsonDoc.json.buffers[Y];return $.byteLength=J,$.extensions={[X6]:{fallback:!0}},X.dispose(),this}}yG.EXTENSION_NAME=X6;yG.EncoderMethod=uG;class en{match(Z){return Z.length>=12&&E0.decodeText(Z.slice(4,12))==="ftypavif"}getSize(Z){if(!this.match(Z))return null;let J=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),X=ln(J,0);if(!X)return null;let Y=X.end;while(X=ln(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 Ow extends T1{constructor(...Z){super(...Z);this.extensionName=AG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/avif",new en)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[AG])X.source=X.extensions[AG].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/avif"){let Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[AG]={source:Q.source},delete Q.source})}}),this}}Ow.EXTENSION_NAME=AG;function ln(Z,J){if(Z.byteLength<4+J)return null;let X=Z.getUint32(J);if(Z.byteLength<X+J||X<8)return null;return{type:E0.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}class Zs{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=E0.decodeText(Z.slice(0,4)),X=E0.decodeText(Z.slice(8,12));if(J!=="RIFF"||X!=="WEBP")return null;let Y=new DataView(Z.buffer,Z.byteOffset),$=12;while($<Y.byteLength){let Q=E0.decodeText(new Uint8Array([Y.getUint8($),Y.getUint8($+1),Y.getUint8($+2),Y.getUint8($+3)])),K=Y.getUint32($+4,!0);if(Q==="VP8 "){let W=Y.getInt16($+14,!0)&16383,G=Y.getInt16($+16,!0)&16383;return[W,G]}else if(Q==="VP8L"){let W=Y.getUint8($+9),G=Y.getUint8($+10),z=Y.getUint8($+11),v=Y.getUint8($+12),H=1+((G&63)<<8|W),V=1+((v&15)<<10|z<<2|(G&192)>>6);return[H,V]}$+=8+K+K%2}return null}getChannels(Z){return 4}}class Tw extends T1{constructor(...Z){super(...Z);this.extensionName=bG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/webp",new Zs)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[bG])X.source=X.extensions[bG].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/webp"){let Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[bG]={source:Q.source},delete Q.source})}}),this}}Tw.EXTENSION_NAME=bG;var S8,Js,Xs;function cD1(Z,J){let X=new S8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==S8.TRIANGULAR_MESH)throw Error(`[${s1}] Unknown geometry type.`);let $=new S8.Mesh;if(!Z.DecodeBufferToMesh(X,$).ok()||$.ptr===0)throw Error(`[${s1}] Decoding failure.`);return $}finally{S8.destroy(X)}}function UD1(Z,J){let Y=J.num_faces()*3,$,Q;if(J.num_points()<=65534){let K=Y*Uint16Array.BYTES_PER_ELEMENT;$=S8._malloc(K),Z.GetTrianglesUInt16Array(J,K,$),Q=new Uint16Array(S8.HEAPU16.buffer,$,Y).slice()}else{let K=Y*Uint32Array.BYTES_PER_ELEMENT;$=S8._malloc(K),Z.GetTrianglesUInt32Array(J,K,$),Q=new Uint32Array(S8.HEAPU32.buffer,$,Y).slice()}return S8._free($),Q}function xD1(Z,J,X,Y){let $=Xs[Y.componentType],Q=Js[Y.componentType],K=X.num_components(),G=J.num_points()*K,z=G*Q.BYTES_PER_ELEMENT,v=S8._malloc(z);Z.GetAttributeDataArrayForAllPoints(J,X,$,z,v);let H=new Q(S8.HEAPF32.buffer,v,G).slice();return S8._free(v),H}function jD1(Z){S8=Z,Js={[K0.ComponentType.FLOAT]:Float32Array,[K0.ComponentType.UNSIGNED_INT]:Uint32Array,[K0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[K0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[K0.ComponentType.SHORT]:Int16Array,[K0.ComponentType.BYTE]:Int8Array},Xs={[K0.ComponentType.FLOAT]:S8.DT_FLOAT32,[K0.ComponentType.UNSIGNED_INT]:S8.DT_UINT32,[K0.ComponentType.UNSIGNED_SHORT]:S8.DT_UINT16,[K0.ComponentType.UNSIGNED_BYTE]:S8.DT_UINT8,[K0.ComponentType.SHORT]:S8.DT_INT16,[K0.ComponentType.BYTE]:S8.DT_INT8}}var U4,lG;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(lG||(lG={}));var B4;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(B4||(B4={}));var Ys={[B4.POSITION]:14,[B4.NORMAL]:10,[B4.COLOR]:8,[B4.TEX_COORD]:12,[B4.GENERIC]:12},yn={decodeSpeed:5,encodeSpeed:5,method:lG.EDGEBREAKER,quantizationBits:Ys,quantizationVolume:"mesh"};function BD1(Z){U4=Z}function LD1(Z,J=yn){let X=DZ({},yn,J);X.quantizationBits=DZ({},Ys,J.quantizationBits);let Y=new U4.MeshBuilder,$=new U4.Mesh,Q=new U4.ExpertEncoder($),K={},W=new U4.DracoInt8Array,G=Z.listTargets().length>0,z=!1;for(let w of Z.listSemantics()){let c=Z.getAttribute(w);if(c.getSparse()){z=!0;continue}let U=DD1(w),j=MD1(Y,c.getComponentType(),$,U4[U],c.getCount(),c.getElementSize(),c.getArray());if(j===-1)throw Error(`Error compressing "${w}" attribute.`);if(K[w]=j,X.quantizationVolume==="mesh"||w!=="POSITION")Q.SetAttributeQuantization(j,X.quantizationBits[U]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:B}=X,L=Math.max(B.max[0]-B.min[0],B.max[1]-B.min[1],B.max[2]-B.min[2]);Q.SetAttributeExplicitQuantization(j,X.quantizationBits[U],c.getElementSize(),B.min,L)}else throw Error("Invalid quantization volume state.")}let v=Z.getIndices();if(!v)throw new Rw("Primitive must have indices.");if(Y.AddFacesToMesh($,v.getCount()/3,v.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===lG.SEQUENTIAL||G||z)Q.SetEncodingMethod(U4.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(U4.MESH_EDGEBREAKER_ENCODING);let H=Q.EncodeToDracoBuffer(!(G||z),W);if(H<=0)throw new Rw("Error applying Draco compression.");let V=new Uint8Array(H);for(let w=0;w<H;++w)V[w]=W.GetValue(w);let q=Q.GetNumberOfEncodedPoints(),F=Q.GetNumberOfEncodedFaces()*3;return U4.destroy(W),U4.destroy($),U4.destroy(Y),U4.destroy(Q),{numVertices:q,numIndices:F,data:V,attributeIDs:K}}function DD1(Z){if(Z==="POSITION")return B4.POSITION;else if(Z==="NORMAL")return B4.NORMAL;else if(Z.startsWith("COLOR_"))return B4.COLOR;else if(Z.startsWith("TEXCOORD_"))return B4.TEX_COORD;return B4.GENERIC}function MD1(Z,J,X,Y,$,Q,K){switch(J){case K0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,Y,$,Q,K);case K0.ComponentType.BYTE:return Z.AddInt8Attribute(X,Y,$,Q,K);case K0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,Y,$,Q,K);case K0.ComponentType.SHORT:return Z.AddInt16Attribute(X,Y,$,Q,K);case K0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,Y,$,Q,K);case K0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,Y,$,Q,K);default:throw Error(`Unexpected component type, "${J}".`)}}class Rw extends Error{}class pG extends T1{constructor(...Z){super(...Z);this.extensionName=s1,this.prereadTypes=[i.PRIMITIVE],this.prewriteTypes=[i.ACCESSOR],this.readDependencies=["draco3d.decoder"],this.writeDependencies=["draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(Z,J){if(Z==="draco3d.decoder")this._decoderModule=J,jD1(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 Error(`[${s1}] 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[s1])continue;let W=K.extensions[s1],[G,z]=Y.get(W.bufferView)||[];if(!z||!G){let v=X.json.bufferViews[W.bufferView],H=X.json.buffers[v.buffer],V=H.uri?X.resources[H.uri]:X.resources[EY],q=v.byteOffset||0,F=v.byteLength,w=E0.toView(V,q,F);G=new this._decoderModule.Decoder,z=cD1(G,w),Y.set(W.bufferView,[G,z]),J.debug(`[${s1}] Decompressed ${w.byteLength} bytes.`)}for(let v in W.attributes){let H=Z.jsonDoc.json.accessors[K.attributes[v]],V=G.GetAttributeByUniqueId(z,W.attributes[v]),q=xD1(G,z,V,H);Z.accessors[K.attributes[v]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(UD1(G,z))}}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 Error(`[${s1}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${s1}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let Y=RD1(this.document),$=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${s1}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=NG(this.document.getRoot().listScenes().pop());for(let K of Array.from(Y.keys())){let W=Y.get(K);if(!W)throw Error("Unexpected primitive.");if($.has(W)){$.set(W,$.get(W));continue}let G=K.getIndices(),z=Z.jsonDoc.json.accessors,v;try{v=LD1(K,DZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof Rw){X.warn(`[${s1}]: ${q.message} Skipping primitive compression.`);continue}throw q}$.set(W,v);let H=Z.createAccessorDef(G);if(H.count=v.numIndices,Z.accessorIndexMap.set(G,z.length),z.push(H),v.numVertices>65534&&K0.getComponentSize(H.componentType)<=2)H.componentType=K0.ComponentType.UNSIGNED_INT;else if(v.numVertices>254&&K0.getComponentSize(H.componentType)<=1)H.componentType=K0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let F=K.getAttribute(q);if(v.attributeIDs[q]===void 0)continue;let w=Z.createAccessorDef(F);w.count=v.numVertices,Z.accessorIndexMap.set(F,z.length),z.push(w)}let V=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(V))Z.otherBufferViews.set(V,[]);Z.otherBufferViews.get(V).push(v.data)}return X.debug(`[${s1}] Compressed ${Y.size} primitives.`),Z.extensionData[s1]={primitiveHashMap:Y,primitiveEncodingMap:$},this}write(Z){let J=Z.extensionData[s1];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[$],W=J.primitiveHashMap.get(Q);if(!W)continue;let G=J.primitiveEncodingMap.get(W);if(!G)continue;K.extensions=K.extensions||{},K.extensions[s1]={bufferView:Z.otherBufferViewsIndexMap.get(G.data),attributes:G.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter((Y)=>Y!==s1),X.extensionsRequired=(X.extensionsRequired||[]).filter((Y)=>Y!==s1)}return this}}pG.EXTENSION_NAME=s1;pG.EncoderMethod=lG;function RD1(Z){let J=Z.getLogger(),X=new Set,Y=new Set,$=0,Q=0;for(let H of Z.getRoot().listMeshes())for(let V of H.listPrimitives())if(!V.getIndices())Y.add(V),$++;else if(V.getMode()!==g1.Mode.TRIANGLES)Y.add(V),Q++;else X.add(V);if($>0)J.warn(`[${s1}] Skipping Draco compression of ${$} non-indexed primitives.`);if(Q>0)J.warn(`[${s1}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),W=new Map;for(let H=0;H<K.length;H++)W.set(K[H],H);let G=new Map,z=new Set,v=new Map;for(let H of Array.from(X)){let V=pn(H,W);if(z.has(V)){v.set(H,V);continue}if(G.has(H.getIndices())){let q=H.getIndices(),F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}for(let q of H.listAttributes())if(G.has(q)){let F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}V=pn(H,W),z.add(V),v.set(H,V),G.set(H.getIndices(),V);for(let q of H.listAttributes())G.set(q,V)}for(let H of Array.from(G.keys())){let V=new Set(H.listParents().map((q)=>q.propertyType));if(V.size!==2||!V.has(i.PRIMITIVE)||!V.has(i.ROOT))throw Error(`[${s1}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let H of Array.from(X)){let V=v.get(H),q=H.getIndices();if(G.get(q)!==V||H.listAttributes().some((F)=>G.get(F)!==V))throw Error(`[${s1}] Draco primitives must share all, or no, accessors.`)}for(let H of Array.from(Y)){let V=H.getIndices();if(G.has(V)||H.listAttributes().some((q)=>G.has(q)))throw Error(`[${s1}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return v}function pn(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 B3 extends O1{init(){this.extensionName=x4,this.propertyType="Light",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:B3.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(Z){return this.set("color",Z)}getIntensity(){return this.get("intensity")}setIntensity(Z){return this.set("intensity",Z)}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getRange(){return this.get("range")}setRange(Z){return this.set("range",Z)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(Z){return this.set("innerConeAngle",Z)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(Z){return this.set("outerConeAngle",Z)}}B3.EXTENSION_NAME=x4;B3.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};class aR extends T1{constructor(...Z){super(...Z);this.extensionName=x4}createLight(Z=""){return new B3(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[x4])return this;let $=(J.json.extensions[x4].lights||[]).map((Q)=>{var K,W;let G=this.createLight().setName(Q.name||"").setType(Q.type);if(Q.color!==void 0)G.setColor(Q.color);if(Q.intensity!==void 0)G.setIntensity(Q.intensity);if(Q.range!==void 0)G.setRange(Q.range);if(((K=Q.spot)==null?void 0:K.innerConeAngle)!==void 0)G.setInnerConeAngle(Q.spot.innerConeAngle);if(((W=Q.spot)==null?void 0:W.outerConeAngle)!==void 0)G.setOuterConeAngle(Q.spot.outerConeAngle);return G});return J.json.nodes.forEach((Q,K)=>{if(!Q.extensions||!Q.extensions[x4])return;let W=Q.extensions[x4];Z.nodes[K].setExtension(x4,$[W.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(!I0.eq(Q.getColor(),[1,1,1]))K.color=Q.getColor();if(Q.getIntensity()!==1)K.intensity=Q.getIntensity();if(Q.getRange()!=null)K.range=Q.getRange();if(Q.getName())K.name=Q.getName();if(Q.getType()===B3.Type.SPOT)K.spot={innerConeAngle:Q.getInnerConeAngle(),outerConeAngle:Q.getOuterConeAngle()};X.push(K),Y.set(Q,X.length-1)}return this.document.getRoot().listNodes().forEach(($)=>{let Q=$.getExtension(x4);if(Q){let K=Z.nodeIndexMap.get($),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[x4]={light:Y.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[x4]={lights:X},this}}aR.EXTENSION_NAME=x4;var{R:ND1,G:PD1,B:OD1}=v5;class nR extends O1{init(){this.extensionName=zZ,this.propertyType="Anisotropy",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new F1(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(Z){return this.set("anisotropyStrength",Z)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(Z){return this.set("anisotropyRotation",Z)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(Z){return this.setRef("anisotropyTexture",Z,{channels:ND1|PD1|OD1})}}nR.EXTENSION_NAME=zZ;class sR extends T1{constructor(...Z){super(...Z);this.extensionName=zZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createAnisotropy(){return new nR(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[zZ]){let K=this.createAnisotropy();Z.materials[Q].setExtension(zZ,K);let W=$.extensions[zZ];if(W.anisotropyStrength!==void 0)K.setAnisotropyStrength(W.anisotropyStrength);if(W.anisotropyRotation!==void 0)K.setAnisotropyRotation(W.anisotropyRotation);if(W.anisotropyTexture!==void 0){let G=W.anisotropyTexture,z=Z.textures[Y[G.index].source];K.setAnisotropyTexture(z),Z.setTextureInfo(K.getAnisotropyTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(zZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[zZ]={};if(Y.getAnisotropyStrength()>0)K.anisotropyStrength=Y.getAnisotropyStrength();if(Y.getAnisotropyRotation()!==0)K.anisotropyRotation=Y.getAnisotropyRotation();if(Y.getAnisotropyTexture()){let W=Y.getAnisotropyTexture(),G=Y.getAnisotropyTextureInfo();K.anisotropyTexture=Z.createTextureInfoDef(W,G)}}}),this}}sR.EXTENSION_NAME=zZ;var{R:gn,G:dn,B:TD1}=v5;class oR extends O1{init(){this.extensionName=vZ,this.propertyType="Clearcoat",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new F1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new F1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new F1(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(Z){return this.set("clearcoatFactor",Z)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(Z){return this.setRef("clearcoatTexture",Z,{channels:gn})}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:dn})}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:gn|dn|TD1})}}oR.EXTENSION_NAME=vZ;class rR extends T1{constructor(...Z){super(...Z);this.extensionName=vZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createClearcoat(){return new oR(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[vZ]){let K=this.createClearcoat();Z.materials[Q].setExtension(vZ,K);let W=$.extensions[vZ];if(W.clearcoatFactor!==void 0)K.setClearcoatFactor(W.clearcoatFactor);if(W.clearcoatRoughnessFactor!==void 0)K.setClearcoatRoughnessFactor(W.clearcoatRoughnessFactor);if(W.clearcoatTexture!==void 0){let G=W.clearcoatTexture,z=Z.textures[Y[G.index].source];K.setClearcoatTexture(z),Z.setTextureInfo(K.getClearcoatTextureInfo(),G)}if(W.clearcoatRoughnessTexture!==void 0){let G=W.clearcoatRoughnessTexture,z=Z.textures[Y[G.index].source];K.setClearcoatRoughnessTexture(z),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),G)}if(W.clearcoatNormalTexture!==void 0){let G=W.clearcoatNormalTexture,z=Z.textures[Y[G.index].source];if(K.setClearcoatNormalTexture(z),Z.setTextureInfo(K.getClearcoatNormalTextureInfo(),G),G.scale!==void 0)K.setClearcoatNormalScale(G.scale)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(vZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[vZ]={clearcoatFactor:Y.getClearcoatFactor(),clearcoatRoughnessFactor:Y.getClearcoatRoughnessFactor()};if(Y.getClearcoatTexture()){let W=Y.getClearcoatTexture(),G=Y.getClearcoatTextureInfo();K.clearcoatTexture=Z.createTextureInfoDef(W,G)}if(Y.getClearcoatRoughnessTexture()){let W=Y.getClearcoatRoughnessTexture(),G=Y.getClearcoatRoughnessTextureInfo();K.clearcoatRoughnessTexture=Z.createTextureInfoDef(W,G)}if(Y.getClearcoatNormalTexture()){let W=Y.getClearcoatNormalTexture(),G=Y.getClearcoatNormalTextureInfo();if(K.clearcoatNormalTexture=Z.createTextureInfoDef(W,G),Y.getClearcoatNormalScale()!==1)K.clearcoatNormalTexture.scale=Y.getClearcoatNormalScale()}}}),this}}rR.EXTENSION_NAME=vZ;var{R:CD1,G:fD1,B:kD1,A:ED1}=v5;class tR extends O1{init(){this.extensionName=VZ,this.propertyType="DiffuseTransmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new F1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new F1(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(Z){return this.set("diffuseTransmissionFactor",Z)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(Z){return this.setRef("diffuseTransmissionTexture",Z,{channels:ED1})}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:CD1|fD1|kD1})}}tR.EXTENSION_NAME=VZ;class eR extends T1{constructor(...Z){super(...Z);this.extensionName=VZ}createDiffuseTransmission(){return new tR(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[VZ]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(VZ,K);let W=$.extensions[VZ];if(W.diffuseTransmissionFactor!==void 0)K.setDiffuseTransmissionFactor(W.diffuseTransmissionFactor);if(W.diffuseTransmissionColorFactor!==void 0)K.setDiffuseTransmissionColorFactor(W.diffuseTransmissionColorFactor);if(W.diffuseTransmissionTexture!==void 0){let G=W.diffuseTransmissionTexture,z=Z.textures[Y[G.index].source];K.setDiffuseTransmissionTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),G)}if(W.diffuseTransmissionColorTexture!==void 0){let G=W.diffuseTransmissionColorTexture,z=Z.textures[Y[G.index].source];K.setDiffuseTransmissionColorTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),G)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let Y=X.getExtension(VZ);if(!Y)continue;let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[VZ]={diffuseTransmissionFactor:Y.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:Y.getDiffuseTransmissionColorFactor()};if(Y.getDiffuseTransmissionTexture()){let W=Y.getDiffuseTransmissionTexture(),G=Y.getDiffuseTransmissionTextureInfo();K.diffuseTransmissionTexture=Z.createTextureInfoDef(W,G)}if(Y.getDiffuseTransmissionColorTexture()){let W=Y.getDiffuseTransmissionColorTexture(),G=Y.getDiffuseTransmissionColorTextureInfo();K.diffuseTransmissionColorTexture=Z.createTextureInfoDef(W,G)}}return this}}eR.EXTENSION_NAME=VZ;class ZN extends O1{init(){this.extensionName=HZ,this.propertyType="Dispersion",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}ZN.EXTENSION_NAME=HZ;class JN extends T1{constructor(...Z){super(...Z);this.extensionName=HZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createDispersion(){return new ZN(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[HZ]){let Q=this.createDispersion();Z.materials[$].setExtension(HZ,Q);let K=Y.extensions[HZ];if(K.dispersion!==void 0)Q.setDispersion(K.dispersion)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(HZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[HZ]={dispersion:Y.getDispersion()}}}),this}}JN.EXTENSION_NAME=HZ;class XN extends O1{init(){this.extensionName=qZ,this.propertyType="EmissiveStrength",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}XN.EXTENSION_NAME=qZ;class YN extends T1{constructor(...Z){super(...Z);this.extensionName=qZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createEmissiveStrength(){return new XN(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[qZ]){let Q=this.createEmissiveStrength();Z.materials[$].setExtension(qZ,Q);let K=Y.extensions[qZ];if(K.emissiveStrength!==void 0)Q.setEmissiveStrength(K.emissiveStrength)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(qZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[qZ]={emissiveStrength:Y.getEmissiveStrength()}}}),this}}YN.EXTENSION_NAME=qZ;class $N extends O1{init(){this.extensionName=FZ,this.propertyType="IOR",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}$N.EXTENSION_NAME=FZ;class Cw extends T1{constructor(...Z){super(...Z);this.extensionName=FZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIOR(){return new $N(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[FZ]){let Q=this.createIOR();Z.materials[$].setExtension(FZ,Q);let K=Y.extensions[FZ];if(K.ior!==void 0)Q.setIOR(K.ior)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(FZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[FZ]={ior:Y.getIOR()}}}),this}}Cw.EXTENSION_NAME=FZ;var{R:ID1,G:_D1}=v5;class QN extends O1{init(){this.extensionName=wZ,this.propertyType="Iridescence",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new F1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new F1(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(Z){return this.set("iridescenceFactor",Z)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(Z){return this.setRef("iridescenceTexture",Z,{channels:ID1})}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:_D1})}}QN.EXTENSION_NAME=wZ;class KN extends T1{constructor(...Z){super(...Z);this.extensionName=wZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIridescence(){return new QN(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[wZ]){let K=this.createIridescence();Z.materials[Q].setExtension(wZ,K);let W=$.extensions[wZ];if(W.iridescenceFactor!==void 0)K.setIridescenceFactor(W.iridescenceFactor);if(W.iridescenceIor!==void 0)K.setIridescenceIOR(W.iridescenceIor);if(W.iridescenceThicknessMinimum!==void 0)K.setIridescenceThicknessMinimum(W.iridescenceThicknessMinimum);if(W.iridescenceThicknessMaximum!==void 0)K.setIridescenceThicknessMaximum(W.iridescenceThicknessMaximum);if(W.iridescenceTexture!==void 0){let G=W.iridescenceTexture,z=Z.textures[Y[G.index].source];K.setIridescenceTexture(z),Z.setTextureInfo(K.getIridescenceTextureInfo(),G)}if(W.iridescenceThicknessTexture!==void 0){let G=W.iridescenceThicknessTexture,z=Z.textures[Y[G.index].source];K.setIridescenceThicknessTexture(z),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(wZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[wZ]={};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 W=Y.getIridescenceTexture(),G=Y.getIridescenceTextureInfo();K.iridescenceTexture=Z.createTextureInfoDef(W,G)}if(Y.getIridescenceThicknessTexture()){let W=Y.getIridescenceThicknessTexture(),G=Y.getIridescenceThicknessTextureInfo();K.iridescenceThicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}KN.EXTENSION_NAME=wZ;var{R:an,G:nn,B:sn,A:on}=v5;class WN extends O1{init(){this.extensionName=cZ,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new F1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new F1(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(Z){return this.set("diffuseFactor",Z)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(Z){return this.setRef("diffuseTexture",Z,{channels:an|nn|sn|on,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:an|nn|sn|on})}}WN.EXTENSION_NAME=cZ;class fw extends T1{constructor(...Z){super(...Z);this.extensionName=cZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createPBRSpecularGlossiness(){return new WN(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[cZ]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(cZ,K);let W=$.extensions[cZ];if(W.diffuseFactor!==void 0)K.setDiffuseFactor(W.diffuseFactor);if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.glossinessFactor!==void 0)K.setGlossinessFactor(W.glossinessFactor);if(W.diffuseTexture!==void 0){let G=W.diffuseTexture,z=Z.textures[Y[G.index].source];K.setDiffuseTexture(z),Z.setTextureInfo(K.getDiffuseTextureInfo(),G)}if(W.specularGlossinessTexture!==void 0){let G=W.specularGlossinessTexture,z=Z.textures[Y[G.index].source];K.setSpecularGlossinessTexture(z),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(cZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[cZ]={diffuseFactor:Y.getDiffuseFactor(),specularFactor:Y.getSpecularFactor(),glossinessFactor:Y.getGlossinessFactor()};if(Y.getDiffuseTexture()){let W=Y.getDiffuseTexture(),G=Y.getDiffuseTextureInfo();K.diffuseTexture=Z.createTextureInfoDef(W,G)}if(Y.getSpecularGlossinessTexture()){let W=Y.getSpecularGlossinessTexture(),G=Y.getSpecularGlossinessTextureInfo();K.specularGlossinessTexture=Z.createTextureInfoDef(W,G)}}}),this}}fw.EXTENSION_NAME=cZ;var{R:hD1,G:SD1,B:bD1,A:AD1}=v5;class GN extends O1{init(){this.extensionName=UZ,this.propertyType="Sheen",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new F1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new F1(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(Z){return this.set("sheenColorFactor",Z)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(Z){return this.setRef("sheenColorTexture",Z,{channels:hD1|SD1|bD1,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:AD1})}}GN.EXTENSION_NAME=UZ;class zN extends T1{constructor(...Z){super(...Z);this.extensionName=UZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSheen(){return new GN(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[UZ]){let K=this.createSheen();Z.materials[Q].setExtension(UZ,K);let W=$.extensions[UZ];if(W.sheenColorFactor!==void 0)K.setSheenColorFactor(W.sheenColorFactor);if(W.sheenRoughnessFactor!==void 0)K.setSheenRoughnessFactor(W.sheenRoughnessFactor);if(W.sheenColorTexture!==void 0){let G=W.sheenColorTexture,z=Z.textures[Y[G.index].source];K.setSheenColorTexture(z),Z.setTextureInfo(K.getSheenColorTextureInfo(),G)}if(W.sheenRoughnessTexture!==void 0){let G=W.sheenRoughnessTexture,z=Z.textures[Y[G.index].source];K.setSheenRoughnessTexture(z),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(UZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[UZ]={sheenColorFactor:Y.getSheenColorFactor(),sheenRoughnessFactor:Y.getSheenRoughnessFactor()};if(Y.getSheenColorTexture()){let W=Y.getSheenColorTexture(),G=Y.getSheenColorTextureInfo();K.sheenColorTexture=Z.createTextureInfoDef(W,G)}if(Y.getSheenRoughnessTexture()){let W=Y.getSheenRoughnessTexture(),G=Y.getSheenRoughnessTextureInfo();K.sheenRoughnessTexture=Z.createTextureInfoDef(W,G)}}}),this}}zN.EXTENSION_NAME=UZ;var{R:mD1,G:uD1,B:lD1,A:yD1}=v5;class vN extends O1{init(){this.extensionName=xZ,this.propertyType="Specular",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new F1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new F1(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(Z){return this.set("specularFactor",Z)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(Z){return this.set("specularColorFactor",Z)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(Z){return this.setRef("specularTexture",Z,{channels:yD1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:mD1|uD1|lD1,isColor:!0})}}vN.EXTENSION_NAME=xZ;class kw extends T1{constructor(...Z){super(...Z);this.extensionName=xZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSpecular(){return new vN(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[xZ]){let K=this.createSpecular();Z.materials[Q].setExtension(xZ,K);let W=$.extensions[xZ];if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.specularColorFactor!==void 0)K.setSpecularColorFactor(W.specularColorFactor);if(W.specularTexture!==void 0){let G=W.specularTexture,z=Z.textures[Y[G.index].source];K.setSpecularTexture(z),Z.setTextureInfo(K.getSpecularTextureInfo(),G)}if(W.specularColorTexture!==void 0){let G=W.specularColorTexture,z=Z.textures[Y[G.index].source];K.setSpecularColorTexture(z),Z.setTextureInfo(K.getSpecularColorTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(xZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[xZ]={};if(Y.getSpecularFactor()!==1)K.specularFactor=Y.getSpecularFactor();if(!I0.eq(Y.getSpecularColorFactor(),[1,1,1]))K.specularColorFactor=Y.getSpecularColorFactor();if(Y.getSpecularTexture()){let W=Y.getSpecularTexture(),G=Y.getSpecularTextureInfo();K.specularTexture=Z.createTextureInfoDef(W,G)}if(Y.getSpecularColorTexture()){let W=Y.getSpecularColorTexture(),G=Y.getSpecularColorTextureInfo();K.specularColorTexture=Z.createTextureInfoDef(W,G)}}}),this}}kw.EXTENSION_NAME=xZ;var{R:pD1}=v5;class VN extends O1{init(){this.extensionName=jZ,this.propertyType="Transmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new F1(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(Z){return this.set("transmissionFactor",Z)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(Z){return this.setRef("transmissionTexture",Z,{channels:pD1})}}VN.EXTENSION_NAME=jZ;class HN extends T1{constructor(...Z){super(...Z);this.extensionName=jZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createTransmission(){return new VN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[jZ]){let K=this.createTransmission();Z.materials[Q].setExtension(jZ,K);let W=$.extensions[jZ];if(W.transmissionFactor!==void 0)K.setTransmissionFactor(W.transmissionFactor);if(W.transmissionTexture!==void 0){let G=W.transmissionTexture,z=Z.textures[Y[G.index].source];K.setTransmissionTexture(z),Z.setTextureInfo(K.getTransmissionTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(jZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[jZ]={transmissionFactor:Y.getTransmissionFactor()};if(Y.getTransmissionTexture()){let W=Y.getTransmissionTexture(),G=Y.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}HN.EXTENSION_NAME=jZ;class qN extends O1{init(){this.extensionName=iJ,this.propertyType="Unlit",this.parentTypes=[i.MATERIAL]}}qN.EXTENSION_NAME=iJ;class Ew extends T1{constructor(...Z){super(...Z);this.extensionName=iJ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createUnlit(){return new qN(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[iJ])Z.materials[Y].setExtension(iJ,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(iJ)){let Y=Z.materialIndexMap.get(X),$=J.json.materials[Y];$.extensions=$.extensions||{},$.extensions[iJ]={}}}),this}}Ew.EXTENSION_NAME=iJ;class FN extends O1{init(){this.extensionName=x6,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new w1})}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")}}FN.EXTENSION_NAME=x6;class wN extends O1{init(){this.extensionName=x6,this.propertyType="MappingList",this.parentTypes=[i.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new w1})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}wN.EXTENSION_NAME=x6;class Nw extends O1{init(){this.extensionName=x6,this.propertyType="Variant",this.parentTypes=["MappingList"]}}Nw.EXTENSION_NAME=x6;class cN extends T1{constructor(...Z){super(...Z);this.extensionName=x6}createMappingList(){return new wN(this.document.getGraph())}createVariant(Z=""){return new Nw(this.document.getGraph(),Z)}createMapping(){return new FN(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof Nw)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[x6])return this;let $=(J.json.extensions[x6].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((v,H)=>{if(!v.extensions||!v.extensions[x6])return;let V=this.createMappingList(),q=v.extensions[x6];for(let F of q.mappings){let w=this.createMapping();if(F.material!==void 0)w.setMaterial(Z.materials[F.material]);for(let c of F.variants||[])w.addVariant($[c]);V.addMapping(w)}G.listPrimitives()[H].setExtension(x6,V)})}),this}write(Z){let J=Z.jsonDoc,X=this.listVariants();if(!X.length)return this;let Y=[],$=new Map;for(let Q of X)$.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((W,G)=>{let z=W.getExtension(x6);if(!z)return;let v=Z.jsonDoc.json.meshes[K].primitives[G],H=z.listMappings().map((V)=>{let q=Z.createPropertyDef(V),F=V.getMaterial();if(F)q.material=Z.materialIndexMap.get(F);return q.variants=V.listVariants().map((w)=>$.get(w)),q});v.extensions=v.extensions||{},v.extensions[x6]={mappings:H}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[x6]={variants:Y},this}}cN.EXTENSION_NAME=x6;var{G:iD1}=v5;class UN extends O1{init(){this.extensionName=BZ,this.propertyType="Volume",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new F1(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(Z){return this.set("thicknessFactor",Z)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(Z){return this.setRef("thicknessTexture",Z,{channels:iD1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}UN.EXTENSION_NAME=BZ;class xN extends T1{constructor(...Z){super(...Z);this.extensionName=BZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createVolume(){return new UN(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[BZ]){let K=this.createVolume();Z.materials[Q].setExtension(BZ,K);let W=$.extensions[BZ];if(W.thicknessFactor!==void 0)K.setThicknessFactor(W.thicknessFactor);if(W.attenuationDistance!==void 0)K.setAttenuationDistance(W.attenuationDistance);if(W.attenuationColor!==void 0)K.setAttenuationColor(W.attenuationColor);if(W.thicknessTexture!==void 0){let G=W.thicknessTexture,z=Z.textures[Y[G.index].source];K.setThicknessTexture(z),Z.setTextureInfo(K.getThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(BZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[BZ]={};if(Y.getThicknessFactor()>0)K.thicknessFactor=Y.getThicknessFactor();if(Number.isFinite(Y.getAttenuationDistance()))K.attenuationDistance=Y.getAttenuationDistance();if(!I0.eq(Y.getAttenuationColor(),[1,1,1]))K.attenuationColor=Y.getAttenuationColor();if(Y.getThicknessTexture()){let W=Y.getThicknessTexture(),G=Y.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}xN.EXTENSION_NAME=BZ;class iG extends T1{constructor(...Z){super(...Z);this.extensionName=rn}read(Z){return this}write(Z){return this}}iG.EXTENSION_NAME=rn;class $s{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=Mw(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=Mw(Z).dataFormatDescriptor[0];if(X.colorModel===Sn)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===bn)return(X.samples[0].channelType&15)===3?4:3;throw Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=Mw(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,$))),W=Math.max(1,Math.floor(J.pixelHeight/Math.pow(2,$))),G=X?16:8;Y+=K/4*(W/4)*G}}return Y}}class jN extends T1{constructor(...Z){super(...Z);this.extensionName=mG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/ktx2",new $s)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[mG]){let X=J.extensions[mG];J.source=X.source}}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/ktx2"){let Y=Z.imageIndexMap.get(X);J.json.textures.forEach(($)=>{if($.source===Y)$.extensions=$.extensions||{},$.extensions[mG]={source:$.source},delete $.source})}}),this}}jN.EXTENSION_NAME=mG;class BN extends O1{init(){this.extensionName=LZ,this.propertyType="Transform",this.parentTypes=[i.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(Z){return this.set("offset",Z)}getRotation(){return this.get("rotation")}setRotation(Z){return this.set("rotation",Z)}getScale(){return this.get("scale")}setScale(Z){return this.set("scale",Z)}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}}BN.EXTENSION_NAME=LZ;class LN extends T1{constructor(...Z){super(...Z);this.extensionName=LZ}createTransform(){return new BN(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[LZ])continue;let Y=this.createTransform(),$=X.extensions[LZ];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(LZ,Y)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,Y]of J){let $=X.getExtension(LZ);if(!$)continue;Y.extensions=Y.extensions||{};let Q={},K=I0.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[LZ]=Q}return this}}LN.EXTENSION_NAME=LZ;var gD1=[i.ROOT,i.SCENE,i.NODE,i.MESH,i.MATERIAL,i.TEXTURE,i.ANIMATION];class DN extends O1{init(){this.extensionName=j4,this.propertyType="Packet",this.parentTypes=gD1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",DZ({},Z))}listProperties(){return Object.keys(this.get("properties"))}getProperty(Z){let J=this.get("properties");return Z in J?J[Z]:null}setProperty(Z,J){this._assertContext(Z);let X=DZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=pR(this.get("context")),J=pR(this.get("properties"));return DZ({"@context":Z},J)}fromJSONLD(Z){Z=pR(Z);let J=Z["@context"];if(J)this.set("context",J);return delete Z["@context"],this.set("properties",Z)}_assertContext(Z){if(!(Z.split(":")[0]in this.get("context")))throw Error(`${j4}: Missing context for term, "${Z}".`)}}DN.EXTENSION_NAME=j4;function pR(Z){return JSON.parse(JSON.stringify(Z))}class MN extends T1{constructor(...Z){super(...Z);this.extensionName=j4}createPacket(){return new DN(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[j4];if(!X||!X.packets)return this;let Y=Z.jsonDoc.json,$=this.document.getRoot(),Q=X.packets.map((G)=>this.createPacket().fromJSONLD(G)),K=[[Y.asset],Y.scenes,Y.nodes,Y.meshes,Y.materials,Y.images,Y.animations],W=[[$],$.listScenes(),$.listNodes(),$.listMeshes(),$.listMaterials(),$.listTextures(),$.listAnimations()];for(let G=0;G<K.length;G++){let z=K[G]||[];for(let v=0;v<z.length;v++){let H=z[v];if(H.extensions&&H.extensions[j4]){let V=H.extensions[j4];W[G][v].setExtension(j4,Q[V.packet])}}}return this}write(Z){let{json:J}=Z.jsonDoc,X=[];for(let Y of this.properties){X.push(Y.toJSONLD());for(let $ of Y.listParents()){let Q;switch($.propertyType){case i.ROOT:Q=J.asset;break;case i.SCENE:Q=J.scenes[Z.sceneIndexMap.get($)];break;case i.NODE:Q=J.nodes[Z.nodeIndexMap.get($)];break;case i.MESH:Q=J.meshes[Z.meshIndexMap.get($)];break;case i.MATERIAL:Q=J.materials[Z.materialIndexMap.get($)];break;case i.TEXTURE:Q=J.images[Z.imageIndexMap.get($)];break;case i.ANIMATION:Q=J.animations[Z.animationIndexMap.get($)];break;default:Q=null,this.document.getLogger().warn(`[${j4}]: Unsupported parent property, "${$.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[j4]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[j4]={packets:X};return this}}MN.EXTENSION_NAME=j4;var dD1=[pG,aR,sR,rR,eR,JN,YN,Cw,KN,fw,kw,zN,HN,Ew,cN,xN,iG,jN,LN,MN],iP6=[Pw,yG,Ow,Tw,...dD1];var aD1=t(UR(),1);function M3(){return M3=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},M3.apply(null,arguments)}var{POINTS:Qs,LINES:Iw,LINE_STRIP:nD1,LINE_LOOP:sD1,TRIANGLES:_w,TRIANGLE_STRIP:oD1,TRIANGLE_FAN:rD1}=g1.Mode;function uY(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function RZ(Z,J){let X=M3({},Z);for(let Y in J)if(J[Y]!==void 0)X[Y]=J[Y];return X}function Ms(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case g1.Mode.POINTS:return J?J.getCount():X.getCount();case g1.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case g1.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case g1.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case g1.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case g1.Mode.TRIANGLE_STRIP:case g1.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw Error("Unexpected mode: "+Z.getMode())}}var tD1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function PN(Z){return tD1.format(Z)}function eD1(Z,J,X=2){let Y=Z>J?"–":"+",$="%";return Y+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function mw(Z,J){return`${PN(Z)} → ${PN(J)} (${eD1(Z,J)})`}function uw(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 ZM1(Z,J,X){Z.swap(J,X);for(let Y of Z.listTargets())Y.swap(J,X)}function Rs(Z){let J=Z.getIndices(),X=uw(Z);if(Z.dispose(),J&&!ON(J))J.dispose();for(let Y of X)if(!ON(Y))Y.dispose()}function MZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function JM1(Z,J=Z){let X=_N(Z,J);for(let Y=0;Y<X.length;Y++)X[Y]=Y;return X}function _N(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function ON(Z){return Z.listParents().some((J)=>J.propertyType!==i.ROOT)}function Ns(Z){for(let J in Z)return!1;return!0}function Ps(Z){let J=c6.fromGraph(Z.getGraph()),X=Z.getMaterial(),Y=J.getRoot().listMaterials().indexOf(X),$=YM1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let z=Z.getAttribute(G),v=z.getElementSize(),H=z.getComponentType();return`${G}:${v}:${H}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((z)=>{let v=Z.getAttribute(z),H=v.getElementSize(),V=v.getComponentType();return`${z}:${H}:${V}`}).join("+")}).join("~");return`${Y}|${$}|${Q}|${K}|${W}`}function XM1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var YM1={[Qs]:Qs,[Iw]:Iw,[nD1]:Iw,[sD1]:Iw,[_w]:_w,[oD1]:_w,[rD1]:_w},L3="center",Ks={pivot:"center"};function Os(Z=Ks){let J=RZ(Ks,Z);return uY(L3,(X)=>{let Y=X.getLogger(),$=X.getRoot(),Q=$.listAnimations().length>0||$.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{Y.debug(`${L3}: Scene ${W+1} / ${$.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let v=NG(K);if(G=[(v.max[0]-v.min[0])/2+v.min[0],(v.max[1]-v.min[1])/2+v.min[1],(v.max[2]-v.min[2])/2+v.min[2]],J.pivot==="above")G[1]=v.max[1];if(J.pivot==="below")G[1]=v.min[1]}else G=J.pivot;Y.debug(`${L3}: Pivot "${G.join(", ")}".`);let z=[-1*G[0],-1*G[1],-1*G[2]];if(Q){Y.debug(`${L3}: Model contains animation or skin. Adding a wrapper node.`);let v=X.createNode("Pivot").setTranslation(z);K.listChildren().forEach((H)=>v.addChild(H)),K.addChild(v)}else Y.debug(`${L3}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((v)=>{let H=v.getTranslation();v.setTranslation([H[0]+z[0],H[1]+z[1],H[2]+z[2]])})}),Y.debug(`${L3}: Complete.`)})}function $M1(Z){let J=new Set,X=Z,Y;while(Y=X.getParentNode()){if(J.has(Y))throw Error("Circular dependency in scene graph.");J.add(Y),X=Y}return X.listParents().filter(($)=>$ instanceof K3)}function QM1(Z){let J=$M1(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 R3=typeof Float32Array<"u"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function KM1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=J[9],V=J[10],q=J[11],F=J[12],w=J[13],c=J[14],U=J[15],j=X*W-Y*K,B=X*G-$*K,L=X*z-Q*K,R=Y*G-$*W,M=Y*z-Q*W,N=$*z-Q*G,P=v*w-H*F,O=v*c-V*F,k=v*U-q*F,E=H*c-V*w,S=H*U-q*w,f=V*U-q*c,C=j*f-B*S+L*E+R*k-M*O+N*P;if(!C)return null;return C=1/C,Z[0]=(W*f-G*S+z*E)*C,Z[1]=($*S-Y*f-Q*E)*C,Z[2]=(w*N-c*M+U*R)*C,Z[3]=(V*M-H*N-q*R)*C,Z[4]=(G*k-K*f-z*O)*C,Z[5]=(X*f-$*k+Q*O)*C,Z[6]=(c*L-F*N-U*B)*C,Z[7]=(v*N-V*L+q*B)*C,Z[8]=(K*S-W*k+z*P)*C,Z[9]=(Y*k-X*S-Q*P)*C,Z[10]=(F*M-w*L+U*j)*C,Z[11]=(H*L-v*M-q*j)*C,Z[12]=(W*O-K*E-G*P)*C,Z[13]=(X*E-Y*O+$*P)*C,Z[14]=(w*B-F*R-c*j)*C,Z[15]=(v*R-H*B+V*j)*C,Z}function WM1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],w=Z[14],c=Z[15],U=J*K-X*Q,j=J*W-Y*Q,B=J*G-$*Q,L=X*W-Y*K,R=X*G-$*K,M=Y*G-$*W,N=z*F-v*q,P=z*w-H*q,O=z*c-V*q,k=v*w-H*F,E=v*c-V*F,S=H*c-V*w;return U*S-j*E+B*k+L*O-R*P+M*N}function Ts(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],w=J[12],c=J[13],U=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*Y+L*W+R*H+M*w,Z[1]=B*$+L*G+R*V+M*c,Z[2]=B*Q+L*z+R*q+M*U,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*Y+L*W+R*H+M*w,Z[5]=B*$+L*G+R*V+M*c,Z[6]=B*Q+L*z+R*q+M*U,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*Y+L*W+R*H+M*w,Z[9]=B*$+L*G+R*V+M*c,Z[10]=B*Q+L*z+R*q+M*U,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*Y+L*W+R*H+M*w,Z[13]=B*$+L*G+R*V+M*c,Z[14]=B*Q+L*z+R*q+M*U,Z[15]=B*K+L*v+R*F+M*j,Z}var j6;(function(Z){Z.RENDER="render",Z.RENDER_CACHED="render-cached",Z.UPLOAD="upload",Z.UPLOAD_NAIVE="upload-naive",Z.DISTINCT="distinct",Z.DISTINCT_POSITION="distinct-position",Z.UNUSED="unused"})(j6||(j6={}));function mY(Z,J){let X=Z.getAttribute("POSITION"),Y=Z.getIndices();switch(J){case j6.RENDER:return Y?Y.getCount():X.getCount();case j6.RENDER_CACHED:return Y?new Set(Y.getArray()).size:X.getCount();case j6.UPLOAD_NAIVE:case j6.UPLOAD:return X.getCount();case j6.DISTINCT:case j6.DISTINCT_POSITION:return GM1(J);case j6.UNUSED:return Y?X.getCount()-new Set(Y.getArray()).size:0;default:return zM1(J)}}function GM1(Z){throw Error(`Not implemented: ${Z}`)}function zM1(Z){throw Error(`Unexpected value: ${Z}`)}var gJ=4294967295;class Cs{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of uw(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(),$=E0.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 vM1(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 vM1(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 VM1(Z,J,X,Y,$=gJ){let Q=J-1,W=X.hash(Y)&Q;for(let G=0;G<=Q;G++){let z=Z[W];if(z===$||X.equal(z,Y))return W;W=W+G+1&Q}throw Error("Hash table full.")}function dG(Z,J,X){let Y=c6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=HM1(Z);let $=Z.getIndices(),Q=$?$.getArray():null,K=mY(Z,j6.RENDER),W=Y.createAccessor(),G=K,z=_N(G,X);for(let H=0;H<G;H++)z[H]=J[Q?Q[H]:H];Z.setIndices(W.setArray(z));let v=uw(Z);for(let H of Z.listAttributes()){let V=MZ(Y,H);TN(H,$,J,V,X),Z.swap(H,V)}for(let H of Z.listTargets())for(let V of H.listAttributes()){let q=MZ(Y,V);TN(V,$,J,q,X),H.swap(V,q)}if($&&$.listParents().length===1)$.dispose();for(let H of v)if(H.listParents().length===1)H.dispose();return Z}function TN(Z,J,X,Y,$){let Q=Z.getElementSize(),K=Z.getArray(),W=J?J.getArray():null,G=J?J.getCount():Z.getCount(),z=new K.constructor($*Q),v=new Uint8Array($);for(let H=0;H<G;H++){let V=W?W[H]:H,q=X[V];if(v[q])continue;for(let F=0;F<Q;F++)z[q*Q+F]=K[V*Q+F];v[q]=1}return Y.setArray(z)}function HM1(Z){let J=mY(Z,j6.UPLOAD),X=Z.getIndices(),Y=X?X.getArray():null;if(!X||!Y)return[JM1(J,1e6),J];let $=new Uint32Array(J).fill(gJ),Q=0;for(let K=0;K<Y.length;K++){let W=Y[K];if($[W]===gJ)$[W]=Q++}return[$,Q]}function qM1(){var Z=new R3(9);if(R3!=Float32Array)Z[1]=0,Z[2]=0,Z[3]=0,Z[5]=0,Z[6]=0,Z[7]=0;return Z[0]=1,Z[4]=1,Z[8]=1,Z}function FM1(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 wM1(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 cM1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=v*K-W*z,V=-v*Q+W*G,q=z*Q-K*G,F=X*H+Y*V+$*q;if(!F)return null;return F=1/F,Z[0]=H*F,Z[1]=(-v*Y+$*z)*F,Z[2]=(W*Y-$*K)*F,Z[3]=V*F,Z[4]=(v*X-$*G)*F,Z[5]=(-W*X+$*Q)*F,Z[6]=q*F,Z[7]=(-z*X+Y*G)*F,Z[8]=(K*X-Y*Q)*F,Z}function lw(){var Z=new R3(3);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function UM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function fs(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 xM1(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 jM1(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 BM1=UM1;(function(){var Z=lw();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();var CN="weld",Sw={overwrite:!0};function hN(Z=Sw){let J=RZ(Sw,Z);return uY(CN,async(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes()){for(let Q of $.listPrimitives())if(yw(Q,J),mY(Q,j6.RENDER)===0)Rs(Q);if($.listPrimitives().length===0)$.dispose()}Y.debug(`${CN}: Complete.`)})}function yw(Z,J=Sw){let X=Z.getGraph(),$=c6.fromGraph(X).getLogger(),Q=M3({},Sw,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===g1.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),W=Z.getIndices(),G=W==null?void 0:W.getArray(),z=W?W.getCount():K,v=new Cs(Z),H=XM1(K+K/4),V=new Uint32Array(H).fill(gJ),q=new Uint32Array(K).fill(gJ),F=0;for(let w=0;w<z;w++){let c=G?G[w]:w;if(q[c]!==gJ)continue;let U=VM1(V,H,v,c,gJ),j=V[U];if(j===gJ)V[U]=c,q[c]=F++;else q[c]=q[j]}$.debug(`${CN}: ${mw(K,F)} vertices.`),dG(Z,q,F)}var{FLOAT:LM1}=K0.ComponentType;function ks(Z,J){let X=Z.getAttribute("POSITION");if(X)Ws(J,X);let Y=Z.getAttribute("NORMAL");if(Y)Gs(J,Y);let $=Z.getAttribute("TANGENT");if($)zs(J,$);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)Ws(J,K);let W=Q.getAttribute("NORMAL");if(W)Gs(J,W);let G=Q.getAttribute("TANGENT");if(G)zs(J,G)}if(WM1(J)<0)DM1(Z)}function Ws(Z,J){let X=J.getComponentType(),Y=J.getNormalized(),$=J.getArray(),Q=X===LM1?$:new Float32Array($.length),K=lw();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=I0.decodeNormalizedInt($[W*3],X),K[1]=I0.decodeNormalizedInt($[W*3+1],X),K[2]=I0.decodeNormalizedInt($[W*3+2],X);else K[0]=$[W*3],K[1]=$[W*3+1],K[2]=$[W*3+2];xM1(K,K,Z),Q[W*3]=K[0],Q[W*3+1]=K[1],Q[W*3+2]=K[2]}J.setArray(Q).setNormalized(!1)}function Gs(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=qM1();FM1(Q,Z),cM1(Q,Q),wM1(Q,Q);let K=lw();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=I0.decodeNormalizedInt(X[W*3],$),K[1]=I0.decodeNormalizedInt(X[W*3+1],$),K[2]=I0.decodeNormalizedInt(X[W*3+2],$);else K[0]=X[W*3],K[1]=X[W*3+1],K[2]=X[W*3+2];if(jM1(K,K,Q),fs(K,K),Y)X[W*3]=I0.decodeNormalizedInt(K[0],$),X[W*3+1]=I0.decodeNormalizedInt(K[1],$),X[W*3+2]=I0.decodeNormalizedInt(K[2],$);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function zs(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=lw();for(let K=0,W=J.getCount();K<W;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],fs(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 DM1(Z){if(Z.getMode()!==g1.Mode.TRIANGLES)return;if(!Z.getIndices())yw(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 MM1(Z,J){for(let X of Z.listPrimitives()){let Y=RM1(X,Z);if(X!==Y)Z.removePrimitive(X).addPrimitive(Y)}for(let X of Z.listPrimitives())dG(X),ks(X,J)}function RM1(Z,J){if(Z.listParents().some((Y)=>Y instanceof PG&&Y!==J))Z=Z.clone();for(let Y of Z.listTargets())if(Y.listParents().some((Q)=>Q instanceof g1&&Q!==Z))Z.removeTarget(Y).addTarget(Y.clone());return Z}var vs=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function Es(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!I0.eq(X,vs))MM1(J,X);for(let Y of Z.listChildren()){let $=Y.getMatrix();Ts($,$,X),Y.setMatrix($)}return Z.setMatrix(vs)}var{LINES:NM1,LINE_STRIP:PM1,LINE_LOOP:OM1,TRIANGLES:TM1,TRIANGLE_STRIP:CM1,TRIANGLE_FAN:fM1}=g1.Mode;function kM1(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())yw(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=Ms(Z),W=new bJ[Y.getComponentType()](Q*2),G=Z.getMode();if(G===PM1)for(let v=0;v<Q;v++)W[v*2]=$[v],W[v*2+1]=$[v+1];else if(G===OM1)for(let v=0;v<Q;v++)if(v<Q-1)W[v*2]=$[v],W[v*2+1]=$[v+1];else W[v*2]=$[v],W[v*2+1]=$[0];else throw Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(NM1);let z=X.getRoot();if(Y.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,Y).setArray(W));else Y.setArray(W)}function Is(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())yw(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=Ms(Z),W=new bJ[Y.getComponentType()](Q*3),G=Z.getMode();if(G===CM1)for(let v=0,H=$.length;v<H-2;v++)if(v%2)W[v*3]=$[v+1],W[v*3+1]=$[v],W[v*3+2]=$[v+2];else W[v*3]=$[v],W[v*3+1]=$[v+1],W[v*3+2]=$[v+2];else if(G===fM1)for(let v=0;v<Q;v++)W[v*3]=$[0],W[v*3+1]=$[v+1],W[v*3+2]=$[v+2];else throw Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(TM1);let z=X.getRoot();if(Y.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,Y).setArray(W));else Y.setArray(W)}var oP6={keepUniqueNames:!1,propertyTypes:[i.ACCESSOR,i.MESH,i.TEXTURE,i.MATERIAL,i.SKIN]};var Vs="dequantize",bw={pattern:/^((?!JOINTS_).)*$/};function _s(Z=bw){let J=RZ(bw,Z);return uY(Vs,(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes())for(let Q of $.listPrimitives())EM1(Q,J);X.createExtension(iG).dispose(),Y.debug(`${Vs}: Complete.`)})}function EM1(Z,J=bw){let X=RZ(bw,J);for(let Y of Z.listSemantics())if(X.pattern.test(Y))fN(Z.getAttribute(Y));for(let Y of Z.listTargets())for(let $ of Y.listSemantics())if(X.pattern.test($))fN(Y.getAttribute($))}function fN(Z){let J=Z.getArray();if(!J)return;let X=Aw(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function Aw(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:hs,ROOT:rP6}=i;function Ss(Z){let J=new c6().setLogger(Z.getLogger()),X=SN(J,Z);return IM1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function IM1(Z,J,X){X||(X=SN(Z,J));for(let Y of J.getRoot().listExtensionsUsed()){let $=Z.createExtension(Y.constructor);if(Y.isRequired())$.setRequired(!0)}return _M1(Z,J,hM1(J),X)}function _M1(Z,J,X,Y){Y||(Y=SN(Z,J));let $=new Map;for(let Q of X)if(!$.has(Q)&&Q.propertyType!==hs)$.set(Q,Y(Q));for(let[Q,K]of $.entries())K.copy(Q,Y);return $}function SN(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return(Y)=>{if(Y.propertyType===hs)return Y;let $=X.get(Y);if(!$)$=new Y.constructor(Z.getGraph()),X.set(Y,$);return $}}function hM1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}function bs(){var Z=new R3(4);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function SM1(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 bM1(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 AM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z[3]=J[3]*X[3],Z}function mM1(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z}function uM1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return Math.hypot(J,X,Y,$)}var As=bM1,lM1=AM1,ms=uM1;(function(){var Z=bs();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=4;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Z[3]=J[W+3],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2],J[W+3]=Z[3];return J}})();var yM1=/color|emissive|diffuse/i;function pM1(Z){return Z.getGraph().listParentEdges(Z).some(($)=>{return $.getAttributes().isColor||yM1.test($.getName())})?"srgb":null}function iM1(Z){let J=Z.getGraph(),X=new Set,Y=new Set;function $(Q){let K=new Set;for(let W of J.listChildEdges(Q))if(W.getChild()instanceof _Y)K.add(W.getName()+"Info");for(let W of J.listChildEdges(Q)){let G=W.getChild();if(X.has(G))continue;if(X.add(G),G instanceof F1&&K.has(W.getName()))Y.add(G);else if(G instanceof O1)$(G)}}return $(Z),Array.from(Y)}function gM1(Z){let X=c6.fromGraph(Z.getGraph()).getRoot(),Y=Z.getGraph().listParentEdges(Z).filter(($)=>$.getParent()!==X).map(($)=>$.getName());return Array.from(new Set(Y))}var D3="prune",kN=0.011764705882352941,Hs={propertyTypes:[i.NODE,i.SKIN,i.MESH,i.CAMERA,i.PRIMITIVE,i.PRIMITIVE_TARGET,i.ANIMATION,i.MATERIAL,i.TEXTURE,i.ACCESSOR,i.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function us(Z=Hs){let J=RZ(Hs,Z),X=new Set(J.propertyTypes),Y=J.keepExtras;return uY(D3,async($)=>{let Q=$.getLogger(),K=$.getRoot(),W=$.getGraph(),G=new ls,z=(v)=>G.dispose(v.target);if(W.addEventListener("node:dispose",z),X.has(i.MESH))for(let v of K.listMeshes()){if(v.listPrimitives().length>0)continue;v.dispose()}if(X.has(i.NODE)){if(!J.keepLeaves)for(let v of K.listScenes())ys(W,v,Y);for(let v of K.listNodes())L4(v,Y)}if(X.has(i.SKIN))for(let v of K.listSkins())L4(v,Y);if(X.has(i.MESH))for(let v of K.listMeshes())L4(v,Y);if(X.has(i.CAMERA))for(let v of K.listCameras())L4(v,Y);if(X.has(i.PRIMITIVE))qs(W,i.PRIMITIVE,Y);if(X.has(i.PRIMITIVE_TARGET))qs(W,i.PRIMITIVE_TARGET,Y);if(!J.keepAttributes&&X.has(i.ACCESSOR)){let v=new Map;for(let H of K.listMeshes())for(let V of H.listPrimitives()){let q=V.getMaterial();if(!q)continue;let F=ps($,V,q),w=dM1(V,F);Fs(V,w),V.listTargets().forEach((c)=>Fs(c,w)),v.has(q)?v.get(q).add(V):v.set(q,new Set([V]))}for(let[H,V]of v)aM1(H,Array.from(V))}if(X.has(i.ANIMATION))for(let v of K.listAnimations()){for(let H of v.listChannels())if(!H.getTargetNode())H.dispose();if(!v.listChannels().length){let H=v.listSamplers();L4(v,Y),H.forEach((V)=>L4(V,Y))}else v.listSamplers().forEach((H)=>L4(H,Y))}if(X.has(i.MATERIAL))K.listMaterials().forEach((v)=>L4(v,Y));if(X.has(i.TEXTURE)){if(K.listTextures().forEach((v)=>L4(v,Y)),!J.keepSolidTextures)await nM1($)}if(X.has(i.ACCESSOR))K.listAccessors().forEach((v)=>L4(v,Y));if(X.has(i.BUFFER))K.listBuffers().forEach((v)=>L4(v,Y));if(W.removeEventListener("node:dispose",z),!G.empty()){let v=G.entries().map(([H,V])=>`${H} (${V})`).join(", ");Q.info(`${D3}: Removed types... ${v}`)}else Q.debug(`${D3}: No unused properties found.`);Q.debug(`${D3}: Complete.`)})}class ls{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 L4(Z,J){let X=Z.listParents().filter(($)=>!($ instanceof W3||$ instanceof QZ)),Y=J&&!Ns(Z.getExtras());if(!X.length&&!Y)Z.dispose()}function qs(Z,J,X){for(let Y of Z.listEdges()){let $=Y.getParent();if($.propertyType===J)L4($,X)}}function ys(Z,J,X){if(J.listChildren().forEach((K)=>ys(Z,K,X)),J instanceof K3)return;let Y=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==i.ROOT&&W!==i.SCENE&&W!==i.NODE}),$=Z.listChildren(J).length===0,Q=X&&!Ns(J.getExtras());if($&&!Y&&!Q)J.dispose()}function Fs(Z,J){for(let X of J)Z.setAttribute(X,null)}function dM1(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 ps(Z,J,X,Y=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let z of Q)if(z.getChild()instanceof _Y)K.add(z.getName());for(let z of Q){let v=z.getName(),H=z.getChild();if(H instanceof F1){if(K.has(v.replace(/Info$/,"")))Y.add(`TEXCOORD_${H.getTexCoord()}`)}if(H instanceof _Y&&v.match(/normalTexture/i))Y.add("TANGENT");if(H instanceof O1)ps(Z,J,H,Y)}let W=X instanceof K7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===g1.Mode.POINTS;if(W&&!G)Y.add("NORMAL");return Y}function aM1(Z,J){let X=iM1(Z),Y=new Set(X.map((G)=>G.getTexCoord())),$=Array.from(Y).sort(),Q=new Map($.map((G,z)=>[G,z])),K=new Map($.map((G,z)=>[`TEXCOORD_${G}`,`TEXCOORD_${z}`]));for(let G of X){let z=G.getTexCoord();G.setTexCoord(Q.get(z))}for(let G of J){let z=G.listSemantics().filter((v)=>v.startsWith("TEXCOORD_")).sort();W(G,z),G.listTargets().forEach((v)=>W(v,z))}function W(G,z){for(let v of z){let H=G.getAttribute(v);if(!H)continue;let V=K.get(v);if(V===v)continue;G.setAttribute(V,H),G.setAttribute(v,null)}}}async function nM1(Z){let J=Z.getRoot(),X=Z.getGraph(),Y=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await oM1(K);if(!G)return;if(pM1(K)==="srgb")VR.convertSRGBToLinear(G,G);let z=K.getName()||K.getURI(),v=(W=K.getSize())==null?void 0:W.join("x"),H=gM1(K);for(let V of X.listParentEdges(K)){let q=V.getParent();if(q!==J&&sM1(q,G,V.getName(),Y))V.dispose()}if(K.listParents().length===1)K.dispose(),Y.debug(`${D3}: Removed solid-color texture "${z}" (${v}px ${H.join(", ")})`)});await Promise.all(Q)}function sM1(Z,J,X,Y){if(Z instanceof K7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(lM1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(BM1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=kN;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return ms(As(bs(),J,[0.5,0.5,1,1]))<=kN}return Y.warn(`${D3}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function oM1(Z){let J=await rM1(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 W=0;W<Q;W++){for(let G=0;G<K;G++)for(let z=0;z<4;z++)X[z]=Math.min(X[z],J.get(W,G,z)),Y[z]=Math.max(Y[z],J.get(W,G,z));if(ms(As($,Y,X))/255>kN)return null}return mM1($,SM1($,Y,X),0.00196078431372549)}async function rM1(Z){try{return await _n(Z.getImage(),Z.getMimeType())}catch(J){return null}}var RN="flatten",ws={cleanup:!0};function is(Z=ws){let J=RZ(ws,Z);return uY(RN,async(X)=>{let Y=X.getRoot(),$=X.getLogger(),Q=new Set;for(let z of Y.listSkins())for(let v of z.listJoints())Q.add(v);let K=new Set;for(let z of Y.listAnimations())for(let v of z.listChannels()){let H=v.getTargetNode();if(H&&v.getTargetPath()!=="weights")K.add(H)}let W=new Set,G=new Set;for(let z of Y.listScenes())z.traverse((v)=>{let H=v.getParentNode();if(!H)return;if(Q.has(H)||W.has(H))W.add(v);if(K.has(H)||G.has(H))G.add(v)});for(let z of Y.listScenes())z.traverse((v)=>{if(K.has(v))return;if(W.has(v))return;if(G.has(v))return;QM1(v)});if(K.size)$.debug(`${RN}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(us({propertyTypes:[i.NODE],keepLeaves:!1}));$.debug(`${RN}: Complete.`)})}function gs(Z){return NG(Z)}var tM1={skipValidation:!1},cs=4294967295,{LINE_STRIP:eM1,LINE_LOOP:ZR1,TRIANGLE_STRIP:JR1,TRIANGLE_FAN:XR1}=g1.Mode;function YR1(Z,J={}){let X=RZ(tM1,J),Y=Z[0],$=c6.fromGraph(Y.getGraph());if(!X.skipValidation&&new Set(Z.map(Ps)).size>1)throw Error("Requires >=2 Primitives, sharing the same Material and Mode, with compatible vertex attributes and indices.");for(let q of Z)switch(q.getMode()){case eM1:case ZR1:kM1(q);break;case JR1:case XR1:Is(q);break}let Q=[],K=new Uint32Array(Z.length),W=0,G=0;for(let q=0;q<Z.length;q++){let F=Z[q],w=F.getIndices(),c=F.getAttribute("POSITION").getCount(),U=w?w.getArray():null,j=w?w.getCount():c,B=new Uint32Array(c).fill(cs);for(let L=0;L<j;L++){let R=U?U[L]:L;if(B[R]===cs)B[R]=W++,K[q]++}Q.push(B),G+=j}let z=$.createPrimitive().setMode(Y.getMode()).setMaterial(Y.getMaterial());for(let q of Y.listSemantics()){let F=Y.getAttribute(q),w=bJ[F.getComponentType()],c=MZ($,F).setArray(new w(W*F.getElementSize()));z.setAttribute(q,c)}let v=Y.getIndices(),H=v?MZ($,v).setArray(_N(G,W)):null;z.setIndices(H);let V=0;for(let q=0;q<Q.length;q++){let F=Z[q],w=F.getIndices(),c=w?w.getCount():-1,U=Q[q];if(w&&H)QR1(w,U,H,V),V+=c;for(let j of z.listSemantics()){let B=F.getAttribute(j),L=z.getAttribute(j);$R1(B,w,U,L)}}return z}function $R1(Z,J,X,Y){let $=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),W=Z.getArray(),G=Y.getArray(),z=new Uint8Array(Z.getCount());for(let v=0,H=J?J.getCount():K;v<H;v++){let V=Q?Q[v]:v,q=X[V];if(z[q])continue;for(let F=0;F<$;F++)G[q*$+F]=W[V*$+F];z[q]=1}}function QR1(Z,J,X,Y){let $=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let W=0;W<$;W++){let G=Q[W],z=J[G];K[Y+W]=z}}var EN="join",{ROOT:KR1,NODE:WR1,MESH:GR1,PRIMITIVE:zR1,ACCESSOR:vR1}=i,NN=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Us={keepMeshes:!1,keepNamed:!1,cleanup:!0,filter:()=>!0};function ds(Z=Us){let J=RZ(Us,Z);return uY(EN,async(X)=>{let Y=X.getRoot(),$=X.getLogger();for(let Q of Y.listScenes())xs(X,Q,J),Q.traverse((K)=>xs(X,K,J));if(J.cleanup)await X.transform(us({propertyTypes:[WR1,GR1,zR1,vR1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));$.debug(`${EN}: Complete.`)})}function xs(Z,J,X){let Y=Z.getLogger(),$={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let z=Q[G];if(!X.filter(z))continue;if(z.listParents().some((V)=>V instanceof QZ))continue;let H=z.getMesh();if(!H)continue;if(z.getExtension("EXT_mesh_gpu_instancing"))continue;if(z.getSkin())continue;for(let V of H.listPrimitives()){if(V.listTargets().length>0)continue;let q=V.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;dG(V),HR1(V);let F=Ps(V),w=H.getName()||z.getName();if(X.keepMeshes||X.keepNamed&&w)F+=`|${G}`;if(!(F in $))$[F]={prims:[],primMeshes:[],primNodes:[],dstNode:z,dstMesh:void 0};let c=$[F];c.prims.push(V),c.primNodes.push(z)}}let K=Object.values($).filter(({prims:G})=>G.length>1),W=new Set(K.flatMap((G)=>G.primNodes));for(let G of W){let z=G.getMesh();if(z.listParents().some((H)=>{return H.propertyType!==KR1&&G!==H}))G.setMesh(z.clone())}for(let G of K){let{dstNode:z,primNodes:v}=G;G.dstMesh=z.getMesh(),G.primMeshes=v.map((H)=>H.getMesh())}for(let G of K){let{prims:z,primNodes:v,primMeshes:H,dstNode:V,dstMesh:q}=G,F=V.getMatrix();for(let U=0;U<z.length;U++){let j=v[U],B=H[U],L=z[U];if(B.removePrimitive(L),ON(L))L=z[U]=VR1(z[U]);if(j!==V)Ts(NN,KM1(NN,F),j.getMatrix()),ks(L,NN)}let w=YR1(z),c=w.listAttributes()[0].getCount();q.addPrimitive(w),Y.debug(`${EN}: Joined Primitives (${z.length}) containing ${PN(c)} vertices under Node "${V.getName()}".`)}}function VR1(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 HR1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)fN(X)}}var{TRANSLATION:tP6,ROTATION:eP6,SCALE:ZO6,WEIGHTS:JO6}=QZ.TargetPath;var qR1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var XO6=M3({level:"high"},qR1);var FR1="unweld";function wR1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let Y=Z.getGraph(),$=c6.fromGraph(Y),Q=$.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,js($,G,X,J)),G.listParents().length===1)G.dispose();for(let G of Z.listTargets())for(let z of G.listAttributes())if(G.swap(z,js($,z,X,J)),z.listParents().length===1)z.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${FR1}: ${mw(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function js(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()),W=X.getArray(),G=J.getElementSize();for(let v=0,H=X.getCount();v<H;v++)for(let V=0;V<G;V++)K[v*G+V]=$[W[v]*G+V];if(!Y.has(J))Y.set(J,new Map);let z=MZ(Z,J).setArray(K);return Y.get(J).set(X,z),z}var Bs;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Bs||(Bs={}));var cR1=0.000001;function UR1(Z,J,X,Y=0.0001){let $=J.length/Z.length,Q=Array($).fill(0),K=Array($).fill(0),W=Array($).fill(0),G=Array($).fill(0),z=Z.length-1,v=1;for(let H=1;H<z;++H){let V=Z[v-1],q=Z[H],F=Z[H+1],w=(q-V)/(F-V),c=!1;if(q!==F&&(H!==1||q!==Z[0])){if(gG(J,v-1,G),gG(J,H,K),gG(J,H+1,W),X==="slerp"){let U=BR1(Q,G,W,w),j=Ds(G,K)+Ds(K,W);c=!hw(K,U,Y)||j+Number.EPSILON>=Math.PI}else if(X==="lerp"){let U=jR1(Q,G,W,w);c=!hw(K,U,Y)}else if(X==="step")c=!hw(K,G)||!hw(K,W)}if(c){if(H!==v)Z[v]=Z[H],Ls(J,v,gG(J,H,Q));v++}}if(z>0)Z[v]=Z[z],Ls(J,v,gG(J,z,Q)),v++;return v}function gG(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)X[Y]=Z[J*$+Y];return X}function Ls(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)Z[J*$+Y]=X[Y]}function hw(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 xR1(Z,J,X){return Z*(1-X)+J*X}function jR1(Z,J,X,Y){for(let $=0;$<J.length;$++)Z[$]=xR1(J[$],X[$],Y);return Z}function BR1(Z,J,X,Y){let $=J[0],Q=J[1],K=J[2],W=J[3],G=X[0],z=X[1],v=X[2],H=X[3],V,q,F,w,c;if(q=$*G+Q*z+K*v+W*H,q<0)q=-q,G=-G,z=-z,v=-v,H=-H;if(1-q>cR1)V=Math.acos(q),F=Math.sin(V),w=Math.sin((1-Y)*V)/F,c=Math.sin(Y*V)/F;else w=1-Y,c=Y;return Z[0]=w*$+c*G,Z[1]=w*Q+c*z,Z[2]=w*K+c*v,Z[3]=w*W+c*H,Z}function Ds(Z,J){let X=LR1(Z,J);return Math.acos(2*X*X-1)}function LR1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var YO6=new Float32Array(0),$O6={ready:Promise.resolve(),resample:UR1,tolerance:0.0001,cleanup:!0};var AY="simplify",{POINTS:as,LINES:DR1,LINE_STRIP:MR1,LINE_LOOP:RR1,TRIANGLES:NR1,TRIANGLE_STRIP:ns,TRIANGLE_FAN:ss}=g1.Mode,os={ratio:0,error:0.0001,lockBorder:!1};function rs(Z){let J=RZ(os,Z),X=J.simplifier;if(!X)throw Error(`${AY}: simplifier dependency required — install "meshoptimizer".`);return uY(AY,async(Y)=>{let $=Y.getLogger();await X.ready,await Y.transform(hN({overwrite:!1}));let Q=0;for(let K of Y.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G!==NR1&&G!==ns&&G!==ss&&G!==as){Q++;continue}if(PR1(W,J),mY(W,j6.RENDER)===0)Rs(W)}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)$.warn(`${AY}: Skipped ${Q} primitives: Unsupported draw mode.`);$.debug(`${AY}: Complete.`)})}function PR1(Z,J){let X=M3({},os,J),Y=X.simplifier,$=Z.getGraph(),Q=c6.fromGraph($),K=Q.getLogger();switch(Z.getMode()){case as:return OR1(Q,Z,X);case DR1:case MR1:case RR1:return K.warn(`${AY}: Skipping primitive simplification: Unsupported draw mode.`),Z;case ns:case ss:Is(Z);break}let W=mY(Z,j6.UPLOAD),G=mY(Z,j6.RENDER);if(G<W/2)dG(Z);let z=Z.getAttribute("POSITION"),v=Z.getIndices(),H=z.getArray(),V=v.getArray();if(!(H instanceof Float32Array))H=Aw(H,z.getComponentType(),z.getNormalized());if(!(V instanceof Uint32Array))V=new Uint32Array(V);let q=Math.floor(X.ratio*G/3)*3,F=X.lockBorder?["LockBorder"]:[],[w,c]=Y.simplify(V,H,3,q,X.error,F);if(Z.setIndices(MZ(Q,v).setArray(w)),v.listParents().length===1)v.dispose();dG(Z);let U=mY(Z,j6.UPLOAD);if(U<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${AY}: ${mw(W,U)} vertices, error: ${c.toFixed(4)}.`),Z}function OR1(Z,J,X){let Y=X.simplifier,$=Z.getLogger();if(J.getIndices())wR1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),z=K.getArray(),v=W?W.getArray():void 0,H=W?W.getComponentSize():void 0;if(!(z instanceof Float32Array))z=Aw(z,K.getComponentType(),K.getNormalized());if(v&&!(v instanceof Float32Array))v=Aw(v,K.getComponentType(),K.getNormalized());let V=Math.floor(X.ratio*G),q=Y.simplifyPoints(z,3,V,v,H),[F,w]=Y.compactMesh(q);$.debug(`${AY}: ${mw(K.getCount(),w)} vertices.`);for(let c of uw(J)){let U=MZ(Z,c);if(TN(c,null,F,U,w),ZM1(J,c,U),c.listParents().length===1)c.dispose()}return J}var IN;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(IN||(IN={}));var QO6={resizeFilter:IN.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var $o=t(Yo(),1);var NZ={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DATA_SCHEMA_VERSION:1,DATA_EXT:".data.json",DIRECTORIES:[(()=>{try{return q5.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))}catch{return null}})(),q5.resolve(process.cwd(),"assets")].filter(Boolean),OPTIMIZER_RUNS:[{suffix:"",options:["--compress","false","--instance","false","--simplify","false"]},{suffix:"-named-nodes",options:["--compress","false","--instance","false","--simplify","false","--join","true","--join-named","false"]}]};class B6{static instance=new B6;optimize=!0;optimizeEveryStart=!1;_modelUriAnimationNames=new Map;_modelUriBoundingBoxes=new Map;_modelUriNodeNames=new Map;_modelUriTrimeshes=new Map;constructor(){}async preloadModels(){let Z=await this._getAbsoluteModelPaths();console.log(`ModelRegistry.preloadModels(): Preloading ${Z.length} models...`);let J=performance.now();for(let Y of Z){if(this.optimize)await this._resolveOptimizedModelPath(Y);await this._loadModelData(Y)}let X=performance.now();console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models in ${X-J}ms!`)}getAnimationNames(Z){let J=this._modelUriAnimationNames.get(Z);if(!J)p.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)p.fatalError(`ModelRegistry.getBoundingBox(): Model ${Z} not found!`);return J}getDepth(Z){let J=this.getBoundingBox(Z);return J.max.z-J.min.z}getHeight(Z){let J=this.getBoundingBox(Z);return J.max.y-J.min.y}getNodeNames(Z){let J=this._modelUriNodeNames.get(Z);if(!J)p.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){p.error(`ModelRegistry.getTrimesh(): Model ${Z} not found!`);return}let 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)p.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=q5.normalize(Z);for(let X of NZ.DIRECTORIES){let Y=q5.normalize(X);if(J.startsWith(Y))return q5.relative(Y,J).replace(/\\/g,"/")}return q5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of NZ.DIRECTORIES){let X=q5.resolve(process.cwd(),J);if(!D4.existsSync(X))continue;let Y=await uF("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let $ of Y)Z.push(q5.join(X,$))}return Z}async _loadModelData(Z){let X=`${this._buildOptimizedModelPath(Z)}${NZ.DATA_EXT}`,Y=this._absoluteModelPathToModelUri(Z),$=this._calculateChecksum(Z),Q;if(D4.existsSync(X))try{let K=D4.readFileSync(X,"utf8"),W=JSON.parse(K);if(W?.schemaVersion!==NZ.DATA_SCHEMA_VERSION)throw Error("ModelRegistry._loadModelData(): Schema version mismatch! Data will be regenerated..");if(W?.source?.sha256!==$)throw Error("ModelRegistry._loadModelData(): Checksum mismatch! Data will be regenerated..");Q=W}catch{}if(!Q){let K=await new cR().read(Z),W=gs(K.getRoot().listScenes()[0]),G=K.getRoot().listNodes().map((H)=>H.getName()),z=K.getRoot().listAnimations().map((H)=>H.getName()),v=await this._buildTrimesh(K);Q={schemaVersion:NZ.DATA_SCHEMA_VERSION,source:{uri:Y,sha256:$},animationNames:z,boundingBox:{min:{x:W.min[0],y:W.min[1],z:W.min[2]},max:{x:W.max[0],y:W.max[1],z:W.max[2]}},nodeNames:G,trimesh:v?{vertices:Array.from(v.vertices),indices:Array.from(v.indices)}:void 0};try{let H=q5.dirname(X);D4.mkdirSync(H,{recursive:!0}),D4.writeFileSync(X,JSON.stringify(Q))}catch(H){p.warning(`ModelRegistry._loadModelData(): Failed to write data file for ${Y}. Error: ${String(H)}`)}}this._modelUriAnimationNames.set(Y,Q.animationNames),this._modelUriBoundingBoxes.set(Y,Q.boundingBox),this._modelUriNodeNames.set(Y,Q.nodeNames),this._modelUriTrimeshes.set(Y,Q.trimesh?{vertices:new Float32Array(Q.trimesh.vertices),indices:new Uint32Array(Q.trimesh.indices)}:void 0)}async _resolveOptimizedModelPath(Z){let J=this._buildOptimizedModelPath(Z);if(!this.optimizeEveryStart&&this._isOptimizedVersionValid(Z))return J;return await this._optimizeModel(Z,J)}_isOptimizedVersionValid(Z){let J=`${this._buildOptimizedModelPath(Z)}${NZ.CHECKSUM_EXT}`;if(!D4.existsSync(J))return!1;let X=this._calculateChecksum(Z),Y=D4.readFileSync(J,"utf8");return X===Y}_calculateChecksum(Z){if(!D4.existsSync(Z))return"";let J=D4.readFileSync(Z);return ER1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=q5.basename(Z),X=J.replace(/\.[^/.]+$/,""),Y=q5.dirname(Z),$=q5.join(Y,NZ.OPTIMIZED_DIR,X);return q5.join($,J)}async _buildTrimesh(Z,J=1,X=0.001){let Y=Ss(Z);Y.setLogger(new z5(MG.WARN)),await Y.transform(Os({pivot:"center"}),is(),ds(),hN(),rs({simplifier:$o.MeshoptSimplifier,ratio:J,error:X}),_s());for(let V of Y.getRoot().listScenes())for(let q of V.listChildren())Es(q);let $=[],Q=0,K=0;for(let V of Y.getRoot().listMeshes())for(let q of V.listPrimitives()){let F=q.getAttribute("POSITION"),w=q.getIndices();if(!F||!w)continue;let c=F.getArray(),U=w.getArray(),j=U instanceof Uint32Array?U:new Uint32Array(U);if(c.length===0||j.length===0)continue;$.push({vertices:c,indices:j}),Q+=c.length,K+=j.length}if($.length===0){p.error("ModelRegistry._buildTrimesh(): Model has no primitives with POSITION and INDICES!");return}let W=new Float32Array(Q),G=new Uint32Array(K),z=0,v=0,H=0;for(let V of $){W.set(V.vertices,z);let q=V.vertices.length/3;for(let F=0;F<V.indices.length;F++)G[H+F]=V.indices[F]+v;z+=V.vertices.length,H+=V.indices.length,v+=q}return{vertices:W,indices:G}}async _optimizeModel(Z,J){let X=q5.dirname(J);D4.rmSync(X,{recursive:!0,force:!0}),D4.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let Y of NZ.OPTIMIZER_RUNS){let $=J.replace(/(\.[^/.]+)$/,`${Y.suffix}$1`),{stderr:Q}=await ji("npx",["@gltf-transform/cli","optimize",Z,$,...Y.options]);if(Q)return p.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return D4.writeFileSync(`${J}${NZ.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var rG;(($)=>{$.DYNAMIC="dynamic";$.FIXED="fixed";$.KINEMATIC_POSITION="kinematic_position";$.KINEMATIC_VELOCITY="kinematic_velocity"})(rG||={});var lN=0.001,Qo="dynamic";class dJ extends j0{_additionalMass=0;_colliders=new Set;_explicitSleep=!1;_enabledPositions={x:!0,y:!0,z:!0};_enabledRotations={x:!0,y:!0,z:!0};_rigidBody;_rigidBodyDesc;_rigidBodyType;_simulation;constructor(Z){super();Z.type??=Qo,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 enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(Z){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(Z,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(Z)}setAdditionalMassProperties(Z){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:J,centerOfMass:X,principalAngularInertia: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"]:X1.RigidBodyType.Dynamic,["fixed"]:X1.RigidBodyType.Fixed,["kinematic_position"]:X1.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:X1.RigidBodyType.KinematicVelocityBased}[Z];if(X===void 0)return p.error(`Invalid RigidBodyType: ${Z}`);this._rigidBody?this._rigidBody.setBodyType(X,!this._explicitSleep):this._rigidBodyDesc.status=X,this._rigidBodyType=Z}addForce(Z){if(!this._requireNotRemoved("addForce"))return;if(!this._requireCreated("addForce"))return;if(!this._requireDynamic("addForce"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addForce(Z,!this._explicitSleep)}addTorque(Z){if(!this._requireNotRemoved("addTorque"))return;if(!this._requireCreated("addTorque"))return;if(!this._requireDynamic("addTorque"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addTorque(Z,!this._explicitSleep)}addChildColliderToSimulation(Z){if(!this._requireNotRemoved("addChildColliderToSimulation"))return;if(!this._requireCreated("addChildColliderToSimulation"))return;Z.addToSimulation(this._simulation,this)}addToSimulation(Z){if(!this._requireNotRemoved("addToSimulation"))return;if(this._rigidBody)return p.error("RigidBody.addToSimulation(): Rigid body already exists in the simulation!");this._simulation=Z,this._rigidBody=this._simulation.createRawRigidBody(this._rigidBodyDesc),this._colliders.forEach((J)=>{if(!J.isSimulated)J.addToSimulation(Z,this)})}applyImpulse(Z){if(!this._requireNotRemoved("applyImpulse"))return;if(!this._requireCreated("applyImpulse"))return;if(!this._requireDynamic("applyImpulse"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulse(Z,!this._explicitSleep)}applyImpulseAtPoint(Z,J){if(!this._requireNotRemoved("applyImpulseAtPoint"))return;if(!this._requireCreated("applyImpulseAtPoint"))return;if(!this._requireDynamic("applyImpulseAtPoint"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulseAtPoint(Z,J,!this._explicitSleep)}applyTorqueImpulse(Z){if(!this._requireNotRemoved("applyTorqueImpulse"))return;if(!this._requireCreated("applyTorqueImpulse"))return;if(!this._requireDynamic("applyTorqueImpulse"))return;this._rigidBody.applyTorqueImpulse(Z,!this._explicitSleep)}createAndAddChildCollider(Z){if(!this._requireNotRemoved("createAndAddChildCollider"))return null;return this._simulation?new A5({...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 p.error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(Z)}lockAllRotations(){if(!this._requireNotRemoved("lockAllRotations"))return;this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){if(!this._requireNotRemoved("lockAllPositions"))return;this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._rigidBody)return p.error("RigidBody.removeFromSimulation(): Rigid body does not exist in the simulation!");this._colliders.forEach((Z)=>{Z.removeFromSimulation()}),this._simulation.removeRawRigidBody(this._rigidBody),this._simulation=void 0,this._rigidBody=void 0}unlinkCollider(Z){if(!this._requireNotRemoved("unlinkCollider"))return;if(!Z.isRemoved)return p.error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(Z)}resetAngularVelocity(){if(!this._requireNotRemoved("resetAngularVelocity"))return;if(!this._requireCreated("resetAngularVelocity"))return;this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){if(!this._requireNotRemoved("resetForces"))return;if(!this._requireCreated("resetForces"))return;this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){if(!this._requireNotRemoved("resetLinearVelocity"))return;if(!this._requireCreated("resetLinearVelocity"))return;this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){if(!this._requireNotRemoved("resetTorques"))return;if(!this._requireCreated("resetTorques"))return;this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){if(!this._requireNotRemoved("sleep"))return;this.setSleeping(!0)}wakeUp(){if(!this._requireNotRemoved("wakeUp"))return;this.setSleeping(!1)}_applyRigidBodyOptions(Z){[["additionalMass",this.setAdditionalMass.bind(this)],["additionalMassProperties",this.setAdditionalMassProperties.bind(this)],["additionalSolverIterations",this.setAdditionalSolverIterations.bind(this)],["angularDamping",this.setAngularDamping.bind(this)],["angularVelocity",this.setAngularVelocity.bind(this)],["dominanceGroup",this.setDominanceGroup.bind(this)],["ccdEnabled",this.setCcdEnabled.bind(this)],["enabled",this.setEnabled.bind(this)],["enabledPositions",this.setEnabledPositions.bind(this)],["enabledRotations",this.setEnabledRotations.bind(this)],["gravityScale",this.setGravityScale.bind(this)],["linearDamping",this.setLinearDamping.bind(this)],["linearVelocity",this.setLinearVelocity.bind(this)],["position",this.setPosition.bind(this)],["rotation",this.setRotation.bind(this)],["sleeping",this.setSleeping.bind(this)],["softCcdPrediction",this.setSoftCcdPrediction.bind(this)]].forEach(([X,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 A5(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??Qo;return{["dynamic"]:()=>X1.RigidBodyDesc.dynamic(),["fixed"]:()=>X1.RigidBodyDesc.fixed(),["kinematic_position"]:()=>X1.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>X1.RigidBodyDesc.kinematicVelocityBased()}[J]()}_requireCreated(Z){if(!this._rigidBody||!this._simulation)p.error(`RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody&&!!this._simulation}_requireDynamic(Z){if(!this.isDynamic)p.error(`RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method: ${Z}()`);return this.isDynamic}_requireKinematic(Z){if(!this.isKinematic)p.error(`RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method: ${Z}()`);return this.isKinematic}_requireNotKinematicPositionBased(Z){if(this.isKinematicPositionBased)p.error(`RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method: ${Z}()`);return!this.isKinematicPositionBased}_requireNotRemoved(Z){if(!this._rigidBody&&!this._rigidBodyDesc)p.error(`RigidBody._requireNotRemoved(): Rigid body has been removed and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody||!!this._rigidBodyDesc}_requireNotSimulated(Z){if(this.isSimulated)p.error(`RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method: ${Z}()`);return!this.isSimulated}_isNegligibleVector(Z){return Math.abs(Z.x)<lN&&Math.abs(Z.y)<lN&&Math.abs(Z.z)<lN}}var yN;(($)=>{$[$.Average=0]="Average";$[$.Min=1]="Min";$[$.Multiply=2]="Multiply";$[$.Max=3]="Max"})(yN||={});var N3;((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"})(N3||={});class A5 extends j0{_collider;_colliderDesc;_onCollision;_parentRigidBody;_relativePosition={x:0,y:0,z:0};_relativeRotation={x:0,y:0,z:0,w:1};_shape;_simulation;_tag;constructor(Z){super();this._colliderDesc=this._createColliderDesc(Z),this._shape=Z.shape,this._applyColliderOptions(Z),this._autoAddToSimulation(Z)}static optionsFromBlockHalfExtents(Z){return{shape:"block",halfExtents:Z}}static optionsFromModelUri(Z,J=1,X){let Y=B6.instance.getBoundingBox(Z),$=Y.max.x-Y.min.x,Q=Y.max.y-Y.min.y,K=Y.max.z-Y.min.z,W=Math.max($,K),G=Math.min($,K),z=W/G,v=W/Q,H=W*J/2,V=(j)=>Math.max(0.01,j),q=()=>({shape:"block",halfExtents:{x:V($*J/2),y:V(Q*J/2),z:V(K*J/2)}}),F=()=>({shape:"round-cylinder",radius:V(H),halfHeight:V(Q*J/2),borderRadius:V(H*0.1)}),w=()=>{let j=B6.instance.getTrimesh(Z,J);if(!j)return;return{shape:"trimesh",vertices:j.vertices,indices:j.indices}},c=()=>({shape:"wedge",extents:{x:$*J,y:Q*J,z:K*J}}),U=()=>({shape:"capsule",radius:V(H),halfHeight:V(Q*J/2-H)});if(X)switch(X){case"block":return q();case"capsule":return U();case"round-cylinder":return F();case"trimesh":{let j=w();if(!j){p.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return j}case"wedge":return c();default:p.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(z>2)return q();if(v>1.5)return F();return U()}get bounciness(){if(!this._requireNotRemoved("bounciness"))return 0;return this._collider?this._collider.restitution():this._colliderDesc.restitution}get bouncinessCombineRule(){if(!this._requireNotRemoved("bouncinessCombineRule"))return 0;return this._collider?this._collider.restitutionCombineRule():this._colliderDesc.restitutionCombineRule}get collisionGroups(){if(!this._requireNotRemoved("collisionGroups"))return{belongsTo:[],collidesWith:[]};return this._collider?v9.decodeRawCollisionGroups(this._collider.collisionGroups()):v9.decodeRawCollisionGroups(this._colliderDesc.collisionGroups)}get friction(){if(!this._requireNotRemoved("friction"))return 0;return this._collider?this._collider.friction():this._colliderDesc.friction}get frictionCombineRule(){if(!this._requireNotRemoved("frictionCombineRule"))return 0;return this._collider?this._collider.frictionCombineRule():this._colliderDesc.frictionCombineRule}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._collider?this._collider.isEnabled():this._colliderDesc.enabled}get isRemoved(){return!this._collider&&!this._colliderDesc}get isSensor(){if(!this._requireNotRemoved("isSensor"))return!1;return this._collider?this._collider.isSensor():this._colliderDesc.isSensor}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return!!this._collider}get parentRigidBody(){if(!this._requireNotRemoved("parentRigidBody"))return;return this._parentRigidBody}get rawCollider(){if(!this._requireNotRemoved("rawCollider"))return;return this._collider}get rawShape(){if(!this._requireNotRemoved("rawShape"))return;return this._collider?this._collider.shape:this._colliderDesc.shape}get relativePosition(){if(!this._requireNotRemoved("relativePosition"))return{x:0,y:0,z:0};return this._relativePosition}get relativeRotation(){if(!this._requireNotRemoved("relativeRotation"))return{x:0,y:0,z:0,w:1};return this._relativeRotation}get shape(){if(!this._requireNotRemoved("shape"))return"none";return this._shape}get tag(){if(!this._requireNotRemoved("tag"))return;return this._tag}setBounciness(Z){if(!this._requireNotRemoved("setBounciness"))return;this._collider?this._collider.setRestitution(Z):this._colliderDesc.setRestitution(Z)}setBouncinessCombineRule(Z){if(!this._requireNotRemoved("setBouncinessCombineRule"))return;this._collider?this._collider.setRestitutionCombineRule(Z):this._colliderDesc.setRestitutionCombineRule(Z)}setCollisionGroups(Z){if(!this._requireNotRemoved("setCollisionGroups"))return;let J=v9.buildRawCollisionGroups(Z);this._collider?this._collider.setCollisionGroups(J):this._colliderDesc.setCollisionGroups(J)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._collider?this._collider.setEnabled(Z):this._colliderDesc.setEnabled(Z)}setFriction(Z){if(!this._requireNotRemoved("setFriction"))return;this._collider?this._collider.setFriction(Z):this._colliderDesc.setFriction(Z)}setFrictionCombineRule(Z){if(!this._requireNotRemoved("setFrictionCombineRule"))return;this._collider?this._collider.setFrictionCombineRule(Z):this._colliderDesc.setFrictionCombineRule(Z)}setMass(Z){if(!this._requireNotRemoved("setMass"))return;this._collider?this._collider.setMass(Z):this._colliderDesc.setMass(Z)}setOnCollision(Z){if(!this._requireNotRemoved("setOnCollision"))return;if(this._onCollision=Z,this.isSimulated)if(this.enableCollisionEvents(!!Z),Z)this._simulation.colliderMap.setColliderCollisionCallback(this,Z);else this._simulation.colliderMap.removeColliderCollisionCallback(this)}setRelativeRotation(Z){if(!this._requireNotRemoved("setRelativeRotation"))return;this._relativeRotation=Z,this._collider?this._collider.parent()?this._collider.setRotationWrtParent(Z):this._collider.setRotation(Z):this._colliderDesc.setRotation(Z)}setRelativePosition(Z){if(!this._requireNotRemoved("setRelativePosition"))return;this._relativePosition=Z,this._collider?this._collider.parent()?this._collider.setTranslationWrtParent(Z):this._collider.setTranslation(Z):this._colliderDesc.setTranslation(Z.x,Z.y,Z.z)}setSensor(Z){if(!this._requireNotRemoved("setSensor"))return;this._collider?this._collider.setSensor(Z):this._colliderDesc.setSensor(Z)}setTag(Z){if(!this._requireNotRemoved("setTag"))return;this._tag=Z}setVoxel(Z,J){if(!this._requireNotRemoved("setVoxel"))return;if(!this._requireSimulated("setVoxel"))return;if(this.shape!=="voxels")return p.error("Collider.setVoxel(): Collider is not a voxels collider!");this._collider.setVoxel(Z.x,Z.y,Z.z,J)}addToSimulation(Z,J){if(!this._requireNotRemoved("addToSimulation"))return;if(!this._requireUnsimulated("addToSimulation"))return;if(J){if(!J.isSimulated)return p.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")p.warning("Collider.addToSimulation(): Trimesh colliders are strongly discouraged to be used with dynamic rigid bodies, they will not contribute any mass!")}if(this._simulation=Z,this._parentRigidBody=J,this._collider=this._simulation.createRawCollider(this._colliderDesc,J?.rawRigidBody),this._colliderDesc=void 0,J)J.linkCollider(this);if(this._onCollision)this.setOnCollision(this._onCollision)}combineVoxelStates(Z){if(!this._requireNotRemoved("combineVoxelStates"))return;if(!this._requireSimulated("combineVoxelStates"))return;if(!Z.isSimulated)return p.error("Collider.combineVoxelStates(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Other collider is not a voxels collider!");this._collider.combineVoxelStates(Z.rawCollider,0,0,0)}enableCollisionEvents(Z){if(!this._requireNotRemoved("enableCollisionEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|X1.ActiveEvents.COLLISION_EVENTS:J&~X1.ActiveEvents.COLLISION_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}enableContactForceEvents(Z){if(!this._requireNotRemoved("enableContactForceEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|X1.ActiveEvents.CONTACT_FORCE_EVENTS:J&~X1.ActiveEvents.CONTACT_FORCE_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}propagateVoxelChange(Z,J){if(!this._requireNotRemoved("propagateVoxelChange"))return;if(!this._requireSimulated("propagateVoxelChange"))return;if(!Z.isSimulated)return p.error("Collider.propagateVoxelChange(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Other collider is not a voxels collider!");this._collider.propagateVoxelChange(Z.rawCollider,J.x,J.y,J.z,0,0,0)}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._requireSimulated("removeFromSimulation"))return;if(this._simulation.removeRawCollider(this._collider),this._simulation=void 0,this._collider=void 0,this._parentRigidBody)this._parentRigidBody.unlinkCollider(this);this._parentRigidBody=void 0}scale(Z){if(!this._requireNotRemoved("scale"))return;switch(this.setRelativePosition({x:this.relativePosition.x*Z,y:this.relativePosition.y*Z,z:this.relativePosition.z*Z}),this._shape){case"ball":{if(this._collider)this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.radius*=Z;return}case"block":{if(this._collider){let J=this._collider.halfExtents();this._collider.setHalfExtents({x:J.x*Z,y:J.y*Z,z:J.z*Z})}else this._colliderDesc.shape.halfExtents.x*=Z,this._colliderDesc.shape.halfExtents.y*=Z,this._colliderDesc.shape.halfExtents.z*=Z;return}case"capsule":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cone":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"round-cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRoundRadius(this._collider.roundRadius()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight=this._colliderDesc.shape.halfHeight*Z,this._colliderDesc.shape.borderRadius=this._colliderDesc.shape.borderRadius*Z,this._colliderDesc.shape.radius=this._colliderDesc.shape.radius*Z;return}case"trimesh":{p.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"voxels":{p.error("Collider.setScale(): Voxels colliders cannot be scaled!");return}case"wedge":{p.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:p.fatalError(`Collider.setScale(): ${this._shape} is not a valid collider shape!`)}}_applyColliderOptions(Z){[["bounciness",this.setBounciness.bind(this)],["bouncinessCombineRule",this.setBouncinessCombineRule.bind(this)],["collisionGroups",this.setCollisionGroups.bind(this)],["enabled",this.setEnabled.bind(this)],["friction",this.setFriction.bind(this)],["frictionCombineRule",this.setFrictionCombineRule.bind(this)],["isSensor",this.setSensor.bind(this)],["mass",this.setMass.bind(this)],["onCollision",this.setOnCollision.bind(this)],["relativePosition",this.setRelativePosition.bind(this)],["relativeRotation",this.setRelativeRotation.bind(this)],["tag",this.setTag.bind(this)]].forEach(([X,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)p.fatalError("Ball collider must have a radius!");return X1.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)p.fatalError("Block collider must have halfExtents!");return X1.ColliderDesc.cuboid(Z.halfExtents.x,Z.halfExtents.y,Z.halfExtents.z)}case"capsule":{if(!Z.halfHeight||!Z.radius)p.fatalError("Capsule collider must have halfHeight and radius!");return X1.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cone collider must have radius and halfHeight!");return X1.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cylinder collider must have radius and halfHeight!");return X1.ColliderDesc.cylinder(Z.halfHeight,Z.radius)}case"round-cylinder":{if(!Z.radius||!Z.halfHeight||!Z.borderRadius)p.fatalError("Round cylinder collider must have radius, halfHeight, and borderRadius!");return X1.ColliderDesc.roundCylinder(Z.halfHeight,Z.radius,Z.borderRadius)}case"trimesh":{if(!Z.indices||!Z.vertices)p.fatalError("Trimesh collider must have vertices and indices!");return X1.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)p.fatalError("Voxels collider must have coordinates and size!");return X1.ColliderDesc.voxels(this._coordinatesToInt32Array(Z.coordinates),Z.size)}case"wedge":{if(!Z.extents)p.fatalError("Wedge collider must have extents!");let Y=this._buildWedgeConvexHullVertices(Z.extents),$=X1.ColliderDesc.convexHull(Y);if(!$)throw p.fatalError("Failed to create convex hull for wedge collider!"),Error("Convex hull creation failed");return $}default:p.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)p.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)p.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)p.error(`Collider._requireNotRemoved(): Collider is removed, invoked method: ${Z}()`);return!this.isRemoved}_setActiveCollisionTypes(){(this._collider??this._colliderDesc).setActiveCollisionTypes(X1.ActiveCollisionTypes.DYNAMIC_DYNAMIC|X1.ActiveCollisionTypes.DYNAMIC_KINEMATIC|X1.ActiveCollisionTypes.DYNAMIC_FIXED|X1.ActiveCollisionTypes.KINEMATIC_KINEMATIC|X1.ActiveCollisionTypes.KINEMATIC_FIXED)}_coordinatesToInt32Array(Z){let J=new Int32Array(Z.length*3);for(let X=0;X<Z.length;X++){let 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 IR1={shape:"voxels"},pN;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(pN||={});class m5 extends j0{_id;_customColliderOptions;_halfExtents;_isLiquid;_lightLevel;_name;_textureUri;constructor(Z={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(Z.id<0)p.fatalError("BlockType.constructor(): BlockType id not set.");super();this._id=Z.id,this._customColliderOptions=Z.customColliderOptions,this._halfExtents=Z.halfExtents??{x:0.5,y:0.5,z:0.5},this._isLiquid=Z.isLiquid??!1,this._name=Z.name,this._textureUri=Z.textureUri,this._lightLevel=Math.min(Z.lightLevel??0,15)}get id(){return this._id}get colliderOptions(){return{...this._customColliderOptions,...IR1}}get halfExtents(){return this._halfExtents}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}get lightLevel(){return this._lightLevel}get name(){return this._name}get size(){return{x:this._halfExtents.x*2,y:this._halfExtents.y*2,z:this._halfExtents.z*2}}get textureUri(){return this._textureUri}createCollider(Z){let J=new A5({...this.colliderOptions,coordinates:Z,size:this.size});if(this.isLiquid)J.setSensor(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_COLLISION")||this.isLiquid)J.enableCollisionEvents(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))J.enableContactForceEvents(!0);if(v9.isDefaultCollisionGroups(J.collisionGroups))J.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return J}serialize(){return T0.serializeBlockType(this)}}var iN;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(iN||={});class tG extends j0{_blockTypes=new Map;_world;constructor(Z){super();this._world=Z}get world(){return this._world}getAllBlockTypes(){return Array.from(this._blockTypes.values())}getBlockType(Z){let J=this._blockTypes.get(Z);if(!J)p.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends m5{constructor(Y=Z){super(Y)}};return this.registerBlockType(X),X}registerBlockType(Z){this._blockTypes.set(Z.id,Z),this.emitWithWorld(this._world,"BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE",{blockTypeRegistry:this,id:Z.id,blockType:Z})}serialize(){return T0.serializeBlockTypeRegistry(this)}}var DO={};_Q(DO,{worldSchema:()=>LO,worldPacketDefinition:()=>e00,vectorSchema:()=>W1,vectorBooleanSchema:()=>DE1,uiSchema:()=>jO,uiPacketDefinition:()=>r00,uiDatasSchema:()=>BO,uiDatasPacketDefinition:()=>t00,uiDataSendPacketDefinition:()=>h00,uiDataSchema:()=>Dz,syncResponseSchema:()=>xO,syncResponsePacketDefinition:()=>o00,syncRequestSchema:()=>gP,syncRequestPacketDefinition:()=>_00,stateRequestSchema:()=>iP,stateRequestPacketDefinition:()=>I00,sceneUIsSchema:()=>UO,sceneUIsPacketDefinition:()=>s00,sceneUISchema:()=>cO,rgbColorSchema:()=>D6,registeredPackets:()=>Ec,quaternionSchema:()=>YO,playersSchema:()=>wO,playersPacketDefinition:()=>n00,playerSchema:()=>FO,physicsDebugRenderSchema:()=>qO,physicsDebugRenderPacketDefinition:()=>d00,physicsDebugRaycastsSchema:()=>HO,physicsDebugRaycastsPacketDefinition:()=>a00,physicsDebugRaycastSchema:()=>VO,particleEmittersSchema:()=>vO,particleEmittersPacketDefinition:()=>g00,particleEmitterSchema:()=>zO,outboundPackets:()=>kc,notificationPermissionRequestSchema:()=>GO,notificationPermissionRequestPacketDefinition:()=>i00,modelNodeOverrideSchema:()=>XO,lightsSchema:()=>WO,lightsPacketDefinition:()=>p00,lightSchema:()=>KO,isValidPacket:()=>RE1,inputSchema:()=>pP,inputPacketDefinition:()=>E00,inboundPackets:()=>fc,hexColorSchema:()=>lP,heartbeatSchema:()=>uP,heartbeatPacketDefinition:()=>C00,entitySchema:()=>$O,entitiesSchema:()=>QO,entitiesPacketDefinition:()=>y00,definePacket:()=>C0,debugConfigSchema:()=>yP,debugConfigPacketDefinition:()=>k00,createPacket:()=>LE1,connectionSchema:()=>mP,connectionPacketDefinition:()=>T00,chunksSchema:()=>JO,chunksPacketDefinition:()=>l00,chunkSchema:()=>ZO,chatMessagesSchema:()=>eP,chatMessagesPacketDefinition:()=>u00,chatMessageSendPacketDefinition:()=>f00,chatMessageSchema:()=>Lz,cameraSchema:()=>tP,cameraPacketDefinition:()=>m00,blocksSchema:()=>sP,blocksPacketDefinition:()=>b00,blockTypesSchema:()=>rP,blockTypesPacketDefinition:()=>A00,blockTypeSchema:()=>oP,blockSchema:()=>nP,bidirectionalPackets:()=>Cc,audiosSchema:()=>aP,audiosPacketDefinition:()=>S00,audioSchema:()=>dP,PacketId:()=>M1});var Cc={};_Q(Cc,{heartbeatPacketDefinition:()=>C00,connectionPacketDefinition:()=>T00});var bP=t(O00(),1);class AP extends bP.default{static instance=new bP.default}var M1;((k)=>{k[k.SYNC_REQUEST=0]="SYNC_REQUEST";k[k.INPUT=1]="INPUT";k[k.STATE_REQUEST=2]="STATE_REQUEST";k[k.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";k[k.UI_DATA_SEND=4]="UI_DATA_SEND";k[k.SYNC_RESPONSE=32]="SYNC_RESPONSE";k[k.AUDIOS=33]="AUDIOS";k[k.BLOCKS=34]="BLOCKS";k[k.BLOCK_TYPES=35]="BLOCK_TYPES";k[k.CHAT_MESSAGES=36]="CHAT_MESSAGES";k[k.CHUNKS=37]="CHUNKS";k[k.ENTITIES=38]="ENTITIES";k[k.WORLD=39]="WORLD";k[k.CAMERA=40]="CAMERA";k[k.UI=41]="UI";k[k.UI_DATAS=42]="UI_DATAS";k[k.SCENE_UIS=43]="SCENE_UIS";k[k.LIGHTS=44]="LIGHTS";k[k.PLAYERS=45]="PLAYERS";k[k.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";k[k.NOTIFICATION_PERMISSION_REQUEST=47]="NOTIFICATION_PERMISSION_REQUEST";k[k.CONNECTION=116]="CONNECTION";k[k.HEARTBEAT=117]="HEARTBEAT";k[k.DEBUG_CONFIG=128]="DEBUG_CONFIG";k[k.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";k[k.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(M1||={});function LE1(Z,J,X){if(!Z.validate(J))throw Error(`Invalid payload for packet with id ${Z.id}. Error: ${AP.instance.errorsText(Z.validate.errors)}`);let Y=[Z.id,J];if(typeof X==="number")Y.push(X);return Y}function C0(Z,J){return{id:Z,schema:J,validate:AP.instance.compile(J)}}var mP={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},ts:{type:"string",nullable:!0}},additionalProperties:!1};var T00=C0(116,mP);var uP={type:"null",nullable:!0};var C00=C0(117,uP);var fc={};_Q(fc,{uiDataSendPacketDefinition:()=>h00,syncRequestPacketDefinition:()=>_00,stateRequestPacketDefinition:()=>I00,inputPacketDefinition:()=>E00,debugConfigPacketDefinition:()=>k00,chatMessageSendPacketDefinition:()=>f00});var lP={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var Lz={type:"object",properties:{m:{type:"string"},c:{...lP,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var f00=C0(3,Lz);var yP={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var k00=C0(128,yP);var pP={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 E00=C0(1,pP);var iP={type:"object",properties:{},additionalProperties:!1};var I00=C0(2,iP);var gP={type:"null",nullable:!0};var _00=C0(0,gP);var Dz={type:"object",properties:{},additionalProperties:!0};var h00=C0(4,Dz);var kc={};_Q(kc,{worldPacketDefinition:()=>e00,uiPacketDefinition:()=>r00,uiDatasPacketDefinition:()=>t00,syncResponsePacketDefinition:()=>o00,sceneUIsPacketDefinition:()=>s00,playersPacketDefinition:()=>n00,physicsDebugRenderPacketDefinition:()=>d00,physicsDebugRaycastsPacketDefinition:()=>a00,particleEmittersPacketDefinition:()=>g00,notificationPermissionRequestPacketDefinition:()=>i00,lightsPacketDefinition:()=>p00,entitiesPacketDefinition:()=>y00,chunksPacketDefinition:()=>l00,chatMessagesPacketDefinition:()=>u00,cameraPacketDefinition:()=>m00,blocksPacketDefinition:()=>b00,blockTypesPacketDefinition:()=>A00,audiosPacketDefinition:()=>S00});var W1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var dP={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 aP={type:"array",items:{...dP}};var S00=C0(33,aP);var nP={type:"object",properties:{i:{type:"number"},c:W1},required:["i","c"],additionalProperties:!1};var sP={type:"array",items:{...nP}};var b00=C0(34,sP);var oP={type:"object",properties:{i:{type:"number"},l:{type:"boolean",nullable:!0},ll:{type:"number",nullable:!0},n:{type:"string",nullable:!0},t:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var rP={type:"array",items:{...oP}};var A00=C0(35,rP);var tP={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 eP={type:"array",items:{...Lz}};var ZO={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 JO={type:"array",items:{...ZO}};var D6={type:"array",items:[{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255}],minItems:3,maxItems:3};var XO={type:"object",properties:{n:{type:"string"},h:{type:"boolean",nullable:!0},o:{type:"number",minimum:0,maximum:1,nullable:!0},r:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},t:{...D6,nullable:!0}},required:["n"],additionalProperties:!1};var YO={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var $O={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:{...XO},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...YO,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...D6,nullable:!0}},required:["i"],additionalProperties:!1};var QO={type:"array",items:{...$O}};var KO={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...D6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",minimum:0,maximum:1,nullable:!0},rm:{type:"boolean",nullable:!0},t:{type:"number",nullable:!0},te:{type:"number",nullable:!0},tp:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var WO={type:"array",items:{...KO}};var GO={type:"null",nullable:!0};var zO={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},b:{type:"number",nullable:!0},ce:{...D6,nullable:!0},cev:{...D6,nullable:!0},cs:{...D6,nullable:!0},csv:{...D6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...W1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...W1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pv:{...W1,nullable:!0},r:{type:"number",nullable:!0},rv:{type:"number",nullable:!0},rm:{type:"boolean",nullable:!0},se:{type:"number",nullable:!0},sev:{type:"number",nullable:!0},ss:{type:"number",nullable:!0},ssv:{type:"number",nullable:!0},t:{type:"boolean",nullable:!0},tu:{type:"string",nullable:!0},v:{...W1,nullable:!0},vv:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var vO={type:"array",items:{...zO}};var VO={type:"object",properties:{o:{...W1},d:{...W1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var HO={type:"array",items:{...VO}};var qO={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var FO={type:"object",properties:{i:{type:"string"},p:{type:"string",nullable:!0},rm:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var wO={type:"array",items:{...FO}};var cO={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"object",nullable:!0},t:{type:"string",nullable:!0},v:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var UO={type:"array",items:{...cO}};var xO={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var jO={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var BO={type:"array",items:{...Dz}};var DE1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var LO={type:"object",properties:{i:{type:"number"},ac:{...D6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...D6,nullable:!0},di:{type:"number",nullable:!0},dp:{...W1,nullable:!0},fc:{...D6,nullable:!0},ff:{type:"number",nullable:!0},fn:{type:"number",nullable:!0},n:{type:"string",nullable:!0},s:{type:"string",nullable:!0},si:{type:"number",nullable:!0},t:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var m00=C0(40,tP);var u00=C0(36,eP);var l00=C0(37,JO);var y00=C0(38,QO);var p00=C0(44,WO);var i00=C0(47,GO);var g00=C0(46,vO);var d00=C0(192,qO);var a00=C0(193,HO);var n00=C0(45,wO);var s00=C0(43,UO);var o00=C0(32,xO);var r00=C0(41,jO);var t00=C0(42,BO);var e00=C0(39,LO);var Ec=new Map,ME1={...Cc,...fc,...kc};for(let Z of Object.values(ME1))if("id"in Z&&"schema"in Z){let J=Z;if(Ec.has(J.id))throw Error(`Packet with id ${J.id} is already registered.`);Ec.set(J.id,J)}function RE1(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=Ec.get(Z[0]);return!!J&&J.validate(Z[1])}var Q0=DO;var Q60=t(O10(),1);import tY from"fs";import Y60 from"path";var H_1=t(D80(),1),q_1=t(IO(),1),F_1=t(hO(),1),rY=t(pc(),1),yO=t(C80(),1);var f80=rY.default;function x5(Z){if(Z===null)return"null";if(Array.isArray(Z))return"array";return typeof Z}function YX(Z){return x5(Z)==="object"}function w_1(Z){return Array.isArray(Z)&&Z.length>0&&Z.every((J)=>("message"in J))}function pO(Z,J){return Z.length<124?Z:J}var k80="graphql-transport-ws";var l5=((Z)=>{return Z[Z.InternalServerError=4500]="InternalServerError",Z[Z.InternalClientError=4005]="InternalClientError",Z[Z.BadRequest=4400]="BadRequest",Z[Z.BadResponse=4004]="BadResponse",Z[Z.Unauthorized=4401]="Unauthorized",Z[Z.Forbidden=4403]="Forbidden",Z[Z.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",Z[Z.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",Z[Z.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",Z[Z.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",Z[Z.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",Z})(l5||{}),y5=((Z)=>{return Z.ConnectionInit="connection_init",Z.ConnectionAck="connection_ack",Z.Ping="ping",Z.Pong="pong",Z.Subscribe="subscribe",Z.Next="next",Z.Error="error",Z.Complete="complete",Z})(y5||{});function E80(Z){if(!YX(Z))throw Error(`Message is expected to be an object, but got ${x5(Z)}`);if(!Z.type)throw Error("Message is missing the 'type' property");if(typeof Z.type!=="string")throw Error(`Message is expects the 'type' property to be a string, but got ${x5(Z.type)}`);switch(Z.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(Z.payload!=null&&!YX(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${Z.payload}"`);break}case"subscribe":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${x5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!YX(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${x5(Z.payload)}`);if(typeof Z.payload.query!=="string")throw Error(`"${Z.type}" message payload expects the 'query' property to be a string, but got ${x5(Z.payload.query)}`);if(Z.payload.variables!=null&&!YX(Z.payload.variables))throw Error(`"${Z.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${x5(Z.payload.variables)}`);if(Z.payload.operationName!=null&&x5(Z.payload.operationName)!=="string")throw Error(`"${Z.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${x5(Z.payload.operationName)}`);if(Z.payload.extensions!=null&&!YX(Z.payload.extensions))throw Error(`"${Z.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${x5(Z.payload.extensions)}`);break}case"next":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${x5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!YX(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${x5(Z.payload)}`);break}case"error":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${x5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!w_1(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(Z.payload)}`);break}case"complete":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${x5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);break}default:throw Error(`Invalid message 'type' property "${Z.type}"`)}return Z}function I80(Z,J){return E80(typeof Z==="string"?JSON.parse(Z,J):Z)}function i3(Z,J){return E80(Z),JSON.stringify(Z,J)}function gO(Z){let{url:J,connectionParams:X,lazy:Y=!0,onNonLazyError:$=console.error,lazyCloseTimeout:Q=0,keepAlive:K=0,disablePong:W,connectionAckWaitTimeout:G=0,retryAttempts:z=5,retryWait:v=async function(h){let _=Math.pow(2,h);await new Promise((a)=>setTimeout(a,_*1000+Math.floor(Math.random()*2700+300)))},shouldRetry:H=iO,on:V,webSocketImpl:q,generateID:F=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(h)=>{let _=Math.random()*16|0;return(h=="x"?_:_&3|8).toString(16)})},jsonMessageReplacer:w,jsonMessageReviver:c}=Z,U;if(q){if(!U_1(q))throw Error("Invalid WebSocket implementation provided");U=q}else if(typeof WebSocket<"u")U=WebSocket;else if(typeof global<"u")U=global.WebSocket||global.MozWebSocket;else if(typeof window<"u")U=window.WebSocket||window.MozWebSocket;if(!U)throw Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let j=U,B=(()=>{let C=(()=>{let _={};return{on(a,s){return _[a]=s,()=>{delete _[a]}},emit(a){if("id"in a)_[a.id]?.(a)}}})(),h={connecting:V?.connecting?[V.connecting]:[],opened:V?.opened?[V.opened]:[],connected:V?.connected?[V.connected]:[],ping:V?.ping?[V.ping]:[],pong:V?.pong?[V.pong]:[],message:V?.message?[C.emit,V.message]:[C.emit],closed:V?.closed?[V.closed]:[],error:V?.error?[V.error]:[]};return{onMessage:C.on,on(_,a){let s=h[_];return s.push(a),()=>{s.splice(s.indexOf(a),1)}},emit(_,...a){for(let s of[...h[_]])s(...a)}}})();function L(C){let h=[B.on("error",(_)=>{h.forEach((a)=>a()),C(_)}),B.on("closed",(_)=>{h.forEach((a)=>a()),C(_)})]}let R,M=0,N,P=!1,O=0,k=!1;async function E(){clearTimeout(N);let[C,h]=await(R??(R=new Promise((s,Z0)=>(async()=>{if(P){if(await v(O),!M)return R=void 0,Z0({code:1000,reason:"All Subscriptions Gone"});O++}B.emit("connecting",P);let o=new j(typeof J==="function"?await J():J,k80),M0,R0;function m0(){if(isFinite(K)&&K>0)clearTimeout(R0),R0=setTimeout(()=>{if(o.readyState===j.OPEN)o.send(i3({type:y5.Ping})),B.emit("ping",!1,void 0)},K)}L((s0)=>{if(R=void 0,clearTimeout(M0),clearTimeout(R0),Z0(s0),s0 instanceof gc)o.close(4499,"Terminated"),o.onerror=null,o.onclose=null}),o.onerror=(s0)=>B.emit("error",s0),o.onclose=(s0)=>B.emit("closed",s0),o.onopen=async()=>{try{B.emit("opened",o);let s0=typeof X==="function"?await X():X;if(o.readyState!==j.OPEN)return;if(o.send(i3(s0?{type:y5.ConnectionInit,payload:s0}:{type:y5.ConnectionInit},w)),isFinite(G)&&G>0)M0=setTimeout(()=>{o.close(l5.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},G);m0()}catch(s0){B.emit("error",s0),o.close(l5.InternalClientError,pO(s0 instanceof Error?s0.message:String(s0),"Internal client error"))}};let P1=!1;o.onmessage=({data:s0})=>{try{let j1=I80(s0,c);if(B.emit("message",j1),j1.type==="ping"||j1.type==="pong"){if(B.emit(j1.type,!0,j1.payload),j1.type==="pong")m0();else if(!W)o.send(i3(j1.payload?{type:y5.Pong,payload:j1.payload}:{type:y5.Pong})),B.emit("pong",!1,j1.payload);return}if(P1)return;if(j1.type!==y5.ConnectionAck)throw Error(`First message cannot be of type ${j1.type}`);clearTimeout(M0),P1=!0,B.emit("connected",o,j1.payload,P),P=!1,O=0,s([o,new Promise((K4,NJ)=>L(NJ))])}catch(j1){o.onmessage=null,B.emit("error",j1),o.close(l5.BadResponse,pO(j1 instanceof Error?j1.message:String(j1),"Bad response"))}}})())));if(C.readyState===j.CLOSING)await h;let _=()=>{},a=new Promise((s)=>_=s);return[C,_,Promise.race([a.then(()=>{if(!M){let s=()=>C.close(1000,"Normal Closure");if(isFinite(Q)&&Q>0)N=setTimeout(()=>{if(C.readyState===j.OPEN)s()},Q);else s()}}),h])]}function S(C){if(iO(C)&&(c_1(C.code)||[l5.InternalServerError,l5.InternalClientError,l5.BadRequest,l5.BadResponse,l5.Unauthorized,l5.SubprotocolNotAcceptable,l5.SubscriberAlreadyExists,l5.TooManyInitialisationRequests].includes(C.code)))throw C;if(k)return!1;if(iO(C)&&C.code===1000)return M>0;if(!z||O>=z)throw C;if(!H(C))throw C;return P=!0}if(!Y)(async()=>{M++;for(;;)try{let[,,C]=await E();await C}catch(C){try{if(!S(C))return}catch(h){return $?.(h)}}})();function f(C,h){let _=F(C),a=!1,s=!1,Z0=()=>{M--,a=!0};return(async()=>{M++;for(;;)try{let[o,M0,R0]=await E();if(a)return M0();let m0=B.onMessage(_,(P1)=>{switch(P1.type){case y5.Next:{h.next(P1.payload);return}case y5.Error:{s=!0,a=!0,h.error(P1.payload),Z0();return}case y5.Complete:{a=!0,Z0();return}}});o.send(i3({id:_,type:y5.Subscribe,payload:C},w)),Z0=()=>{if(!a&&o.readyState===j.OPEN)o.send(i3({id:_,type:y5.Complete},w));M--,a=!0,M0()},await R0.finally(m0);return}catch(o){if(!S(o))return}})().then(()=>{if(!s)h.complete()}).catch((o)=>{h.error(o)}),()=>{if(!a)Z0()}}return{on:B.on,subscribe:f,iterate(C){let h=[],_={done:!1,error:null,resolve:()=>{}},a=f(C,{next(Z0){h.push(Z0),_.resolve()},error(Z0){_.done=!0,_.error=Z0,_.resolve()},complete(){_.done=!0,_.resolve()}}),s=async function*(){for(;;){if(!h.length)await new Promise((o)=>_.resolve=o);while(h.length)yield h.shift();if(_.error)throw _.error;if(_.done)return}}();return s.throw=async(Z0)=>{if(!_.done)_.done=!0,_.error=Z0,_.resolve();return{done:!0,value:void 0}},s.return=async()=>{return a(),{done:!0,value:void 0}},s},async dispose(){if(k=!0,R){let[C]=await R;C.close(1000,"Normal Closure")}},terminate(){if(R)B.emit("closed",new gc)}}}class gc extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function iO(Z){return YX(Z)&&"code"in Z&&"reason"in Z}function c_1(Z){if([1000,1001,1006,1005,1012,1013,1014].includes(Z))return!1;return Z>=1000&&Z<=1999}function U_1(Z){return typeof Z==="function"&&"constructor"in Z&&"CLOSED"in Z&&"CLOSING"in Z&&"CONNECTING"in Z&&"OPEN"in Z}var $60=t(X60(),1);var Ez="./dev/persistence",ac=process.env.HYTOPIA_NOTIFICATION_SERVICE_URL||"https://prod.notifications.hytopia.com";class P4{static instance=new P4;creatorApiKey=process.env.HYTOPIA_API_KEY;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;_gqlWs;constructor(){this._gqlWs=gO({url:"wss://prod.gql.hytopia.com/graphql",webSocketImpl:f80});try{this._creativeGateway=new $60.CreativeGateway}catch{console.warn(["━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","\uD83D\uDEA8 HYTOPIA PLATFORM GATEWAY IS NOT INITIALIZED \uD83D\uDEA8","","\uD83D\uDD27 Local development is still possible, but these features will be disabled:"," • \uD83D\uDC64 Player Accounts"," • \uD83C\uDFAD Player Cosmetics"," • \uD83D\uDC1B Crash Analytics & Debug Logs","","\uD83D\uDCA1 These features will be enabled but modified:"," • \uD83D\uDCBE Player & Global Persisted Data - Data will be persisted"," locally in the ./dev/persistence directory of your project."," Player ids for data persistence will begin at 1 for the first "," player to join your local server, and increments for each"," additional player. This means that if you restart your"," server, the first player id will be 1 again. This is to ensure"," that data persistence across server restarts can be easily"," tested and debugged in local development.","","To enable the HYTOPIA Platform Gateway locally:"," 1. Set these environment variables:"," HYTOPIA_API_KEY, HYTOPIA_GAME_ID, HYTOPIA_LOBBY_ID"," 2. You can find these values at: https://create.hytopia.com","","Note: In production, these environment variables will be auto-populated ","& the HYTOPIA Platform Gateway will automatically be initialized \uD83D\uDE80","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",""].join(`
399
+ >>> no match, partial?`,Z,H,J,V),H===W)return!0}return!1}let F;if(typeof z==="string")F=v===z,this.debug("string match",z,v,F);else F=z.test(v),this.debug("pattern match",z,v,F);if(!F)return!1}if(Q===W&&K===G)return!0;else if(Q===W)return X;else if(K===G)return Q===W-1&&Z[Q]==="";else throw Error("wtf?")}braceExpand(){return pi(this.pattern,this.options)}parse(Z){KG(Z);let J=this.options;if(Z==="**")return J6;if(Z==="")return"";let X,Y=null;if(X=Z.match(hc1))Y=J.dot?bc1:Sc1;else if(X=Z.match(Nc1))Y=(J.nocase?J.dot?Cc1:Tc1:J.dot?Oc1:Pc1)(X[1]);else if(X=Z.match(Ac1))Y=(J.nocase?J.dot?uc1:mc1:J.dot?lc1:yc1)(X);else if(X=Z.match(fc1))Y=J.dot?Ec1:kc1;else if(X=Z.match(Ic1))Y=_c1;let $=Z6.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?gc1:J.dot?dc1:ac1,Y=new Set(J.nocase?["i"]:[]),$=Z.map((W)=>{let G=W.map((z)=>{if(z instanceof RegExp)for(let v of z.flags.split(""))Y.add(v);return typeof z==="string"?tc1(z):z===J6?J6:z._src});return G.forEach((z,v)=>{let H=G[v+1],V=G[v-1];if(z!==J6||V===J6)return;if(V===void 0)if(H!==void 0&&H!==J6)G[v+1]="(?:\\/|"+X+"\\/)?"+H;else G[v]=X;else if(H===void 0)G[v-1]=V+"(?:\\/|"+X+")?";else if(H!==J6)G[v-1]=V+"(?:\\/|\\/"+X+"\\/)"+H,G[v+1]=J6}),G.filter((z)=>z!==J6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if($="^"+Q+$+K+"$",this.negate)$="^(?!"+$+").+$";try{this.regexp=new RegExp($,[...Y].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit(Z){if(this.preserveMultipleSlashes)return Z.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Z))return["",...Z.split(/\/+/)];else return Z.split(/\/+/)}match(Z,J=this.partial){if(this.debug("match",Z,this.pattern),this.comment)return!1;if(this.empty)return Z==="";if(Z==="/"&&J)return!0;let X=this.options;if(this.isWindows)Z=Z.split("\\").join("/");let 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 W=$[K],G=Y;if(X.matchBase&&W.length===1)G=[Q];if(this.matchOne(G,W,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return h6.defaults(Z).Minimatch}}h6.AST=Z6;h6.Minimatch=V4;h6.escape=Z3;h6.unescape=F9;import{fileURLToPath as fU1}from"node:url";var J3=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,gi=new Set,pM=typeof process==="object"&&!!process?process:{},di=(Z,J,X,Y)=>{typeof pM.emitWarning==="function"?pM.emitWarning(Z,J,X,Y):console.error(`[${X}] ${J}: ${Z}`)},PF=globalThis.AbortController,ii=globalThis.AbortSignal;if(typeof PF>"u"){ii=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(Y,$){this._onabort.push($)}},PF=class{constructor(){J()}signal=new ii;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=pM.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,di("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 ec1=(Z)=>!gi.has(Z),aR6=Symbol("type"),IJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),ai=(Z)=>!IJ(Z)?null:Z<=Math.pow(2,8)?Uint8Array:Z<=Math.pow(2,16)?Uint16Array:Z<=Math.pow(2,32)?Uint32Array:Z<=Number.MAX_SAFE_INTEGER?GG:null;class GG extends Array{constructor(Z){super(Z);this.fill(0)}}class X3{heap;length;static#Z=!1;static create(Z){let J=ai(Z);if(!J)return[];X3.#Z=!0;let X=new X3(Z,J);return X3.#Z=!1,X}constructor(Z,J){if(!X3.#Z)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new J(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}}class zG{#Z;#J;#Y;#X;#$;#v;#H;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#z;#V;#Q;#F;#c;#w;#x;#O;#j;#T;#D;#L;#B;#N;#U;#f;static unsafeExposeInternals(Z){return{starts:Z.#D,ttls:Z.#L,sizes:Z.#T,keyMap:Z.#z,keyList:Z.#V,valList:Z.#Q,next:Z.#F,prev:Z.#c,get head(){return Z.#w},get tail(){return Z.#x},free:Z.#O,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,Y,$)=>Z.#h(J,X,Y,$),moveToTail:(J)=>Z.#A(J),indexes:(J)=>Z.#P(J),rindexes:(J)=>Z.#C(J),isStale:(J)=>Z.#R(J)}}get max(){return this.#Z}get maxSize(){return this.#J}get calculatedSize(){return this.#G}get size(){return this.#W}get fetchMethod(){return this.#v}get memoMethod(){return this.#H}get dispose(){return this.#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:W,dispose:G,onInsert:z,disposeAfter:v,noDisposeOnSet:H,noUpdateTTL:V,maxSize:q=0,maxEntrySize:F=0,sizeCalculation:w,fetchMethod:c,memoMethod:U,noDeleteOnFetchRejection:j,noDeleteOnStaleGet:B,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:R,ignoreFetchAbort:M}=Z;if(J!==0&&!IJ(J))throw TypeError("max option must be a nonnegative integer");let N=J?ai(J):Array;if(!N)throw Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=F||this.#J,this.sizeCalculation=w,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(U!==void 0&&typeof U!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#H=U,c!==void 0&&typeof c!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#v=c,this.#N=!!c,this.#z=new Map,this.#V=Array(J).fill(void 0),this.#Q=Array(J).fill(void 0),this.#F=new N(J),this.#c=new N(J),this.#w=0,this.#x=0,this.#O=X3.create(J),this.#W=0,this.#G=0,typeof G==="function")this.#Y=G;if(typeof z==="function")this.#X=z;if(typeof v==="function")this.#$=v,this.#j=[];else this.#$=void 0,this.#j=void 0;if(this.#B=!!this.#Y,this.#f=!!this.#X,this.#U=!!this.#$,this.noDisposeOnSet=!!H,this.noUpdateTTL=!!V,this.noDeleteOnFetchRejection=!!j,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!IJ(this.#J))throw TypeError("maxSize must be a positive integer if specified")}if(!IJ(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#u()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!B,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=IJ(Y)||Y===0?Y:1,this.ttlAutopurge=!!$,this.ttl=X||0,this.ttl){if(!IJ(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(ec1("LRU_CACHE_UNBOUNDED"))gi.add("LRU_CACHE_UNBOUNDED"),di("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",zG)}}getRemainingTTL(Z){return this.#z.has(Z)?1/0:0}#K(){let Z=new GG(this.#Z),J=new GG(this.#Z);this.#L=Z,this.#D=J,this.#k=($,Q,K=J3.now())=>{if(J[$]=Q!==0?K:0,Z[$]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#R($))this.#E(this.#V[$],"expire")},Q+1);if(W.unref)W.unref()}},this.#I=($)=>{J[$]=Z[$]!==0?J3.now():0},this.#M=($,Q)=>{if(Z[Q]){let K=Z[Q],W=J[Q];if(!K||!W)return;$.ttl=K,$.start=W,$.now=X||Y();let G=$.now-W;$.remainingTTL=K-G}};let X=0,Y=()=>{let $=J3.now();if(this.ttlResolution>0){X=$;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return $};this.getRemainingTTL=($)=>{let Q=this.#z.get($);if(Q===void 0)return 0;let K=Z[Q],W=J[Q];if(!K||!W)return 1/0;let G=(X||Y())-W;return K-G},this.#R=($)=>{let Q=J[$],K=Z[$];return!!K&&!!Q&&(X||Y())-Q>K}}#I=()=>{};#M=()=>{};#k=()=>{};#R=()=>!1;#u(){let Z=new GG(this.#Z);this.#G=0,this.#T=Z,this.#_=(J)=>{this.#G-=Z[J],Z[J]=0},this.#l=(J,X,Y,$)=>{if(this.#q(X))return 0;if(!IJ(Y))if($){if(typeof $!=="function")throw TypeError("sizeCalculation must be a function");if(Y=$(X,J),!IJ(Y))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return Y},this.#S=(J,X,Y)=>{if(Z[J]=X,this.#J){let $=this.#J-Z[J];while(this.#G>$)this.#b(!0)}if(this.#G+=Z[J],Y)Y.entrySize=X,Y.totalCalculatedSize=this.#G}}#_=(Z)=>{};#S=(Z,J,X)=>{};#l=(Z,J,X,Y)=>{if(X||Y)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#x;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#w)break;else J=this.#c[J]}}*#C({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#w;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#x)break;else J=this.#F[J]}}#y(Z){return Z!==void 0&&this.#z.get(this.#V[Z])===Z}*entries(){for(let Z of this.#P())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#C())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*keys(){for(let Z of this.#P()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#C()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#P())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#C())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,J={}){for(let X of this.#P()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;if(Z($,this.#V[X],this))return this.get(this.#V[X],J)}}forEach(Z,J=this){for(let X of this.#P()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#V[X],this)}}rforEach(Z,J=this){for(let X of this.#C()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#V[X],this)}}purgeStale(){let Z=!1;for(let J of this.#C({allowStale:!0}))if(this.#R(J))this.#E(this.#V[J],"expire"),Z=!0;return Z}info(Z){let J=this.#z.get(Z);if(J===void 0)return;let X=this.#Q[J],Y=this.#q(X)?X.__staleWhileFetching:X;if(Y===void 0)return;let $={value:Y};if(this.#L&&this.#D){let Q=this.#L[J],K=this.#D[J];if(Q&&K){let W=Q-(J3.now()-K);$.ttl=W,$.start=Date.now()}}if(this.#T)$.size=this.#T[J];return $}dump(){let Z=[];for(let J of this.#P({allowStale:!0})){let X=this.#V[J],Y=this.#Q[J],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0||X===void 0)continue;let Q={value:$};if(this.#L&&this.#D){Q.ttl=this.#L[J];let K=J3.now()-this.#D[J];Q.start=Math.floor(Date.now()-K)}if(this.#T)Q.size=this.#T[J];Z.unshift([X,Q])}return Z}load(Z){this.clear();for(let[J,X]of Z){if(X.start){let Y=Date.now()-X.start;X.start=J3.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:W}=X,{noUpdateTTL:G=this.noUpdateTTL}=X,z=this.#l(Z,J,X.size||0,K);if(this.maxEntrySize&&z>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#E(Z,"set"),this}let v=this.#W===0?void 0:this.#z.get(Z);if(v===void 0){if(v=this.#W===0?this.#x:this.#O.length!==0?this.#O.pop():this.#W===this.#Z?this.#b(!1):this.#W,this.#V[v]=Z,this.#Q[v]=J,this.#z.set(Z,v),this.#F[this.#x]=v,this.#c[v]=this.#x,this.#x=v,this.#W++,this.#S(v,z,W),W)W.set="add";if(G=!1,this.#f)this.#X?.(J,Z,"add")}else{this.#A(v);let H=this.#Q[v];if(J!==H){if(this.#N&&this.#q(H)){H.__abortController.abort(Error("replaced"));let{__staleWhileFetching:V}=H;if(V!==void 0&&!Q){if(this.#B)this.#Y?.(V,Z,"set");if(this.#U)this.#j?.push([V,Z,"set"])}}else if(!Q){if(this.#B)this.#Y?.(H,Z,"set");if(this.#U)this.#j?.push([H,Z,"set"])}if(this.#_(v),this.#S(v,z,W),this.#Q[v]=J,W){W.set="replace";let V=H&&this.#q(H)?H.__staleWhileFetching:H;if(V!==void 0)W.oldValue=V}}else if(W)W.set="update";if(this.#f)this.onInsert?.(J,Z,J===H?"update":"replace")}if(Y!==0&&!this.#L)this.#K();if(this.#L){if(!G)this.#k(v,Y,$);if(W)this.#M(W,v)}if(!Q&&this.#U&&this.#j){let H=this.#j,V;while(V=H?.shift())this.#$?.(...V)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#w];if(this.#b(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#U&&this.#j){let Z=this.#j,J;while(J=Z?.shift())this.#$?.(...J)}}}#b(Z){let J=this.#w,X=this.#V[J],Y=this.#Q[J];if(this.#N&&this.#q(Y))Y.__abortController.abort(Error("evicted"));else if(this.#B||this.#U){if(this.#B)this.#Y?.(Y,X,"evict");if(this.#U)this.#j?.push([Y,X,"evict"])}if(this.#_(J),Z)this.#V[J]=void 0,this.#Q[J]=void 0,this.#O.push(J);if(this.#W===1)this.#w=this.#x=0,this.#O.length=0;else this.#w=this.#F[J];return this.#z.delete(X),this.#W--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:Y}=J,$=this.#z.get(Z);if($!==void 0){let Q=this.#Q[$];if(this.#q(Q)&&Q.__staleWhileFetching===void 0)return!1;if(!this.#R($)){if(X)this.#I($);if(Y)Y.has="hit",this.#M(Y,$);return!0}else if(Y)Y.has="stale",this.#M(Y,$)}else if(Y)Y.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,Y=this.#z.get(Z);if(Y===void 0||!X&&this.#R(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 PF,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:Y},G=(F,w=!1)=>{let{aborted:c}=Q.signal,U=X.ignoreFetchAbort&&F!==void 0;if(X.status)if(c&&!w){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,U)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(c&&!U&&!w)return v(Q.signal.reason);let j=V;if(this.#Q[J]===V)if(F===void 0)if(j.__staleWhileFetching)this.#Q[J]=j.__staleWhileFetching;else this.#E(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,F,W.options)}return F},z=(F)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=F;return v(F)},v=(F)=>{let{aborted:w}=Q.signal,c=w&&X.allowStaleOnFetchAbort,U=c||X.allowStaleOnFetchRejection,j=U||X.noDeleteOnFetchRejection,B=V;if(this.#Q[J]===V){if(!j||B.__staleWhileFetching===void 0)this.#E(Z,"fetch");else if(!c)this.#Q[J]=B.__staleWhileFetching}if(U){if(X.status&&B.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return B.__staleWhileFetching}else if(B.__returned===B)throw F},H=(F,w)=>{let c=this.#v?.(Z,$,W);if(c&&c instanceof Promise)c.then((U)=>F(U===void 0?void 0:U),w);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(F(void 0),X.allowStaleOnFetchAbort)F=(U)=>G(U,!0)}})};if(X.status)X.status.fetchDispatched=!0;let V=new Promise(H).then(G,z),q=Object.assign(V,{__abortController:Q,__staleWhileFetching:$,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#z.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#N)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof PF}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:W=0,sizeCalculation:G=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:v=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:H=this.allowStaleOnFetchRejection,ignoreFetchAbort:V=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:F,forceRefresh:w=!1,status:c,signal:U}=J;if(!this.#N){if(c)c.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,status:c})}let j={allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:z,noDeleteOnFetchRejection:v,allowStaleOnFetchRejection:H,allowStaleOnFetchAbort:q,ignoreFetchAbort:V,status:c,signal:U},B=this.#z.get(Z);if(B===void 0){if(c)c.fetch="miss";let L=this.#h(Z,B,j,F);return L.__returned=L}else{let L=this.#Q[B];if(this.#q(L)){let O=X&&L.__staleWhileFetching!==void 0;if(c){if(c.fetch="inflight",O)c.returnedStale=!0}return O?L.__staleWhileFetching:L.__returned=L}let R=this.#R(B);if(!w&&!R){if(c)c.fetch="hit";if(this.#A(B),Y)this.#I(B);if(c)this.#M(c,B);return L}let M=this.#h(Z,B,j,F),P=M.__staleWhileFetching!==void 0&&X;if(c){if(c.fetch=R?"stale":"refresh",P&&R)c.returnedStale=!0}return P?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#H;if(!X)throw Error("no memoMethod provided to constructor");let{context:Y,forceRefresh:$,...Q}=J,K=this.get(Z,Q);if(!$&&K!==void 0)return K;let W=X(Z,K,{options:Q,context:Y});return this.set(Z,W,Q),W}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:Y=this.updateAgeOnGet,noDeleteOnStaleGet:$=this.noDeleteOnStaleGet,status:Q}=J,K=this.#z.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#M(Q,K);if(this.#R(K)){if(Q)Q.get="stale";if(!G){if(!$)this.#E(Z,"expire");if(Q&&X)Q.returnedStale=!0;return X?W:void 0}else{if(Q&&X&&W.__staleWhileFetching!==void 0)Q.returnedStale=!0;return X?W.__staleWhileFetching:void 0}}else{if(Q)Q.get="hit";if(G)return W.__staleWhileFetching;if(this.#A(K),Y)this.#I(K);return W}}else if(Q)Q.get="miss"}#p(Z,J){this.#c[J]=Z,this.#F[Z]=J}#A(Z){if(Z!==this.#x){if(Z===this.#w)this.#w=this.#F[Z];else this.#p(this.#c[Z],this.#F[Z]);this.#p(this.#x,Z),this.#x=Z}}delete(Z){return this.#E(Z,"delete")}#E(Z,J){let X=!1;if(this.#W!==0){let Y=this.#z.get(Z);if(Y!==void 0)if(X=!0,this.#W===1)this.#m(J);else{this.#_(Y);let $=this.#Q[Y];if(this.#q($))$.__abortController.abort(Error("deleted"));else if(this.#B||this.#U){if(this.#B)this.#Y?.($,Z,J);if(this.#U)this.#j?.push([$,Z,J])}if(this.#z.delete(Z),this.#V[Y]=void 0,this.#Q[Y]=void 0,Y===this.#x)this.#x=this.#c[Y];else if(Y===this.#w)this.#w=this.#F[Y];else{let Q=this.#c[Y];this.#F[Q]=this.#F[Y];let K=this.#F[Y];this.#c[K]=this.#c[Y]}this.#W--,this.#O.push(Y)}}if(this.#U&&this.#j?.length){let Y=this.#j,$;while($=Y?.shift())this.#$?.(...$)}return X}clear(){return this.#m("delete")}#m(Z){for(let J of this.#C({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(Error("deleted"));else{let Y=this.#V[J];if(this.#B)this.#Y?.(X,Y,Z);if(this.#U)this.#j?.push([X,Y,Z])}}if(this.#z.clear(),this.#Q.fill(void 0),this.#V.fill(void 0),this.#L&&this.#D)this.#L.fill(0),this.#D.fill(0);if(this.#T)this.#T.fill(0);if(this.#w=0,this.#x=0,this.#O.length=0,this.#G=0,this.#W=0,this.#U&&this.#j){let J=this.#j,X;while(X=J?.shift())this.#$?.(...X)}}}import{posix as vU1,win32 as eM}from"node:path";import{fileURLToPath as VU1}from"node:url";import{lstatSync as HU1,readdir as qU1,readdirSync as FU1,readlinkSync as wU1,realpathSync as cU1}from"fs";import*as UU1 from"node:fs";import{lstat as jU1,readdir as BU1,readlink as LU1,realpath as DU1}from"node:fs/promises";import{EventEmitter as sM}from"node:events";import ti from"node:stream";import{StringDecoder as ZU1}from"node:string_decoder";var ni=typeof process==="object"&&process?process:{stdout:null,stderr:null},JU1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof CY||Z instanceof ti||XU1(Z)||YU1(Z)),XU1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof sM&&typeof Z.pipe==="function"&&Z.pipe!==ti.Writable.prototype.pipe,YU1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof sM&&typeof Z.write==="function"&&typeof Z.end==="function",ZZ=Symbol("EOF"),JZ=Symbol("maybeEmitEnd"),_J=Symbol("emittedEnd"),OF=Symbol("emittingEnd"),vG=Symbol("emittedError"),TF=Symbol("closed"),si=Symbol("read"),CF=Symbol("flush"),oi=Symbol("flushChunk"),w9=Symbol("encoding"),Y3=Symbol("decoder"),y8=Symbol("flowing"),VG=Symbol("paused"),$3=Symbol("resume"),p8=Symbol("buffer"),S6=Symbol("pipes"),i8=Symbol("bufferLength"),iM=Symbol("bufferPush"),fF=Symbol("bufferShift"),w6=Symbol("objectMode"),U8=Symbol("destroyed"),gM=Symbol("error"),dM=Symbol("emitData"),ri=Symbol("emitEnd"),aM=Symbol("emitEnd2"),Y7=Symbol("async"),nM=Symbol("abort"),kF=Symbol("aborted"),HG=Symbol("signal"),TY=Symbol("dataListeners"),I5=Symbol("discarded"),qG=(Z)=>Promise.resolve().then(Z),$U1=(Z)=>Z(),QU1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",KU1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,WU1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class oM{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[$3](),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 ei extends oM{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 GU1=(Z)=>!!Z.objectMode,zU1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class CY extends sM{[y8]=!1;[VG]=!1;[S6]=[];[p8]=[];[w6];[w9];[Y7];[Y3];[ZZ]=!1;[_J]=!1;[OF]=!1;[TF]=!1;[vG]=null;[i8]=0;[U8]=!1;[HG];[kF]=!1;[TY]=0;[I5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(GU1(J))this[w6]=!0,this[w9]=null;else if(zU1(J))this[w9]=J.encoding,this[w6]=!1;else this[w6]=!1,this[w9]=null;if(this[Y7]=!!J.async,this[Y3]=this[w9]?new ZU1(this[w9]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[p8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[S6]});let{signal:X}=J;if(X)if(this[HG]=X,X.aborted)this[nM]();else X.addEventListener("abort",()=>this[nM]())}get bufferLength(){return this[i8]}get encoding(){return this[w9]}set encoding(Z){throw Error("Encoding must be set at instantiation time")}setEncoding(Z){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[w6]}set objectMode(Z){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[Y7]}set["async"](Z){this[Y7]=this[Y7]||!!Z}[nM](){this[kF]=!0,this.emit("abort",this[HG]?.reason),this.destroy(this[HG]?.reason)}get aborted(){return this[kF]}set aborted(Z){}write(Z,J,X){if(this[kF])return!1;if(this[ZZ])throw Error("write after end");if(this[U8])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof J==="function")X=J,J="utf8";if(!J)J="utf8";let Y=this[Y7]?qG:$U1;if(!this[w6]&&!Buffer.isBuffer(Z)){if(WU1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(KU1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[w6]){if(this[y8]&&this[i8]!==0)this[CF](!0);if(this[y8])this.emit("data",Z);else this[iM](Z);if(this[i8]!==0)this.emit("readable");if(X)Y(X);return this[y8]}if(!Z.length){if(this[i8]!==0)this.emit("readable");if(X)Y(X);return this[y8]}if(typeof Z==="string"&&!(J===this[w9]&&!this[Y3]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[w9])Z=this[Y3].write(Z);if(this[y8]&&this[i8]!==0)this[CF](!0);if(this[y8])this.emit("data",Z);else this[iM](Z);if(this[i8]!==0)this.emit("readable");if(X)Y(X);return this[y8]}read(Z){if(this[U8])return null;if(this[I5]=!1,this[i8]===0||Z===0||Z&&Z>this[i8])return this[JZ](),null;if(this[w6])Z=null;if(this[p8].length>1&&!this[w6])this[p8]=[this[w9]?this[p8].join(""):Buffer.concat(this[p8],this[i8])];let J=this[si](Z||null,this[p8][0]);return this[JZ](),J}[si](Z,J){if(this[w6])this[fF]();else{let X=J;if(Z===X.length||Z===null)this[fF]();else if(typeof X==="string")this[p8][0]=X.slice(Z),J=X.slice(0,Z),this[i8]-=Z;else this[p8][0]=X.subarray(Z),J=X.subarray(0,Z),this[i8]-=Z}if(this.emit("data",J),!this[p8].length&&!this[ZZ])this.emit("drain");return J}end(Z,J,X){if(typeof Z==="function")X=Z,Z=void 0;if(typeof J==="function")X=J,J="utf8";if(Z!==void 0)this.write(Z,J);if(X)this.once("end",X);if(this[ZZ]=!0,this.writable=!1,this[y8]||!this[VG])this[JZ]();return this}[$3](){if(this[U8])return;if(!this[TY]&&!this[S6].length)this[I5]=!0;if(this[VG]=!1,this[y8]=!0,this.emit("resume"),this[p8].length)this[CF]();else if(this[ZZ])this[JZ]();else this.emit("drain")}resume(){return this[$3]()}pause(){this[y8]=!1,this[VG]=!0,this[I5]=!1}get destroyed(){return this[U8]}get flowing(){return this[y8]}get paused(){return this[VG]}[iM](Z){if(this[w6])this[i8]+=1;else this[i8]+=Z.length;this[p8].push(Z)}[fF](){if(this[w6])this[i8]-=1;else this[i8]-=this[p8][0].length;return this[p8].shift()}[CF](Z=!1){do;while(this[oi](this[fF]())&&this[p8].length);if(!Z&&!this[p8].length&&!this[ZZ])this.emit("drain")}[oi](Z){return this.emit("data",Z),this[y8]}pipe(Z,J){if(this[U8])return Z;this[I5]=!1;let X=this[_J];if(J=J||{},Z===ni.stdout||Z===ni.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 oM(this,Z,J):new ei(this,Z,J)),this[Y7])qG(()=>this[$3]());else this[$3]();return Z}unpipe(Z){let J=this[S6].find((X)=>X.dest===Z);if(J){if(this[S6].length===1){if(this[y8]&&this[TY]===0)this[y8]=!1;this[S6]=[]}else this[S6].splice(this[S6].indexOf(J),1);J.unpipe()}}addListener(Z,J){return this.on(Z,J)}on(Z,J){let X=super.on(Z,J);if(Z==="data"){if(this[I5]=!1,this[TY]++,!this[S6].length&&!this[y8])this[$3]()}else if(Z==="readable"&&this[i8]!==0)super.emit("readable");else if(QU1(Z)&&this[_J])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[vG]){let Y=J;if(this[Y7])qG(()=>Y.call(this,this[vG]));else Y.call(this,this[vG])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[TY]=this.listeners("data").length,this[TY]===0&&!this[I5]&&!this[S6].length)this[y8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[TY]=0,!this[I5]&&!this[S6].length)this[y8]=!1}return J}get emittedEnd(){return this[_J]}[JZ](){if(!this[OF]&&!this[_J]&&!this[U8]&&this[p8].length===0&&this[ZZ]){if(this[OF]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[TF])this.emit("close");this[OF]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==U8&&this[U8])return!1;else if(Z==="data")return!this[w6]&&!X?!1:this[Y7]?(qG(()=>this[dM](X)),!0):this[dM](X);else if(Z==="end")return this[ri]();else if(Z==="close"){if(this[TF]=!0,!this[_J]&&!this[U8])return!1;let $=super.emit("close");return this.removeAllListeners("close"),$}else if(Z==="error"){this[vG]=X,super.emit(gM,X);let $=!this[HG]||this.listeners("error").length?super.emit("error",X):!1;return this[JZ](),$}else if(Z==="resume"){let $=super.emit("resume");return this[JZ](),$}else if(Z==="finish"||Z==="prefinish"){let $=super.emit(Z);return this.removeAllListeners(Z),$}let Y=super.emit(Z,...J);return this[JZ](),Y}[dM](Z){for(let X of this[S6])if(X.dest.write(Z)===!1)this.pause();let J=this[I5]?!1:super.emit("data",Z);return this[JZ](),J}[ri](){if(this[_J])return!1;return this[_J]=!0,this.readable=!1,this[Y7]?(qG(()=>this[aM]()),!0):this[aM]()}[aM](){if(this[Y3]){let J=this[Y3].end();if(J){for(let X of this[S6])X.dest.write(J);if(!this[I5])super.emit("data",J)}}for(let J of this[S6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[w6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[w6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[w6])throw Error("cannot concat in objectMode");let Z=await this.collect();return this[w9]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(U8,()=>J(Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[I5]=!1;let Z=!1,J=async()=>{return this.pause(),Z=!0,{value:void 0,done:!0}};return{next:()=>{if(Z)return J();let Y=this.read();if(Y!==null)return Promise.resolve({done:!1,value:Y});if(this[ZZ])return J();let $,Q,K=(v)=>{this.off("data",W),this.off("end",G),this.off(U8,z),J(),Q(v)},W=(v)=>{this.off("error",K),this.off("end",G),this.off(U8,z),this.pause(),$({value:v,done:!!this[ZZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(U8,z),J(),$({done:!0,value:void 0})},z=()=>K(Error("stream destroyed"));return new Promise((v,H)=>{Q=H,$=v,this.once(U8,z),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[I5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(gM,J),this.off(U8,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(gM,J),this.once(U8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[U8]){if(Z)this.emit("error",Z);else this.emit(U8);return this}this[U8]=!0,this[I5]=!0,this[p8].length=0,this[i8]=0;let J=this;if(typeof J.close==="function"&&!this[TF])J.close();if(Z)this.emit("error",Z);else this.emit(U8);return this}static get isStream(){return JU1}}var xU1=cU1.native,wG={lstatSync:HU1,readdir:qU1,readdirSync:FU1,readlinkSync:wU1,realpathSync:xU1,promises:{lstat:jU1,readdir:BU1,readlink:LU1,realpath:DU1}},$g=(Z)=>!Z||Z===wG||Z===UU1?wG:{...wG,...Z,promises:{...wG.promises,...Z.promises||{}}},Qg=/^\\\\\?\\([a-z]:)\\?$/i,MU1=(Z)=>Z.replace(/\//g,"\\").replace(Qg,"$1\\"),RU1=/[\\\/]/,q4=0,Kg=1,Wg=2,$7=4,Gg=6,zg=8,fY=10,vg=12,H4=15,FG=~H4,rM=16,Zg=32,cG=64,c9=128,EF=256,_F=512,Jg=cG|c9|_F,NU1=1023,tM=(Z)=>Z.isFile()?zg:Z.isDirectory()?$7:Z.isSymbolicLink()?fY:Z.isCharacterDevice()?Wg:Z.isBlockDevice()?Gg:Z.isSocket()?vg:Z.isFIFO()?Kg:q4,Xg=new Map,UG=(Z)=>{let J=Xg.get(Z);if(J)return J;let X=Z.normalize("NFKD");return Xg.set(Z,X),X},Yg=new Map,IF=(Z)=>{let J=Yg.get(Z);if(J)return J;let X=UG(Z.toLowerCase());return Yg.set(Z,X),X};class ZR extends zG{constructor(){super({max:256})}}class Vg extends zG{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var Hg=Symbol("PathScurry setAsCwd");class b6{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}#H;get rdev(){return this.#H}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#z;get size(){return this.#z}#V;get blocks(){return this.#V}#Q;get atimeMs(){return this.#Q}#F;get mtimeMs(){return this.#F}#c;get ctimeMs(){return this.#c}#w;get birthtimeMs(){return this.#w}#x;get atime(){return this.#x}#O;get mtime(){return this.#O}#j;get ctime(){return this.#j}#T;get birthtime(){return this.#T}#D;#L;#B;#N;#U;#f;#K;#I;#M;#k;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=q4,X,Y,$,Q,K){if(this.name=Z,this.#D=$?IF(Z):UG(Z),this.#K=J&NU1,this.nocase=$,this.roots=Y,this.root=X||this,this.#I=Q,this.#B=K.fullpath,this.#U=K.relative,this.#f=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=$g(K.fs)}depth(){if(this.#L!==void 0)return this.#L;if(!this.parent)return this.#L=0;return this.#L=this.parent.depth()+1}childrenCache(){return this.#I}resolve(Z){if(!Z)return this;let J=this.getRootString(Z),Y=Z.substring(J.length).split(this.splitSep);return J?this.getRoot(J).#R(Y):this.#R(Y)}#R(Z){let J=this;for(let X of Z)J=J.child(X);return J}children(){let Z=this.#I.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#I.set(this,J),this.#K&=~rM,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),Y=this.nocase?IF(Z):UG(Z);for(let W of X)if(W.#D===Y)return W;let $=this.parent?this.sep:"",Q=this.#B?this.#B+$+Z:void 0,K=this.newChild(Z,q4,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=c9;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#U!==void 0)return this.#U;let Z=this.name,J=this.parent;if(!J)return this.#U=this.name;let X=J.relative();return X+(!X||!J.parent?"":this.sep)+Z}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#f!==void 0)return this.#f;let Z=this.name,J=this.parent;if(!J)return this.#f=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#B!==void 0)return this.#B;let Z=this.name,J=this.parent;if(!J)return this.#B=this.name;let Y=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#B=Y}fullpathPosix(){if(this.#N!==void 0)return this.#N;if(this.sep==="/")return this.#N=this.fullpath();if(!this.parent){let Y=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(Y))return this.#N=`//?/${Y}`;else return this.#N=Y}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#N=X}isUnknown(){return(this.#K&H4)===q4}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&H4)===zg}isDirectory(){return(this.#K&H4)===$7}isCharacterDevice(){return(this.#K&H4)===Wg}isBlockDevice(){return(this.#K&H4)===Gg}isFIFO(){return(this.#K&H4)===Kg}isSocket(){return(this.#K&H4)===vg}isSymbolicLink(){return(this.#K&fY)===fY}lstatCached(){return this.#K&Zg?this:void 0}readlinkCached(){return this.#M}realpathCached(){return this.#k}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#M)return!0;if(!this.parent)return!1;let Z=this.#K&H4;return!(Z!==q4&&Z!==fY||this.#K&EF||this.#K&c9)}calledReaddir(){return!!(this.#K&rM)}isENOENT(){return!!(this.#K&c9)}isNamed(Z){return!this.nocase?this.#D===UG(Z):this.#D===IF(Z)}async readlink(){let Z=this.#M;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=await this.#Z.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(J);if(X)return this.#M=X}catch(J){this.#b(J.code);return}}readlinkSync(){let Z=this.#M;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=this.#Z.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(J);if(X)return this.#M=X}catch(J){this.#b(J.code);return}}#u(Z){this.#K|=rM;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#_()}}#_(){if(this.#K&c9)return;this.#K=(this.#K|c9)&FG,this.#S()}#S(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#_()}#l(){this.#K|=_F,this.#P()}#P(){if(this.#K&cG)return;let Z=this.#K;if((Z&H4)===$7)Z&=FG;this.#K=Z|cG,this.#S()}#C(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#P();else if(Z==="ENOENT")this.#_();else this.children().provisional=0}#y(Z=""){if(Z==="ENOTDIR")this.parent.#P();else if(Z==="ENOENT")this.#_()}#b(Z=""){let J=this.#K;if(J|=EF,Z==="ENOENT")J|=c9;if(Z==="EINVAL"||Z==="UNKNOWN")J&=FG;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#P()}#h(Z,J){return this.#p(Z,J)||this.#q(Z,J)}#q(Z,J){let X=tM(Z),Y=this.newChild(Z.name,X,{parent:this}),$=Y.#K&H4;if($!==$7&&$!==fY&&$!==q4)Y.#K|=cG;return J.unshift(Y),J.provisional++,Y}#p(Z,J){for(let X=J.provisional;X<J.length;X++){let Y=J[X];if((this.nocase?IF(Z.name):UG(Z.name))!==Y.#D)continue;return this.#A(Z,Y,X,J)}}#A(Z,J,X,Y){let $=J.name;if(J.#K=J.#K&FG|tM(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&c9)===0)try{return this.#E(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#y(Z.code)}}lstatSync(){if((this.#K&c9)===0)try{return this.#E(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#y(Z.code)}}#E(Z){let{atime:J,atimeMs:X,birthtime:Y,birthtimeMs:$,blksize:Q,blocks:K,ctime:W,ctimeMs:G,dev:z,gid:v,ino:H,mode:V,mtime:q,mtimeMs:F,nlink:w,rdev:c,size:U,uid:j}=Z;this.#x=J,this.#Q=X,this.#T=Y,this.#w=$,this.#W=Q,this.#V=K,this.#j=W,this.#c=G,this.#J=z,this.#v=v,this.#G=H,this.#Y=V,this.#O=q,this.#F=F,this.#X=w,this.#H=c,this.#z=U,this.#$=j;let B=tM(Z);if(this.#K=this.#K&FG|B|Zg,B!==q4&&B!==$7&&B!==fY)this.#K|=cG}#m=[];#g=!1;#d(Z){this.#g=!1;let J=this.#m.slice();this.#m.length=0,J.forEach((X)=>X(null,Z))}readdirCB(Z,J=!1){if(!this.canReaddir()){if(J)Z(null,[]);else queueMicrotask(()=>Z(null,[]));return}let X=this.children();if(this.calledReaddir()){let $=X.slice(0,X.provisional);if(J)Z(null,$);else queueMicrotask(()=>Z(null,$));return}if(this.#m.push(Z),this.#g)return;this.#g=!0;let Y=this.fullpath();this.#Z.readdir(Y,{withFileTypes:!0},($,Q)=>{if($)this.#C($.code),X.provisional=0;else{for(let K of Q)this.#h(K,X);this.#u(X)}this.#d(X.slice(0,X.provisional));return})}#i;async readdir(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();if(this.#i)await this.#i;else{let X=()=>{};this.#i=new Promise((Y)=>X=Y);try{for(let Y of await this.#Z.promises.readdir(J,{withFileTypes:!0}))this.#h(Y,Z);this.#u(Z)}catch(Y){this.#C(Y.code),Z.provisional=0}this.#i=void 0,X()}return Z.slice(0,Z.provisional)}readdirSync(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();try{for(let X of this.#Z.readdirSync(J,{withFileTypes:!0}))this.#h(X,Z);this.#u(Z)}catch(X){this.#C(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&Jg)return!1;let Z=H4&this.#K;if(!(Z===q4||Z===$7||Z===fY))return!1;return!0}shouldWalk(Z,J){return(this.#K&$7)===$7&&!(this.#K&Jg)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#k)return this.#k;if((_F|EF|c9)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}realpathSync(){if(this.#k)return this.#k;if((_F|EF|c9)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}[Hg](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.#U=X.join(this.sep),Y.#f=X.join("/"),Y=Y.parent,X.push("..");Y=Z;while(Y&&Y.parent&&!J.has(Y))Y.#U=void 0,Y.#f=void 0,Y=Y.parent}}class hF extends b6{sep="\\";splitSep=RU1;constructor(Z,J=q4,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}newChild(Z,J=q4,X={}){return new hF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return eM.parse(Z).root}getRoot(Z){if(Z=MU1(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 xG(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(Qg,"$1\\"),Z===J}}class SF extends b6{splitSep="/";sep="/";constructor(Z,J=q4,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=q4,X={}){return new SF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class JR{root;rootPath;roots;cwd;#Z;#J;#Y;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:Y,childrenCacheSize:$=16384,fs:Q=wG}={}){if(this.#X=$g(Q),Z instanceof URL||Z.startsWith("file://"))Z=VU1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new ZR,this.#J=new ZR,this.#Y=new Vg($);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if(Y===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=Y,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let G=this.root,z=W.length-1,v=J.sep,H=this.rootPath,V=!1;for(let q of W){let F=z--;G=G.child(q,{relative:Array(F).fill("..").join(v),relativePosix:Array(F).fill("..").join("/"),fullpath:H+=(V?"":v)+q}),V=!0}this.cwd=G}depth(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.depth()}childrenCache(){return this.#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 b6))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 b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0}=J;if(!Z.canReaddir())return[];else if(X)return Z.readdirSync();else return Z.readdirSync().map((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 b6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.readlink();return J?X:X?.fullpath()}readlinkSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z.withFileTypes,Z=this.cwd;let X=Z.readlinkSync();return J?X:X?.fullpath()}async realpath(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.realpath();return J?X:X?.fullpath()}realpathSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z.withFileTypes,Z=this.cwd;let X=Z.realpathSync();return J?X:X?.fullpath()}async walk(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let W=new Set,G=(v,H)=>{W.add(v),v.readdirCB((V,q)=>{if(V)return H(V);let F=q.length;if(!F)return H();let w=()=>{if(--F===0)H()};for(let c of q){if(!$||$(c))K.push(X?c:c.fullpath());if(Y&&c.isSymbolicLink())c.realpath().then((U)=>U?.isUnknown()?U.lstat():U).then((U)=>U?.shouldWalk(W,Q)?G(U,w):w());else if(c.shouldWalk(W,Q))G(c,w);else w()}},!0)},z=Z;return new Promise((v,H)=>{G(z,(V)=>{if(V)return H(V);v(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let W=new Set([Z]);for(let G of W){let z=G.readdirSync();for(let v of z){if(!$||$(v))K.push(X?v:v.fullpath());let H=v;if(v.isSymbolicLink()){if(!(Y&&(H=v.realpathSync())))continue;if(H.isUnknown())H.lstatSync()}if(H.shouldWalk(W,Q))W.add(H)}}return K}[Symbol.asyncIterator](){return this.iterate()}iterate(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;return this.stream(Z,J)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J;if(!$||$(Z))yield X?Z:Z.fullpath();let K=new Set([Z]);for(let W of K){let G=W.readdirSync();for(let z of G){if(!$||$(z))yield X?z:z.fullpath();let v=z;if(z.isSymbolicLink()){if(!(Y&&(v=z.realpathSync())))continue;if(v.isUnknown())v.lstatSync()}if(v.shouldWalk(K,Q))K.add(v)}}}stream(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new CY({objectMode:!0});if(!$||$(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=(w,c,U=!1)=>{if(w)return K.emit("error",w);if(Y&&!U){let j=[];for(let B of c)if(B.isSymbolicLink())j.push(B.realpath().then((L)=>L?.isUnknown()?L.lstat():L));if(j.length){Promise.all(j).then(()=>q(null,c,!0));return}}for(let j of c)if(j&&(!$||$(j))){if(!K.write(X?j:j.fullpath()))H=!0}z--;for(let j of c){let B=j.realpathCached()||j;if(B.shouldWalk(W,Q))G.push(B)}if(H&&!K.flowing)K.once("drain",v);else if(!F)v()},F=!0;V.readdirCB(q,!0),F=!1}};return v(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new CY({objectMode:!0}),W=new Set;if(!$||$(Z))K.write(X?Z:Z.fullpath());let G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=V.readdirSync();for(let F of q)if(!$||$(F)){if(!K.write(X?F:F.fullpath()))H=!0}z--;for(let F of q){let w=F;if(F.isSymbolicLink()){if(!(Y&&(w=F.realpathSync())))continue;if(w.isUnknown())w.lstatSync()}if(w.shouldWalk(W,Q))G.push(w)}}if(H&&!K.flowing)K.once("drain",v)};return v(),K}chdir(Z=this.cwd){let J=this.cwd;this.cwd=typeof Z==="string"?this.cwd.resolve(Z):Z,this.cwd[Hg](J)}}class xG extends JR{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,eM,"\\",{...J,nocase:X});this.nocase=X;for(let Y=this.cwd;Y;Y=Y.parent)Y.nocase=this.nocase}parseRootPath(Z){return eM.parse(Z).root.toUpperCase()}newRoot(Z){return new hF(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class jG extends JR{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,vU1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new SF(this.rootPath,$7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class bF extends jG{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var QN6=process.platform==="win32"?hF:SF,qg=process.platform==="win32"?xG:process.platform==="darwin"?bF:jG;var PU1=(Z)=>Z.length>=1,OU1=(Z)=>Z.length>=1;class Q3{#Z;#J;#Y;length;#X;#$;#v;#H;#W;#G;#z=!0;constructor(Z,J,X,Y){if(!PU1(Z))throw TypeError("empty pattern list");if(!OU1(J))throw TypeError("empty glob list");if(J.length!==Z.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw TypeError("index out of range");if(this.#Z=Z,this.#J=J,this.#Y=X,this.#X=Y,this.#Y===0){if(this.isUNC()){let[$,Q,K,W,...G]=this.#Z,[z,v,H,V,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let F=[$,Q,K,W,""].join("/"),w=[z,v,H,V,""].join("/");this.#Z=[F,...G],this.#J=[w,...q],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[$,...Q]=this.#Z,[K,...W]=this.#J;if(Q[0]==="")Q.shift(),W.shift();let G=$+"/",z=K+"/";this.#Z=[G,...Q],this.#J=[z,...W],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]===J6}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 Q3(this.#Z,this.#J,this.#Y+1,this.#X),this.#$.#G=this.#G,this.#$.#W=this.#W,this.#$.#H=this.#H,this.#$}isUNC(){let Z=this.#Z;return this.#W!==void 0?this.#W:this.#W=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.#H!==void 0?this.#H:this.#H=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.#G!==void 0?this.#G:this.#G=Z[0]===""&&Z.length>1||this.isDrive()||this.isUNC()}root(){let Z=this.#Z[0];return typeof Z==="string"&&this.isAbsolute()&&this.#Y===0?Z:""}checkFollowGlobstar(){return!(this.#Y===0||!this.isGlobstar()||!this.#z)}markFollowGlobstar(){if(this.#Y===0||!this.isGlobstar()||!this.#z)return!1;return this.#z=!1,!0}}var TU1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class BG{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:Y,noglobstar:$,platform:Q=TU1}){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 V4(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let Y=J.set[X],$=J.globParts[X];if(!Y||!$)throw Error("invalid pattern object");while(Y[0]==="."&&$[0]===".")Y.shift(),$.shift();let Q=new Q3(Y,$,0,this.platform),K=new V4(Q.globString(),this.mmopts),W=$[$.length-1]==="**",G=Q.isAbsolute();if(G)this.absolute.push(K);else this.relative.push(K);if(W)if(G)this.absoluteChildren.push(K);else this.relativeChildren.push(K)}}ignored(Z){let J=Z.fullpath(),X=`${J}/`,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 XR{store;constructor(Z=new Map){this.store=Z}copy(){return new XR(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 Fg{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 wg{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 Error("attempting to walk unknown path");return J}entries(){return this.keys().map((Z)=>[Z,this.store.get(Z)])}keys(){return[...this.store.keys()].filter((Z)=>Z.canReaddir())}}class LG{hasWalkedCache;matches=new Fg;subwalks=new wg;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new XR}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 W,G,z=!1;while(typeof(W=$.pattern())==="string"&&(G=$.rest()))Y=Y.resolve(W),$=G,z=!0;if(W=$.pattern(),G=$.rest(),z){if(this.hasWalkedCache.hasWalked(Y,$))continue;this.hasWalkedCache.storeWalked(Y,$)}if(typeof W==="string"){let v=W===".."||W===""||W===".";this.matches.add(Y.resolve(W),K,v);continue}else if(W===J6){if(!Y.isSymbolicLink()||this.follow||$.checkFollowGlobstar())this.subwalks.add(Y,$);let v=G?.pattern(),H=G?.rest();if(!G||(v===""||v===".")&&!H)this.matches.add(Y,K,v===""||v===".");else if(v===".."){let V=Y.parent||Y;if(!H)this.matches.add(V,K,!0);else if(!this.hasWalkedCache.hasWalked(V,H))this.subwalks.add(V,H)}}else if(W instanceof RegExp)this.subwalks.add(Y,$)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new LG(this.opts,this.hasWalkedCache)}filterEntries(Z,J){let X=this.subwalks.get(Z),Y=this.child();for(let $ of J)for(let Q of X){let K=Q.isAbsolute(),W=Q.pattern(),G=Q.rest();if(W===J6)Y.testGlobstar($,Q,G,K);else if(W instanceof RegExp)Y.testRegExp($,W,G,K);else Y.testString($,W,G,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 CU1=(Z,J)=>typeof Z==="string"?new BG([Z],J):Array.isArray(Z)?new BG(Z,J):Z;class YR{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#J;#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=CU1(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#X(Z){return this.seen.has(Z)||!!this.#J?.ignored?.(Z)}#$(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 LG(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,W,G]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,W,G).then(()=>Q())}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let W=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,W,X,Q);else K.readdirCB((G,z)=>this.walkCB3(K,z,X,Q),!0)}Q()}walkCB3(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,W,G).then(()=>Q())}for(let[K,W]of X.subwalks.entries())$++,this.walkCB2(K,W,X.child(),Q);Q()}walkCBSync(Z,J,X){if(this.signal?.aborted)X();this.walkCB2Sync(Z,J,new LG(this.opts),X)}walkCB2Sync(Z,J,X,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,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let W=K.readdirSync();this.walkCB3Sync(K,W,X,Q)}Q()}walkCB3Sync(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let[K,W]of X.subwalks.entries())$++,this.walkCB2Sync(K,W,X.child(),Q);Q()}}class AF extends YR{matches=new Set;constructor(Z,J,X){super(Z,J,X)}matchEmit(Z){this.matches.add(Z)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Z,J)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)J(this.signal.reason);else Z(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class mF extends YR{results;constructor(Z,J,X){super(Z,J,X);this.results=new CY({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 kU1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Q7{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Z,J){if(!J)throw TypeError("glob options required");if(this.withFileTypes=!!J.withFileTypes,this.signal=J.signal,this.follow=!!J.follow,this.dot=!!J.dot,this.dotRelative=!!J.dotRelative,this.nodir=!!J.nodir,this.mark=!!J.mark,!J.cwd)this.cwd="";else if(J.cwd instanceof URL||J.cwd.startsWith("file://"))J.cwd=fU1(J.cwd);if(this.cwd=J.cwd||"",this.root=J.root,this.magicalBraces=!!J.magicalBraces,this.nobrace=!!J.nobrace,this.noext=!!J.noext,this.realpath=!!J.realpath,this.absolute=J.absolute,this.includeChildMatches=J.includeChildMatches!==!1,this.noglobstar=!!J.noglobstar,this.matchBase=!!J.matchBase,this.maxDepth=typeof J.maxDepth==="number"?J.maxDepth:1/0,this.stat=!!J.stat,this.ignore=J.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof Z==="string")Z=[Z];if(this.windowsPathsNoEscape=!!J.windowsPathsNoEscape||J.allowWindowsEscape===!1,this.windowsPathsNoEscape)Z=Z.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(J.noglobstar)throw TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||kU1,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?xG:J.platform==="darwin"?bF:J.platform?jG:qg;this.scurry=new W(this.cwd,{nocase:J.nocase,fs:J.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",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((W)=>new V4(W,Y)),[Q,K]=$.reduce((W,G)=>{return W[0].push(...G.set),W[1].push(...G.globParts),W},[[],[]]);this.patterns=Q.map((W,G)=>{let z=K[G];if(!z)throw Error("invalid pattern object");return new Q3(W,z,0,this.platform)})}async walk(){return[...await new AF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new AF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new mF(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 mF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var $R=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new V4(X,J).hasMagic())return!0;return!1};function lF(Z,J={}){return new Q7(Z,J).streamSync()}function Ug(Z,J={}){return new Q7(Z,J).stream()}function xg(Z,J={}){return new Q7(Z,J).walkSync()}async function cg(Z,J={}){return new Q7(Z,J).walk()}function yF(Z,J={}){return new Q7(Z,J).iterateSync()}function jg(Z,J={}){return new Q7(Z,J).iterate()}var EU1=lF,IU1=Object.assign(Ug,{sync:lF}),_U1=yF,hU1=Object.assign(jg,{sync:yF}),SU1=Object.assign(xg,{stream:lF,iterate:yF}),uF=Object.assign(cg,{glob:cg,globSync:xg,sync:SU1,globStream:Ug,stream:IU1,globStreamSync:lF,streamSync:EU1,globIterate:jg,iterate:hU1,globIterateSync:yF,iterateSync:_U1,Glob:Q7,hasMagic:$R,escape:Z3,unescape:F9});uF.glob=uF;class QR{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 XZ{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 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 pF extends QR{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 XZ(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 DG(){return DG=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},DG.apply(this,arguments)}class U9{constructor(Z){if(this.list=[],Z)for(let J of Z)this.list.push(J)}add(Z){this.list.push(Z)}remove(Z){let J=this.list.indexOf(Z);if(J>=0)this.list.splice(J,1)}removeChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);for(let X of J)this.remove(X);return J}listRefsByChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);return J}values(){return this.list}}class w1{constructor(Z){if(this.set=new Set,this.map=new Map,Z)for(let J of Z)this.add(J)}add(Z){let J=Z.getChild();this.removeChild(J),this.set.add(Z),this.map.set(J,Z)}remove(Z){this.set.delete(Z),this.map.delete(Z.getChild())}removeChild(Z){let J=this.map.get(Z)||null;if(J)this.remove(J);return J}getRefByChild(Z){return this.map.get(Z)||null}values(){return Array.from(this.set)}}class A6{constructor(Z){if(this.map={},Z)Object.assign(this.map,Z)}set(Z,J){this.map[Z]=J}delete(Z){delete this.map[Z]}get(Z){return this.map[Z]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}}var H1=Symbol("attributes"),hJ=Symbol("immutableKeys");class iF extends QR{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[H1]=void 0,this[hJ]=void 0,this.graph=Z,this[hJ]=new Set,this[H1]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let Y=Z[X];if(Y instanceof iF){let $=this.graph._createEdge(X,this,Y);this[hJ].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[H1]){let Y=this[H1][X];if(Y instanceof XZ){let $=Y;if($.getChild()===Z)this.setRef(X,J,$.getAttributes())}else if(Y instanceof U9)for(let $ of Y.listRefsByChild(Z)){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if(Y instanceof w1){let $=Y.getRefByChild(Z);if($){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if(Y instanceof A6)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[H1][Z]}set(Z,J){return this[H1][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[H1][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[hJ].has(Z))throw Error(`Cannot overwrite immutable attribute, "${Z}".`);let Y=this[H1][Z];if(Y)Y.dispose();if(!J)return this;let $=this.graph._createEdge(Z,this,J,X);return this[H1][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 U9)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[H1][Z];if(J instanceof U9||J instanceof w1)return J;throw Error(`Expected RefList or RefSet for attribute "${Z}"`)}listRefMapKeys(Z){return this.assertRefMap(Z).keys()}listRefMapValues(Z){return this.assertRefMap(Z).values().map((J)=>J.getChild())}getRefMap(Z,J){let 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,DG({},Y,{key:J}));return $.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[H1][Z];if(J instanceof A6)return J;throw Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(DG({},Z,{target:this})),this.graph.dispatchEvent(DG({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[H1][J]===Z){if(this[H1][J]=null,this[hJ].has(J))Z.getChild().dispose()}else if(this[H1][J]instanceof U9)this[H1][J].remove(Z);else if(this[H1][J]instanceof w1)this[H1][J].remove(Z);else if(this[H1][J]instanceof A6){let X=this[H1][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 Pg="v4.2.1",EY="@glb.bin",i;(function(Z){Z.ACCESSOR="Accessor",Z.ANIMATION="Animation",Z.ANIMATION_CHANNEL="AnimationChannel",Z.ANIMATION_SAMPLER="AnimationSampler",Z.BUFFER="Buffer",Z.CAMERA="Camera",Z.MATERIAL="Material",Z.MESH="Mesh",Z.PRIMITIVE="Primitive",Z.PRIMITIVE_TARGET="PrimitiveTarget",Z.NODE="Node",Z.ROOT="Root",Z.SCENE="Scene",Z.SKIN="Skin",Z.TEXTURE="Texture",Z.TEXTURE_INFO="TextureInfo"})(i||(i={}));var oF;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(oF||(oF={}));var h5;(function(Z){Z.ARRAY_BUFFER="ARRAY_BUFFER",Z.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",Z.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",Z.OTHER="OTHER",Z.SPARSE="SPARSE"})(h5||(h5={}));var v5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(v5||(v5={}));var YZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(YZ||(YZ={}));var bJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array};class E0{static createBufferFromDataURI(Z){if(typeof Buffer>"u"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let 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 Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class VR{static hexToFactor(Z,J){Z=Math.floor(Z);let X=J;return X[0]=(Z>>16&255)/255,X[1]=(Z>>8&255)/255,X[2]=(Z&255)/255,this.convertSRGBToLinear(J,J)}static factorToHex(Z){let J=[...Z],[X,Y,$]=this.convertLinearToSRGB(Z,J);return X*255<<16^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 Og{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),bU1(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 TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class eF{match(Z){return Z.length>=8&&Z[0]===137&&Z[1]===80&&Z[2]===78&&Z[3]===71&&Z[4]===13&&Z[5]===10&&Z[6]===26&&Z[7]===10}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset);if(E0.decodeText(Z.slice(12,16))===eF.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}}eF.PNG_FRIED_CHUNK_NAME="CgBI";class _5{static registerFormat(Z,J){this.impls[Z]=J}static getMimeType(Z){for(let J in this.impls)if(this.impls[J].match(Z))return J;return null}static getSize(Z,J){if(!this.impls[J])return null;return this.impls[J].getSize(Z)}static getChannels(Z,J){if(!this.impls[J])return null;return this.impls[J].getChannels(Z)}static getVRAMByteLength(Z,J){if(!this.impls[J])return null;if(this.impls[J].getVRAMByteLength)return this.impls[J].getVRAMByteLength(Z);let X=0,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}`}}_5.impls={"image/jpeg":new Og,"image/png":new eF};function bU1(Z,J){if(J>Z.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw TypeError("Invalid JPG, marker table corrupted");return Z}class $Z{static basename(Z){let J=Z.split(/[\\/]/).pop();return J.substring(0,J.lastIndexOf("."))}static extension(Z){if(Z.startsWith("data:image/")){let J=Z.match(/data:(image\/\w+)/)[1];return _5.mimeTypeToExtension(J)}else if(Z.startsWith("data:model/gltf+json"))return"gltf";else if(Z.startsWith("data:model/gltf-binary"))return"glb";else if(Z.startsWith("data:application/"))return"bin";return Z.split(/[\\/]/).pop().split(/[.]/).pop()}}var WR=typeof Float32Array<"u"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function AU1(){var Z=new WR(3);if(WR!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function KR(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function mU1(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=AU1();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();function NG(Z){let J=Tg(),X=Z.propertyType===i.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=uU1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))GR(K.min,J),GR(K.max,J)});return J}function uU1(Z,J){let X=Tg();for(let Y of Z.listPrimitives()){let $=Y.getAttribute("POSITION"),Q=Y.getIndices();if(!$)continue;let K=[0,0,0],W=[0,0,0];for(let G=0,z=Q?Q.getCount():$.getCount();G<z;G++){let v=Q?Q.getScalar(G):G;K=$.getElement(v,K),W=mU1(W,K,J),GR(W,X)}}return X}function GR(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 Tg(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}var Bg="https://null.example";class F4{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return $Z.basename(new URL(Z,Bg).pathname)}static extension(Z){return $Z.extension(new URL(Z,Bg).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)}}F4.DEFAULT_INIT={};F4.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;function Lg(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function kY(Z){if(Lg(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Lg(X)===!1)return!1;if(Object.hasOwn(X,"isPrototypeOf")===!1)return!1;return!0}var zR,MG;(function(Z){Z[Z.SILENT=4]="SILENT",Z[Z.ERROR=3]="ERROR",Z[Z.WARN=2]="WARN",Z[Z.INFO=1]="INFO",Z[Z.DEBUG=0]="DEBUG"})(MG||(MG={}));class z5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=z5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=z5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=z5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=z5.Verbosity.ERROR)console.error(Z)}}zR=z5;z5.Verbosity=MG;z5.DEFAULT_INSTANCE=new zR(zR.Verbosity.INFO);function lU1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],w=Z[14],c=Z[15],U=J*K-X*Q,j=J*W-Y*Q,B=J*G-$*Q,L=X*W-Y*K,R=X*G-$*K,M=Y*G-$*W,N=z*F-v*q,P=z*w-H*q,O=z*c-V*q,k=v*w-H*F,E=v*c-V*F,S=H*c-V*w;return U*S-j*E+B*k+L*O-R*P+M*N}function yU1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],w=J[12],c=J[13],U=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*Y+L*W+R*H+M*w,Z[1]=B*$+L*G+R*V+M*c,Z[2]=B*Q+L*z+R*q+M*U,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*Y+L*W+R*H+M*w,Z[5]=B*$+L*G+R*V+M*c,Z[6]=B*Q+L*z+R*q+M*U,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*Y+L*W+R*H+M*w,Z[9]=B*$+L*G+R*V+M*c,Z[10]=B*Q+L*z+R*q+M*U,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*Y+L*W+R*H+M*w,Z[13]=B*$+L*G+R*V+M*c,Z[14]=B*Q+L*z+R*q+M*U,Z[15]=B*K+L*v+R*F+M*j,Z}function pU1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],z=J[9],v=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,z,v),Z}function iU1(Z,J){var X=new WR(3);pU1(X,J);var Y=1/X[0],$=1/X[1],Q=1/X[2],K=J[0]*Y,W=J[1]*$,G=J[2]*Q,z=J[4]*Y,v=J[5]*$,H=J[6]*Q,V=J[8]*Y,q=J[9]*$,F=J[10]*Q,w=K+v+F,c=0;if(w>0)c=Math.sqrt(w+1)*2,Z[3]=0.25*c,Z[0]=(H-q)/c,Z[1]=(V-G)/c,Z[2]=(W-z)/c;else if(K>v&&K>F)c=Math.sqrt(1+K-v-F)*2,Z[3]=(H-q)/c,Z[0]=0.25*c,Z[1]=(W+z)/c,Z[2]=(V+G)/c;else if(v>F)c=Math.sqrt(1+v-K-F)*2,Z[3]=(V-G)/c,Z[0]=(W+z)/c,Z[1]=0.25*c,Z[2]=(H+q)/c;else c=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/c,Z[0]=(V+G)/c,Z[1]=(H+q)/c,Z[2]=0.25*c;return Z}class I0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let 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 Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(I0.clamp(Z,0,1)*65535);case 5121:return Math.round(I0.clamp(Z,0,1)*255);case 5122:return Math.round(I0.clamp(Z,-1,1)*32767);case 5120:return Math.round(I0.clamp(Z,-1,1)*127);default:throw Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=KR([Z[0],Z[1],Z[2]]),Q=KR([Z[4],Z[5],Z[6]]),K=KR([Z[8],Z[9],Z[10]]);if(lU1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),z=1/$,v=1/Q,H=1/K;G[0]*=z,G[1]*=z,G[2]*=z,G[4]*=v,G[5]*=v,G[6]*=v,G[8]*=H,G[9]*=H,G[10]*=H,iU1(X,G),Y[0]=$,Y[1]=Q,Y[2]=K}static compose(Z,J,X,Y){let $=Y,Q=J[0],K=J[1],W=J[2],G=J[3],z=Q+Q,v=K+K,H=W+W,V=Q*z,q=Q*v,F=Q*H,w=K*v,c=K*H,U=W*H,j=G*z,B=G*v,L=G*H,R=X[0],M=X[1],N=X[2];return $[0]=(1-(w+U))*R,$[1]=(q+L)*R,$[2]=(F-B)*R,$[3]=0,$[4]=(q-L)*M,$[5]=(1-(V+U))*M,$[6]=(c+j)*M,$[7]=0,$[8]=(F+B)*N,$[9]=(c-j)*N,$[10]=(1-(V+w))*N,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function gU1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function dU1(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 aU1(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 W=Q.getChild(),G=K.getChild();if(W===G)continue;if(!W.equals(G))return!1}return!0}function Cg(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 fg(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!kY(Z)||!kY(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 W=X[K],G=Y[K];if(rF(W)&&rF(G)){if(!Cg(W,G))return!1}else if(kY(W)&&kY(G)){if(!fg(W,G))return!1}else if(W!==G)return!1}return!0}function rF(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Dg="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",nU1=999,sU1=6,Mg=new Set,oU1=function(){let J="";for(let X=0;X<sU1;X++)J+=Dg.charAt(Math.floor(Math.random()*Dg.length));return J},kg=function(){for(let J=0;J<nU1;J++){let X=oU1();if(!Mg.has(X))return Mg.add(X),X}return""},SJ=(Z)=>Z,rU1=new Set;class Zw extends iF{constructor(Z,J=""){super(Z);this[H1].name=J,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(Z,J){if(Array.isArray(J))J=J.slice();return super.set(Z,J)}getName(){return this.get("name")}setName(Z){return this.set("name",Z)}getExtras(){return this.get("extras")}setExtras(Z){return this.set("extras",Z)}clone(){return new this.constructor(this.graph).copy(this,SJ)}copy(Z,J=SJ){for(let X in this[H1]){let Y=this[H1][X];if(Y instanceof XZ){if(!this[hJ].has(X))Y.dispose()}else if(Y instanceof U9||Y instanceof w1)for(let $ of Y.values())$.dispose();else if(Y instanceof A6)for(let $ of Y.values())$.dispose()}for(let X in Z[H1]){let Y=this[H1][X],$=Z[H1][X];if($ instanceof XZ)if(this[hJ].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof w1||$ instanceof U9)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof A6)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(kY($))this[H1][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[H1][X]=$.slice();else this[H1][X]=$}return this}equals(Z,J=rU1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[H1]){if(J.has(X))continue;let Y=this[H1][X],$=Z[H1][X];if(Y instanceof XZ||$ instanceof XZ){if(!gU1(Y,$))return!1}else if(Y instanceof w1||$ instanceof w1||Y instanceof U9||$ instanceof U9){if(!dU1(Y,$))return!1}else if(Y instanceof A6||$ instanceof A6){if(!aU1(Y,$))return!1}else if(kY(Y)||kY($)){if(!fg(Y,$))return!1}else if(rF(Y)||rF($)){if(!Cg(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 U6 extends Zw{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new A6})}getExtension(Z){return this.getRefMap("extensions",Z)}setExtension(Z,J){if(J)J._validateParent(this);return this.setRefMap("extensions",Z,J)}listExtensions(){return this.listRefMapValues("extensions")}}class K0 extends U6{init(){this.propertyType=i.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:K0.Type.SCALAR,componentType:K0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case K0.Type.SCALAR:return 1;case K0.Type.VEC2:return 2;case K0.Type.VEC3:return 3;case K0.Type.VEC4:return 4;case K0.Type.MAT2:return 4;case K0.Type.MAT3:return 9;case K0.Type.MAT4:return 16;default:throw Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case K0.ComponentType.BYTE:return 1;case K0.ComponentType.UNSIGNED_BYTE:return 1;case K0.ComponentType.SHORT:return 2;case K0.ComponentType.UNSIGNED_SHORT:return 2;case K0.ComponentType.UNSIGNED_INT:return 4;case K0.ComponentType.FLOAT:return 4;default:throw Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),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 K0.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(Z){return this.set("normalized",Z)}getScalar(Z){let J=this.getElementSize(),X=this.getComponentType(),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?tU1(Z):K0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}K0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};K0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function tU1(Z){switch(Z.constructor){case Float32Array:return K0.ComponentType.FLOAT;case Uint32Array:return K0.ComponentType.UNSIGNED_INT;case Uint16Array:return K0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return K0.ComponentType.UNSIGNED_BYTE;case Int16Array:return K0.ComponentType.SHORT;case Int8Array:return K0.ComponentType.BYTE;default:throw Error("Unknown accessor componentType.")}}class HR extends U6{init(){this.propertyType=i.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new w1,samplers:new w1})}addChannel(Z){return this.addRef("channels",Z)}removeChannel(Z){return this.removeRef("channels",Z)}listChannels(){return this.listRefs("channels")}addSampler(Z){return this.addRef("samplers",Z)}removeSampler(Z){return this.removeRef("samplers",Z)}listSamplers(){return this.listRefs("samplers")}}class QZ extends U6{init(){this.propertyType=i.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(Z){return this.set("targetPath",Z)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(Z){return this.setRef("targetNode",Z)}getSampler(){return this.getRef("sampler")}setSampler(Z){return this.setRef("sampler",Z)}}QZ.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class AJ extends U6{init(){this.propertyType=i.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:AJ.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(Z){return this.set("interpolation",Z)}getInput(){return this.getRef("input")}setInput(Z){return this.setRef("input",Z,{usage:h5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:h5.OTHER})}}AJ.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class qR extends U6{init(){this.propertyType=i.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class IY extends U6{init(){this.propertyType=i.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:IY.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)}}IY.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class O1 extends Zw{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}O1.EXTENSION_NAME=void 0;class F1 extends U6{init(){this.propertyType=i.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:F1.WrapMode.REPEAT,wrapT:F1.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}getMagFilter(){return this.get("magFilter")}setMagFilter(Z){return this.set("magFilter",Z)}getMinFilter(){return this.get("minFilter")}setMinFilter(Z){return this.set("minFilter",Z)}getWrapS(){return this.get("wrapS")}setWrapS(Z){return this.set("wrapS",Z)}getWrapT(){return this.get("wrapT")}setWrapT(Z){return this.set("wrapT",Z)}}F1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};F1.MagFilter={NEAREST:9728,LINEAR:9729};F1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:gF,G:dF,B:aF,A:eU1}=v5;class K7 extends U6{init(){this.propertyType=i.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:K7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new F1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new F1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new F1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new F1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new F1(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(Z){return this.set("doubleSided",Z)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(Z){let J=this.get("baseColorFactor").slice();return J[3]=Z,this.set("baseColorFactor",J)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(Z){return this.set("alphaMode",Z)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(Z){return this.set("alphaCutoff",Z)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(Z){return this.set("baseColorFactor",Z)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(Z){return this.setRef("baseColorTexture",Z,{channels:gF|dF|aF|eU1,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:gF|dF|aF,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:gF|dF|aF})}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:gF})}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:dF|aF})}}K7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class PG extends U6{init(){this.propertyType=i.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new w1})}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 Jw extends U6{init(){this.propertyType=i.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new w1})}copy(Z,J=SJ){if(J===SJ)throw Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return I0.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),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())yU1(X,X,J.getMatrix());return X}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);for(let X of Z.listParents())if(X.propertyType===i.SCENE)X.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}getParentNode(){for(let Z of this.listParents())if(Z.propertyType===i.NODE)return Z;return null}getMesh(){return this.getRef("mesh")}setMesh(Z){return this.setRef("mesh",Z)}getCamera(){return this.getRef("camera")}setCamera(Z){return this.setRef("camera",Z)}getSkin(){return this.getRef("skin")}setSkin(Z){return this.setRef("skin",Z)}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}traverse(Z){Z(this);for(let J of this.listChildren())J.traverse(Z);return this}}class g1 extends U6{init(){this.propertyType=i.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:g1.Mode.TRIANGLES,material:null,indices:null,attributes:new A6,targets:new w1})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:h5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:h5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}getMode(){return this.get("mode")}setMode(Z){return this.set("mode",Z)}listTargets(){return this.listRefs("targets")}addTarget(Z){return this.addRef("targets",Z)}removeTarget(Z){return this.removeRef("targets",Z)}}g1.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class FR extends Zw{init(){this.propertyType=i.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:h5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function m6(){return m6=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},m6.apply(null,arguments)}class K3 extends U6{init(){this.propertyType=i.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new w1})}copy(Z,J=SJ){if(J===SJ)throw Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class wR extends U6{init(){this.propertyType=i.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new w1})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(Z){return this.setRef("skeleton",Z)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(Z){return this.setRef("inverseBindMatrices",Z,{usage:h5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class _Y extends U6{init(){this.propertyType=i.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||_5.extensionToMimeType($Z.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=_5.extensionToMimeType($Z.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",E0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return _5.getSize(Z,this.getMimeType())}}class W3 extends U6{init(){this.propertyType=i.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Pg}`,version:"2.0"},defaultScene:null,accessors:new w1,animations:new w1,buffers:new w1,cameras:new w1,materials:new w1,meshes:new w1,nodes:new w1,scenes:new w1,skins:new w1,textures:new w1})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw Error("Root cannot be cloned.")}copy(Z,J=SJ){if(J===SJ)throw Error("Root cannot be copied.");this.set("asset",m6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(m6({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let Y=Z.getExtension(X);this.setExtension(X,J(Y))}return this}_addChildOfRoot(Z){if(Z instanceof K3)this.addRef("scenes",Z);else if(Z instanceof Jw)this.addRef("nodes",Z);else if(Z instanceof IY)this.addRef("cameras",Z);else if(Z instanceof wR)this.addRef("skins",Z);else if(Z instanceof PG)this.addRef("meshes",Z);else if(Z instanceof K7)this.addRef("materials",Z);else if(Z instanceof _Y)this.addRef("textures",Z);else if(Z instanceof HR)this.addRef("animations",Z);else if(Z instanceof K0)this.addRef("accessors",Z);else if(Z instanceof qR)this.addRef("buffers",Z);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((Z)=>Z.isRequired())}_enableExtension(Z){return this._extensions.add(Z),this}_disableExtension(Z){return this._extensions.delete(Z),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(Z){return this.setRef("defaultScene",Z)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class c6{static fromGraph(Z){return c6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new pF,this._root=new W3(this._graph),this._logger=z5.DEFAULT_INSTANCE,c6._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find((Y)=>Y.extensionName===J)||new Z(this)}createScene(Z=""){return new K3(this._graph,Z)}createNode(Z=""){return new Jw(this._graph,Z)}createCamera(Z=""){return new IY(this._graph,Z)}createSkin(Z=""){return new wR(this._graph,Z)}createMesh(Z=""){return new PG(this._graph,Z)}createPrimitive(){return new g1(this._graph)}createPrimitiveTarget(Z=""){return new FR(this._graph,Z)}createMaterial(Z=""){return new K7(this._graph,Z)}createTexture(Z=""){return new _Y(this._graph,Z)}createAnimation(Z=""){return new HR(this._graph,Z)}createAnimationChannel(Z=""){return new QZ(this._graph,Z)}createAnimationSampler(Z=""){return new AJ(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new K0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new qR(this._graph,Z)}}c6._GRAPH_DOCUMENTS=new WeakMap;class T1{constructor(Z){this.extensionName="",this.prereadTypes=[],this.prewriteTypes=[],this.readDependencies=[],this.writeDependencies=[],this.document=void 0,this.required=!1,this.properties=new Set,this._listener=void 0,this.document=Z,Z.getRoot()._enableExtension(this),this._listener=(X)=>{let Y=X,$=Y.target;if($ instanceof O1&&$.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}}T1.EXTENSION_NAME=void 0;class Eg{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 Rg={logger:z5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},Zx1=new Set([i.BUFFER,i.TEXTURE,i.MATERIAL,i.MESH,i.PRIMITIVE,i.NODE,i.SCENE]);class Ig{static read(Z,J=Rg){let X=m6({},Rg,J),{json:Y}=Z,$=new c6().setLogger(X.logger);this.validate(Z,X);let Q=new Eg(Z),K=Y.asset,W=$.getRoot().getAsset();if(K.copyright)W.copyright=K.copyright;if(K.extras)W.extras=K.extras;if(Y.extras!==void 0)$.getRoot().setExtras(m6({},Y.extras));let G=Y.extensionsUsed||[],z=Y.extensionsRequired||[];X.extensions.sort((M,N)=>M.EXTENSION_NAME>N.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let N=$.createExtension(M).setRequired(z.includes(M.EXTENSION_NAME)),P=N.prereadTypes.filter((O)=>!Zx1.has(O));if(P.length)X.logger.warn(`Preread hooks for some types (${P.join()}), requested by extension ${N.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of N.readDependencies)N.install(O,X.dependencies[O])}let v=Y.buffers||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.BUFFER)).forEach((M)=>M.preread(Q,i.BUFFER)),Q.buffers=v.map((M)=>{let N=$.createBuffer(M.name);if(M.extras)N.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)N.setURI(M.uri);return N});let H=Y.bufferViews||[];Q.bufferViewBuffers=H.map((M,N)=>{if(!Q.bufferViews[N]){let P=Z.json.buffers[M.buffer],O=P.uri?Z.resources[P.uri]:Z.resources[EY],k=M.byteOffset||0;Q.bufferViews[N]=E0.toView(O,k,M.byteLength)}return Q.buffers[M.buffer]});let V=Y.accessors||[];Q.accessors=V.map((M)=>{let N=Q.bufferViewBuffers[M.bufferView],P=$.createAccessor(M.name,N).setType(M.type);if(M.extras)P.setExtras(M.extras);if(M.normalized!==void 0)P.setNormalized(M.normalized);if(M.bufferView===void 0)return P;return P.setArray(sF(M,Q)),P});let q=Y.images||[],F=Y.textures||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.TEXTURE)).forEach((M)=>M.preread(Q,i.TEXTURE)),Q.textures=q.map((M)=>{let N=$.createTexture(M.name);if(M.extras)N.setExtras(M.extras);if(M.bufferView!==void 0){let P=Y.bufferViews[M.bufferView],O=Z.json.buffers[P.buffer],k=O.uri?Z.resources[O.uri]:Z.resources[EY],E=P.byteOffset||0,S=P.byteLength,f=k.slice(E,E+S);N.setImage(f)}else if(M.uri!==void 0){if(N.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)N.setURI(M.uri)}if(M.mimeType!==void 0)N.setMimeType(M.mimeType);else if(M.uri){let P=$Z.extension(M.uri);N.setMimeType(_5.extensionToMimeType(P))}return N}),$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MATERIAL)).forEach((M)=>M.preread(Q,i.MATERIAL));let w=Y.materials||[];Q.materials=w.map((M)=>{let N=$.createMaterial(M.name);if(M.extras)N.setExtras(M.extras);if(M.alphaMode!==void 0)N.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)N.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)N.setDoubleSided(M.doubleSided);let P=M.pbrMetallicRoughness||{};if(P.baseColorFactor!==void 0)N.setBaseColorFactor(P.baseColorFactor);if(M.emissiveFactor!==void 0)N.setEmissiveFactor(M.emissiveFactor);if(P.metallicFactor!==void 0)N.setMetallicFactor(P.metallicFactor);if(P.roughnessFactor!==void 0)N.setRoughnessFactor(P.roughnessFactor);if(P.baseColorTexture!==void 0){let O=P.baseColorTexture,k=Q.textures[F[O.index].source];N.setBaseColorTexture(k),Q.setTextureInfo(N.getBaseColorTextureInfo(),O)}if(M.emissiveTexture!==void 0){let O=M.emissiveTexture,k=Q.textures[F[O.index].source];N.setEmissiveTexture(k),Q.setTextureInfo(N.getEmissiveTextureInfo(),O)}if(M.normalTexture!==void 0){let O=M.normalTexture,k=Q.textures[F[O.index].source];if(N.setNormalTexture(k),Q.setTextureInfo(N.getNormalTextureInfo(),O),M.normalTexture.scale!==void 0)N.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let O=M.occlusionTexture,k=Q.textures[F[O.index].source];if(N.setOcclusionTexture(k),Q.setTextureInfo(N.getOcclusionTextureInfo(),O),M.occlusionTexture.strength!==void 0)N.setOcclusionStrength(M.occlusionTexture.strength)}if(P.metallicRoughnessTexture!==void 0){let O=P.metallicRoughnessTexture,k=Q.textures[F[O.index].source];N.setMetallicRoughnessTexture(k),Q.setTextureInfo(N.getMetallicRoughnessTextureInfo(),O)}return N}),$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MESH)).forEach((M)=>M.preread(Q,i.MESH));let c=Y.meshes||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.PRIMITIVE)).forEach((M)=>M.preread(Q,i.PRIMITIVE)),Q.meshes=c.map((M)=>{let N=$.createMesh(M.name);if(M.extras)N.setExtras(M.extras);if(M.weights!==void 0)N.setWeights(M.weights);return(M.primitives||[]).forEach((O)=>{let k=$.createPrimitive();if(O.extras)k.setExtras(O.extras);if(O.material!==void 0)k.setMaterial(Q.materials[O.material]);if(O.mode!==void 0)k.setMode(O.mode);for(let[f,C]of Object.entries(O.attributes||{}))k.setAttribute(f,Q.accessors[C]);if(O.indices!==void 0)k.setIndices(Q.accessors[O.indices]);let E=M.extras&&M.extras.targetNames||[];(O.targets||[]).forEach((f,C)=>{let h=E[C]||C.toString(),_=$.createPrimitiveTarget(h);for(let[a,s]of Object.entries(f))_.setAttribute(a,Q.accessors[s]);k.addTarget(_)}),N.addPrimitive(k)}),N});let U=Y.cameras||[];Q.cameras=U.map((M)=>{let N=$.createCamera(M.name).setType(M.type);if(M.extras)N.setExtras(M.extras);if(M.type===IY.Type.PERSPECTIVE){let P=M.perspective;if(N.setYFov(P.yfov),N.setZNear(P.znear),P.zfar!==void 0)N.setZFar(P.zfar);if(P.aspectRatio!==void 0)N.setAspectRatio(P.aspectRatio)}else{let P=M.orthographic;N.setZNear(P.znear).setZFar(P.zfar).setXMag(P.xmag).setYMag(P.ymag)}return N});let j=Y.nodes||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.NODE)).forEach((M)=>M.preread(Q,i.NODE)),Q.nodes=j.map((M)=>{let N=$.createNode(M.name);if(M.extras)N.setExtras(M.extras);if(M.translation!==void 0)N.setTranslation(M.translation);if(M.rotation!==void 0)N.setRotation(M.rotation);if(M.scale!==void 0)N.setScale(M.scale);if(M.matrix!==void 0){let P=[0,0,0],O=[0,0,0,1],k=[1,1,1];I0.decompose(M.matrix,P,O,k),N.setTranslation(P),N.setRotation(O),N.setScale(k)}if(M.weights!==void 0)N.setWeights(M.weights);return N});let B=Y.skins||[];Q.skins=B.map((M)=>{let N=$.createSkin(M.name);if(M.extras)N.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)N.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)N.setSkeleton(Q.nodes[M.skeleton]);for(let P of M.joints)N.addJoint(Q.nodes[P]);return N}),j.map((M,N)=>{let P=Q.nodes[N];if((M.children||[]).forEach((k)=>P.addChild(Q.nodes[k])),M.mesh!==void 0)P.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)P.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)P.setSkin(Q.skins[M.skin])});let L=Y.animations||[];Q.animations=L.map((M)=>{let N=$.createAnimation(M.name);if(M.extras)N.setExtras(M.extras);let O=(M.samplers||[]).map((E)=>{let S=$.createAnimationSampler().setInput(Q.accessors[E.input]).setOutput(Q.accessors[E.output]).setInterpolation(E.interpolation||AJ.Interpolation.LINEAR);if(E.extras)S.setExtras(E.extras);return N.addSampler(S),S});return(M.channels||[]).forEach((E)=>{let S=$.createAnimationChannel().setSampler(O[E.sampler]).setTargetPath(E.target.path);if(E.target.node!==void 0)S.setTargetNode(Q.nodes[E.target.node]);if(E.extras)S.setExtras(E.extras);N.addChannel(S)}),N});let R=Y.scenes||[];if($.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.SCENE)).forEach((M)=>M.preread(Q,i.SCENE)),Q.scenes=R.map((M)=>{let N=$.createScene(M.name);if(M.extras)N.setExtras(M.extras);return(M.nodes||[]).map((O)=>Q.nodes[O]).forEach((O)=>N.addChild(O)),N}),Y.scene!==void 0)$.getRoot().setDefaultScene(Q.scenes[Y.scene]);return $.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),V.forEach((M,N)=>{let P=Q.accessors[N],O=!!M.sparse,k=!M.bufferView&&!P.getArray();if(O||k)P.setSparse(!0).setArray(Xx1(M,Q))}),$}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let Y of X.extensionsRequired)if(!J.extensions.find(($)=>$.EXTENSION_NAME===Y))throw 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 Jx1(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=bJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,z=new Q(Z.count*K),v=new DataView(Y.buffer,Y.byteOffset,Y.byteLength),H=$.byteStride;for(let V=0;V<Z.count;V++)for(let q=0;q<K;q++){let F=G+V*H+q*W,w;switch(Z.componentType){case K0.ComponentType.FLOAT:w=v.getFloat32(F,!0);break;case K0.ComponentType.UNSIGNED_INT:w=v.getUint32(F,!0);break;case K0.ComponentType.UNSIGNED_SHORT:w=v.getUint16(F,!0);break;case K0.ComponentType.UNSIGNED_BYTE:w=v.getUint8(F);break;case K0.ComponentType.SHORT:w=v.getInt16(F,!0);break;case K0.ComponentType.BYTE:w=v.getInt8(F);break;default:throw Error(`Unexpected componentType "${Z.componentType}".`)}z[V*K+q]=w}return z}function sF(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=bJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if($.byteStride!==void 0&&$.byteStride!==G)return Jx1(Z,J);let z=Y.byteOffset+(Z.byteOffset||0),v=Z.count*K*W;return new Q(Y.buffer.slice(z,z+v))}function Xx1(Z,J){let X=bJ[Z.componentType],Y=K0.getElementSize(Z.type),$;if(Z.bufferView!==void 0)$=sF(Z,J);else $=new X(Z.count*Y);let Q=Z.sparse;if(!Q)return $;let K=Q.count,W=m6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=m6({},Z,Q.values,{count:K}),z=sF(W,J),v=sF(G,J);for(let H=0;H<W.count;H++)for(let V=0;V<Y;V++)$[z[H]*Y+V]=v[H*Y+V];return $}var RG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(RG||(RG={}));class w4{constructor(Z,J,X){this._doc=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this._accessorUsageMap=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this._doc=Z,this.jsonDoc=J,this.options=X;let Y=Z.getRoot(),$=Y.listBuffers().length,Q=Y.listTextures().length;this.bufferURIGenerator=new vR($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new vR(Q>1,(K)=>Yx1(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===YZ.GLB)this.imageBufferViews.push(J),Z.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:J.byteLength});else{let Y=_5.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 Error($)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return h5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:Y}=X.getAttributes();if(Y)return Y;if(X.getParent().propertyType!==i.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return h5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}w4.BufferViewTarget=RG;w4.BufferViewUsage=h5;w4.USAGE_TO_TARGET={[h5.ARRAY_BUFFER]:RG.ARRAY_BUFFER,[h5.ELEMENT_ARRAY_BUFFER]:RG.ELEMENT_ARRAY_BUFFER};class vR{constructor(Z,J){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=Z,this.basename=J}createURI(Z,J){if(Z.getURI())return Z.getURI();else if(!this.multiple)return`${this.basename(Z)}.${J}`;else{let X=this.basename(Z);return this.counter[X]=this.counter[X]||1,`${X}_${this.counter[X]++}.${J}`}}}function Yx1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:nF}=w4,{UNSIGNED_INT:$x1,UNSIGNED_SHORT:Qx1,UNSIGNED_BYTE:Kx1}=K0.ComponentType,Wx1=new Set([i.ACCESSOR,i.BUFFER,i.MATERIAL,i.MESH]);class _g{static write(Z,J){let X=Z.getGraph(),Y=Z.getRoot(),$={asset:m6({generator:`glTF-Transform ${Pg}`},Y.getAsset()),extras:m6({},Y.getExtras())},Q={json:$,resources:{}},K=new w4(Z,Q,J),W=J.logger||z5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((c)=>c.EXTENSION_NAME)),z=Z.getRoot().listExtensionsUsed().filter((c)=>G.has(c.extensionName)).sort((c,U)=>c.extensionName>U.extensionName?1:-1),v=Z.getRoot().listExtensionsRequired().filter((c)=>G.has(c.extensionName)).sort((c,U)=>c.extensionName>U.extensionName?1:-1);if(z.length<Z.getRoot().listExtensionsUsed().length)W.warn("Some extensions were not registered for I/O, and will not be written.");for(let c of z){let U=c.prewriteTypes.filter((j)=>!Wx1.has(j));if(U.length)W.warn(`Prewrite hooks for some types (${U.join()}), requested by extension ${c.extensionName}, are unsupported. Please file an issue or a PR.`);for(let j of c.writeDependencies)c.install(j,J.dependencies[j])}function H(c,U,j,B){let L=[],R=0;for(let P of c){let O=K.createAccessorDef(P);O.bufferView=$.bufferViews.length;let k=P.getArray(),E=E0.pad(E0.toView(k));O.byteOffset=R,R+=E.byteLength,L.push(E),K.accessorIndexMap.set(P,$.accessors.length),$.accessors.push(O)}let M=E0.concat(L),N={buffer:U,byteOffset:j,byteLength:M.byteLength};if(B)N.target=B;return $.bufferViews.push(N),{buffers:L,byteLength:R}}function V(c,U,j){let B=c[0].getCount(),L=0;for(let O of c){let k=K.createAccessorDef(O);k.bufferView=$.bufferViews.length,k.byteOffset=L;let E=O.getElementSize(),S=O.getComponentSize();L+=E0.padNumber(E*S),K.accessorIndexMap.set(O,$.accessors.length),$.accessors.push(k)}let R=B*L,M=new ArrayBuffer(R),N=new DataView(M);for(let O=0;O<B;O++){let k=0;for(let E of c){let S=E.getElementSize(),f=E.getComponentSize(),C=E.getComponentType(),h=E.getArray();for(let _=0;_<S;_++){let a=O*L+k+_*f,s=h[O*S+_];switch(C){case K0.ComponentType.FLOAT:N.setFloat32(a,s,!0);break;case K0.ComponentType.BYTE:N.setInt8(a,s);break;case K0.ComponentType.SHORT:N.setInt16(a,s,!0);break;case K0.ComponentType.UNSIGNED_BYTE:N.setUint8(a,s);break;case K0.ComponentType.UNSIGNED_SHORT:N.setUint16(a,s,!0);break;case K0.ComponentType.UNSIGNED_INT:N.setUint32(a,s,!0);break;default:throw Error("Unexpected component type: "+C)}}k+=E0.padNumber(S*f)}}let P={buffer:U,byteOffset:j,byteLength:R,byteStride:L,target:w4.BufferViewTarget.ARRAY_BUFFER};return $.bufferViews.push(P),{byteLength:R,buffers:[new Uint8Array(M)]}}function q(c,U,j){let B=[],L=0,R=new Map,M=-1/0,N=!1;for(let C of c){let h=K.createAccessorDef(C);$.accessors.push(h),K.accessorIndexMap.set(C,$.accessors.length-1);let _=[],a=[],s=[],Z0=Array(C.getElementSize()).fill(0);for(let m0=0,P1=C.getCount();m0<P1;m0++){if(C.getElement(m0,s),I0.eq(s,Z0,0))continue;M=Math.max(m0,M),_.push(m0);for(let s0=0;s0<s.length;s0++)a.push(s[s0])}let o=_.length,M0={accessorDef:h,count:o};if(R.set(C,M0),o===0)continue;if(o>C.getCount()/2)N=!0;let R0=bJ[C.getComponentType()];M0.indices=_,M0.values=new R0(a)}if(!Number.isFinite(M))return{buffers:B,byteLength:L};if(N)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let P=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,O=M<255?Kx1:M<65535?Qx1:$x1,k={buffer:U,byteOffset:j+L,byteLength:0};for(let C of c){let h=R.get(C);if(h.count===0)continue;h.indicesByteOffset=k.byteLength;let _=E0.pad(E0.toView(new P(h.indices)));B.push(_),L+=_.byteLength,k.byteLength+=_.byteLength}$.bufferViews.push(k);let E=$.bufferViews.length-1,S={buffer:U,byteOffset:j+L,byteLength:0};for(let C of c){let h=R.get(C);if(h.count===0)continue;h.valuesByteOffset=S.byteLength;let _=E0.pad(E0.toView(h.values));B.push(_),L+=_.byteLength,S.byteLength+=_.byteLength}$.bufferViews.push(S);let f=$.bufferViews.length-1;for(let C of c){let h=R.get(C);if(h.count===0)continue;h.accessorDef.sparse={count:h.count,indices:{bufferView:E,byteOffset:h.indicesByteOffset,componentType:O},values:{bufferView:f,byteOffset:h.valuesByteOffset}}}return{buffers:B,byteLength:L}}if($.accessors=[],$.bufferViews=[],$.samplers=[],$.textures=[],$.images=Y.listTextures().map((c,U)=>{let j=K.createPropertyDef(c);if(c.getMimeType())j.mimeType=c.getMimeType();let B=c.getImage();if(B)K.createImageData(j,B,c);return K.imageIndexMap.set(c,U),j}),z.filter((c)=>c.prewriteTypes.includes(i.ACCESSOR)).forEach((c)=>c.prewrite(K,i.ACCESSOR)),Y.listAccessors().forEach((c)=>{let{accessorUsageGroupedByParent:U,accessorParents:j}=K;if(K.accessorIndexMap.has(c))return;let B=K.getAccessorUsage(c);if(K.addAccessorToUsageGroup(c,B),U.has(B)){let L=X.listParents(c).find((R)=>R.propertyType!==i.ROOT);j.set(c,L)}}),z.filter((c)=>c.prewriteTypes.includes(i.BUFFER)).forEach((c)=>c.prewrite(K,i.BUFFER)),(Y.listAccessors().length>0||K.otherBufferViews.size>0||Y.listTextures().length>0&&J.format===YZ.GLB)&&Y.listBuffers().length===0)throw Error("Buffer required for Document resources, but none was found.");if($.buffers=[],Y.listBuffers().forEach((c,U)=>{let j=K.createPropertyDef(c),B=K.accessorUsageGroupedByParent,L=c.listParents().filter((S)=>S instanceof K0),R=new Set(L.map((S)=>K.accessorParents.get(S))),M=new Map(Array.from(R).map((S,f)=>[S,f])),N={};for(let S of L){var P;if(K.accessorIndexMap.has(S))continue;let f=K.getAccessorUsage(S),C=f;if(B.has(f)){let h=K.accessorParents.get(S);C+=`:${M.get(h)}`}N[P=C]||(N[P]={usage:f,accessors:[]}),N[C].accessors.push(S)}let O=[],k=$.buffers.length,E=0;for(let{usage:S,accessors:f}of Object.values(N))if(S===nF.ARRAY_BUFFER&&J.vertexLayout===oF.INTERLEAVED){let C=V(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===nF.ARRAY_BUFFER)for(let C of f){let h=V([C],k,E);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else if(S===nF.SPARSE){let C=q(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===nF.ELEMENT_ARRAY_BUFFER){let C=w4.BufferViewTarget.ELEMENT_ARRAY_BUFFER,h=H(f,k,E,C);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else{let C=H(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}if(K.imageBufferViews.length&&U===0){for(let S=0;S<K.imageBufferViews.length;S++)if($.bufferViews[$.images[S].bufferView].byteOffset=E,E+=K.imageBufferViews[S].byteLength,O.push(K.imageBufferViews[S]),E%8){let f=8-E%8;E+=f,O.push(new Uint8Array(f))}}if(K.otherBufferViews.has(c))for(let S of K.otherBufferViews.get(c))$.bufferViews.push({buffer:k,byteOffset:E,byteLength:S.byteLength}),K.otherBufferViewsIndexMap.set(S,$.bufferViews.length-1),E+=S.byteLength,O.push(S);if(E){let S;if(J.format===YZ.GLB)S=EY;else S=K.bufferURIGenerator.createURI(c,"bin"),j.uri=S;j.byteLength=E,K.assignResourceURI(S,E0.concat(O),!0)}$.buffers.push(j),K.bufferIndexMap.set(c,U)}),Y.listAccessors().find((c)=>!c.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");z.filter((c)=>c.prewriteTypes.includes(i.MATERIAL)).forEach((c)=>c.prewrite(K,i.MATERIAL)),$.materials=Y.listMaterials().map((c,U)=>{let j=K.createPropertyDef(c);if(c.getAlphaMode()!==K7.AlphaMode.OPAQUE)j.alphaMode=c.getAlphaMode();if(c.getAlphaMode()===K7.AlphaMode.MASK)j.alphaCutoff=c.getAlphaCutoff();if(c.getDoubleSided())j.doubleSided=!0;if(j.pbrMetallicRoughness={},!I0.eq(c.getBaseColorFactor(),[1,1,1,1]))j.pbrMetallicRoughness.baseColorFactor=c.getBaseColorFactor();if(!I0.eq(c.getEmissiveFactor(),[0,0,0]))j.emissiveFactor=c.getEmissiveFactor();if(c.getRoughnessFactor()!==1)j.pbrMetallicRoughness.roughnessFactor=c.getRoughnessFactor();if(c.getMetallicFactor()!==1)j.pbrMetallicRoughness.metallicFactor=c.getMetallicFactor();if(c.getBaseColorTexture()){let B=c.getBaseColorTexture(),L=c.getBaseColorTextureInfo();j.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(B,L)}if(c.getEmissiveTexture()){let B=c.getEmissiveTexture(),L=c.getEmissiveTextureInfo();j.emissiveTexture=K.createTextureInfoDef(B,L)}if(c.getNormalTexture()){let B=c.getNormalTexture(),L=c.getNormalTextureInfo(),R=K.createTextureInfoDef(B,L);if(c.getNormalScale()!==1)R.scale=c.getNormalScale();j.normalTexture=R}if(c.getOcclusionTexture()){let B=c.getOcclusionTexture(),L=c.getOcclusionTextureInfo(),R=K.createTextureInfoDef(B,L);if(c.getOcclusionStrength()!==1)R.strength=c.getOcclusionStrength();j.occlusionTexture=R}if(c.getMetallicRoughnessTexture()){let B=c.getMetallicRoughnessTexture(),L=c.getMetallicRoughnessTextureInfo();j.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(B,L)}return K.materialIndexMap.set(c,U),j}),z.filter((c)=>c.prewriteTypes.includes(i.MESH)).forEach((c)=>c.prewrite(K,i.MESH)),$.meshes=Y.listMeshes().map((c,U)=>{let j=K.createPropertyDef(c),B=null;if(j.primitives=c.listPrimitives().map((L)=>{let R={attributes:{}};R.mode=L.getMode();let M=L.getMaterial();if(M)R.material=K.materialIndexMap.get(M);if(Object.keys(L.getExtras()).length)R.extras=L.getExtras();let N=L.getIndices();if(N)R.indices=K.accessorIndexMap.get(N);for(let P of L.listSemantics())R.attributes[P]=K.accessorIndexMap.get(L.getAttribute(P));for(let P of L.listTargets()){let O={};for(let k of P.listSemantics())O[k]=K.accessorIndexMap.get(P.getAttribute(k));R.targets=R.targets||[],R.targets.push(O)}if(L.listTargets().length&&!B)B=L.listTargets().map((P)=>P.getName());return R}),c.getWeights().length)j.weights=c.getWeights();if(B)j.extras=j.extras||{},j.extras.targetNames=B;return K.meshIndexMap.set(c,U),j}),$.cameras=Y.listCameras().map((c,U)=>{let j=K.createPropertyDef(c);if(j.type=c.getType(),j.type===IY.Type.PERSPECTIVE){j.perspective={znear:c.getZNear(),zfar:c.getZFar(),yfov:c.getYFov()};let B=c.getAspectRatio();if(B!==null)j.perspective.aspectRatio=B}else j.orthographic={znear:c.getZNear(),zfar:c.getZFar(),xmag:c.getXMag(),ymag:c.getYMag()};return K.cameraIndexMap.set(c,U),j}),$.nodes=Y.listNodes().map((c,U)=>{let j=K.createPropertyDef(c);if(!I0.eq(c.getTranslation(),[0,0,0]))j.translation=c.getTranslation();if(!I0.eq(c.getRotation(),[0,0,0,1]))j.rotation=c.getRotation();if(!I0.eq(c.getScale(),[1,1,1]))j.scale=c.getScale();if(c.getWeights().length)j.weights=c.getWeights();return K.nodeIndexMap.set(c,U),j}),$.skins=Y.listSkins().map((c,U)=>{let j=K.createPropertyDef(c),B=c.getInverseBindMatrices();if(B)j.inverseBindMatrices=K.accessorIndexMap.get(B);let L=c.getSkeleton();if(L)j.skeleton=K.nodeIndexMap.get(L);return j.joints=c.listJoints().map((R)=>K.nodeIndexMap.get(R)),K.skinIndexMap.set(c,U),j}),Y.listNodes().forEach((c,U)=>{let j=$.nodes[U],B=c.getMesh();if(B)j.mesh=K.meshIndexMap.get(B);let L=c.getCamera();if(L)j.camera=K.cameraIndexMap.get(L);let R=c.getSkin();if(R)j.skin=K.skinIndexMap.get(R);if(c.listChildren().length>0)j.children=c.listChildren().map((M)=>K.nodeIndexMap.get(M))}),$.animations=Y.listAnimations().map((c,U)=>{let j=K.createPropertyDef(c),B=new Map;return j.samplers=c.listSamplers().map((L,R)=>{let M=K.createPropertyDef(L);return M.input=K.accessorIndexMap.get(L.getInput()),M.output=K.accessorIndexMap.get(L.getOutput()),M.interpolation=L.getInterpolation(),B.set(L,R),M}),j.channels=c.listChannels().map((L)=>{let R=K.createPropertyDef(L);return R.sampler=B.get(L.getSampler()),R.target={node:K.nodeIndexMap.get(L.getTargetNode()),path:L.getTargetPath()},R}),K.animationIndexMap.set(c,U),j}),$.scenes=Y.listScenes().map((c,U)=>{let j=K.createPropertyDef(c);return j.nodes=c.listChildren().map((B)=>K.nodeIndexMap.get(B)),K.sceneIndexMap.set(c,U),j});let w=Y.getDefaultScene();if(w)$.scene=Y.listScenes().indexOf(w);return $.extensionsUsed=z.map((c)=>c.extensionName),$.extensionsRequired=v.map((c)=>c.extensionName),z.forEach((c)=>c.write(K)),Gx1($),Q}}function Gx1(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 tF;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(tF||(tF={}));class hg{constructor(){this._logger=z5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=oF.INTERLEAVED,this.lastReadBytes=0,this.lastWriteBytes=0}setLogger(Z){return this._logger=Z,this}registerExtensions(Z){for(let J of Z)this._extensions.add(J),J.register();return this}registerDependencies(Z){return Object.assign(this._dependencies,Z),this}setVertexLayout(Z){return this._vertexLayout=Z,this}async read(Z){return await this.readJSON(await this.readAsJSON(Z))}async readAsJSON(Z){let J=await this.readURI(Z,"view");this.lastReadBytes=J.byteLength;let X=Ng(J)?this._binaryToJSON(J):{json:JSON.parse(E0.decodeText(J)),resources:{}};return await this._readResourcesExternal(X,this.dirname(Z)),this._readResourcesInternal(X),X}async readJSON(Z){return Z=this._copyJSON(Z),this._readResourcesInternal(Z),Ig.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(E0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some((Y)=>zx1(J,Y)))throw Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some((Y)=>vx1(J,Y)))throw Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(E0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===YZ.GLB&&Z.getRoot().listBuffers().length>1)throw Error("GLB must have 0–1 buffers.");return _g.write(Z,{format:J.format||YZ.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:m6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:YZ.GLB}),Y=new Uint32Array([1179937895,2,12]),$=JSON.stringify(J),Q=E0.pad(E0.encodeText($),32),K=E0.toView(new Uint32Array([Q.byteLength,1313821514])),W=E0.concat([K,Q]);Y[Y.length-1]+=W.byteLength;let G=Object.values(X)[0];if(!G||!G.byteLength)return E0.concat([E0.toView(Y),W]);let z=E0.pad(G,0),v=E0.toView(new Uint32Array([z.byteLength,5130562])),H=E0.concat([v,z]);return Y[Y.length-1]+=H.byteLength,E0.concat([E0.toView(Y),W,H])}async _readResourcesExternal(Z,J){var X=this;let Y=Z.json.images||[],$=Z.json.buffers||[],Q=[...Y,...$].map(async function(K){let W=K.uri;if(!W||W.match(/data:/))return Promise.resolve();Z.resources[W]=await X.readURI(X.resolve(J,W),"view"),X.lastReadBytes+=Z.resources[W].byteLength});await Promise.all(Q)}_readResourcesInternal(Z){function J($){if(!$.uri)return;if($.uri in Z.resources){E0.assertView(Z.resources[$.uri]);return}if($.uri.match(/data:/)){let Q=`__${kg()}.${$Z.extension($.uri)}`;Z.resources[Q]=E0.createBufferFromDataURI($.uri),$.uri=Q}}(Z.json.images||[]).forEach(($)=>{if($.bufferView===void 0&&$.uri===void 0)throw 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:m6({},Z.json),resources:m6({},Z.resources)},J)Z.json.images=J.map((Y)=>m6({},Y));if(X)Z.json.buffers=X.map((Y)=>m6({},Y));return Z}_binaryToJSON(Z){if(!Ng(Z))throw Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==tF.JSON)throw Error("Missing required GLB JSON chunk.");let X=20,Y=J[0],$=E0.decodeText(E0.toView(Z,X,Y)),Q=JSON.parse($),K=X+Y;if(Z.byteLength<=K)return{json:Q,resources:{}};let W=new Uint32Array(Z.buffer,Z.byteOffset+K,2);if(W[1]!==tF.BIN)return{json:Q,resources:{}};let G=W[0],z=E0.toView(Z,K+8,G);return{json:Q,resources:{[EY]:z}}}}function zx1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function vx1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Ng(Z){if(Z.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let J=new Uint32Array(Z.buffer,Z.byteOffset,3);return J[0]===1179937895&&J[1]===2}class cR extends hg{constructor(Z=null,J=F4.DEFAULT_INIT){super();this._fetch=void 0,this._fetchConfig=void 0,this._init=void 0,this._fetchEnabled=!1,this._fetch=Z,this._fetchConfig=J,this._init=this.init()}async init(){if(this._init)return this._init;return Promise.all([import("fs"),import("path")]).then(([Z,J])=>{this._fs=Z.promises,this._path=J})}setAllowNetwork(Z){if(Z&&!this._fetch)throw Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),F4.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw Error("Network request blocked. Allow HTTP requests explicitly, if needed.");let X=await this._fetch(Z,this._fetchConfig);switch(J){case"view":return new Uint8Array(await X.arrayBuffer());case"text":return X.text()}}else switch(J){case"view":return this._fs.readFile(Z);case"text":return this._fs.readFile(Z,"utf8")}}resolve(Z,J){if(F4.isAbsoluteURL(Z)||F4.isAbsoluteURL(J))return F4.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(F4.isAbsoluteURL(Z))return F4.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:YZ.GLTF,basename:$Z.basename(Z)}),{_fs:Q,_path:K}=this,W=K.dirname(Z),G=JSON.stringify(Y,null,2);await Q.writeFile(Z,G),this.lastWriteBytes+=G.length;for(let z of Vx1(Object.keys($),10))await Promise.all(z.map(async function(v){if(F4.isAbsoluteURL(v)){if(F4.extension(v)==="bin")throw Error(`Cannot write buffer to path "${v}".`);return}let H=K.join(W,decodeURIComponent(v));await Q.mkdir(K.dirname(H),{recursive:!0}),await Q.writeFile(H,$[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 Vx1(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 En=t(UR(),1),In=t(wn(),1),$D1=t(kn(),1);async function QD1(Z,J){if(!(Z instanceof Uint8Array))throw Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:Y}=await In.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return En.default(new Uint8Array(X),[Y.width,Y.height,4],[4,4*Y.width|0,1],0)}async function _n(Z,J){return QD1(Z)}var Sn=163,bn=166;function KD1(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class x3{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 uP6=new Uint8Array([0]),p6=[171,75,84,88,32,50,48,187,13,10,26,10];function hn(Z){return new TextDecoder().decode(Z)}function Mw(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,p6.length);if(J[0]!==p6[0]||J[1]!==p6[1]||J[2]!==p6[2]||J[3]!==p6[3]||J[4]!==p6[4]||J[5]!==p6[5]||J[6]!==p6[6]||J[7]!==p6[7]||J[8]!==p6[8]||J[9]!==p6[9]||J[10]!==p6[10]||J[11]!==p6[11])throw Error("Missing KTX 2.0 identifier.");let X=KD1(),Y=17*Uint32Array.BYTES_PER_ELEMENT,$=new x3(Z,p6.length,Y,!0);X.vkFormat=$._nextUint32(),X.typeSize=$._nextUint32(),X.pixelWidth=$._nextUint32(),X.pixelHeight=$._nextUint32(),X.pixelDepth=$._nextUint32(),X.layerCount=$._nextUint32(),X.faceCount=$._nextUint32(),X.levelCount=$._nextUint32(),X.supercompressionScheme=$._nextUint32();let Q=$._nextUint32(),K=$._nextUint32(),W=$._nextUint32(),G=$._nextUint32(),z=$._nextUint64(),v=$._nextUint64(),H=Math.max(X.levelCount,1)*3*8,V=new x3(Z,p6.length+Y,H,!0);for(let O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+V._nextUint64(),V._nextUint64()),uncompressedByteLength:V._nextUint64()});let q=new x3(Z,Q,K,!0);q._skip(4);let F=q._nextUint16(),w=q._nextUint16(),c=q._nextUint16(),U=q._nextUint16(),j=q._nextUint8(),B=q._nextUint8(),L=q._nextUint8(),R=q._nextUint8(),M=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],N=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],O={vendorId:F,descriptorType:w,versionNumber:c,colorModel:j,colorPrimaries:B,transferFunction:L,flags:R,texelBlockDimension:M,bytesPlane:N,samples:[]},k=6,E=4,S=(U/4-k)/E;for(let O8=0;O8<S;O8++){let q6={bitOffset:q._nextUint16(),bitLength:q._nextUint8(),channelType:q._nextUint8(),samplePosition:[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(q6.channelType&64)q6.sampleLower=q._nextInt32(),q6.sampleUpper=q._nextInt32();else q6.sampleLower=q._nextUint32(),q6.sampleUpper=q._nextUint32();O.samples[O8]=q6}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(O);let f=new x3(Z,W,G,!0);while(f._offset<G){let O8=f._nextUint32(),q6=f._scan(O8),kH=hn(q6);if(X.keyValue[kH]=f._nextUint8Array(O8-q6.byteLength-1),kH.match(/^ktx/i)){let BA=hn(X.keyValue[kH]);X.keyValue[kH]=BA.substring(0,BA.lastIndexOf("\x00"))}let DG1=O8%4?4-O8%4:0;f._skip(DG1)}if(v<=0)return X;let C=new x3(Z,z,v,!0),h=C._nextUint16(),_=C._nextUint16(),a=C._nextUint32(),s=C._nextUint32(),Z0=C._nextUint32(),o=C._nextUint32(),M0=[];for(let O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)M0.push({imageFlags:C._nextUint32(),rgbSliceByteOffset:C._nextUint32(),rgbSliceByteLength:C._nextUint32(),alphaSliceByteOffset:C._nextUint32(),alphaSliceByteLength:C._nextUint32()});let R0=z+C._offset,m0=R0+a,P1=m0+s,s0=P1+Z0,j1=new Uint8Array(Z.buffer,Z.byteOffset+R0,a),K4=new Uint8Array(Z.buffer,Z.byteOffset+m0,s),NJ=new Uint8Array(Z.buffer,Z.byteOffset+P1,Z0),IQ=new Uint8Array(Z.buffer,Z.byteOffset+s0,o);return X.globalData={endpointCount:h,selectorCount:_,imageDescs:M0,endpointsData:j1,selectorsData:K4,tablesData:NJ,extendedData:IQ},X}var GZ="EXT_mesh_gpu_instancing",X6="EXT_meshopt_compression",bG="EXT_texture_webp",AG="EXT_texture_avif",s1="KHR_draco_mesh_compression",x4="KHR_lights_punctual",zZ="KHR_materials_anisotropy",vZ="KHR_materials_clearcoat",VZ="KHR_materials_diffuse_transmission",HZ="KHR_materials_dispersion",qZ="KHR_materials_emissive_strength",FZ="KHR_materials_ior",wZ="KHR_materials_iridescence",cZ="KHR_materials_pbrSpecularGlossiness",UZ="KHR_materials_sheen",xZ="KHR_materials_specular",jZ="KHR_materials_transmission",iJ="KHR_materials_unlit",BZ="KHR_materials_volume",x6="KHR_materials_variants",rn="KHR_mesh_quantization",mG="KHR_texture_basisu",LZ="KHR_texture_transform",j4="KHR_xmp_json_ld",iR="INSTANCE_ATTRIBUTE";class dR extends O1{init(){this.extensionName=GZ,this.propertyType="InstancedMesh",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:iR})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}dR.EXTENSION_NAME=GZ;class Pw extends T1{constructor(...Z){super(...Z);this.extensionName=GZ,this.provideTypes=[i.NODE],this.prewriteTypes=[i.ACCESSOR]}createInstancedMesh(){return new dR(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[GZ])return;let Q=Y.extensions[GZ],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[$].setExtension(GZ,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(iR);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,iR);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let Y=X.getExtension(GZ);if(Y){let $=Z.nodeIndexMap.get(X),Q=J.json.nodes[$],K={attributes:{}};Y.listSemantics().forEach((W)=>{let G=Y.getAttribute(W);K.attributes[W]=Z.accessorIndexMap.get(G)}),Q.extensions=Q.extensions||{},Q.extensions[GZ]=K}}),this}}Pw.EXTENSION_NAME=GZ;function DZ(){return DZ=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},DZ.apply(null,arguments)}var uG;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(uG||(uG={}));var j3;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(j3||(j3={}));var Y8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})(Y8||(Y8={}));function WD1(Z){if(!Z.extensions||!Z.extensions[X6])return!1;return!!Z.extensions[X6].fallback}var{BYTE:GD1,SHORT:An,FLOAT:zD1}=K0.ComponentType,{encodeNormalizedInt:mn,decodeNormalizedInt:gR}=I0;function vD1(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!==j3.ATTRIBUTES)return K;if($!==Y8.NONE){let W=Z.getNormalized()?VD1(Z):new Float32Array(K.array);switch($){case Y8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=zD1,K.normalized=!1,K.array=J.encodeFilterExp(W,Z.getCount(),K.byteStride,Q);break;case Y8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?An:GD1,K.normalized=!0,W=Z.getElementSize()===3?qD1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case Y8.QUATERNION:K.byteStride=8,K.componentType=An,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>gR(G,Z.getComponentType())),K.max=K.max.map((G)=>gR(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>mn(G,K.componentType)),K.max=K.max.map((G)=>mn(G,K.componentType))}else if(K.byteStride%4)K.array=HD1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function VD1(Z){let J=Z.getComponentType(),X=Z.getArray(),Y=new Float32Array(X.length);for(let $=0;$<X.length;$++)Y[$]=gR(X[$],J);return Y}function HD1(Z,J){let Y=E0.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 W=0;W<J;W++)Q[K*Y+W]=Z[K*J+W];return Q}function qD1(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 FD1(Z,J){if(J===w4.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some((Y)=>{return Y instanceof g1&&Y.getMode()===g1.Mode.TRIANGLES})?j3.TRIANGLES:j3.INDICES;return j3.ATTRIBUTES}function wD1(Z,J){let X=J.getGraph().listParentEdges(Z).filter((Y)=>!(Y.getParent()instanceof W3));for(let Y of X){let $=Y.getName(),Q=Y.getAttributes().key||"",K=Y.getParent().propertyType===i.PRIMITIVE_TARGET;if($==="indices")return{filter:Y8.NONE};if($==="attributes"){if(Q==="POSITION")return{filter:Y8.NONE};if(Q==="TEXCOORD_0")return{filter:Y8.NONE};if(Q.startsWith("JOINTS_"))return{filter:Y8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:Y8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:Y8.NONE}:{filter:Y8.OCTAHEDRAL,bits:8}}if($==="output"){let W=tn(Z);if(W==="rotation")return{filter:Y8.QUATERNION,bits:16};if(W==="translation")return{filter:Y8.EXPONENTIAL,bits:12};if(W==="scale")return{filter:Y8.EXPONENTIAL,bits:12};return{filter:Y8.NONE}}if($==="input")return{filter:Y8.NONE};if($==="inverseBindMatrices")return{filter:Y8.NONE}}return{filter:Y8.NONE}}function tn(Z){for(let J of Z.listParents()){if(!(J instanceof AJ))continue;for(let X of J.listParents()){if(!(X instanceof QZ))continue;return X.getTargetPath()}}return null}var un={method:uG.QUANTIZE};class yG extends T1{constructor(...Z){super(...Z);this.extensionName=X6,this.prereadTypes=[i.BUFFER,i.PRIMITIVE],this.prewriteTypes=[i.BUFFER,i.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=un,this._encoderFallbackBuffer=null,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={}}install(Z,J){if(Z==="meshopt.decoder")this._decoder=J;if(Z==="meshopt.encoder")this._encoder=J;return this}setEncoderOptions(Z){return this._encoderOptions=DZ({},un,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw Error(`[${X6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw Error(`[${X6}]: Missing WASM support.`)}if(J===i.BUFFER)this._prereadBuffers(Z);else if(J===i.PRIMITIVE)this._prereadPrimitives(Z);return this}_prereadBuffers(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[X6])return;let Q=Y.extensions[X6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,z=Q.byteStride,v=new Uint8Array(G*z),H=J.json.buffers[Q.buffer],V=H.uri?J.resources[H.uri]:J.resources[EY],q=E0.toView(V,K,W);this._decoder.decodeGltfBuffer(v,G,z,q,Q.mode,Q.filter),Z.bufferViews[$]=v})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y)=>{if(!Y.extensions||!Y.extensions[X6])return;let $=Y.extensions[X6],Q=Z.buffers[$.buffer],K=Z.buffers[Y.buffer],W=J.json.buffers[Y.buffer];if(WD1(W))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 K0)Y.swap(J,X);J.dispose()}return this}prewrite(Z,J){if(J===i.ACCESSOR)this._prewriteAccessors(Z);else if(J===i.BUFFER)this._prewriteBuffers(Z);return this}_prewriteAccessors(Z){let J=Z.jsonDoc.json,X=this._encoder,Y=this._encoderOptions,$=this.document.getGraph(),Q=this.document.createBuffer(),K=this.document.getRoot().listBuffers().indexOf(Q),W=1,G=new Map,z=(v)=>{for(let H of $.listParents(v)){if(H.propertyType===i.ROOT)continue;let V=G.get(v);if(V===void 0)G.set(v,V=W++);return V}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let v of this.document.getRoot().listAccessors()){if(tn(v)==="weights")continue;if(v.getSparse())continue;let H=Z.getAccessorUsage(v),V=Z.accessorUsageGroupedByParent.has(H)?z(v):null,q=FD1(v,H),F=Y.method===uG.FILTER?wD1(v,this.document):{filter:Y8.NONE},w=vD1(v,X,q,F),{array:c,byteStride:U}=w,j=v.getBuffer();if(!j)throw Error(`${X6}: Missing buffer for accessor.`);let B=this.document.getRoot().listBuffers().indexOf(j),L=[H,V,q,F.filter,U,B].join(":"),R=this._encoderBufferViews[L],M=this._encoderBufferViewData[L],N=this._encoderBufferViewAccessors[L];if(!R||!M)N=this._encoderBufferViewAccessors[L]=[],M=this._encoderBufferViewData[L]=[],R=this._encoderBufferViews[L]={buffer:K,target:w4.USAGE_TO_TARGET[H],byteOffset:0,byteLength:0,byteStride:H===w4.BufferViewUsage.ARRAY_BUFFER?U:void 0,extensions:{[X6]:{buffer:B,byteOffset:0,byteLength:0,mode:q,filter:F.filter!==Y8.NONE?F.filter:void 0,byteStride:U,count:0}}};let P=Z.createAccessorDef(v);if(P.componentType=w.componentType,P.normalized=w.normalized,P.byteOffset=R.byteLength,P.min&&w.min)P.min=w.min;if(P.max&&w.max)P.max=w.max;Z.accessorIndexMap.set(v,J.accessors.length),J.accessors.push(P),N.push(P),M.push(new Uint8Array(c.buffer,c.byteOffset,c.byteLength)),R.byteLength+=c.byteLength,R.extensions.EXT_meshopt_compression.count+=v.getCount()}}_prewriteBuffers(Z){let J=this._encoder;for(let X in this._encoderBufferViews){let Y=this._encoderBufferViews[X],$=this._encoderBufferViewData[X],Q=this.document.getRoot().listBuffers()[Y.extensions[X6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:z}=Y.extensions[X6],v=E0.concat($),H=J.encodeGltfBuffer(v,W,G,z),V=E0.pad(H);Y.extensions[X6].byteLength=H.byteLength,$.length=0,$.push(V),K.push(V),Z.otherBufferViews.set(Q,K)}}write(Z){let J=0;for(let Q in this._encoderBufferViews){let K=this._encoderBufferViews[Q],W=this._encoderBufferViewData[Q][0],G=Z.otherBufferViewsIndexMap.get(W),z=this._encoderBufferViewAccessors[Q];for(let q of z)q.bufferView=G;let v=Z.jsonDoc.json.bufferViews[G],H=v.byteOffset||0;Object.assign(v,K),v.byteOffset=J;let V=v.extensions[X6];V.byteOffset=H,J+=E0.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,Y=Z.bufferIndexMap.get(X),$=Z.jsonDoc.json.buffers[Y];return $.byteLength=J,$.extensions={[X6]:{fallback:!0}},X.dispose(),this}}yG.EXTENSION_NAME=X6;yG.EncoderMethod=uG;class en{match(Z){return Z.length>=12&&E0.decodeText(Z.slice(4,12))==="ftypavif"}getSize(Z){if(!this.match(Z))return null;let J=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),X=ln(J,0);if(!X)return null;let Y=X.end;while(X=ln(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 Ow extends T1{constructor(...Z){super(...Z);this.extensionName=AG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/avif",new en)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[AG])X.source=X.extensions[AG].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/avif"){let Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[AG]={source:Q.source},delete Q.source})}}),this}}Ow.EXTENSION_NAME=AG;function ln(Z,J){if(Z.byteLength<4+J)return null;let X=Z.getUint32(J);if(Z.byteLength<X+J||X<8)return null;return{type:E0.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}class Zs{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=E0.decodeText(Z.slice(0,4)),X=E0.decodeText(Z.slice(8,12));if(J!=="RIFF"||X!=="WEBP")return null;let Y=new DataView(Z.buffer,Z.byteOffset),$=12;while($<Y.byteLength){let Q=E0.decodeText(new Uint8Array([Y.getUint8($),Y.getUint8($+1),Y.getUint8($+2),Y.getUint8($+3)])),K=Y.getUint32($+4,!0);if(Q==="VP8 "){let W=Y.getInt16($+14,!0)&16383,G=Y.getInt16($+16,!0)&16383;return[W,G]}else if(Q==="VP8L"){let W=Y.getUint8($+9),G=Y.getUint8($+10),z=Y.getUint8($+11),v=Y.getUint8($+12),H=1+((G&63)<<8|W),V=1+((v&15)<<10|z<<2|(G&192)>>6);return[H,V]}$+=8+K+K%2}return null}getChannels(Z){return 4}}class Tw extends T1{constructor(...Z){super(...Z);this.extensionName=bG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/webp",new Zs)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[bG])X.source=X.extensions[bG].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/webp"){let Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[bG]={source:Q.source},delete Q.source})}}),this}}Tw.EXTENSION_NAME=bG;var S8,Js,Xs;function cD1(Z,J){let X=new S8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==S8.TRIANGULAR_MESH)throw Error(`[${s1}] Unknown geometry type.`);let $=new S8.Mesh;if(!Z.DecodeBufferToMesh(X,$).ok()||$.ptr===0)throw Error(`[${s1}] Decoding failure.`);return $}finally{S8.destroy(X)}}function UD1(Z,J){let Y=J.num_faces()*3,$,Q;if(J.num_points()<=65534){let K=Y*Uint16Array.BYTES_PER_ELEMENT;$=S8._malloc(K),Z.GetTrianglesUInt16Array(J,K,$),Q=new Uint16Array(S8.HEAPU16.buffer,$,Y).slice()}else{let K=Y*Uint32Array.BYTES_PER_ELEMENT;$=S8._malloc(K),Z.GetTrianglesUInt32Array(J,K,$),Q=new Uint32Array(S8.HEAPU32.buffer,$,Y).slice()}return S8._free($),Q}function xD1(Z,J,X,Y){let $=Xs[Y.componentType],Q=Js[Y.componentType],K=X.num_components(),G=J.num_points()*K,z=G*Q.BYTES_PER_ELEMENT,v=S8._malloc(z);Z.GetAttributeDataArrayForAllPoints(J,X,$,z,v);let H=new Q(S8.HEAPF32.buffer,v,G).slice();return S8._free(v),H}function jD1(Z){S8=Z,Js={[K0.ComponentType.FLOAT]:Float32Array,[K0.ComponentType.UNSIGNED_INT]:Uint32Array,[K0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[K0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[K0.ComponentType.SHORT]:Int16Array,[K0.ComponentType.BYTE]:Int8Array},Xs={[K0.ComponentType.FLOAT]:S8.DT_FLOAT32,[K0.ComponentType.UNSIGNED_INT]:S8.DT_UINT32,[K0.ComponentType.UNSIGNED_SHORT]:S8.DT_UINT16,[K0.ComponentType.UNSIGNED_BYTE]:S8.DT_UINT8,[K0.ComponentType.SHORT]:S8.DT_INT16,[K0.ComponentType.BYTE]:S8.DT_INT8}}var U4,lG;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(lG||(lG={}));var B4;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(B4||(B4={}));var Ys={[B4.POSITION]:14,[B4.NORMAL]:10,[B4.COLOR]:8,[B4.TEX_COORD]:12,[B4.GENERIC]:12},yn={decodeSpeed:5,encodeSpeed:5,method:lG.EDGEBREAKER,quantizationBits:Ys,quantizationVolume:"mesh"};function BD1(Z){U4=Z}function LD1(Z,J=yn){let X=DZ({},yn,J);X.quantizationBits=DZ({},Ys,J.quantizationBits);let Y=new U4.MeshBuilder,$=new U4.Mesh,Q=new U4.ExpertEncoder($),K={},W=new U4.DracoInt8Array,G=Z.listTargets().length>0,z=!1;for(let w of Z.listSemantics()){let c=Z.getAttribute(w);if(c.getSparse()){z=!0;continue}let U=DD1(w),j=MD1(Y,c.getComponentType(),$,U4[U],c.getCount(),c.getElementSize(),c.getArray());if(j===-1)throw Error(`Error compressing "${w}" attribute.`);if(K[w]=j,X.quantizationVolume==="mesh"||w!=="POSITION")Q.SetAttributeQuantization(j,X.quantizationBits[U]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:B}=X,L=Math.max(B.max[0]-B.min[0],B.max[1]-B.min[1],B.max[2]-B.min[2]);Q.SetAttributeExplicitQuantization(j,X.quantizationBits[U],c.getElementSize(),B.min,L)}else throw Error("Invalid quantization volume state.")}let v=Z.getIndices();if(!v)throw new Rw("Primitive must have indices.");if(Y.AddFacesToMesh($,v.getCount()/3,v.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===lG.SEQUENTIAL||G||z)Q.SetEncodingMethod(U4.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(U4.MESH_EDGEBREAKER_ENCODING);let H=Q.EncodeToDracoBuffer(!(G||z),W);if(H<=0)throw new Rw("Error applying Draco compression.");let V=new Uint8Array(H);for(let w=0;w<H;++w)V[w]=W.GetValue(w);let q=Q.GetNumberOfEncodedPoints(),F=Q.GetNumberOfEncodedFaces()*3;return U4.destroy(W),U4.destroy($),U4.destroy(Y),U4.destroy(Q),{numVertices:q,numIndices:F,data:V,attributeIDs:K}}function DD1(Z){if(Z==="POSITION")return B4.POSITION;else if(Z==="NORMAL")return B4.NORMAL;else if(Z.startsWith("COLOR_"))return B4.COLOR;else if(Z.startsWith("TEXCOORD_"))return B4.TEX_COORD;return B4.GENERIC}function MD1(Z,J,X,Y,$,Q,K){switch(J){case K0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,Y,$,Q,K);case K0.ComponentType.BYTE:return Z.AddInt8Attribute(X,Y,$,Q,K);case K0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,Y,$,Q,K);case K0.ComponentType.SHORT:return Z.AddInt16Attribute(X,Y,$,Q,K);case K0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,Y,$,Q,K);case K0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,Y,$,Q,K);default:throw Error(`Unexpected component type, "${J}".`)}}class Rw extends Error{}class pG extends T1{constructor(...Z){super(...Z);this.extensionName=s1,this.prereadTypes=[i.PRIMITIVE],this.prewriteTypes=[i.ACCESSOR],this.readDependencies=["draco3d.decoder"],this.writeDependencies=["draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(Z,J){if(Z==="draco3d.decoder")this._decoderModule=J,jD1(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 Error(`[${s1}] 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[s1])continue;let W=K.extensions[s1],[G,z]=Y.get(W.bufferView)||[];if(!z||!G){let v=X.json.bufferViews[W.bufferView],H=X.json.buffers[v.buffer],V=H.uri?X.resources[H.uri]:X.resources[EY],q=v.byteOffset||0,F=v.byteLength,w=E0.toView(V,q,F);G=new this._decoderModule.Decoder,z=cD1(G,w),Y.set(W.bufferView,[G,z]),J.debug(`[${s1}] Decompressed ${w.byteLength} bytes.`)}for(let v in W.attributes){let H=Z.jsonDoc.json.accessors[K.attributes[v]],V=G.GetAttributeByUniqueId(z,W.attributes[v]),q=xD1(G,z,V,H);Z.accessors[K.attributes[v]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(UD1(G,z))}}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 Error(`[${s1}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${s1}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let Y=RD1(this.document),$=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${s1}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=NG(this.document.getRoot().listScenes().pop());for(let K of Array.from(Y.keys())){let W=Y.get(K);if(!W)throw Error("Unexpected primitive.");if($.has(W)){$.set(W,$.get(W));continue}let G=K.getIndices(),z=Z.jsonDoc.json.accessors,v;try{v=LD1(K,DZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof Rw){X.warn(`[${s1}]: ${q.message} Skipping primitive compression.`);continue}throw q}$.set(W,v);let H=Z.createAccessorDef(G);if(H.count=v.numIndices,Z.accessorIndexMap.set(G,z.length),z.push(H),v.numVertices>65534&&K0.getComponentSize(H.componentType)<=2)H.componentType=K0.ComponentType.UNSIGNED_INT;else if(v.numVertices>254&&K0.getComponentSize(H.componentType)<=1)H.componentType=K0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let F=K.getAttribute(q);if(v.attributeIDs[q]===void 0)continue;let w=Z.createAccessorDef(F);w.count=v.numVertices,Z.accessorIndexMap.set(F,z.length),z.push(w)}let V=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(V))Z.otherBufferViews.set(V,[]);Z.otherBufferViews.get(V).push(v.data)}return X.debug(`[${s1}] Compressed ${Y.size} primitives.`),Z.extensionData[s1]={primitiveHashMap:Y,primitiveEncodingMap:$},this}write(Z){let J=Z.extensionData[s1];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[$],W=J.primitiveHashMap.get(Q);if(!W)continue;let G=J.primitiveEncodingMap.get(W);if(!G)continue;K.extensions=K.extensions||{},K.extensions[s1]={bufferView:Z.otherBufferViewsIndexMap.get(G.data),attributes:G.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter((Y)=>Y!==s1),X.extensionsRequired=(X.extensionsRequired||[]).filter((Y)=>Y!==s1)}return this}}pG.EXTENSION_NAME=s1;pG.EncoderMethod=lG;function RD1(Z){let J=Z.getLogger(),X=new Set,Y=new Set,$=0,Q=0;for(let H of Z.getRoot().listMeshes())for(let V of H.listPrimitives())if(!V.getIndices())Y.add(V),$++;else if(V.getMode()!==g1.Mode.TRIANGLES)Y.add(V),Q++;else X.add(V);if($>0)J.warn(`[${s1}] Skipping Draco compression of ${$} non-indexed primitives.`);if(Q>0)J.warn(`[${s1}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),W=new Map;for(let H=0;H<K.length;H++)W.set(K[H],H);let G=new Map,z=new Set,v=new Map;for(let H of Array.from(X)){let V=pn(H,W);if(z.has(V)){v.set(H,V);continue}if(G.has(H.getIndices())){let q=H.getIndices(),F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}for(let q of H.listAttributes())if(G.has(q)){let F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}V=pn(H,W),z.add(V),v.set(H,V),G.set(H.getIndices(),V);for(let q of H.listAttributes())G.set(q,V)}for(let H of Array.from(G.keys())){let V=new Set(H.listParents().map((q)=>q.propertyType));if(V.size!==2||!V.has(i.PRIMITIVE)||!V.has(i.ROOT))throw Error(`[${s1}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let H of Array.from(X)){let V=v.get(H),q=H.getIndices();if(G.get(q)!==V||H.listAttributes().some((F)=>G.get(F)!==V))throw Error(`[${s1}] Draco primitives must share all, or no, accessors.`)}for(let H of Array.from(Y)){let V=H.getIndices();if(G.has(V)||H.listAttributes().some((q)=>G.has(q)))throw Error(`[${s1}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return v}function pn(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 B3 extends O1{init(){this.extensionName=x4,this.propertyType="Light",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:B3.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(Z){return this.set("color",Z)}getIntensity(){return this.get("intensity")}setIntensity(Z){return this.set("intensity",Z)}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getRange(){return this.get("range")}setRange(Z){return this.set("range",Z)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(Z){return this.set("innerConeAngle",Z)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(Z){return this.set("outerConeAngle",Z)}}B3.EXTENSION_NAME=x4;B3.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};class aR extends T1{constructor(...Z){super(...Z);this.extensionName=x4}createLight(Z=""){return new B3(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[x4])return this;let $=(J.json.extensions[x4].lights||[]).map((Q)=>{var K,W;let G=this.createLight().setName(Q.name||"").setType(Q.type);if(Q.color!==void 0)G.setColor(Q.color);if(Q.intensity!==void 0)G.setIntensity(Q.intensity);if(Q.range!==void 0)G.setRange(Q.range);if(((K=Q.spot)==null?void 0:K.innerConeAngle)!==void 0)G.setInnerConeAngle(Q.spot.innerConeAngle);if(((W=Q.spot)==null?void 0:W.outerConeAngle)!==void 0)G.setOuterConeAngle(Q.spot.outerConeAngle);return G});return J.json.nodes.forEach((Q,K)=>{if(!Q.extensions||!Q.extensions[x4])return;let W=Q.extensions[x4];Z.nodes[K].setExtension(x4,$[W.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(!I0.eq(Q.getColor(),[1,1,1]))K.color=Q.getColor();if(Q.getIntensity()!==1)K.intensity=Q.getIntensity();if(Q.getRange()!=null)K.range=Q.getRange();if(Q.getName())K.name=Q.getName();if(Q.getType()===B3.Type.SPOT)K.spot={innerConeAngle:Q.getInnerConeAngle(),outerConeAngle:Q.getOuterConeAngle()};X.push(K),Y.set(Q,X.length-1)}return this.document.getRoot().listNodes().forEach(($)=>{let Q=$.getExtension(x4);if(Q){let K=Z.nodeIndexMap.get($),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[x4]={light:Y.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[x4]={lights:X},this}}aR.EXTENSION_NAME=x4;var{R:ND1,G:PD1,B:OD1}=v5;class nR extends O1{init(){this.extensionName=zZ,this.propertyType="Anisotropy",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new F1(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(Z){return this.set("anisotropyStrength",Z)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(Z){return this.set("anisotropyRotation",Z)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(Z){return this.setRef("anisotropyTexture",Z,{channels:ND1|PD1|OD1})}}nR.EXTENSION_NAME=zZ;class sR extends T1{constructor(...Z){super(...Z);this.extensionName=zZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createAnisotropy(){return new nR(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[zZ]){let K=this.createAnisotropy();Z.materials[Q].setExtension(zZ,K);let W=$.extensions[zZ];if(W.anisotropyStrength!==void 0)K.setAnisotropyStrength(W.anisotropyStrength);if(W.anisotropyRotation!==void 0)K.setAnisotropyRotation(W.anisotropyRotation);if(W.anisotropyTexture!==void 0){let G=W.anisotropyTexture,z=Z.textures[Y[G.index].source];K.setAnisotropyTexture(z),Z.setTextureInfo(K.getAnisotropyTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(zZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[zZ]={};if(Y.getAnisotropyStrength()>0)K.anisotropyStrength=Y.getAnisotropyStrength();if(Y.getAnisotropyRotation()!==0)K.anisotropyRotation=Y.getAnisotropyRotation();if(Y.getAnisotropyTexture()){let W=Y.getAnisotropyTexture(),G=Y.getAnisotropyTextureInfo();K.anisotropyTexture=Z.createTextureInfoDef(W,G)}}}),this}}sR.EXTENSION_NAME=zZ;var{R:gn,G:dn,B:TD1}=v5;class oR extends O1{init(){this.extensionName=vZ,this.propertyType="Clearcoat",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new F1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new F1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new F1(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(Z){return this.set("clearcoatFactor",Z)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(Z){return this.setRef("clearcoatTexture",Z,{channels:gn})}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:dn})}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:gn|dn|TD1})}}oR.EXTENSION_NAME=vZ;class rR extends T1{constructor(...Z){super(...Z);this.extensionName=vZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createClearcoat(){return new oR(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[vZ]){let K=this.createClearcoat();Z.materials[Q].setExtension(vZ,K);let W=$.extensions[vZ];if(W.clearcoatFactor!==void 0)K.setClearcoatFactor(W.clearcoatFactor);if(W.clearcoatRoughnessFactor!==void 0)K.setClearcoatRoughnessFactor(W.clearcoatRoughnessFactor);if(W.clearcoatTexture!==void 0){let G=W.clearcoatTexture,z=Z.textures[Y[G.index].source];K.setClearcoatTexture(z),Z.setTextureInfo(K.getClearcoatTextureInfo(),G)}if(W.clearcoatRoughnessTexture!==void 0){let G=W.clearcoatRoughnessTexture,z=Z.textures[Y[G.index].source];K.setClearcoatRoughnessTexture(z),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),G)}if(W.clearcoatNormalTexture!==void 0){let G=W.clearcoatNormalTexture,z=Z.textures[Y[G.index].source];if(K.setClearcoatNormalTexture(z),Z.setTextureInfo(K.getClearcoatNormalTextureInfo(),G),G.scale!==void 0)K.setClearcoatNormalScale(G.scale)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(vZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[vZ]={clearcoatFactor:Y.getClearcoatFactor(),clearcoatRoughnessFactor:Y.getClearcoatRoughnessFactor()};if(Y.getClearcoatTexture()){let W=Y.getClearcoatTexture(),G=Y.getClearcoatTextureInfo();K.clearcoatTexture=Z.createTextureInfoDef(W,G)}if(Y.getClearcoatRoughnessTexture()){let W=Y.getClearcoatRoughnessTexture(),G=Y.getClearcoatRoughnessTextureInfo();K.clearcoatRoughnessTexture=Z.createTextureInfoDef(W,G)}if(Y.getClearcoatNormalTexture()){let W=Y.getClearcoatNormalTexture(),G=Y.getClearcoatNormalTextureInfo();if(K.clearcoatNormalTexture=Z.createTextureInfoDef(W,G),Y.getClearcoatNormalScale()!==1)K.clearcoatNormalTexture.scale=Y.getClearcoatNormalScale()}}}),this}}rR.EXTENSION_NAME=vZ;var{R:CD1,G:fD1,B:kD1,A:ED1}=v5;class tR extends O1{init(){this.extensionName=VZ,this.propertyType="DiffuseTransmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new F1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new F1(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(Z){return this.set("diffuseTransmissionFactor",Z)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(Z){return this.setRef("diffuseTransmissionTexture",Z,{channels:ED1})}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:CD1|fD1|kD1})}}tR.EXTENSION_NAME=VZ;class eR extends T1{constructor(...Z){super(...Z);this.extensionName=VZ}createDiffuseTransmission(){return new tR(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[VZ]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(VZ,K);let W=$.extensions[VZ];if(W.diffuseTransmissionFactor!==void 0)K.setDiffuseTransmissionFactor(W.diffuseTransmissionFactor);if(W.diffuseTransmissionColorFactor!==void 0)K.setDiffuseTransmissionColorFactor(W.diffuseTransmissionColorFactor);if(W.diffuseTransmissionTexture!==void 0){let G=W.diffuseTransmissionTexture,z=Z.textures[Y[G.index].source];K.setDiffuseTransmissionTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),G)}if(W.diffuseTransmissionColorTexture!==void 0){let G=W.diffuseTransmissionColorTexture,z=Z.textures[Y[G.index].source];K.setDiffuseTransmissionColorTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),G)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let Y=X.getExtension(VZ);if(!Y)continue;let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[VZ]={diffuseTransmissionFactor:Y.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:Y.getDiffuseTransmissionColorFactor()};if(Y.getDiffuseTransmissionTexture()){let W=Y.getDiffuseTransmissionTexture(),G=Y.getDiffuseTransmissionTextureInfo();K.diffuseTransmissionTexture=Z.createTextureInfoDef(W,G)}if(Y.getDiffuseTransmissionColorTexture()){let W=Y.getDiffuseTransmissionColorTexture(),G=Y.getDiffuseTransmissionColorTextureInfo();K.diffuseTransmissionColorTexture=Z.createTextureInfoDef(W,G)}}return this}}eR.EXTENSION_NAME=VZ;class ZN extends O1{init(){this.extensionName=HZ,this.propertyType="Dispersion",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}ZN.EXTENSION_NAME=HZ;class JN extends T1{constructor(...Z){super(...Z);this.extensionName=HZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createDispersion(){return new ZN(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[HZ]){let Q=this.createDispersion();Z.materials[$].setExtension(HZ,Q);let K=Y.extensions[HZ];if(K.dispersion!==void 0)Q.setDispersion(K.dispersion)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(HZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[HZ]={dispersion:Y.getDispersion()}}}),this}}JN.EXTENSION_NAME=HZ;class XN extends O1{init(){this.extensionName=qZ,this.propertyType="EmissiveStrength",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}XN.EXTENSION_NAME=qZ;class YN extends T1{constructor(...Z){super(...Z);this.extensionName=qZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createEmissiveStrength(){return new XN(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[qZ]){let Q=this.createEmissiveStrength();Z.materials[$].setExtension(qZ,Q);let K=Y.extensions[qZ];if(K.emissiveStrength!==void 0)Q.setEmissiveStrength(K.emissiveStrength)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(qZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[qZ]={emissiveStrength:Y.getEmissiveStrength()}}}),this}}YN.EXTENSION_NAME=qZ;class $N extends O1{init(){this.extensionName=FZ,this.propertyType="IOR",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}$N.EXTENSION_NAME=FZ;class Cw extends T1{constructor(...Z){super(...Z);this.extensionName=FZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIOR(){return new $N(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[FZ]){let Q=this.createIOR();Z.materials[$].setExtension(FZ,Q);let K=Y.extensions[FZ];if(K.ior!==void 0)Q.setIOR(K.ior)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(FZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[FZ]={ior:Y.getIOR()}}}),this}}Cw.EXTENSION_NAME=FZ;var{R:ID1,G:_D1}=v5;class QN extends O1{init(){this.extensionName=wZ,this.propertyType="Iridescence",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new F1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new F1(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(Z){return this.set("iridescenceFactor",Z)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(Z){return this.setRef("iridescenceTexture",Z,{channels:ID1})}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:_D1})}}QN.EXTENSION_NAME=wZ;class KN extends T1{constructor(...Z){super(...Z);this.extensionName=wZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIridescence(){return new QN(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[wZ]){let K=this.createIridescence();Z.materials[Q].setExtension(wZ,K);let W=$.extensions[wZ];if(W.iridescenceFactor!==void 0)K.setIridescenceFactor(W.iridescenceFactor);if(W.iridescenceIor!==void 0)K.setIridescenceIOR(W.iridescenceIor);if(W.iridescenceThicknessMinimum!==void 0)K.setIridescenceThicknessMinimum(W.iridescenceThicknessMinimum);if(W.iridescenceThicknessMaximum!==void 0)K.setIridescenceThicknessMaximum(W.iridescenceThicknessMaximum);if(W.iridescenceTexture!==void 0){let G=W.iridescenceTexture,z=Z.textures[Y[G.index].source];K.setIridescenceTexture(z),Z.setTextureInfo(K.getIridescenceTextureInfo(),G)}if(W.iridescenceThicknessTexture!==void 0){let G=W.iridescenceThicknessTexture,z=Z.textures[Y[G.index].source];K.setIridescenceThicknessTexture(z),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(wZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[wZ]={};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 W=Y.getIridescenceTexture(),G=Y.getIridescenceTextureInfo();K.iridescenceTexture=Z.createTextureInfoDef(W,G)}if(Y.getIridescenceThicknessTexture()){let W=Y.getIridescenceThicknessTexture(),G=Y.getIridescenceThicknessTextureInfo();K.iridescenceThicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}KN.EXTENSION_NAME=wZ;var{R:an,G:nn,B:sn,A:on}=v5;class WN extends O1{init(){this.extensionName=cZ,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new F1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new F1(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(Z){return this.set("diffuseFactor",Z)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(Z){return this.setRef("diffuseTexture",Z,{channels:an|nn|sn|on,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:an|nn|sn|on})}}WN.EXTENSION_NAME=cZ;class fw extends T1{constructor(...Z){super(...Z);this.extensionName=cZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createPBRSpecularGlossiness(){return new WN(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[cZ]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(cZ,K);let W=$.extensions[cZ];if(W.diffuseFactor!==void 0)K.setDiffuseFactor(W.diffuseFactor);if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.glossinessFactor!==void 0)K.setGlossinessFactor(W.glossinessFactor);if(W.diffuseTexture!==void 0){let G=W.diffuseTexture,z=Z.textures[Y[G.index].source];K.setDiffuseTexture(z),Z.setTextureInfo(K.getDiffuseTextureInfo(),G)}if(W.specularGlossinessTexture!==void 0){let G=W.specularGlossinessTexture,z=Z.textures[Y[G.index].source];K.setSpecularGlossinessTexture(z),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(cZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[cZ]={diffuseFactor:Y.getDiffuseFactor(),specularFactor:Y.getSpecularFactor(),glossinessFactor:Y.getGlossinessFactor()};if(Y.getDiffuseTexture()){let W=Y.getDiffuseTexture(),G=Y.getDiffuseTextureInfo();K.diffuseTexture=Z.createTextureInfoDef(W,G)}if(Y.getSpecularGlossinessTexture()){let W=Y.getSpecularGlossinessTexture(),G=Y.getSpecularGlossinessTextureInfo();K.specularGlossinessTexture=Z.createTextureInfoDef(W,G)}}}),this}}fw.EXTENSION_NAME=cZ;var{R:hD1,G:SD1,B:bD1,A:AD1}=v5;class GN extends O1{init(){this.extensionName=UZ,this.propertyType="Sheen",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new F1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new F1(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(Z){return this.set("sheenColorFactor",Z)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(Z){return this.setRef("sheenColorTexture",Z,{channels:hD1|SD1|bD1,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:AD1})}}GN.EXTENSION_NAME=UZ;class zN extends T1{constructor(...Z){super(...Z);this.extensionName=UZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSheen(){return new GN(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[UZ]){let K=this.createSheen();Z.materials[Q].setExtension(UZ,K);let W=$.extensions[UZ];if(W.sheenColorFactor!==void 0)K.setSheenColorFactor(W.sheenColorFactor);if(W.sheenRoughnessFactor!==void 0)K.setSheenRoughnessFactor(W.sheenRoughnessFactor);if(W.sheenColorTexture!==void 0){let G=W.sheenColorTexture,z=Z.textures[Y[G.index].source];K.setSheenColorTexture(z),Z.setTextureInfo(K.getSheenColorTextureInfo(),G)}if(W.sheenRoughnessTexture!==void 0){let G=W.sheenRoughnessTexture,z=Z.textures[Y[G.index].source];K.setSheenRoughnessTexture(z),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(UZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[UZ]={sheenColorFactor:Y.getSheenColorFactor(),sheenRoughnessFactor:Y.getSheenRoughnessFactor()};if(Y.getSheenColorTexture()){let W=Y.getSheenColorTexture(),G=Y.getSheenColorTextureInfo();K.sheenColorTexture=Z.createTextureInfoDef(W,G)}if(Y.getSheenRoughnessTexture()){let W=Y.getSheenRoughnessTexture(),G=Y.getSheenRoughnessTextureInfo();K.sheenRoughnessTexture=Z.createTextureInfoDef(W,G)}}}),this}}zN.EXTENSION_NAME=UZ;var{R:mD1,G:uD1,B:lD1,A:yD1}=v5;class vN extends O1{init(){this.extensionName=xZ,this.propertyType="Specular",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new F1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new F1(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(Z){return this.set("specularFactor",Z)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(Z){return this.set("specularColorFactor",Z)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(Z){return this.setRef("specularTexture",Z,{channels:yD1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:mD1|uD1|lD1,isColor:!0})}}vN.EXTENSION_NAME=xZ;class kw extends T1{constructor(...Z){super(...Z);this.extensionName=xZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSpecular(){return new vN(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[xZ]){let K=this.createSpecular();Z.materials[Q].setExtension(xZ,K);let W=$.extensions[xZ];if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.specularColorFactor!==void 0)K.setSpecularColorFactor(W.specularColorFactor);if(W.specularTexture!==void 0){let G=W.specularTexture,z=Z.textures[Y[G.index].source];K.setSpecularTexture(z),Z.setTextureInfo(K.getSpecularTextureInfo(),G)}if(W.specularColorTexture!==void 0){let G=W.specularColorTexture,z=Z.textures[Y[G.index].source];K.setSpecularColorTexture(z),Z.setTextureInfo(K.getSpecularColorTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(xZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[xZ]={};if(Y.getSpecularFactor()!==1)K.specularFactor=Y.getSpecularFactor();if(!I0.eq(Y.getSpecularColorFactor(),[1,1,1]))K.specularColorFactor=Y.getSpecularColorFactor();if(Y.getSpecularTexture()){let W=Y.getSpecularTexture(),G=Y.getSpecularTextureInfo();K.specularTexture=Z.createTextureInfoDef(W,G)}if(Y.getSpecularColorTexture()){let W=Y.getSpecularColorTexture(),G=Y.getSpecularColorTextureInfo();K.specularColorTexture=Z.createTextureInfoDef(W,G)}}}),this}}kw.EXTENSION_NAME=xZ;var{R:pD1}=v5;class VN extends O1{init(){this.extensionName=jZ,this.propertyType="Transmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new F1(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(Z){return this.set("transmissionFactor",Z)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(Z){return this.setRef("transmissionTexture",Z,{channels:pD1})}}VN.EXTENSION_NAME=jZ;class HN extends T1{constructor(...Z){super(...Z);this.extensionName=jZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createTransmission(){return new VN(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[jZ]){let K=this.createTransmission();Z.materials[Q].setExtension(jZ,K);let W=$.extensions[jZ];if(W.transmissionFactor!==void 0)K.setTransmissionFactor(W.transmissionFactor);if(W.transmissionTexture!==void 0){let G=W.transmissionTexture,z=Z.textures[Y[G.index].source];K.setTransmissionTexture(z),Z.setTextureInfo(K.getTransmissionTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(jZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[jZ]={transmissionFactor:Y.getTransmissionFactor()};if(Y.getTransmissionTexture()){let W=Y.getTransmissionTexture(),G=Y.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}HN.EXTENSION_NAME=jZ;class qN extends O1{init(){this.extensionName=iJ,this.propertyType="Unlit",this.parentTypes=[i.MATERIAL]}}qN.EXTENSION_NAME=iJ;class Ew extends T1{constructor(...Z){super(...Z);this.extensionName=iJ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createUnlit(){return new qN(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[iJ])Z.materials[Y].setExtension(iJ,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(iJ)){let Y=Z.materialIndexMap.get(X),$=J.json.materials[Y];$.extensions=$.extensions||{},$.extensions[iJ]={}}}),this}}Ew.EXTENSION_NAME=iJ;class FN extends O1{init(){this.extensionName=x6,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new w1})}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")}}FN.EXTENSION_NAME=x6;class wN extends O1{init(){this.extensionName=x6,this.propertyType="MappingList",this.parentTypes=[i.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new w1})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}wN.EXTENSION_NAME=x6;class Nw extends O1{init(){this.extensionName=x6,this.propertyType="Variant",this.parentTypes=["MappingList"]}}Nw.EXTENSION_NAME=x6;class cN extends T1{constructor(...Z){super(...Z);this.extensionName=x6}createMappingList(){return new wN(this.document.getGraph())}createVariant(Z=""){return new Nw(this.document.getGraph(),Z)}createMapping(){return new FN(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof Nw)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[x6])return this;let $=(J.json.extensions[x6].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((v,H)=>{if(!v.extensions||!v.extensions[x6])return;let V=this.createMappingList(),q=v.extensions[x6];for(let F of q.mappings){let w=this.createMapping();if(F.material!==void 0)w.setMaterial(Z.materials[F.material]);for(let c of F.variants||[])w.addVariant($[c]);V.addMapping(w)}G.listPrimitives()[H].setExtension(x6,V)})}),this}write(Z){let J=Z.jsonDoc,X=this.listVariants();if(!X.length)return this;let Y=[],$=new Map;for(let Q of X)$.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((W,G)=>{let z=W.getExtension(x6);if(!z)return;let v=Z.jsonDoc.json.meshes[K].primitives[G],H=z.listMappings().map((V)=>{let q=Z.createPropertyDef(V),F=V.getMaterial();if(F)q.material=Z.materialIndexMap.get(F);return q.variants=V.listVariants().map((w)=>$.get(w)),q});v.extensions=v.extensions||{},v.extensions[x6]={mappings:H}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[x6]={variants:Y},this}}cN.EXTENSION_NAME=x6;var{G:iD1}=v5;class UN extends O1{init(){this.extensionName=BZ,this.propertyType="Volume",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new F1(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(Z){return this.set("thicknessFactor",Z)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(Z){return this.setRef("thicknessTexture",Z,{channels:iD1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}UN.EXTENSION_NAME=BZ;class xN extends T1{constructor(...Z){super(...Z);this.extensionName=BZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createVolume(){return new UN(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[BZ]){let K=this.createVolume();Z.materials[Q].setExtension(BZ,K);let W=$.extensions[BZ];if(W.thicknessFactor!==void 0)K.setThicknessFactor(W.thicknessFactor);if(W.attenuationDistance!==void 0)K.setAttenuationDistance(W.attenuationDistance);if(W.attenuationColor!==void 0)K.setAttenuationColor(W.attenuationColor);if(W.thicknessTexture!==void 0){let G=W.thicknessTexture,z=Z.textures[Y[G.index].source];K.setThicknessTexture(z),Z.setTextureInfo(K.getThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(BZ);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[BZ]={};if(Y.getThicknessFactor()>0)K.thicknessFactor=Y.getThicknessFactor();if(Number.isFinite(Y.getAttenuationDistance()))K.attenuationDistance=Y.getAttenuationDistance();if(!I0.eq(Y.getAttenuationColor(),[1,1,1]))K.attenuationColor=Y.getAttenuationColor();if(Y.getThicknessTexture()){let W=Y.getThicknessTexture(),G=Y.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}xN.EXTENSION_NAME=BZ;class iG extends T1{constructor(...Z){super(...Z);this.extensionName=rn}read(Z){return this}write(Z){return this}}iG.EXTENSION_NAME=rn;class $s{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=Mw(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=Mw(Z).dataFormatDescriptor[0];if(X.colorModel===Sn)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===bn)return(X.samples[0].channelType&15)===3?4:3;throw Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=Mw(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,$))),W=Math.max(1,Math.floor(J.pixelHeight/Math.pow(2,$))),G=X?16:8;Y+=K/4*(W/4)*G}}return Y}}class jN extends T1{constructor(...Z){super(...Z);this.extensionName=mG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/ktx2",new $s)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[mG]){let X=J.extensions[mG];J.source=X.source}}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/ktx2"){let Y=Z.imageIndexMap.get(X);J.json.textures.forEach(($)=>{if($.source===Y)$.extensions=$.extensions||{},$.extensions[mG]={source:$.source},delete $.source})}}),this}}jN.EXTENSION_NAME=mG;class BN extends O1{init(){this.extensionName=LZ,this.propertyType="Transform",this.parentTypes=[i.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(Z){return this.set("offset",Z)}getRotation(){return this.get("rotation")}setRotation(Z){return this.set("rotation",Z)}getScale(){return this.get("scale")}setScale(Z){return this.set("scale",Z)}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}}BN.EXTENSION_NAME=LZ;class LN extends T1{constructor(...Z){super(...Z);this.extensionName=LZ}createTransform(){return new BN(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[LZ])continue;let Y=this.createTransform(),$=X.extensions[LZ];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(LZ,Y)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,Y]of J){let $=X.getExtension(LZ);if(!$)continue;Y.extensions=Y.extensions||{};let Q={},K=I0.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[LZ]=Q}return this}}LN.EXTENSION_NAME=LZ;var gD1=[i.ROOT,i.SCENE,i.NODE,i.MESH,i.MATERIAL,i.TEXTURE,i.ANIMATION];class DN extends O1{init(){this.extensionName=j4,this.propertyType="Packet",this.parentTypes=gD1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",DZ({},Z))}listProperties(){return Object.keys(this.get("properties"))}getProperty(Z){let J=this.get("properties");return Z in J?J[Z]:null}setProperty(Z,J){this._assertContext(Z);let X=DZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=pR(this.get("context")),J=pR(this.get("properties"));return DZ({"@context":Z},J)}fromJSONLD(Z){Z=pR(Z);let J=Z["@context"];if(J)this.set("context",J);return delete Z["@context"],this.set("properties",Z)}_assertContext(Z){if(!(Z.split(":")[0]in this.get("context")))throw Error(`${j4}: Missing context for term, "${Z}".`)}}DN.EXTENSION_NAME=j4;function pR(Z){return JSON.parse(JSON.stringify(Z))}class MN extends T1{constructor(...Z){super(...Z);this.extensionName=j4}createPacket(){return new DN(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[j4];if(!X||!X.packets)return this;let Y=Z.jsonDoc.json,$=this.document.getRoot(),Q=X.packets.map((G)=>this.createPacket().fromJSONLD(G)),K=[[Y.asset],Y.scenes,Y.nodes,Y.meshes,Y.materials,Y.images,Y.animations],W=[[$],$.listScenes(),$.listNodes(),$.listMeshes(),$.listMaterials(),$.listTextures(),$.listAnimations()];for(let G=0;G<K.length;G++){let z=K[G]||[];for(let v=0;v<z.length;v++){let H=z[v];if(H.extensions&&H.extensions[j4]){let V=H.extensions[j4];W[G][v].setExtension(j4,Q[V.packet])}}}return this}write(Z){let{json:J}=Z.jsonDoc,X=[];for(let Y of this.properties){X.push(Y.toJSONLD());for(let $ of Y.listParents()){let Q;switch($.propertyType){case i.ROOT:Q=J.asset;break;case i.SCENE:Q=J.scenes[Z.sceneIndexMap.get($)];break;case i.NODE:Q=J.nodes[Z.nodeIndexMap.get($)];break;case i.MESH:Q=J.meshes[Z.meshIndexMap.get($)];break;case i.MATERIAL:Q=J.materials[Z.materialIndexMap.get($)];break;case i.TEXTURE:Q=J.images[Z.imageIndexMap.get($)];break;case i.ANIMATION:Q=J.animations[Z.animationIndexMap.get($)];break;default:Q=null,this.document.getLogger().warn(`[${j4}]: Unsupported parent property, "${$.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[j4]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[j4]={packets:X};return this}}MN.EXTENSION_NAME=j4;var dD1=[pG,aR,sR,rR,eR,JN,YN,Cw,KN,fw,kw,zN,HN,Ew,cN,xN,iG,jN,LN,MN],iP6=[Pw,yG,Ow,Tw,...dD1];var aD1=t(UR(),1);function M3(){return M3=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},M3.apply(null,arguments)}var{POINTS:Qs,LINES:Iw,LINE_STRIP:nD1,LINE_LOOP:sD1,TRIANGLES:_w,TRIANGLE_STRIP:oD1,TRIANGLE_FAN:rD1}=g1.Mode;function uY(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function RZ(Z,J){let X=M3({},Z);for(let Y in J)if(J[Y]!==void 0)X[Y]=J[Y];return X}function Ms(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case g1.Mode.POINTS:return J?J.getCount():X.getCount();case g1.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case g1.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case g1.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case g1.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case g1.Mode.TRIANGLE_STRIP:case g1.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw Error("Unexpected mode: "+Z.getMode())}}var tD1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function PN(Z){return tD1.format(Z)}function eD1(Z,J,X=2){let Y=Z>J?"–":"+",$="%";return Y+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function mw(Z,J){return`${PN(Z)} → ${PN(J)} (${eD1(Z,J)})`}function uw(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 ZM1(Z,J,X){Z.swap(J,X);for(let Y of Z.listTargets())Y.swap(J,X)}function Rs(Z){let J=Z.getIndices(),X=uw(Z);if(Z.dispose(),J&&!ON(J))J.dispose();for(let Y of X)if(!ON(Y))Y.dispose()}function MZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function JM1(Z,J=Z){let X=_N(Z,J);for(let Y=0;Y<X.length;Y++)X[Y]=Y;return X}function _N(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function ON(Z){return Z.listParents().some((J)=>J.propertyType!==i.ROOT)}function Ns(Z){for(let J in Z)return!1;return!0}function Ps(Z){let J=c6.fromGraph(Z.getGraph()),X=Z.getMaterial(),Y=J.getRoot().listMaterials().indexOf(X),$=YM1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let z=Z.getAttribute(G),v=z.getElementSize(),H=z.getComponentType();return`${G}:${v}:${H}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((z)=>{let v=Z.getAttribute(z),H=v.getElementSize(),V=v.getComponentType();return`${z}:${H}:${V}`}).join("+")}).join("~");return`${Y}|${$}|${Q}|${K}|${W}`}function XM1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var YM1={[Qs]:Qs,[Iw]:Iw,[nD1]:Iw,[sD1]:Iw,[_w]:_w,[oD1]:_w,[rD1]:_w},L3="center",Ks={pivot:"center"};function Os(Z=Ks){let J=RZ(Ks,Z);return uY(L3,(X)=>{let Y=X.getLogger(),$=X.getRoot(),Q=$.listAnimations().length>0||$.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{Y.debug(`${L3}: Scene ${W+1} / ${$.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let v=NG(K);if(G=[(v.max[0]-v.min[0])/2+v.min[0],(v.max[1]-v.min[1])/2+v.min[1],(v.max[2]-v.min[2])/2+v.min[2]],J.pivot==="above")G[1]=v.max[1];if(J.pivot==="below")G[1]=v.min[1]}else G=J.pivot;Y.debug(`${L3}: Pivot "${G.join(", ")}".`);let z=[-1*G[0],-1*G[1],-1*G[2]];if(Q){Y.debug(`${L3}: Model contains animation or skin. Adding a wrapper node.`);let v=X.createNode("Pivot").setTranslation(z);K.listChildren().forEach((H)=>v.addChild(H)),K.addChild(v)}else Y.debug(`${L3}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((v)=>{let H=v.getTranslation();v.setTranslation([H[0]+z[0],H[1]+z[1],H[2]+z[2]])})}),Y.debug(`${L3}: Complete.`)})}function $M1(Z){let J=new Set,X=Z,Y;while(Y=X.getParentNode()){if(J.has(Y))throw Error("Circular dependency in scene graph.");J.add(Y),X=Y}return X.listParents().filter(($)=>$ instanceof K3)}function QM1(Z){let J=$M1(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 R3=typeof Float32Array<"u"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function KM1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=J[9],V=J[10],q=J[11],F=J[12],w=J[13],c=J[14],U=J[15],j=X*W-Y*K,B=X*G-$*K,L=X*z-Q*K,R=Y*G-$*W,M=Y*z-Q*W,N=$*z-Q*G,P=v*w-H*F,O=v*c-V*F,k=v*U-q*F,E=H*c-V*w,S=H*U-q*w,f=V*U-q*c,C=j*f-B*S+L*E+R*k-M*O+N*P;if(!C)return null;return C=1/C,Z[0]=(W*f-G*S+z*E)*C,Z[1]=($*S-Y*f-Q*E)*C,Z[2]=(w*N-c*M+U*R)*C,Z[3]=(V*M-H*N-q*R)*C,Z[4]=(G*k-K*f-z*O)*C,Z[5]=(X*f-$*k+Q*O)*C,Z[6]=(c*L-F*N-U*B)*C,Z[7]=(v*N-V*L+q*B)*C,Z[8]=(K*S-W*k+z*P)*C,Z[9]=(Y*k-X*S-Q*P)*C,Z[10]=(F*M-w*L+U*j)*C,Z[11]=(H*L-v*M-q*j)*C,Z[12]=(W*O-K*E-G*P)*C,Z[13]=(X*E-Y*O+$*P)*C,Z[14]=(w*B-F*R-c*j)*C,Z[15]=(v*R-H*B+V*j)*C,Z}function WM1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],w=Z[14],c=Z[15],U=J*K-X*Q,j=J*W-Y*Q,B=J*G-$*Q,L=X*W-Y*K,R=X*G-$*K,M=Y*G-$*W,N=z*F-v*q,P=z*w-H*q,O=z*c-V*q,k=v*w-H*F,E=v*c-V*F,S=H*c-V*w;return U*S-j*E+B*k+L*O-R*P+M*N}function Ts(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],w=J[12],c=J[13],U=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*Y+L*W+R*H+M*w,Z[1]=B*$+L*G+R*V+M*c,Z[2]=B*Q+L*z+R*q+M*U,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*Y+L*W+R*H+M*w,Z[5]=B*$+L*G+R*V+M*c,Z[6]=B*Q+L*z+R*q+M*U,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*Y+L*W+R*H+M*w,Z[9]=B*$+L*G+R*V+M*c,Z[10]=B*Q+L*z+R*q+M*U,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*Y+L*W+R*H+M*w,Z[13]=B*$+L*G+R*V+M*c,Z[14]=B*Q+L*z+R*q+M*U,Z[15]=B*K+L*v+R*F+M*j,Z}var j6;(function(Z){Z.RENDER="render",Z.RENDER_CACHED="render-cached",Z.UPLOAD="upload",Z.UPLOAD_NAIVE="upload-naive",Z.DISTINCT="distinct",Z.DISTINCT_POSITION="distinct-position",Z.UNUSED="unused"})(j6||(j6={}));function mY(Z,J){let X=Z.getAttribute("POSITION"),Y=Z.getIndices();switch(J){case j6.RENDER:return Y?Y.getCount():X.getCount();case j6.RENDER_CACHED:return Y?new Set(Y.getArray()).size:X.getCount();case j6.UPLOAD_NAIVE:case j6.UPLOAD:return X.getCount();case j6.DISTINCT:case j6.DISTINCT_POSITION:return GM1(J);case j6.UNUSED:return Y?X.getCount()-new Set(Y.getArray()).size:0;default:return zM1(J)}}function GM1(Z){throw Error(`Not implemented: ${Z}`)}function zM1(Z){throw Error(`Unexpected value: ${Z}`)}var gJ=4294967295;class Cs{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of uw(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(),$=E0.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 vM1(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 vM1(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 VM1(Z,J,X,Y,$=gJ){let Q=J-1,W=X.hash(Y)&Q;for(let G=0;G<=Q;G++){let z=Z[W];if(z===$||X.equal(z,Y))return W;W=W+G+1&Q}throw Error("Hash table full.")}function dG(Z,J,X){let Y=c6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=HM1(Z);let $=Z.getIndices(),Q=$?$.getArray():null,K=mY(Z,j6.RENDER),W=Y.createAccessor(),G=K,z=_N(G,X);for(let H=0;H<G;H++)z[H]=J[Q?Q[H]:H];Z.setIndices(W.setArray(z));let v=uw(Z);for(let H of Z.listAttributes()){let V=MZ(Y,H);TN(H,$,J,V,X),Z.swap(H,V)}for(let H of Z.listTargets())for(let V of H.listAttributes()){let q=MZ(Y,V);TN(V,$,J,q,X),H.swap(V,q)}if($&&$.listParents().length===1)$.dispose();for(let H of v)if(H.listParents().length===1)H.dispose();return Z}function TN(Z,J,X,Y,$){let Q=Z.getElementSize(),K=Z.getArray(),W=J?J.getArray():null,G=J?J.getCount():Z.getCount(),z=new K.constructor($*Q),v=new Uint8Array($);for(let H=0;H<G;H++){let V=W?W[H]:H,q=X[V];if(v[q])continue;for(let F=0;F<Q;F++)z[q*Q+F]=K[V*Q+F];v[q]=1}return Y.setArray(z)}function HM1(Z){let J=mY(Z,j6.UPLOAD),X=Z.getIndices(),Y=X?X.getArray():null;if(!X||!Y)return[JM1(J,1e6),J];let $=new Uint32Array(J).fill(gJ),Q=0;for(let K=0;K<Y.length;K++){let W=Y[K];if($[W]===gJ)$[W]=Q++}return[$,Q]}function qM1(){var Z=new R3(9);if(R3!=Float32Array)Z[1]=0,Z[2]=0,Z[3]=0,Z[5]=0,Z[6]=0,Z[7]=0;return Z[0]=1,Z[4]=1,Z[8]=1,Z}function FM1(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 wM1(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 cM1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=v*K-W*z,V=-v*Q+W*G,q=z*Q-K*G,F=X*H+Y*V+$*q;if(!F)return null;return F=1/F,Z[0]=H*F,Z[1]=(-v*Y+$*z)*F,Z[2]=(W*Y-$*K)*F,Z[3]=V*F,Z[4]=(v*X-$*G)*F,Z[5]=(-W*X+$*Q)*F,Z[6]=q*F,Z[7]=(-z*X+Y*G)*F,Z[8]=(K*X-Y*Q)*F,Z}function lw(){var Z=new R3(3);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function UM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function fs(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 xM1(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 jM1(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 BM1=UM1;(function(){var Z=lw();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();var CN="weld",Sw={overwrite:!0};function hN(Z=Sw){let J=RZ(Sw,Z);return uY(CN,async(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes()){for(let Q of $.listPrimitives())if(yw(Q,J),mY(Q,j6.RENDER)===0)Rs(Q);if($.listPrimitives().length===0)$.dispose()}Y.debug(`${CN}: Complete.`)})}function yw(Z,J=Sw){let X=Z.getGraph(),$=c6.fromGraph(X).getLogger(),Q=M3({},Sw,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===g1.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),W=Z.getIndices(),G=W==null?void 0:W.getArray(),z=W?W.getCount():K,v=new Cs(Z),H=XM1(K+K/4),V=new Uint32Array(H).fill(gJ),q=new Uint32Array(K).fill(gJ),F=0;for(let w=0;w<z;w++){let c=G?G[w]:w;if(q[c]!==gJ)continue;let U=VM1(V,H,v,c,gJ),j=V[U];if(j===gJ)V[U]=c,q[c]=F++;else q[c]=q[j]}$.debug(`${CN}: ${mw(K,F)} vertices.`),dG(Z,q,F)}var{FLOAT:LM1}=K0.ComponentType;function ks(Z,J){let X=Z.getAttribute("POSITION");if(X)Ws(J,X);let Y=Z.getAttribute("NORMAL");if(Y)Gs(J,Y);let $=Z.getAttribute("TANGENT");if($)zs(J,$);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)Ws(J,K);let W=Q.getAttribute("NORMAL");if(W)Gs(J,W);let G=Q.getAttribute("TANGENT");if(G)zs(J,G)}if(WM1(J)<0)DM1(Z)}function Ws(Z,J){let X=J.getComponentType(),Y=J.getNormalized(),$=J.getArray(),Q=X===LM1?$:new Float32Array($.length),K=lw();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=I0.decodeNormalizedInt($[W*3],X),K[1]=I0.decodeNormalizedInt($[W*3+1],X),K[2]=I0.decodeNormalizedInt($[W*3+2],X);else K[0]=$[W*3],K[1]=$[W*3+1],K[2]=$[W*3+2];xM1(K,K,Z),Q[W*3]=K[0],Q[W*3+1]=K[1],Q[W*3+2]=K[2]}J.setArray(Q).setNormalized(!1)}function Gs(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=qM1();FM1(Q,Z),cM1(Q,Q),wM1(Q,Q);let K=lw();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=I0.decodeNormalizedInt(X[W*3],$),K[1]=I0.decodeNormalizedInt(X[W*3+1],$),K[2]=I0.decodeNormalizedInt(X[W*3+2],$);else K[0]=X[W*3],K[1]=X[W*3+1],K[2]=X[W*3+2];if(jM1(K,K,Q),fs(K,K),Y)X[W*3]=I0.decodeNormalizedInt(K[0],$),X[W*3+1]=I0.decodeNormalizedInt(K[1],$),X[W*3+2]=I0.decodeNormalizedInt(K[2],$);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function zs(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=lw();for(let K=0,W=J.getCount();K<W;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],fs(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 DM1(Z){if(Z.getMode()!==g1.Mode.TRIANGLES)return;if(!Z.getIndices())yw(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 MM1(Z,J){for(let X of Z.listPrimitives()){let Y=RM1(X,Z);if(X!==Y)Z.removePrimitive(X).addPrimitive(Y)}for(let X of Z.listPrimitives())dG(X),ks(X,J)}function RM1(Z,J){if(Z.listParents().some((Y)=>Y instanceof PG&&Y!==J))Z=Z.clone();for(let Y of Z.listTargets())if(Y.listParents().some((Q)=>Q instanceof g1&&Q!==Z))Z.removeTarget(Y).addTarget(Y.clone());return Z}var vs=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function Es(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!I0.eq(X,vs))MM1(J,X);for(let Y of Z.listChildren()){let $=Y.getMatrix();Ts($,$,X),Y.setMatrix($)}return Z.setMatrix(vs)}var{LINES:NM1,LINE_STRIP:PM1,LINE_LOOP:OM1,TRIANGLES:TM1,TRIANGLE_STRIP:CM1,TRIANGLE_FAN:fM1}=g1.Mode;function kM1(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())yw(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=Ms(Z),W=new bJ[Y.getComponentType()](Q*2),G=Z.getMode();if(G===PM1)for(let v=0;v<Q;v++)W[v*2]=$[v],W[v*2+1]=$[v+1];else if(G===OM1)for(let v=0;v<Q;v++)if(v<Q-1)W[v*2]=$[v],W[v*2+1]=$[v+1];else W[v*2]=$[v],W[v*2+1]=$[0];else throw Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(NM1);let z=X.getRoot();if(Y.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,Y).setArray(W));else Y.setArray(W)}function Is(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())yw(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=Ms(Z),W=new bJ[Y.getComponentType()](Q*3),G=Z.getMode();if(G===CM1)for(let v=0,H=$.length;v<H-2;v++)if(v%2)W[v*3]=$[v+1],W[v*3+1]=$[v],W[v*3+2]=$[v+2];else W[v*3]=$[v],W[v*3+1]=$[v+1],W[v*3+2]=$[v+2];else if(G===fM1)for(let v=0;v<Q;v++)W[v*3]=$[0],W[v*3+1]=$[v+1],W[v*3+2]=$[v+2];else throw Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(TM1);let z=X.getRoot();if(Y.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,Y).setArray(W));else Y.setArray(W)}var oP6={keepUniqueNames:!1,propertyTypes:[i.ACCESSOR,i.MESH,i.TEXTURE,i.MATERIAL,i.SKIN]};var Vs="dequantize",bw={pattern:/^((?!JOINTS_).)*$/};function _s(Z=bw){let J=RZ(bw,Z);return uY(Vs,(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes())for(let Q of $.listPrimitives())EM1(Q,J);X.createExtension(iG).dispose(),Y.debug(`${Vs}: Complete.`)})}function EM1(Z,J=bw){let X=RZ(bw,J);for(let Y of Z.listSemantics())if(X.pattern.test(Y))fN(Z.getAttribute(Y));for(let Y of Z.listTargets())for(let $ of Y.listSemantics())if(X.pattern.test($))fN(Y.getAttribute($))}function fN(Z){let J=Z.getArray();if(!J)return;let X=Aw(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function Aw(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:hs,ROOT:rP6}=i;function Ss(Z){let J=new c6().setLogger(Z.getLogger()),X=SN(J,Z);return IM1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function IM1(Z,J,X){X||(X=SN(Z,J));for(let Y of J.getRoot().listExtensionsUsed()){let $=Z.createExtension(Y.constructor);if(Y.isRequired())$.setRequired(!0)}return _M1(Z,J,hM1(J),X)}function _M1(Z,J,X,Y){Y||(Y=SN(Z,J));let $=new Map;for(let Q of X)if(!$.has(Q)&&Q.propertyType!==hs)$.set(Q,Y(Q));for(let[Q,K]of $.entries())K.copy(Q,Y);return $}function SN(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return(Y)=>{if(Y.propertyType===hs)return Y;let $=X.get(Y);if(!$)$=new Y.constructor(Z.getGraph()),X.set(Y,$);return $}}function hM1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}function bs(){var Z=new R3(4);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function SM1(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 bM1(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 AM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z[3]=J[3]*X[3],Z}function mM1(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z}function uM1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return Math.hypot(J,X,Y,$)}var As=bM1,lM1=AM1,ms=uM1;(function(){var Z=bs();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=4;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Z[3]=J[W+3],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2],J[W+3]=Z[3];return J}})();var yM1=/color|emissive|diffuse/i;function pM1(Z){return Z.getGraph().listParentEdges(Z).some(($)=>{return $.getAttributes().isColor||yM1.test($.getName())})?"srgb":null}function iM1(Z){let J=Z.getGraph(),X=new Set,Y=new Set;function $(Q){let K=new Set;for(let W of J.listChildEdges(Q))if(W.getChild()instanceof _Y)K.add(W.getName()+"Info");for(let W of J.listChildEdges(Q)){let G=W.getChild();if(X.has(G))continue;if(X.add(G),G instanceof F1&&K.has(W.getName()))Y.add(G);else if(G instanceof O1)$(G)}}return $(Z),Array.from(Y)}function gM1(Z){let X=c6.fromGraph(Z.getGraph()).getRoot(),Y=Z.getGraph().listParentEdges(Z).filter(($)=>$.getParent()!==X).map(($)=>$.getName());return Array.from(new Set(Y))}var D3="prune",kN=0.011764705882352941,Hs={propertyTypes:[i.NODE,i.SKIN,i.MESH,i.CAMERA,i.PRIMITIVE,i.PRIMITIVE_TARGET,i.ANIMATION,i.MATERIAL,i.TEXTURE,i.ACCESSOR,i.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function us(Z=Hs){let J=RZ(Hs,Z),X=new Set(J.propertyTypes),Y=J.keepExtras;return uY(D3,async($)=>{let Q=$.getLogger(),K=$.getRoot(),W=$.getGraph(),G=new ls,z=(v)=>G.dispose(v.target);if(W.addEventListener("node:dispose",z),X.has(i.MESH))for(let v of K.listMeshes()){if(v.listPrimitives().length>0)continue;v.dispose()}if(X.has(i.NODE)){if(!J.keepLeaves)for(let v of K.listScenes())ys(W,v,Y);for(let v of K.listNodes())L4(v,Y)}if(X.has(i.SKIN))for(let v of K.listSkins())L4(v,Y);if(X.has(i.MESH))for(let v of K.listMeshes())L4(v,Y);if(X.has(i.CAMERA))for(let v of K.listCameras())L4(v,Y);if(X.has(i.PRIMITIVE))qs(W,i.PRIMITIVE,Y);if(X.has(i.PRIMITIVE_TARGET))qs(W,i.PRIMITIVE_TARGET,Y);if(!J.keepAttributes&&X.has(i.ACCESSOR)){let v=new Map;for(let H of K.listMeshes())for(let V of H.listPrimitives()){let q=V.getMaterial();if(!q)continue;let F=ps($,V,q),w=dM1(V,F);Fs(V,w),V.listTargets().forEach((c)=>Fs(c,w)),v.has(q)?v.get(q).add(V):v.set(q,new Set([V]))}for(let[H,V]of v)aM1(H,Array.from(V))}if(X.has(i.ANIMATION))for(let v of K.listAnimations()){for(let H of v.listChannels())if(!H.getTargetNode())H.dispose();if(!v.listChannels().length){let H=v.listSamplers();L4(v,Y),H.forEach((V)=>L4(V,Y))}else v.listSamplers().forEach((H)=>L4(H,Y))}if(X.has(i.MATERIAL))K.listMaterials().forEach((v)=>L4(v,Y));if(X.has(i.TEXTURE)){if(K.listTextures().forEach((v)=>L4(v,Y)),!J.keepSolidTextures)await nM1($)}if(X.has(i.ACCESSOR))K.listAccessors().forEach((v)=>L4(v,Y));if(X.has(i.BUFFER))K.listBuffers().forEach((v)=>L4(v,Y));if(W.removeEventListener("node:dispose",z),!G.empty()){let v=G.entries().map(([H,V])=>`${H} (${V})`).join(", ");Q.info(`${D3}: Removed types... ${v}`)}else Q.debug(`${D3}: No unused properties found.`);Q.debug(`${D3}: Complete.`)})}class ls{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 L4(Z,J){let X=Z.listParents().filter(($)=>!($ instanceof W3||$ instanceof QZ)),Y=J&&!Ns(Z.getExtras());if(!X.length&&!Y)Z.dispose()}function qs(Z,J,X){for(let Y of Z.listEdges()){let $=Y.getParent();if($.propertyType===J)L4($,X)}}function ys(Z,J,X){if(J.listChildren().forEach((K)=>ys(Z,K,X)),J instanceof K3)return;let Y=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==i.ROOT&&W!==i.SCENE&&W!==i.NODE}),$=Z.listChildren(J).length===0,Q=X&&!Ns(J.getExtras());if($&&!Y&&!Q)J.dispose()}function Fs(Z,J){for(let X of J)Z.setAttribute(X,null)}function dM1(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 ps(Z,J,X,Y=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let z of Q)if(z.getChild()instanceof _Y)K.add(z.getName());for(let z of Q){let v=z.getName(),H=z.getChild();if(H instanceof F1){if(K.has(v.replace(/Info$/,"")))Y.add(`TEXCOORD_${H.getTexCoord()}`)}if(H instanceof _Y&&v.match(/normalTexture/i))Y.add("TANGENT");if(H instanceof O1)ps(Z,J,H,Y)}let W=X instanceof K7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===g1.Mode.POINTS;if(W&&!G)Y.add("NORMAL");return Y}function aM1(Z,J){let X=iM1(Z),Y=new Set(X.map((G)=>G.getTexCoord())),$=Array.from(Y).sort(),Q=new Map($.map((G,z)=>[G,z])),K=new Map($.map((G,z)=>[`TEXCOORD_${G}`,`TEXCOORD_${z}`]));for(let G of X){let z=G.getTexCoord();G.setTexCoord(Q.get(z))}for(let G of J){let z=G.listSemantics().filter((v)=>v.startsWith("TEXCOORD_")).sort();W(G,z),G.listTargets().forEach((v)=>W(v,z))}function W(G,z){for(let v of z){let H=G.getAttribute(v);if(!H)continue;let V=K.get(v);if(V===v)continue;G.setAttribute(V,H),G.setAttribute(v,null)}}}async function nM1(Z){let J=Z.getRoot(),X=Z.getGraph(),Y=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await oM1(K);if(!G)return;if(pM1(K)==="srgb")VR.convertSRGBToLinear(G,G);let z=K.getName()||K.getURI(),v=(W=K.getSize())==null?void 0:W.join("x"),H=gM1(K);for(let V of X.listParentEdges(K)){let q=V.getParent();if(q!==J&&sM1(q,G,V.getName(),Y))V.dispose()}if(K.listParents().length===1)K.dispose(),Y.debug(`${D3}: Removed solid-color texture "${z}" (${v}px ${H.join(", ")})`)});await Promise.all(Q)}function sM1(Z,J,X,Y){if(Z instanceof K7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(lM1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(BM1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=kN;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return ms(As(bs(),J,[0.5,0.5,1,1]))<=kN}return Y.warn(`${D3}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function oM1(Z){let J=await rM1(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 W=0;W<Q;W++){for(let G=0;G<K;G++)for(let z=0;z<4;z++)X[z]=Math.min(X[z],J.get(W,G,z)),Y[z]=Math.max(Y[z],J.get(W,G,z));if(ms(As($,Y,X))/255>kN)return null}return mM1($,SM1($,Y,X),0.00196078431372549)}async function rM1(Z){try{return await _n(Z.getImage(),Z.getMimeType())}catch(J){return null}}var RN="flatten",ws={cleanup:!0};function is(Z=ws){let J=RZ(ws,Z);return uY(RN,async(X)=>{let Y=X.getRoot(),$=X.getLogger(),Q=new Set;for(let z of Y.listSkins())for(let v of z.listJoints())Q.add(v);let K=new Set;for(let z of Y.listAnimations())for(let v of z.listChannels()){let H=v.getTargetNode();if(H&&v.getTargetPath()!=="weights")K.add(H)}let W=new Set,G=new Set;for(let z of Y.listScenes())z.traverse((v)=>{let H=v.getParentNode();if(!H)return;if(Q.has(H)||W.has(H))W.add(v);if(K.has(H)||G.has(H))G.add(v)});for(let z of Y.listScenes())z.traverse((v)=>{if(K.has(v))return;if(W.has(v))return;if(G.has(v))return;QM1(v)});if(K.size)$.debug(`${RN}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(us({propertyTypes:[i.NODE],keepLeaves:!1}));$.debug(`${RN}: Complete.`)})}function gs(Z){return NG(Z)}var tM1={skipValidation:!1},cs=4294967295,{LINE_STRIP:eM1,LINE_LOOP:ZR1,TRIANGLE_STRIP:JR1,TRIANGLE_FAN:XR1}=g1.Mode;function YR1(Z,J={}){let X=RZ(tM1,J),Y=Z[0],$=c6.fromGraph(Y.getGraph());if(!X.skipValidation&&new Set(Z.map(Ps)).size>1)throw Error("Requires >=2 Primitives, sharing the same Material and Mode, with compatible vertex attributes and indices.");for(let q of Z)switch(q.getMode()){case eM1:case ZR1:kM1(q);break;case JR1:case XR1:Is(q);break}let Q=[],K=new Uint32Array(Z.length),W=0,G=0;for(let q=0;q<Z.length;q++){let F=Z[q],w=F.getIndices(),c=F.getAttribute("POSITION").getCount(),U=w?w.getArray():null,j=w?w.getCount():c,B=new Uint32Array(c).fill(cs);for(let L=0;L<j;L++){let R=U?U[L]:L;if(B[R]===cs)B[R]=W++,K[q]++}Q.push(B),G+=j}let z=$.createPrimitive().setMode(Y.getMode()).setMaterial(Y.getMaterial());for(let q of Y.listSemantics()){let F=Y.getAttribute(q),w=bJ[F.getComponentType()],c=MZ($,F).setArray(new w(W*F.getElementSize()));z.setAttribute(q,c)}let v=Y.getIndices(),H=v?MZ($,v).setArray(_N(G,W)):null;z.setIndices(H);let V=0;for(let q=0;q<Q.length;q++){let F=Z[q],w=F.getIndices(),c=w?w.getCount():-1,U=Q[q];if(w&&H)QR1(w,U,H,V),V+=c;for(let j of z.listSemantics()){let B=F.getAttribute(j),L=z.getAttribute(j);$R1(B,w,U,L)}}return z}function $R1(Z,J,X,Y){let $=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),W=Z.getArray(),G=Y.getArray(),z=new Uint8Array(Z.getCount());for(let v=0,H=J?J.getCount():K;v<H;v++){let V=Q?Q[v]:v,q=X[V];if(z[q])continue;for(let F=0;F<$;F++)G[q*$+F]=W[V*$+F];z[q]=1}}function QR1(Z,J,X,Y){let $=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let W=0;W<$;W++){let G=Q[W],z=J[G];K[Y+W]=z}}var EN="join",{ROOT:KR1,NODE:WR1,MESH:GR1,PRIMITIVE:zR1,ACCESSOR:vR1}=i,NN=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Us={keepMeshes:!1,keepNamed:!1,cleanup:!0,filter:()=>!0};function ds(Z=Us){let J=RZ(Us,Z);return uY(EN,async(X)=>{let Y=X.getRoot(),$=X.getLogger();for(let Q of Y.listScenes())xs(X,Q,J),Q.traverse((K)=>xs(X,K,J));if(J.cleanup)await X.transform(us({propertyTypes:[WR1,GR1,zR1,vR1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));$.debug(`${EN}: Complete.`)})}function xs(Z,J,X){let Y=Z.getLogger(),$={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let z=Q[G];if(!X.filter(z))continue;if(z.listParents().some((V)=>V instanceof QZ))continue;let H=z.getMesh();if(!H)continue;if(z.getExtension("EXT_mesh_gpu_instancing"))continue;if(z.getSkin())continue;for(let V of H.listPrimitives()){if(V.listTargets().length>0)continue;let q=V.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;dG(V),HR1(V);let F=Ps(V),w=H.getName()||z.getName();if(X.keepMeshes||X.keepNamed&&w)F+=`|${G}`;if(!(F in $))$[F]={prims:[],primMeshes:[],primNodes:[],dstNode:z,dstMesh:void 0};let c=$[F];c.prims.push(V),c.primNodes.push(z)}}let K=Object.values($).filter(({prims:G})=>G.length>1),W=new Set(K.flatMap((G)=>G.primNodes));for(let G of W){let z=G.getMesh();if(z.listParents().some((H)=>{return H.propertyType!==KR1&&G!==H}))G.setMesh(z.clone())}for(let G of K){let{dstNode:z,primNodes:v}=G;G.dstMesh=z.getMesh(),G.primMeshes=v.map((H)=>H.getMesh())}for(let G of K){let{prims:z,primNodes:v,primMeshes:H,dstNode:V,dstMesh:q}=G,F=V.getMatrix();for(let U=0;U<z.length;U++){let j=v[U],B=H[U],L=z[U];if(B.removePrimitive(L),ON(L))L=z[U]=VR1(z[U]);if(j!==V)Ts(NN,KM1(NN,F),j.getMatrix()),ks(L,NN)}let w=YR1(z),c=w.listAttributes()[0].getCount();q.addPrimitive(w),Y.debug(`${EN}: Joined Primitives (${z.length}) containing ${PN(c)} vertices under Node "${V.getName()}".`)}}function VR1(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 HR1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)fN(X)}}var{TRANSLATION:tP6,ROTATION:eP6,SCALE:ZO6,WEIGHTS:JO6}=QZ.TargetPath;var qR1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var XO6=M3({level:"high"},qR1);var FR1="unweld";function wR1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let Y=Z.getGraph(),$=c6.fromGraph(Y),Q=$.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,js($,G,X,J)),G.listParents().length===1)G.dispose();for(let G of Z.listTargets())for(let z of G.listAttributes())if(G.swap(z,js($,z,X,J)),z.listParents().length===1)z.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${FR1}: ${mw(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function js(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()),W=X.getArray(),G=J.getElementSize();for(let v=0,H=X.getCount();v<H;v++)for(let V=0;V<G;V++)K[v*G+V]=$[W[v]*G+V];if(!Y.has(J))Y.set(J,new Map);let z=MZ(Z,J).setArray(K);return Y.get(J).set(X,z),z}var Bs;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Bs||(Bs={}));var cR1=0.000001;function UR1(Z,J,X,Y=0.0001){let $=J.length/Z.length,Q=Array($).fill(0),K=Array($).fill(0),W=Array($).fill(0),G=Array($).fill(0),z=Z.length-1,v=1;for(let H=1;H<z;++H){let V=Z[v-1],q=Z[H],F=Z[H+1],w=(q-V)/(F-V),c=!1;if(q!==F&&(H!==1||q!==Z[0])){if(gG(J,v-1,G),gG(J,H,K),gG(J,H+1,W),X==="slerp"){let U=BR1(Q,G,W,w),j=Ds(G,K)+Ds(K,W);c=!hw(K,U,Y)||j+Number.EPSILON>=Math.PI}else if(X==="lerp"){let U=jR1(Q,G,W,w);c=!hw(K,U,Y)}else if(X==="step")c=!hw(K,G)||!hw(K,W)}if(c){if(H!==v)Z[v]=Z[H],Ls(J,v,gG(J,H,Q));v++}}if(z>0)Z[v]=Z[z],Ls(J,v,gG(J,z,Q)),v++;return v}function gG(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)X[Y]=Z[J*$+Y];return X}function Ls(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)Z[J*$+Y]=X[Y]}function hw(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 xR1(Z,J,X){return Z*(1-X)+J*X}function jR1(Z,J,X,Y){for(let $=0;$<J.length;$++)Z[$]=xR1(J[$],X[$],Y);return Z}function BR1(Z,J,X,Y){let $=J[0],Q=J[1],K=J[2],W=J[3],G=X[0],z=X[1],v=X[2],H=X[3],V,q,F,w,c;if(q=$*G+Q*z+K*v+W*H,q<0)q=-q,G=-G,z=-z,v=-v,H=-H;if(1-q>cR1)V=Math.acos(q),F=Math.sin(V),w=Math.sin((1-Y)*V)/F,c=Math.sin(Y*V)/F;else w=1-Y,c=Y;return Z[0]=w*$+c*G,Z[1]=w*Q+c*z,Z[2]=w*K+c*v,Z[3]=w*W+c*H,Z}function Ds(Z,J){let X=LR1(Z,J);return Math.acos(2*X*X-1)}function LR1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var YO6=new Float32Array(0),$O6={ready:Promise.resolve(),resample:UR1,tolerance:0.0001,cleanup:!0};var AY="simplify",{POINTS:as,LINES:DR1,LINE_STRIP:MR1,LINE_LOOP:RR1,TRIANGLES:NR1,TRIANGLE_STRIP:ns,TRIANGLE_FAN:ss}=g1.Mode,os={ratio:0,error:0.0001,lockBorder:!1};function rs(Z){let J=RZ(os,Z),X=J.simplifier;if(!X)throw Error(`${AY}: simplifier dependency required — install "meshoptimizer".`);return uY(AY,async(Y)=>{let $=Y.getLogger();await X.ready,await Y.transform(hN({overwrite:!1}));let Q=0;for(let K of Y.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G!==NR1&&G!==ns&&G!==ss&&G!==as){Q++;continue}if(PR1(W,J),mY(W,j6.RENDER)===0)Rs(W)}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)$.warn(`${AY}: Skipped ${Q} primitives: Unsupported draw mode.`);$.debug(`${AY}: Complete.`)})}function PR1(Z,J){let X=M3({},os,J),Y=X.simplifier,$=Z.getGraph(),Q=c6.fromGraph($),K=Q.getLogger();switch(Z.getMode()){case as:return OR1(Q,Z,X);case DR1:case MR1:case RR1:return K.warn(`${AY}: Skipping primitive simplification: Unsupported draw mode.`),Z;case ns:case ss:Is(Z);break}let W=mY(Z,j6.UPLOAD),G=mY(Z,j6.RENDER);if(G<W/2)dG(Z);let z=Z.getAttribute("POSITION"),v=Z.getIndices(),H=z.getArray(),V=v.getArray();if(!(H instanceof Float32Array))H=Aw(H,z.getComponentType(),z.getNormalized());if(!(V instanceof Uint32Array))V=new Uint32Array(V);let q=Math.floor(X.ratio*G/3)*3,F=X.lockBorder?["LockBorder"]:[],[w,c]=Y.simplify(V,H,3,q,X.error,F);if(Z.setIndices(MZ(Q,v).setArray(w)),v.listParents().length===1)v.dispose();dG(Z);let U=mY(Z,j6.UPLOAD);if(U<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${AY}: ${mw(W,U)} vertices, error: ${c.toFixed(4)}.`),Z}function OR1(Z,J,X){let Y=X.simplifier,$=Z.getLogger();if(J.getIndices())wR1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),z=K.getArray(),v=W?W.getArray():void 0,H=W?W.getComponentSize():void 0;if(!(z instanceof Float32Array))z=Aw(z,K.getComponentType(),K.getNormalized());if(v&&!(v instanceof Float32Array))v=Aw(v,K.getComponentType(),K.getNormalized());let V=Math.floor(X.ratio*G),q=Y.simplifyPoints(z,3,V,v,H),[F,w]=Y.compactMesh(q);$.debug(`${AY}: ${mw(K.getCount(),w)} vertices.`);for(let c of uw(J)){let U=MZ(Z,c);if(TN(c,null,F,U,w),ZM1(J,c,U),c.listParents().length===1)c.dispose()}return J}var IN;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(IN||(IN={}));var QO6={resizeFilter:IN.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var $o=t(Yo(),1);var NZ={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DATA_SCHEMA_VERSION:1,DATA_EXT:".data.json",DIRECTORIES:[(()=>{try{return q5.dirname(g.resolve("@hytopia.com/assets"))}catch{return null}})(),q5.resolve(process.cwd(),"assets")].filter(Boolean),OPTIMIZER_RUNS:[{suffix:"",options:["--compress","false","--instance","false","--simplify","false"]},{suffix:"-named-nodes",options:["--compress","false","--instance","false","--simplify","false","--join","true","--join-named","false"]}]};class B6{static instance=new B6;optimize=!0;optimizeEveryStart=!1;_modelUriAnimationNames=new Map;_modelUriBoundingBoxes=new Map;_modelUriNodeNames=new Map;_modelUriTrimeshes=new Map;constructor(){}async preloadModels(){let Z=await this._getAbsoluteModelPaths();console.log(`ModelRegistry.preloadModels(): Preloading ${Z.length} models...`);let J=performance.now();for(let Y of Z){if(this.optimize)await this._resolveOptimizedModelPath(Y);await this._loadModelData(Y)}let X=performance.now();console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models in ${X-J}ms!`)}getAnimationNames(Z){let J=this._modelUriAnimationNames.get(Z);if(!J)p.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)p.fatalError(`ModelRegistry.getBoundingBox(): Model ${Z} not found!`);return J}getDepth(Z){let J=this.getBoundingBox(Z);return J.max.z-J.min.z}getHeight(Z){let J=this.getBoundingBox(Z);return J.max.y-J.min.y}getNodeNames(Z){let J=this._modelUriNodeNames.get(Z);if(!J)p.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){p.error(`ModelRegistry.getTrimesh(): Model ${Z} not found!`);return}let 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)p.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=q5.normalize(Z);for(let X of NZ.DIRECTORIES){let Y=q5.normalize(X);if(J.startsWith(Y))return q5.relative(Y,J).replace(/\\/g,"/")}return q5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of NZ.DIRECTORIES){let X=q5.resolve(process.cwd(),J);if(!D4.existsSync(X))continue;let Y=await uF("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let $ of Y)Z.push(q5.join(X,$))}return Z}async _loadModelData(Z){let X=`${this._buildOptimizedModelPath(Z)}${NZ.DATA_EXT}`,Y=this._absoluteModelPathToModelUri(Z),$=this._calculateChecksum(Z),Q;if(D4.existsSync(X))try{let K=D4.readFileSync(X,"utf8"),W=JSON.parse(K);if(W?.schemaVersion!==NZ.DATA_SCHEMA_VERSION)throw Error("ModelRegistry._loadModelData(): Schema version mismatch! Data will be regenerated..");if(W?.source?.sha256!==$)throw Error("ModelRegistry._loadModelData(): Checksum mismatch! Data will be regenerated..");Q=W}catch{}if(!Q){let K=await new cR().read(Z),W=gs(K.getRoot().listScenes()[0]),G=K.getRoot().listNodes().map((H)=>H.getName()),z=K.getRoot().listAnimations().map((H)=>H.getName()),v=await this._buildTrimesh(K);Q={schemaVersion:NZ.DATA_SCHEMA_VERSION,source:{uri:Y,sha256:$},animationNames:z,boundingBox:{min:{x:W.min[0],y:W.min[1],z:W.min[2]},max:{x:W.max[0],y:W.max[1],z:W.max[2]}},nodeNames:G,trimesh:v?{vertices:Array.from(v.vertices),indices:Array.from(v.indices)}:void 0};try{let H=q5.dirname(X);D4.mkdirSync(H,{recursive:!0}),D4.writeFileSync(X,JSON.stringify(Q))}catch(H){p.warning(`ModelRegistry._loadModelData(): Failed to write data file for ${Y}. Error: ${String(H)}`)}}this._modelUriAnimationNames.set(Y,Q.animationNames),this._modelUriBoundingBoxes.set(Y,Q.boundingBox),this._modelUriNodeNames.set(Y,Q.nodeNames),this._modelUriTrimeshes.set(Y,Q.trimesh?{vertices:new Float32Array(Q.trimesh.vertices),indices:new Uint32Array(Q.trimesh.indices)}:void 0)}async _resolveOptimizedModelPath(Z){let J=this._buildOptimizedModelPath(Z);if(!this.optimizeEveryStart&&this._isOptimizedVersionValid(Z))return J;return await this._optimizeModel(Z,J)}_isOptimizedVersionValid(Z){let J=`${this._buildOptimizedModelPath(Z)}${NZ.CHECKSUM_EXT}`;if(!D4.existsSync(J))return!1;let X=this._calculateChecksum(Z),Y=D4.readFileSync(J,"utf8");return X===Y}_calculateChecksum(Z){if(!D4.existsSync(Z))return"";let J=D4.readFileSync(Z);return ER1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=q5.basename(Z),X=J.replace(/\.[^/.]+$/,""),Y=q5.dirname(Z),$=q5.join(Y,NZ.OPTIMIZED_DIR,X);return q5.join($,J)}async _buildTrimesh(Z,J=1,X=0.001){let Y=Ss(Z);Y.setLogger(new z5(MG.WARN)),await Y.transform(Os({pivot:"center"}),is(),ds(),hN(),rs({simplifier:$o.MeshoptSimplifier,ratio:J,error:X}),_s());for(let V of Y.getRoot().listScenes())for(let q of V.listChildren())Es(q);let $=[],Q=0,K=0;for(let V of Y.getRoot().listMeshes())for(let q of V.listPrimitives()){let F=q.getAttribute("POSITION"),w=q.getIndices();if(!F||!w)continue;let c=F.getArray(),U=w.getArray(),j=U instanceof Uint32Array?U:new Uint32Array(U);if(c.length===0||j.length===0)continue;$.push({vertices:c,indices:j}),Q+=c.length,K+=j.length}if($.length===0){p.error("ModelRegistry._buildTrimesh(): Model has no primitives with POSITION and INDICES!");return}let W=new Float32Array(Q),G=new Uint32Array(K),z=0,v=0,H=0;for(let V of $){W.set(V.vertices,z);let q=V.vertices.length/3;for(let F=0;F<V.indices.length;F++)G[H+F]=V.indices[F]+v;z+=V.vertices.length,H+=V.indices.length,v+=q}return{vertices:W,indices:G}}async _optimizeModel(Z,J){let X=q5.dirname(J);D4.rmSync(X,{recursive:!0,force:!0}),D4.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let Y of NZ.OPTIMIZER_RUNS){let $=J.replace(/(\.[^/.]+)$/,`${Y.suffix}$1`),{stderr:Q}=await ji("npx",["@gltf-transform/cli","optimize",Z,$,...Y.options]);if(Q)return p.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return D4.writeFileSync(`${J}${NZ.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var rG;(($)=>{$.DYNAMIC="dynamic";$.FIXED="fixed";$.KINEMATIC_POSITION="kinematic_position";$.KINEMATIC_VELOCITY="kinematic_velocity"})(rG||={});var lN=0.001,Qo="dynamic";class dJ extends j0{_additionalMass=0;_colliders=new Set;_explicitSleep=!1;_enabledPositions={x:!0,y:!0,z:!0};_enabledRotations={x:!0,y:!0,z:!0};_rigidBody;_rigidBodyDesc;_rigidBodyType;_simulation;constructor(Z){super();Z.type??=Qo,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 enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(Z){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(Z,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(Z)}setAdditionalMassProperties(Z){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:J,centerOfMass:X,principalAngularInertia: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"]:X1.RigidBodyType.Dynamic,["fixed"]:X1.RigidBodyType.Fixed,["kinematic_position"]:X1.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:X1.RigidBodyType.KinematicVelocityBased}[Z];if(X===void 0)return p.error(`Invalid RigidBodyType: ${Z}`);this._rigidBody?this._rigidBody.setBodyType(X,!this._explicitSleep):this._rigidBodyDesc.status=X,this._rigidBodyType=Z}addForce(Z){if(!this._requireNotRemoved("addForce"))return;if(!this._requireCreated("addForce"))return;if(!this._requireDynamic("addForce"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addForce(Z,!this._explicitSleep)}addTorque(Z){if(!this._requireNotRemoved("addTorque"))return;if(!this._requireCreated("addTorque"))return;if(!this._requireDynamic("addTorque"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addTorque(Z,!this._explicitSleep)}addChildColliderToSimulation(Z){if(!this._requireNotRemoved("addChildColliderToSimulation"))return;if(!this._requireCreated("addChildColliderToSimulation"))return;Z.addToSimulation(this._simulation,this)}addToSimulation(Z){if(!this._requireNotRemoved("addToSimulation"))return;if(this._rigidBody)return p.error("RigidBody.addToSimulation(): Rigid body already exists in the simulation!");this._simulation=Z,this._rigidBody=this._simulation.createRawRigidBody(this._rigidBodyDesc),this._colliders.forEach((J)=>{if(!J.isSimulated)J.addToSimulation(Z,this)})}applyImpulse(Z){if(!this._requireNotRemoved("applyImpulse"))return;if(!this._requireCreated("applyImpulse"))return;if(!this._requireDynamic("applyImpulse"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulse(Z,!this._explicitSleep)}applyImpulseAtPoint(Z,J){if(!this._requireNotRemoved("applyImpulseAtPoint"))return;if(!this._requireCreated("applyImpulseAtPoint"))return;if(!this._requireDynamic("applyImpulseAtPoint"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulseAtPoint(Z,J,!this._explicitSleep)}applyTorqueImpulse(Z){if(!this._requireNotRemoved("applyTorqueImpulse"))return;if(!this._requireCreated("applyTorqueImpulse"))return;if(!this._requireDynamic("applyTorqueImpulse"))return;this._rigidBody.applyTorqueImpulse(Z,!this._explicitSleep)}createAndAddChildCollider(Z){if(!this._requireNotRemoved("createAndAddChildCollider"))return null;return this._simulation?new A5({...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 p.error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(Z)}lockAllRotations(){if(!this._requireNotRemoved("lockAllRotations"))return;this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){if(!this._requireNotRemoved("lockAllPositions"))return;this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._rigidBody)return p.error("RigidBody.removeFromSimulation(): Rigid body does not exist in the simulation!");this._colliders.forEach((Z)=>{Z.removeFromSimulation()}),this._simulation.removeRawRigidBody(this._rigidBody),this._simulation=void 0,this._rigidBody=void 0}unlinkCollider(Z){if(!this._requireNotRemoved("unlinkCollider"))return;if(!Z.isRemoved)return p.error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(Z)}resetAngularVelocity(){if(!this._requireNotRemoved("resetAngularVelocity"))return;if(!this._requireCreated("resetAngularVelocity"))return;this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){if(!this._requireNotRemoved("resetForces"))return;if(!this._requireCreated("resetForces"))return;this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){if(!this._requireNotRemoved("resetLinearVelocity"))return;if(!this._requireCreated("resetLinearVelocity"))return;this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){if(!this._requireNotRemoved("resetTorques"))return;if(!this._requireCreated("resetTorques"))return;this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){if(!this._requireNotRemoved("sleep"))return;this.setSleeping(!0)}wakeUp(){if(!this._requireNotRemoved("wakeUp"))return;this.setSleeping(!1)}_applyRigidBodyOptions(Z){[["additionalMass",this.setAdditionalMass.bind(this)],["additionalMassProperties",this.setAdditionalMassProperties.bind(this)],["additionalSolverIterations",this.setAdditionalSolverIterations.bind(this)],["angularDamping",this.setAngularDamping.bind(this)],["angularVelocity",this.setAngularVelocity.bind(this)],["dominanceGroup",this.setDominanceGroup.bind(this)],["ccdEnabled",this.setCcdEnabled.bind(this)],["enabled",this.setEnabled.bind(this)],["enabledPositions",this.setEnabledPositions.bind(this)],["enabledRotations",this.setEnabledRotations.bind(this)],["gravityScale",this.setGravityScale.bind(this)],["linearDamping",this.setLinearDamping.bind(this)],["linearVelocity",this.setLinearVelocity.bind(this)],["position",this.setPosition.bind(this)],["rotation",this.setRotation.bind(this)],["sleeping",this.setSleeping.bind(this)],["softCcdPrediction",this.setSoftCcdPrediction.bind(this)]].forEach(([X,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 A5(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??Qo;return{["dynamic"]:()=>X1.RigidBodyDesc.dynamic(),["fixed"]:()=>X1.RigidBodyDesc.fixed(),["kinematic_position"]:()=>X1.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>X1.RigidBodyDesc.kinematicVelocityBased()}[J]()}_requireCreated(Z){if(!this._rigidBody||!this._simulation)p.error(`RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody&&!!this._simulation}_requireDynamic(Z){if(!this.isDynamic)p.error(`RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method: ${Z}()`);return this.isDynamic}_requireKinematic(Z){if(!this.isKinematic)p.error(`RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method: ${Z}()`);return this.isKinematic}_requireNotKinematicPositionBased(Z){if(this.isKinematicPositionBased)p.error(`RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method: ${Z}()`);return!this.isKinematicPositionBased}_requireNotRemoved(Z){if(!this._rigidBody&&!this._rigidBodyDesc)p.error(`RigidBody._requireNotRemoved(): Rigid body has been removed and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody||!!this._rigidBodyDesc}_requireNotSimulated(Z){if(this.isSimulated)p.error(`RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method: ${Z}()`);return!this.isSimulated}_isNegligibleVector(Z){return Math.abs(Z.x)<lN&&Math.abs(Z.y)<lN&&Math.abs(Z.z)<lN}}var yN;(($)=>{$[$.Average=0]="Average";$[$.Min=1]="Min";$[$.Multiply=2]="Multiply";$[$.Max=3]="Max"})(yN||={});var N3;((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"})(N3||={});class A5 extends j0{_collider;_colliderDesc;_onCollision;_parentRigidBody;_relativePosition={x:0,y:0,z:0};_relativeRotation={x:0,y:0,z:0,w:1};_shape;_simulation;_tag;constructor(Z){super();this._colliderDesc=this._createColliderDesc(Z),this._shape=Z.shape,this._applyColliderOptions(Z),this._autoAddToSimulation(Z)}static optionsFromBlockHalfExtents(Z){return{shape:"block",halfExtents:Z}}static optionsFromModelUri(Z,J=1,X){let Y=B6.instance.getBoundingBox(Z),$=Y.max.x-Y.min.x,Q=Y.max.y-Y.min.y,K=Y.max.z-Y.min.z,W=Math.max($,K),G=Math.min($,K),z=W/G,v=W/Q,H=W*J/2,V=(j)=>Math.max(0.01,j),q=()=>({shape:"block",halfExtents:{x:V($*J/2),y:V(Q*J/2),z:V(K*J/2)}}),F=()=>({shape:"round-cylinder",radius:V(H),halfHeight:V(Q*J/2),borderRadius:V(H*0.1)}),w=()=>{let j=B6.instance.getTrimesh(Z,J);if(!j)return;return{shape:"trimesh",vertices:j.vertices,indices:j.indices}},c=()=>({shape:"wedge",extents:{x:$*J,y:Q*J,z:K*J}}),U=()=>({shape:"capsule",radius:V(H),halfHeight:V(Q*J/2-H)});if(X)switch(X){case"block":return q();case"capsule":return U();case"round-cylinder":return F();case"trimesh":{let j=w();if(!j){p.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return j}case"wedge":return c();default:p.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(z>2)return q();if(v>1.5)return F();return U()}get bounciness(){if(!this._requireNotRemoved("bounciness"))return 0;return this._collider?this._collider.restitution():this._colliderDesc.restitution}get bouncinessCombineRule(){if(!this._requireNotRemoved("bouncinessCombineRule"))return 0;return this._collider?this._collider.restitutionCombineRule():this._colliderDesc.restitutionCombineRule}get collisionGroups(){if(!this._requireNotRemoved("collisionGroups"))return{belongsTo:[],collidesWith:[]};return this._collider?v9.decodeRawCollisionGroups(this._collider.collisionGroups()):v9.decodeRawCollisionGroups(this._colliderDesc.collisionGroups)}get friction(){if(!this._requireNotRemoved("friction"))return 0;return this._collider?this._collider.friction():this._colliderDesc.friction}get frictionCombineRule(){if(!this._requireNotRemoved("frictionCombineRule"))return 0;return this._collider?this._collider.frictionCombineRule():this._colliderDesc.frictionCombineRule}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._collider?this._collider.isEnabled():this._colliderDesc.enabled}get isRemoved(){return!this._collider&&!this._colliderDesc}get isSensor(){if(!this._requireNotRemoved("isSensor"))return!1;return this._collider?this._collider.isSensor():this._colliderDesc.isSensor}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return!!this._collider}get parentRigidBody(){if(!this._requireNotRemoved("parentRigidBody"))return;return this._parentRigidBody}get rawCollider(){if(!this._requireNotRemoved("rawCollider"))return;return this._collider}get rawShape(){if(!this._requireNotRemoved("rawShape"))return;return this._collider?this._collider.shape:this._colliderDesc.shape}get relativePosition(){if(!this._requireNotRemoved("relativePosition"))return{x:0,y:0,z:0};return this._relativePosition}get relativeRotation(){if(!this._requireNotRemoved("relativeRotation"))return{x:0,y:0,z:0,w:1};return this._relativeRotation}get shape(){if(!this._requireNotRemoved("shape"))return"none";return this._shape}get tag(){if(!this._requireNotRemoved("tag"))return;return this._tag}setBounciness(Z){if(!this._requireNotRemoved("setBounciness"))return;this._collider?this._collider.setRestitution(Z):this._colliderDesc.setRestitution(Z)}setBouncinessCombineRule(Z){if(!this._requireNotRemoved("setBouncinessCombineRule"))return;this._collider?this._collider.setRestitutionCombineRule(Z):this._colliderDesc.setRestitutionCombineRule(Z)}setCollisionGroups(Z){if(!this._requireNotRemoved("setCollisionGroups"))return;let J=v9.buildRawCollisionGroups(Z);this._collider?this._collider.setCollisionGroups(J):this._colliderDesc.setCollisionGroups(J)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._collider?this._collider.setEnabled(Z):this._colliderDesc.setEnabled(Z)}setFriction(Z){if(!this._requireNotRemoved("setFriction"))return;this._collider?this._collider.setFriction(Z):this._colliderDesc.setFriction(Z)}setFrictionCombineRule(Z){if(!this._requireNotRemoved("setFrictionCombineRule"))return;this._collider?this._collider.setFrictionCombineRule(Z):this._colliderDesc.setFrictionCombineRule(Z)}setMass(Z){if(!this._requireNotRemoved("setMass"))return;this._collider?this._collider.setMass(Z):this._colliderDesc.setMass(Z)}setOnCollision(Z){if(!this._requireNotRemoved("setOnCollision"))return;if(this._onCollision=Z,this.isSimulated)if(this.enableCollisionEvents(!!Z),Z)this._simulation.colliderMap.setColliderCollisionCallback(this,Z);else this._simulation.colliderMap.removeColliderCollisionCallback(this)}setRelativeRotation(Z){if(!this._requireNotRemoved("setRelativeRotation"))return;this._relativeRotation=Z,this._collider?this._collider.parent()?this._collider.setRotationWrtParent(Z):this._collider.setRotation(Z):this._colliderDesc.setRotation(Z)}setRelativePosition(Z){if(!this._requireNotRemoved("setRelativePosition"))return;this._relativePosition=Z,this._collider?this._collider.parent()?this._collider.setTranslationWrtParent(Z):this._collider.setTranslation(Z):this._colliderDesc.setTranslation(Z.x,Z.y,Z.z)}setSensor(Z){if(!this._requireNotRemoved("setSensor"))return;this._collider?this._collider.setSensor(Z):this._colliderDesc.setSensor(Z)}setTag(Z){if(!this._requireNotRemoved("setTag"))return;this._tag=Z}setVoxel(Z,J){if(!this._requireNotRemoved("setVoxel"))return;if(!this._requireSimulated("setVoxel"))return;if(this.shape!=="voxels")return p.error("Collider.setVoxel(): Collider is not a voxels collider!");this._collider.setVoxel(Z.x,Z.y,Z.z,J)}addToSimulation(Z,J){if(!this._requireNotRemoved("addToSimulation"))return;if(!this._requireUnsimulated("addToSimulation"))return;if(J){if(!J.isSimulated)return p.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")p.warning("Collider.addToSimulation(): Trimesh colliders are strongly discouraged to be used with dynamic rigid bodies, they will not contribute any mass!")}if(this._simulation=Z,this._parentRigidBody=J,this._collider=this._simulation.createRawCollider(this._colliderDesc,J?.rawRigidBody),this._colliderDesc=void 0,J)J.linkCollider(this);if(this._onCollision)this.setOnCollision(this._onCollision)}combineVoxelStates(Z){if(!this._requireNotRemoved("combineVoxelStates"))return;if(!this._requireSimulated("combineVoxelStates"))return;if(!Z.isSimulated)return p.error("Collider.combineVoxelStates(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Other collider is not a voxels collider!");this._collider.combineVoxelStates(Z.rawCollider,0,0,0)}enableCollisionEvents(Z){if(!this._requireNotRemoved("enableCollisionEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|X1.ActiveEvents.COLLISION_EVENTS:J&~X1.ActiveEvents.COLLISION_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}enableContactForceEvents(Z){if(!this._requireNotRemoved("enableContactForceEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|X1.ActiveEvents.CONTACT_FORCE_EVENTS:J&~X1.ActiveEvents.CONTACT_FORCE_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}propagateVoxelChange(Z,J){if(!this._requireNotRemoved("propagateVoxelChange"))return;if(!this._requireSimulated("propagateVoxelChange"))return;if(!Z.isSimulated)return p.error("Collider.propagateVoxelChange(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Other collider is not a voxels collider!");this._collider.propagateVoxelChange(Z.rawCollider,J.x,J.y,J.z,0,0,0)}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._requireSimulated("removeFromSimulation"))return;if(this._simulation.removeRawCollider(this._collider),this._simulation=void 0,this._collider=void 0,this._parentRigidBody)this._parentRigidBody.unlinkCollider(this);this._parentRigidBody=void 0}scale(Z){if(!this._requireNotRemoved("scale"))return;switch(this.setRelativePosition({x:this.relativePosition.x*Z,y:this.relativePosition.y*Z,z:this.relativePosition.z*Z}),this._shape){case"ball":{if(this._collider)this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.radius*=Z;return}case"block":{if(this._collider){let J=this._collider.halfExtents();this._collider.setHalfExtents({x:J.x*Z,y:J.y*Z,z:J.z*Z})}else this._colliderDesc.shape.halfExtents.x*=Z,this._colliderDesc.shape.halfExtents.y*=Z,this._colliderDesc.shape.halfExtents.z*=Z;return}case"capsule":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cone":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"round-cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRoundRadius(this._collider.roundRadius()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight=this._colliderDesc.shape.halfHeight*Z,this._colliderDesc.shape.borderRadius=this._colliderDesc.shape.borderRadius*Z,this._colliderDesc.shape.radius=this._colliderDesc.shape.radius*Z;return}case"trimesh":{p.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"voxels":{p.error("Collider.setScale(): Voxels colliders cannot be scaled!");return}case"wedge":{p.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:p.fatalError(`Collider.setScale(): ${this._shape} is not a valid collider shape!`)}}_applyColliderOptions(Z){[["bounciness",this.setBounciness.bind(this)],["bouncinessCombineRule",this.setBouncinessCombineRule.bind(this)],["collisionGroups",this.setCollisionGroups.bind(this)],["enabled",this.setEnabled.bind(this)],["friction",this.setFriction.bind(this)],["frictionCombineRule",this.setFrictionCombineRule.bind(this)],["isSensor",this.setSensor.bind(this)],["mass",this.setMass.bind(this)],["onCollision",this.setOnCollision.bind(this)],["relativePosition",this.setRelativePosition.bind(this)],["relativeRotation",this.setRelativeRotation.bind(this)],["tag",this.setTag.bind(this)]].forEach(([X,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)p.fatalError("Ball collider must have a radius!");return X1.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)p.fatalError("Block collider must have halfExtents!");return X1.ColliderDesc.cuboid(Z.halfExtents.x,Z.halfExtents.y,Z.halfExtents.z)}case"capsule":{if(!Z.halfHeight||!Z.radius)p.fatalError("Capsule collider must have halfHeight and radius!");return X1.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cone collider must have radius and halfHeight!");return X1.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cylinder collider must have radius and halfHeight!");return X1.ColliderDesc.cylinder(Z.halfHeight,Z.radius)}case"round-cylinder":{if(!Z.radius||!Z.halfHeight||!Z.borderRadius)p.fatalError("Round cylinder collider must have radius, halfHeight, and borderRadius!");return X1.ColliderDesc.roundCylinder(Z.halfHeight,Z.radius,Z.borderRadius)}case"trimesh":{if(!Z.indices||!Z.vertices)p.fatalError("Trimesh collider must have vertices and indices!");return X1.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)p.fatalError("Voxels collider must have coordinates and size!");return X1.ColliderDesc.voxels(this._coordinatesToInt32Array(Z.coordinates),Z.size)}case"wedge":{if(!Z.extents)p.fatalError("Wedge collider must have extents!");let Y=this._buildWedgeConvexHullVertices(Z.extents),$=X1.ColliderDesc.convexHull(Y);if(!$)throw p.fatalError("Failed to create convex hull for wedge collider!"),Error("Convex hull creation failed");return $}default:p.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)p.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)p.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)p.error(`Collider._requireNotRemoved(): Collider is removed, invoked method: ${Z}()`);return!this.isRemoved}_setActiveCollisionTypes(){(this._collider??this._colliderDesc).setActiveCollisionTypes(X1.ActiveCollisionTypes.DYNAMIC_DYNAMIC|X1.ActiveCollisionTypes.DYNAMIC_KINEMATIC|X1.ActiveCollisionTypes.DYNAMIC_FIXED|X1.ActiveCollisionTypes.KINEMATIC_KINEMATIC|X1.ActiveCollisionTypes.KINEMATIC_FIXED)}_coordinatesToInt32Array(Z){let J=new Int32Array(Z.length*3);for(let X=0;X<Z.length;X++){let 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 IR1={shape:"voxels"},pN;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(pN||={});class m5 extends j0{_id;_customColliderOptions;_halfExtents;_isLiquid;_lightLevel;_name;_textureUri;constructor(Z={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(Z.id<0)p.fatalError("BlockType.constructor(): BlockType id not set.");super();this._id=Z.id,this._customColliderOptions=Z.customColliderOptions,this._halfExtents=Z.halfExtents??{x:0.5,y:0.5,z:0.5},this._isLiquid=Z.isLiquid??!1,this._name=Z.name,this._textureUri=Z.textureUri,this._lightLevel=Math.min(Z.lightLevel??0,15)}get id(){return this._id}get colliderOptions(){return{...this._customColliderOptions,...IR1}}get halfExtents(){return this._halfExtents}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}get lightLevel(){return this._lightLevel}get name(){return this._name}get size(){return{x:this._halfExtents.x*2,y:this._halfExtents.y*2,z:this._halfExtents.z*2}}get textureUri(){return this._textureUri}createCollider(Z){let J=new A5({...this.colliderOptions,coordinates:Z,size:this.size});if(this.isLiquid)J.setSensor(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_COLLISION")||this.isLiquid)J.enableCollisionEvents(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))J.enableContactForceEvents(!0);if(v9.isDefaultCollisionGroups(J.collisionGroups))J.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return J}serialize(){return T0.serializeBlockType(this)}}var iN;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(iN||={});class tG extends j0{_blockTypes=new Map;_world;constructor(Z){super();this._world=Z}get world(){return this._world}getAllBlockTypes(){return Array.from(this._blockTypes.values())}getBlockType(Z){let J=this._blockTypes.get(Z);if(!J)p.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends m5{constructor(Y=Z){super(Y)}};return this.registerBlockType(X),X}registerBlockType(Z){this._blockTypes.set(Z.id,Z),this.emitWithWorld(this._world,"BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE",{blockTypeRegistry:this,id:Z.id,blockType:Z})}serialize(){return T0.serializeBlockTypeRegistry(this)}}var DO={};_Q(DO,{worldSchema:()=>LO,worldPacketDefinition:()=>e00,vectorSchema:()=>W1,vectorBooleanSchema:()=>DE1,uiSchema:()=>jO,uiPacketDefinition:()=>r00,uiDatasSchema:()=>BO,uiDatasPacketDefinition:()=>t00,uiDataSendPacketDefinition:()=>h00,uiDataSchema:()=>Dz,syncResponseSchema:()=>xO,syncResponsePacketDefinition:()=>o00,syncRequestSchema:()=>gP,syncRequestPacketDefinition:()=>_00,stateRequestSchema:()=>iP,stateRequestPacketDefinition:()=>I00,sceneUIsSchema:()=>UO,sceneUIsPacketDefinition:()=>s00,sceneUISchema:()=>cO,rgbColorSchema:()=>D6,registeredPackets:()=>Ec,quaternionSchema:()=>YO,playersSchema:()=>wO,playersPacketDefinition:()=>n00,playerSchema:()=>FO,physicsDebugRenderSchema:()=>qO,physicsDebugRenderPacketDefinition:()=>d00,physicsDebugRaycastsSchema:()=>HO,physicsDebugRaycastsPacketDefinition:()=>a00,physicsDebugRaycastSchema:()=>VO,particleEmittersSchema:()=>vO,particleEmittersPacketDefinition:()=>g00,particleEmitterSchema:()=>zO,outboundPackets:()=>kc,notificationPermissionRequestSchema:()=>GO,notificationPermissionRequestPacketDefinition:()=>i00,modelNodeOverrideSchema:()=>XO,lightsSchema:()=>WO,lightsPacketDefinition:()=>p00,lightSchema:()=>KO,isValidPacket:()=>RE1,inputSchema:()=>pP,inputPacketDefinition:()=>E00,inboundPackets:()=>fc,hexColorSchema:()=>lP,heartbeatSchema:()=>uP,heartbeatPacketDefinition:()=>C00,entitySchema:()=>$O,entitiesSchema:()=>QO,entitiesPacketDefinition:()=>y00,definePacket:()=>C0,debugConfigSchema:()=>yP,debugConfigPacketDefinition:()=>k00,createPacket:()=>LE1,connectionSchema:()=>mP,connectionPacketDefinition:()=>T00,chunksSchema:()=>JO,chunksPacketDefinition:()=>l00,chunkSchema:()=>ZO,chatMessagesSchema:()=>eP,chatMessagesPacketDefinition:()=>u00,chatMessageSendPacketDefinition:()=>f00,chatMessageSchema:()=>Lz,cameraSchema:()=>tP,cameraPacketDefinition:()=>m00,blocksSchema:()=>sP,blocksPacketDefinition:()=>b00,blockTypesSchema:()=>rP,blockTypesPacketDefinition:()=>A00,blockTypeSchema:()=>oP,blockSchema:()=>nP,bidirectionalPackets:()=>Cc,audiosSchema:()=>aP,audiosPacketDefinition:()=>S00,audioSchema:()=>dP,PacketId:()=>M1});var Cc={};_Q(Cc,{heartbeatPacketDefinition:()=>C00,connectionPacketDefinition:()=>T00});var bP=t(O00(),1);class AP extends bP.default{static instance=new bP.default}var M1;((k)=>{k[k.SYNC_REQUEST=0]="SYNC_REQUEST";k[k.INPUT=1]="INPUT";k[k.STATE_REQUEST=2]="STATE_REQUEST";k[k.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";k[k.UI_DATA_SEND=4]="UI_DATA_SEND";k[k.SYNC_RESPONSE=32]="SYNC_RESPONSE";k[k.AUDIOS=33]="AUDIOS";k[k.BLOCKS=34]="BLOCKS";k[k.BLOCK_TYPES=35]="BLOCK_TYPES";k[k.CHAT_MESSAGES=36]="CHAT_MESSAGES";k[k.CHUNKS=37]="CHUNKS";k[k.ENTITIES=38]="ENTITIES";k[k.WORLD=39]="WORLD";k[k.CAMERA=40]="CAMERA";k[k.UI=41]="UI";k[k.UI_DATAS=42]="UI_DATAS";k[k.SCENE_UIS=43]="SCENE_UIS";k[k.LIGHTS=44]="LIGHTS";k[k.PLAYERS=45]="PLAYERS";k[k.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";k[k.NOTIFICATION_PERMISSION_REQUEST=47]="NOTIFICATION_PERMISSION_REQUEST";k[k.CONNECTION=116]="CONNECTION";k[k.HEARTBEAT=117]="HEARTBEAT";k[k.DEBUG_CONFIG=128]="DEBUG_CONFIG";k[k.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";k[k.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(M1||={});function LE1(Z,J,X){if(!Z.validate(J))throw Error(`Invalid payload for packet with id ${Z.id}. Error: ${AP.instance.errorsText(Z.validate.errors)}`);let Y=[Z.id,J];if(typeof X==="number")Y.push(X);return Y}function C0(Z,J){return{id:Z,schema:J,validate:AP.instance.compile(J)}}var mP={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},ts:{type:"string",nullable:!0}},additionalProperties:!1};var T00=C0(116,mP);var uP={type:"null",nullable:!0};var C00=C0(117,uP);var fc={};_Q(fc,{uiDataSendPacketDefinition:()=>h00,syncRequestPacketDefinition:()=>_00,stateRequestPacketDefinition:()=>I00,inputPacketDefinition:()=>E00,debugConfigPacketDefinition:()=>k00,chatMessageSendPacketDefinition:()=>f00});var lP={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var Lz={type:"object",properties:{m:{type:"string"},c:{...lP,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var f00=C0(3,Lz);var yP={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var k00=C0(128,yP);var pP={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 E00=C0(1,pP);var iP={type:"object",properties:{},additionalProperties:!1};var I00=C0(2,iP);var gP={type:"null",nullable:!0};var _00=C0(0,gP);var Dz={type:"object",properties:{},additionalProperties:!0};var h00=C0(4,Dz);var kc={};_Q(kc,{worldPacketDefinition:()=>e00,uiPacketDefinition:()=>r00,uiDatasPacketDefinition:()=>t00,syncResponsePacketDefinition:()=>o00,sceneUIsPacketDefinition:()=>s00,playersPacketDefinition:()=>n00,physicsDebugRenderPacketDefinition:()=>d00,physicsDebugRaycastsPacketDefinition:()=>a00,particleEmittersPacketDefinition:()=>g00,notificationPermissionRequestPacketDefinition:()=>i00,lightsPacketDefinition:()=>p00,entitiesPacketDefinition:()=>y00,chunksPacketDefinition:()=>l00,chatMessagesPacketDefinition:()=>u00,cameraPacketDefinition:()=>m00,blocksPacketDefinition:()=>b00,blockTypesPacketDefinition:()=>A00,audiosPacketDefinition:()=>S00});var W1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var dP={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 aP={type:"array",items:{...dP}};var S00=C0(33,aP);var nP={type:"object",properties:{i:{type:"number"},c:W1},required:["i","c"],additionalProperties:!1};var sP={type:"array",items:{...nP}};var b00=C0(34,sP);var oP={type:"object",properties:{i:{type:"number"},l:{type:"boolean",nullable:!0},ll:{type:"number",nullable:!0},n:{type:"string",nullable:!0},t:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var rP={type:"array",items:{...oP}};var A00=C0(35,rP);var tP={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 eP={type:"array",items:{...Lz}};var ZO={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 JO={type:"array",items:{...ZO}};var D6={type:"array",items:[{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255}],minItems:3,maxItems:3};var XO={type:"object",properties:{n:{type:"string"},h:{type:"boolean",nullable:!0},o:{type:"number",minimum:0,maximum:1,nullable:!0},r:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},t:{...D6,nullable:!0}},required:["n"],additionalProperties:!1};var YO={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var $O={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:{...XO},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...YO,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...D6,nullable:!0}},required:["i"],additionalProperties:!1};var QO={type:"array",items:{...$O}};var KO={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...D6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",minimum:0,maximum:1,nullable:!0},rm:{type:"boolean",nullable:!0},t:{type:"number",nullable:!0},te:{type:"number",nullable:!0},tp:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var WO={type:"array",items:{...KO}};var GO={type:"null",nullable:!0};var zO={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},b:{type:"number",nullable:!0},ce:{...D6,nullable:!0},cev:{...D6,nullable:!0},cs:{...D6,nullable:!0},csv:{...D6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...W1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...W1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pv:{...W1,nullable:!0},r:{type:"number",nullable:!0},rv:{type:"number",nullable:!0},rm:{type:"boolean",nullable:!0},se:{type:"number",nullable:!0},sev:{type:"number",nullable:!0},ss:{type:"number",nullable:!0},ssv:{type:"number",nullable:!0},t:{type:"boolean",nullable:!0},tu:{type:"string",nullable:!0},v:{...W1,nullable:!0},vv:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var vO={type:"array",items:{...zO}};var VO={type:"object",properties:{o:{...W1},d:{...W1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var HO={type:"array",items:{...VO}};var qO={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var FO={type:"object",properties:{i:{type:"string"},p:{type:"string",nullable:!0},rm:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var wO={type:"array",items:{...FO}};var cO={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"object",nullable:!0},t:{type:"string",nullable:!0},v:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var UO={type:"array",items:{...cO}};var xO={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var jO={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var BO={type:"array",items:{...Dz}};var DE1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var LO={type:"object",properties:{i:{type:"number"},ac:{...D6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...D6,nullable:!0},di:{type:"number",nullable:!0},dp:{...W1,nullable:!0},fc:{...D6,nullable:!0},ff:{type:"number",nullable:!0},fn:{type:"number",nullable:!0},n:{type:"string",nullable:!0},s:{type:"string",nullable:!0},si:{type:"number",nullable:!0},t:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var m00=C0(40,tP);var u00=C0(36,eP);var l00=C0(37,JO);var y00=C0(38,QO);var p00=C0(44,WO);var i00=C0(47,GO);var g00=C0(46,vO);var d00=C0(192,qO);var a00=C0(193,HO);var n00=C0(45,wO);var s00=C0(43,UO);var o00=C0(32,xO);var r00=C0(41,jO);var t00=C0(42,BO);var e00=C0(39,LO);var Ec=new Map,ME1={...Cc,...fc,...kc};for(let Z of Object.values(ME1))if("id"in Z&&"schema"in Z){let J=Z;if(Ec.has(J.id))throw Error(`Packet with id ${J.id} is already registered.`);Ec.set(J.id,J)}function RE1(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=Ec.get(Z[0]);return!!J&&J.validate(Z[1])}var Q0=DO;var Q60=t(O10(),1);import tY from"fs";import Y60 from"path";var H_1=t(D80(),1),q_1=t(IO(),1),F_1=t(hO(),1),rY=t(pc(),1),yO=t(C80(),1);var f80=rY.default;function x5(Z){if(Z===null)return"null";if(Array.isArray(Z))return"array";return typeof Z}function YX(Z){return x5(Z)==="object"}function w_1(Z){return Array.isArray(Z)&&Z.length>0&&Z.every((J)=>("message"in J))}function pO(Z,J){return Z.length<124?Z:J}var k80="graphql-transport-ws";var l5=((Z)=>{return Z[Z.InternalServerError=4500]="InternalServerError",Z[Z.InternalClientError=4005]="InternalClientError",Z[Z.BadRequest=4400]="BadRequest",Z[Z.BadResponse=4004]="BadResponse",Z[Z.Unauthorized=4401]="Unauthorized",Z[Z.Forbidden=4403]="Forbidden",Z[Z.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",Z[Z.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",Z[Z.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",Z[Z.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",Z[Z.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",Z})(l5||{}),y5=((Z)=>{return Z.ConnectionInit="connection_init",Z.ConnectionAck="connection_ack",Z.Ping="ping",Z.Pong="pong",Z.Subscribe="subscribe",Z.Next="next",Z.Error="error",Z.Complete="complete",Z})(y5||{});function E80(Z){if(!YX(Z))throw Error(`Message is expected to be an object, but got ${x5(Z)}`);if(!Z.type)throw Error("Message is missing the 'type' property");if(typeof Z.type!=="string")throw Error(`Message is expects the 'type' property to be a string, but got ${x5(Z.type)}`);switch(Z.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(Z.payload!=null&&!YX(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${Z.payload}"`);break}case"subscribe":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${x5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!YX(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${x5(Z.payload)}`);if(typeof Z.payload.query!=="string")throw Error(`"${Z.type}" message payload expects the 'query' property to be a string, but got ${x5(Z.payload.query)}`);if(Z.payload.variables!=null&&!YX(Z.payload.variables))throw Error(`"${Z.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${x5(Z.payload.variables)}`);if(Z.payload.operationName!=null&&x5(Z.payload.operationName)!=="string")throw Error(`"${Z.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${x5(Z.payload.operationName)}`);if(Z.payload.extensions!=null&&!YX(Z.payload.extensions))throw Error(`"${Z.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${x5(Z.payload.extensions)}`);break}case"next":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${x5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!YX(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${x5(Z.payload)}`);break}case"error":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${x5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!w_1(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(Z.payload)}`);break}case"complete":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${x5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);break}default:throw Error(`Invalid message 'type' property "${Z.type}"`)}return Z}function I80(Z,J){return E80(typeof Z==="string"?JSON.parse(Z,J):Z)}function i3(Z,J){return E80(Z),JSON.stringify(Z,J)}function gO(Z){let{url:J,connectionParams:X,lazy:Y=!0,onNonLazyError:$=console.error,lazyCloseTimeout:Q=0,keepAlive:K=0,disablePong:W,connectionAckWaitTimeout:G=0,retryAttempts:z=5,retryWait:v=async function(h){let _=Math.pow(2,h);await new Promise((a)=>setTimeout(a,_*1000+Math.floor(Math.random()*2700+300)))},shouldRetry:H=iO,on:V,webSocketImpl:q,generateID:F=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(h)=>{let _=Math.random()*16|0;return(h=="x"?_:_&3|8).toString(16)})},jsonMessageReplacer:w,jsonMessageReviver:c}=Z,U;if(q){if(!U_1(q))throw Error("Invalid WebSocket implementation provided");U=q}else if(typeof WebSocket<"u")U=WebSocket;else if(typeof global<"u")U=global.WebSocket||global.MozWebSocket;else if(typeof window<"u")U=window.WebSocket||window.MozWebSocket;if(!U)throw Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let j=U,B=(()=>{let C=(()=>{let _={};return{on(a,s){return _[a]=s,()=>{delete _[a]}},emit(a){if("id"in a)_[a.id]?.(a)}}})(),h={connecting:V?.connecting?[V.connecting]:[],opened:V?.opened?[V.opened]:[],connected:V?.connected?[V.connected]:[],ping:V?.ping?[V.ping]:[],pong:V?.pong?[V.pong]:[],message:V?.message?[C.emit,V.message]:[C.emit],closed:V?.closed?[V.closed]:[],error:V?.error?[V.error]:[]};return{onMessage:C.on,on(_,a){let s=h[_];return s.push(a),()=>{s.splice(s.indexOf(a),1)}},emit(_,...a){for(let s of[...h[_]])s(...a)}}})();function L(C){let h=[B.on("error",(_)=>{h.forEach((a)=>a()),C(_)}),B.on("closed",(_)=>{h.forEach((a)=>a()),C(_)})]}let R,M=0,N,P=!1,O=0,k=!1;async function E(){clearTimeout(N);let[C,h]=await(R??(R=new Promise((s,Z0)=>(async()=>{if(P){if(await v(O),!M)return R=void 0,Z0({code:1000,reason:"All Subscriptions Gone"});O++}B.emit("connecting",P);let o=new j(typeof J==="function"?await J():J,k80),M0,R0;function m0(){if(isFinite(K)&&K>0)clearTimeout(R0),R0=setTimeout(()=>{if(o.readyState===j.OPEN)o.send(i3({type:y5.Ping})),B.emit("ping",!1,void 0)},K)}L((s0)=>{if(R=void 0,clearTimeout(M0),clearTimeout(R0),Z0(s0),s0 instanceof gc)o.close(4499,"Terminated"),o.onerror=null,o.onclose=null}),o.onerror=(s0)=>B.emit("error",s0),o.onclose=(s0)=>B.emit("closed",s0),o.onopen=async()=>{try{B.emit("opened",o);let s0=typeof X==="function"?await X():X;if(o.readyState!==j.OPEN)return;if(o.send(i3(s0?{type:y5.ConnectionInit,payload:s0}:{type:y5.ConnectionInit},w)),isFinite(G)&&G>0)M0=setTimeout(()=>{o.close(l5.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},G);m0()}catch(s0){B.emit("error",s0),o.close(l5.InternalClientError,pO(s0 instanceof Error?s0.message:String(s0),"Internal client error"))}};let P1=!1;o.onmessage=({data:s0})=>{try{let j1=I80(s0,c);if(B.emit("message",j1),j1.type==="ping"||j1.type==="pong"){if(B.emit(j1.type,!0,j1.payload),j1.type==="pong")m0();else if(!W)o.send(i3(j1.payload?{type:y5.Pong,payload:j1.payload}:{type:y5.Pong})),B.emit("pong",!1,j1.payload);return}if(P1)return;if(j1.type!==y5.ConnectionAck)throw Error(`First message cannot be of type ${j1.type}`);clearTimeout(M0),P1=!0,B.emit("connected",o,j1.payload,P),P=!1,O=0,s([o,new Promise((K4,NJ)=>L(NJ))])}catch(j1){o.onmessage=null,B.emit("error",j1),o.close(l5.BadResponse,pO(j1 instanceof Error?j1.message:String(j1),"Bad response"))}}})())));if(C.readyState===j.CLOSING)await h;let _=()=>{},a=new Promise((s)=>_=s);return[C,_,Promise.race([a.then(()=>{if(!M){let s=()=>C.close(1000,"Normal Closure");if(isFinite(Q)&&Q>0)N=setTimeout(()=>{if(C.readyState===j.OPEN)s()},Q);else s()}}),h])]}function S(C){if(iO(C)&&(c_1(C.code)||[l5.InternalServerError,l5.InternalClientError,l5.BadRequest,l5.BadResponse,l5.Unauthorized,l5.SubprotocolNotAcceptable,l5.SubscriberAlreadyExists,l5.TooManyInitialisationRequests].includes(C.code)))throw C;if(k)return!1;if(iO(C)&&C.code===1000)return M>0;if(!z||O>=z)throw C;if(!H(C))throw C;return P=!0}if(!Y)(async()=>{M++;for(;;)try{let[,,C]=await E();await C}catch(C){try{if(!S(C))return}catch(h){return $?.(h)}}})();function f(C,h){let _=F(C),a=!1,s=!1,Z0=()=>{M--,a=!0};return(async()=>{M++;for(;;)try{let[o,M0,R0]=await E();if(a)return M0();let m0=B.onMessage(_,(P1)=>{switch(P1.type){case y5.Next:{h.next(P1.payload);return}case y5.Error:{s=!0,a=!0,h.error(P1.payload),Z0();return}case y5.Complete:{a=!0,Z0();return}}});o.send(i3({id:_,type:y5.Subscribe,payload:C},w)),Z0=()=>{if(!a&&o.readyState===j.OPEN)o.send(i3({id:_,type:y5.Complete},w));M--,a=!0,M0()},await R0.finally(m0);return}catch(o){if(!S(o))return}})().then(()=>{if(!s)h.complete()}).catch((o)=>{h.error(o)}),()=>{if(!a)Z0()}}return{on:B.on,subscribe:f,iterate(C){let h=[],_={done:!1,error:null,resolve:()=>{}},a=f(C,{next(Z0){h.push(Z0),_.resolve()},error(Z0){_.done=!0,_.error=Z0,_.resolve()},complete(){_.done=!0,_.resolve()}}),s=async function*(){for(;;){if(!h.length)await new Promise((o)=>_.resolve=o);while(h.length)yield h.shift();if(_.error)throw _.error;if(_.done)return}}();return s.throw=async(Z0)=>{if(!_.done)_.done=!0,_.error=Z0,_.resolve();return{done:!0,value:void 0}},s.return=async()=>{return a(),{done:!0,value:void 0}},s},async dispose(){if(k=!0,R){let[C]=await R;C.close(1000,"Normal Closure")}},terminate(){if(R)B.emit("closed",new gc)}}}class gc extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function iO(Z){return YX(Z)&&"code"in Z&&"reason"in Z}function c_1(Z){if([1000,1001,1006,1005,1012,1013,1014].includes(Z))return!1;return Z>=1000&&Z<=1999}function U_1(Z){return typeof Z==="function"&&"constructor"in Z&&"CLOSED"in Z&&"CLOSING"in Z&&"CONNECTING"in Z&&"OPEN"in Z}var $60=t(X60(),1);var Ez="./dev/persistence",ac=process.env.HYTOPIA_NOTIFICATION_SERVICE_URL||"https://prod.notifications.hytopia.com";class P4{static instance=new P4;creatorApiKey=process.env.HYTOPIA_API_KEY;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;_gqlWs;constructor(){this._gqlWs=gO({url:"wss://prod.gql.hytopia.com/graphql",webSocketImpl:f80});try{this._creativeGateway=new $60.CreativeGateway}catch{console.warn(["━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","\uD83D\uDEA8 HYTOPIA PLATFORM GATEWAY IS NOT INITIALIZED \uD83D\uDEA8","","\uD83D\uDD27 Local development is still possible, but these features will be disabled:"," • \uD83D\uDC64 Player Accounts"," • \uD83C\uDFAD Player Cosmetics"," • \uD83D\uDC1B Crash Analytics & Debug Logs","","\uD83D\uDCA1 These features will be enabled but modified:"," • \uD83D\uDCBE Player & Global Persisted Data - Data will be persisted"," locally in the ./dev/persistence directory of your project."," Player ids for data persistence will begin at 1 for the first "," player to join your local server, and increments for each"," additional player. This means that if you restart your"," server, the first player id will be 1 again. This is to ensure"," that data persistence across server restarts can be easily"," tested and debugged in local development.","","To enable the HYTOPIA Platform Gateway locally:"," 1. Set these environment variables:"," HYTOPIA_API_KEY, HYTOPIA_GAME_ID, HYTOPIA_LOBBY_ID"," 2. You can find these values at: https://create.hytopia.com","","Note: In production, these environment variables will be auto-populated ","& the HYTOPIA Platform Gateway will automatically be initialized \uD83D\uDE80","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",""].join(`
400
400
  `))}}get isGatewayAvailable(){return!!this._creativeGateway}async getGlobalData(Z){if(!this._creativeGateway&&process.env.NODE_ENV==="production")return p.warning("PlatformGateway.getGlobalData(): You are running in production mode, but the Platform Gateway is not initialized! No data will be returned."),{error:{code:"gatewayError",message:"Platform Gateway is not initialized."}};return this._creativeGateway?await this._creativeGateway.kv.get(Z):this._readDevGlobalDataLocally(Z)}async getPlayerCosmetics(Z){let J=this._gqlWs.iterate({query:`{
401
401
  userById(id: "${Z}") {
402
402
  characterSettings { skinTone hairColor eyeColor hairStyle }
@@ -542,7 +542,7 @@ xkiy5MGE6Xbe6AybpI1Hg+ET8zOyO1c5GroDQ6w9AoGAKC+zMSn3ahj8Cobpt51M
542
542
  997nuSH5YQLe5+Bl5RXkZBSSNUHAczvgRHDgKi2SEHPLI2HoONLp1BvsKLQgXPJh
543
543
  T8Y+oVbsNcG8DraW9kEzVm8esk3IqJEKmH01U2LW4EsWFKyhKSr6Yr7Y97A8oNb5
544
544
  qyLISxkkFOndPeDIzSNnADk=
545
- -----END PRIVATE KEY-----`;var XA=process.env.PORT??8080,YA="0.10.42",JA;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(JA||={});class LW extends j0{static instance=new LW;_webserver=uB.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:YA,runtime:"node"})}),this._webserver.use(uB.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(uB.default.static(uX6.dirname(g.resolve("@hytopia.com/assets")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?AX6.createServer(this._webserver):mX6.createServer({key:OK1,cert:PK1},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else p.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(XA,this._onStarted),console.info(`WebServer.start(): Server running on port ${XA}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return p.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let Y=lX6.parse(Z.url??"",!0).query,$=Y.connectionId?.toString(),Q=Y.sessionToken?.toString()??"";if($&&PQ.instance.isValidConnectionId($))Z.connectionId=$;else{let K=await P4.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
545
+ -----END PRIVATE KEY-----`;var XA=process.env.PORT??8080,YA="0.10.43",JA;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(JA||={});class LW extends j0{static instance=new LW;_webserver=uB.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:YA,runtime:"node"})}),this._webserver.use(uB.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(uB.default.static(uX6.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?AX6.createServer(this._webserver):mX6.createServer({key:OK1,cert:PK1},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else p.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(XA,this._onStarted),console.info(`WebServer.start(): Server running on port ${XA}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return p.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let Y=lX6.parse(Z.url??"",!0).query,$=Y.connectionId?.toString(),Q=Y.sessionToken?.toString()??"";if($&&PQ.instance.isValidConnectionId($))Z.connectionId=$;else{let K=await P4.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
546
546
  Content-Type: text/plain\r
547
547
  Content-Length: ${W.length}\r
548
548
  Connection: close\r