@dcl-regenesislabs/web-editor 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/editor.js
CHANGED
|
@@ -32447,12 +32447,12 @@ ${Fi}`),Uc.prefill=null;const Ls=nn.current;Ls!==null&&(Ls.focus(),requestAnimat
|
|
|
32447
32447
|
`):"…"}),O.jsx(cs,{variant:"ghost",size:"lg",onClick:ZSe,children:Hie()})]})})}function avr(t){return O.jsx("div",{className:"eui-loading",children:O.jsxs("div",{className:"eui-loading-card",children:[O.jsx("div",{className:"eui-loading-x",children:"✕"}),O.jsx("div",{className:"eui-loading-title",children:t.health.kind==="build"?"Your scene has a code error":"Your scene’s code crashed"}),O.jsx("div",{className:"eui-loading-sub",children:"Fix the file and save — the scene rebuilds and loads again automatically."}),O.jsx("pre",{className:"eui-loading-log err",children:t.health.lines.join(`
|
|
32448
32448
|
`)}),t.project!==null&&window.editorShell!==void 0&&O.jsx(cs,{variant:"secondary",size:"lg",onClick:()=>{var n;return void((n=window.editorShell)==null?void 0:n.openProject(t.project))},children:"Try again"}),O.jsx(cs,{variant:"ghost",size:"lg",onClick:ZSe,children:Hie()})]})})}function svr(t){const[n,r]=bt.useState(null);if(n===t.health)return null;const a=XDt(t.health);return O.jsxs("div",{className:"eui-stall-notice bottom",children:[O.jsx("span",{className:"ic",children:"✖"}),O.jsxs("div",{className:"msg",children:[O.jsx("b",{children:t.health.kind==="build"?"Your scene has a code error.":"Your scene’s code crashed."}),O.jsxs("span",{children:[t.health.lines[0]," — ",t.health.kind==="build"?"the running scene keeps the last working build until you fix it.":"fix the file and save — the scene reloads automatically."]})]}),a!==null&&window.editorShell!==void 0&&O.jsxs(tv,{className:"act",onClick:()=>kHe(a.path,a.line),children:[Xm(a.path),":",a.line]}),O.jsx(tv,{className:"act",onClick:t.onLogs,children:"View logs"}),O.jsx("button",{className:"eui-stall-x",onClick:()=>r(t.health),...ld("Dismiss"),children:"✕"})]})}function ovr(t){const[n,r]=bt.useState(!1);return n?O.jsx(O.Fragment,{}):O.jsxs("div",{className:"eui-stall-notice",children:[O.jsx("span",{className:"ic",children:"⚠"}),O.jsxs("div",{className:"msg",children:[O.jsx("b",{children:"Editor tools couldn’t load for this scene."}),O.jsx("span",{children:"The live view is shown, but the hierarchy and inspector didn’t attach. Reloading the editor usually fixes this."})]}),O.jsx(tv,{className:"act",onClick:JYe,children:"Reload editor"}),O.jsx(tv,{className:"act",onClick:t.onLogs,children:"View logs"}),O.jsx("button",{className:"eui-stall-x",onClick:()=>r(!0),...ld("Dismiss"),children:"✕"})]})}function cvr(){switch(tt.status){case"logging-in":return"Connecting to scene…";case"loading-snapshot":return"Loading scene…";case"error":return"Scene error — see logs";case"scene-broken":return"This scene’s code crashed — see the logs below";default:return"Starting engine…"}}function lvr(t){const n=window.editorShell,[r,a]=bt.useState(null),[s,l]=bt.useState(0),d=bt.useRef(!1),[m,_]=bt.useState(null),[x,T]=bt.useState([]),[A,M]=bt.useState(null),F=bt.useRef(null),B=pGe(),H=na(()=>Uc.mode==="studio");if(bt.useEffect(()=>{var he,te,de;if(n===void 0)return;const _e=Ee=>{Xy()||dIn(Ee.realm),d.current=!0,l(lt=>lt+1),a(Ee)};n.getState().then(Ee=>{var lt;T(Ee.logs.slice(-80)),M(((lt=Ee.projects.find(Et=>Et.path===t.project))==null?void 0:lt.title)??null)}),n.onStackLog(Ee=>T(lt=>[...lt.slice(-200),Ee])),(he=n.onServersReady)==null||he.call(n,_e),(te=n.onServersError)==null||te.call(n,Ee=>_(Ee)),(de=n.requestReady)==null||de.call(n).then(Ee=>{Ee!=null&&!d.current&&_e(Ee)})},[]),bt.useEffect(()=>{F.current!==null&&(F.current.scrollTop=F.current.scrollHeight)},[x]),r!==null){const _e=new URLSearchParams;return _e.set("realm",r.realm),_e.set("systemScene",r.systemScene),_e.set("position",r.position),r.spawn!==""&&_e.set("spawn",r.spawn),r.spawnPoints!=="[]"&&_e.set("spawnPoints",r.spawnPoints),_e.set("project",t.project),O.jsx(rvr,{params:_e,preview:s})}const ee=m!==null&&B!==null,Z=ee&&Xy()?XDt(B):null;if(H&&Xy()&&m!==null)return O.jsx("div",{className:"eui-loading-studio",children:O.jsx(Y$t,{shown:!0,fill:!0,height:360})});const K=[...x].reverse().find(_e=>_e.startsWith("Downloading"));return O.jsx("div",{className:"eui-loading",children:O.jsxs("div",{className:"eui-loading-card",children:[m===null?O.jsx(N_,{size:"xl"}):O.jsx("div",{className:"eui-loading-x",children:"✖"}),O.jsx("div",{className:"eui-loading-title",children:m===null?`Starting ${Xy()?A??"your scene":vBn(t.project)}…`:ee?"Your scene has a code error":"Failed to start the scene"}),O.jsx("div",{className:"eui-loading-sub",children:m===null?Xy()?K??"Building the scene.":"Building the scene and launching the local servers.":ee?"The scene can’t build until it’s fixed. Fix the file, then try again.":m}),ee&&O.jsx("pre",{className:"eui-loading-log err",children:B.lines.join(`
|
|
32449
32449
|
`)}),m!==null&&!ee&&O.jsx("pre",{ref:F,className:"eui-loading-log",children:x.length>0?x.map(eH).join(`
|
|
32450
|
-
`):"…"}),Z!==null&&O.jsx(cs,{variant:"primary",size:"lg",onClick:()=>kHe(Z.path,Z.line),children:"Open the code"}),m!==null&&O.jsx(cs,{variant:"secondary",size:"lg",onClick:()=>void(n==null?void 0:n.openProject(t.project)),children:"Try again"}),O.jsx(cs,{variant:"ghost",size:"lg",onClick:ZSe,children:Hie()})]})})}function uvr(){const t=na(()=>jA.project),n=na(()=>jA.opens);return t===null?null:O.jsx(lvr,{project:t},`${t}#${n}`)}const NBe=262144,qCt=174,czt=85,fvr=112,GCt="abcdefghijklmnopqrstuvwxyz234567";function dvr(t){let n="",r=0,a=0;for(const s of t)for(a=a<<8|s,r+=8;r>=5;)n+=GCt[a>>>r-5&31],r-=5;return r>0&&(n+=GCt[a<<5-r&31]),n}async function ZVe(t,n){const r=new Uint8Array(await crypto.subtle.digest("SHA-256",n)),a=new Uint8Array(36);return a.set([1,t,18,32]),a.set(r,4),a}function bne(t){const n=[];for(;t>=128;)n.push(t%128|128),t=Math.floor(t/128);return n.push(t),n}function pvr(t){const n=[],r=[8,2,24,...bne(t.reduce((a,s)=>a+s.fileSize,0))];for(const a of t){const s=[10,a.cid.length,...a.cid,18,0,24,...bne(a.tsize)];n.push(18,...bne(s.length),...s),r.push(32,...bne(a.fileSize))}return n.push(10,...bne(r.length),...r),Uint8Array.from(n)}function lzt(t){return`b${dvr(t)}`}async function mvr(t){return lzt(await ZVe(czt,t))}async function bxe(t){if(t.length<=NBe)return mvr(t);let n=[];for(let r=0;r<t.length;r+=NBe){const a=t.subarray(r,r+NBe);n.push({cid:await ZVe(czt,a),tsize:a.length,fileSize:a.length})}do{const r=[];for(let a=0;a<n.length;a+=qCt){const s=n.slice(a,a+qCt),l=pvr(s);r.push({cid:await ZVe(fvr,l),tsize:l.length+s.reduce((d,m)=>d+m.tsize,0),fileSize:s.reduce((d,m)=>d+m.fileSize,0)})}n=r}while(n.length>1);return lzt(n[0].cid)}const DBe="/scene";function uzt(t){const n=[];for(const r of t.split("/"))r===".."?n.pop():r!==""&&r!=="."&&n.push(r);return"/"+n.join("/")}const cI=(t,n)=>uzt(t+"/"+n);function j7(t){const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function hvr(t){const n=t.slice(t.lastIndexOf("/")+1),r=n.lastIndexOf(".");return r<=0?"":n.slice(r)}const _vr=new TextDecoder;class gvr{constructor(){this.files=new Map,this.dirs=new Set,this.parsed=new Map}set(n,r){this.files.set(n,r),this.parsed.delete(n);for(let a=j7(n);!this.dirs.has(a)&&(this.dirs.add(a),a!=="/");a=j7(a));}has(n){return this.files.has(n)}isDir(n){return this.dirs.has(n)}read(n){return this.files.get(n)}text(n){const r=this.files.get(n);return r===void 0||typeof r=="string"?r:_vr.decode(r)}json(n){if(this.parsed.has(n))return this.parsed.get(n);let r;const a=this.text(n);if(a!==void 0)try{r=JSON.parse(a)}catch{r=void 0}return this.parsed.set(n,r),r}}const y_=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),aTe=".dcl-package.json",JCt=t=>Array.isArray(t)?t.filter(n=>typeof n=="string"):[];async function fzt(t,n){if(!await t.has(n))return;const r=await t.read(n,aTe);if(r!==void 0)try{const a=JSON.parse(new TextDecoder().decode(r));return!y_(a)||typeof a.integrity!="string"?void 0:{integrity:a.integrity,files:Number(a.files)||0,bytes:Number(a.bytes)||0,installScripts:JCt(a.installScripts),native:a.native===!0,nodeBuiltins:JCt(a.nodeBuiltins)}}catch{return}}const yvr=async(t,n,r)=>t.write(n,aTe,new TextEncoder().encode(JSON.stringify(r)));async function sTe(t,n,r){let a;try{a=await fetch(t,n===void 0?{}:{integrity:n,mode:"cors"})}catch(s){if(n===void 0)throw s;const l=await fetch(t).then(d=>d.ok,()=>!1);throw new Error(l?`${r} does not match the hash this editor was published with. The editor will not run it: reload the page, and if this persists the files you were served were altered.`:`${r} could not be loaded (${t}). Check the connection and reload the page.`)}if(!a.ok)throw new Error(`${r} could not be loaded: ${a.status} ${t}`);return a}const HCt=/\.(tsx?|mts|cts|jsx?|mjs|cjs|json|composite|css|txt)$/,vvr=/\.d\.[mc]?ts$/;function bvr(t){const n=t.get("scene.json");if(n!==void 0)try{const r=JSON.parse(new TextDecoder().decode(n)).main;return typeof r=="string"?r:void 0}catch{return}}async function xvr(t){const{integrity:n}=t;if(n===void 0)return new Worker(t.workerUrl);const r=new URL(t.workerUrl,location.href).href,a=await(await sTe(r,n.worker,"web-build/worker.js")).text(),s=URL.createObjectURL(new Blob([a],{type:"text/javascript"})),l=new Worker(s);return setTimeout(()=>URL.revokeObjectURL(s),6e4),l}function wvr(t){const n=xvr(t),r=F=>void n.then(B=>B.postMessage(F),()=>{}),a=new Map;let s=1;const l=new Map;let d=1,m=()=>{},_=()=>{};const x=new Promise((F,B)=>{m=F,_=B}),T=F=>{var B;_(new Error(F));for(const[H,ee]of a){const Z={type:"failed",buildId:H,message:F};(B=t.onEvent)==null||B.call(t,Z),ee.resolve({buildId:H,ok:!1,outputs:new Map,diagnostics:[],events:[...ee.events,Z],ms:0})}a.clear();for(const H of l.values())H.reject(new Error(F));l.clear()},A=F=>{var H,ee;const B=F.data;if(B.type==="ready")m({sdkVersion:B.sdkVersion,esbuildVersion:B.esbuildVersion,snapshot:{sdkVersion:B.sdkVersion,provided:B.provided}});else if(B.type==="packagesSet"){const Z=l.get(B.requestId);l.delete(B.requestId),B.error===void 0?Z==null||Z.resolve(B.shadowed):Z==null||Z.reject(new Error(B.error))}else if(B.type==="initFailed")T(B.message);else if(B.type==="event")(H=a.get(B.event.buildId))==null||H.events.push(B.event),(ee=t.onEvent)==null||ee.call(t,B.event);else{const Z=a.get(B.buildId);if(Z===void 0)return;a.delete(B.buildId),Z.resolve({buildId:B.buildId,ok:Z.events.some(K=>K.type==="bundleSaved"),outputs:new Map(B.outputs),diagnostics:Z.events.flatMap(K=>K.type==="diagnostics"?K.diagnostics:[]),events:Z.events,ms:B.ms})}};n.then(F=>{F.onerror=B=>T(B.message||"The build worker failed to start"),F.onmessage=A},F=>T(F instanceof Error?F.message:String(F)));const{integrity:M}=t;return r({type:"init",wasmUrl:new URL(t.wasmUrl,location.href).href,snapshotUrl:new URL(t.snapshotUrl,location.href).href,integrity:M===void 0?void 0:{wasm:M.wasm,snapshot:M.snapshot}}),x.catch(()=>{}),{ready:x,build(F,B={}){const H=s++,ee=bvr(F),Z=[...F].filter(([K])=>HCt.test(K)&&K!==ee);return new Promise(K=>{a.set(H,{events:[],resolve:K}),r({type:"build",buildId:H,files:Z,options:B})})},async setPackages(F,B){const H=[];let ee=0;for(const[_e,he]of Object.entries((F==null?void 0:F.packages)??{})){const te=B===void 0?void 0:await fzt(B,_e);if(B===void 0||(te==null?void 0:te.integrity)!==he.integrity)throw new Error(`${_e} is not in the package store`);for(const de of await B.list(_e)){if(!HCt.test(de)||vvr.test(de)||de===aTe)continue;const Ee=await B.read(_e,de);if(Ee===void 0)throw new Error(`${_e} is incomplete in the package store: ${de}`);H.push([_e,de,Ee]),ee+=Ee.length}}const Z=d++,K=await new Promise((_e,he)=>{l.set(Z,{resolve:_e,reject:he}),r({type:"packages",requestId:Z,lock:F,files:H})});return{packages:Object.keys((F==null?void 0:F.packages)??{}).length-K.length,files:H.length,bytes:ee,shadowed:K}},dispose(){n.then(F=>F.terminate(),()=>{}),T("The scene builder was disposed")}}}const QCt=[".tsx",".ts",".jsx",".js",".css",".json"],YCt=[".jsx",".js",".css",".json",".tsx",".ts"],Svr={".js":[".ts",".tsx"],".jsx":[".ts",".tsx"],".mjs":[".mts"],".cjs":[".cts"]},XCt=t=>!/^\.{0,2}\//.test(t)&&t!=="."&&t!=="..",Tvr=t=>t.split("/",t.startsWith("@")?2:1).join("/"),RBe=t=>(t+"/").includes("/node_modules/");function kvr(t){const n=t.replace(/^\.\//,""),r=(n.includes("/")?n:"**/"+n).replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\/|\*\*|\*|\?/g,a=>a==="**/"?"(?:.*/)?":a==="**"?".*":a==="*"?"[^/]*":"[^/]");return new RegExp("^"+r+"$")}class Evr{constructor(n){this.config=n,this.packages=new Map}resolve(n,r,a){const s=this.locate(n,r,a);return s===void 0?{kind:"missing"}:s.disabled?{kind:"disabled",path:s.path}:{kind:"file",path:s.path,sideEffects:this.hasSideEffects(s.path)}}locate(n,r,a){if(!XCt(n))return this.loadPath(n.startsWith("/")?uzt(n):cI(r,n),a);for(const[d,m]of Object.entries(this.config.aliases??{}))if(n===d||n.startsWith(d+"/"))return this.loadPath(m+n.slice(d.length),a);const s=this.enclosingPackage(r);if(n.startsWith("#"))return s===null?void 0:this.packageImports(s,n,a);if(s!==null&&y_(s.json.browser)){const d=s.json.browser[n];if(d===!1)return{path:n,disabled:!0};if(typeof d=="string")return XCt(d)?this.loadPackage(d,s.dir,a):this.loadPath(cI(s.dir,d),a)}const{tsconfig:l}=this.config;if(l!==void 0&&!RBe(r)){const d=this.loadTsconfigPath(l,n,a);if(d!==void 0)return d}return this.loadPackage(n,r,a)}loadTsconfigPath(n,r,a){let s;for(const[l,d]of Object.entries(n.paths??{})){const m=l.indexOf("*");if(m===-1){if(l===r){s={star:"",prefix:1/0,targets:d};break}continue}const _=l.slice(0,m),x=l.slice(m+1);r.length<_.length+x.length||!r.startsWith(_)||!r.endsWith(x)||(s===void 0||_.length>s.prefix)&&(s={star:r.slice(_.length,r.length-x.length),prefix:_.length,targets:d})}if(s!==void 0)for(const l of s.targets){const d=this.loadPath(cI(n.pathsBase,l.replace("*",s.star)),a);if(d!==void 0)return d}return n.baseUrl===void 0?void 0:this.loadPath(cI(n.baseUrl,r),a)}loadPackage(n,r,a){var d,m;const s=Tvr(n),l=n.slice(s.length);for(let _=r;;_=j7(_)){if(!_.endsWith("/node_modules")){let x=cI(_,"node_modules/"+s);const T=(d=this.config.links)==null?void 0:d[s];if(!this.config.vfs.isDir(x)&&T!==void 0&&_===this.config.linkRoot&&(x=T),this.config.vfs.isDir(x)){const A=(m=this.packageAt(x))==null?void 0:m.json.exports;if(A!=null){const F=this.matchExports(x,A,"."+l,a);return F===void 0?void 0:this.applyBrowserMap(F,a)}const M=this.loadPath(x+l,a);if(M!==void 0)return M}}if(_==="/")return}}packageImports(n,r,a){const{imports:s}=n.json;return y_(s)?this.matchSubpath(s,r,a,d=>d.startsWith("./")?this.loadPath(cI(n.dir,d),a):this.loadPackage(d,n.dir,a)):void 0}matchExports(n,r,a,s){const l=y_(r)&&Object.keys(r).some(m=>m.startsWith("."))?r:{".":r},d=this.matchSubpath(l,a,s,m=>{if(!m.startsWith("./"))return;const _=cI(n,m);return this.config.vfs.has(_)?{path:_}:void 0});return d==null?void 0:d.path}matchSubpath(n,r,a,s){const l=new Set(["browser","default","module",a]),d=(x,T)=>{if(typeof x=="string")return s(T===null?x:x.split("*").join(T));if(Array.isArray(x)){for(const A of x){const M=d(A,T);if(M!==void 0)return M}return}if(y_(x)){for(const[A,M]of Object.entries(x)){if(!l.has(A))continue;const F=d(M,T);if(F!==void 0)return F}return}return x===null?null:void 0};if(Object.prototype.hasOwnProperty.call(n,r)&&!r.includes("*"))return d(n[r],null)??void 0;let m;for(const x of Object.keys(n)){const T=x.indexOf("*"),A=T===-1?x:x.slice(0,T),M=T===-1?"":x.slice(T+1);T===-1&&!x.endsWith("/")||r.length<A.length+M.length||!r.startsWith(A)||!r.endsWith(M)||(m===void 0||x.length>m.key.length)&&(m={key:x,star:r.slice(A.length,r.length-M.length)})}if(m===void 0)return;const _=n[m.key];return m.key.endsWith("/")&&typeof _=="string"?s(_+m.star):d(_,m.star)??void 0}loadPath(n,r){const a=this.loadAsFile(n)??this.loadAsDirectory(n,r);return a===void 0?void 0:this.applyBrowserMap(a,r)}applyBrowserMap(n,r){const a=this.enclosingPackage(j7(n));if(a===null||!y_(a.json.browser))return{path:n};const s="./"+n.slice(a.dir.length+1),l=s.replace(/\.(js|json)$/,"");for(const d of[s,l,s.slice(2),l.slice(2)]){const m=a.json.browser[d];if(m===!1)return{path:n,disabled:!0};if(typeof m=="string"){const _=cI(a.dir,m),x=this.loadAsFile(_)??this.loadAsDirectory(_,r);return x===void 0?void 0:{path:x}}}return{path:n}}loadAsFile(n){const{vfs:r}=this.config;if(r.has(n))return n;for(const s of RBe(n)?YCt:QCt)if(r.has(n+s))return n+s;const a=hvr(n);for(const s of Svr[a]??[]){const l=n.slice(0,-a.length)+s;if(r.has(l))return l}}loadAsIndex(n){for(const r of RBe(n)?YCt:QCt){const a=n+"/index"+r;if(this.config.vfs.has(a))return a}}loadAsDirectory(n,r){if(!this.config.vfs.isDir(n))return;const a=this.packageAt(n);return(a===null?void 0:this.loadMainField(a,r))??this.loadAsIndex(n)}loadMainField(n,r){const a=m=>{if(typeof m!="string")return;const _=cI(n.dir,m);return this.loadAsFile(_)??this.loadAsIndex(_)},s=a(n.json.browser);if(s!==void 0)return s;const l=a(n.json.module);if(l===void 0)return a(n.json.main);const d=n.json.main===void 0?this.loadAsIndex(n.dir):a(n.json.main);return r==="require"&&d!==void 0?d:l}packageAt(n){const r=this.packages.get(n);if(r!==void 0)return r;const a=this.config.vfs.json(n+"/package.json"),s=y_(a)?{dir:n,json:a}:null;return this.packages.set(n,s),s}enclosingPackage(n){for(let r=n;;r=j7(r)){const a=this.packageAt(r);if(a!==null)return a;if(r==="/")return null}}hasSideEffects(n){const r=this.enclosingPackage(j7(n)),a=r==null?void 0:r.json.sideEffects;if(r===null||a===void 0||a===!0)return!0;if(!Array.isArray(a))return a!==!1;const s=n.slice(r.dir.length+1);return a.some(l=>typeof l=="string"&&kvr(l).test(s))}}const ZCt="@dcl/asset-packs";function KCt(t,n){const r=t.get(n);if(r!==void 0)try{const a=JSON.parse(new TextDecoder().decode(r));return y_(a)?a:void 0}catch{return}}function Cvr(t){const n=new Map,r=KCt(t,"package.json"),a=y_(r==null?void 0:r.dependencies)?r.dependencies[ZCt]:void 0;if(typeof a!="string"||!a.startsWith("file:"))return n;const s=cI(DBe,a.slice(5));if(!s.startsWith(`${DBe}/`))return n;const l=s.slice(DBe.length+1),d=KCt(t,`${l}/package.json`);if((d==null?void 0:d.name)!==ZCt||d.version!=="0.0.1-stub"||!t.has(`${l}/dist/index.js`))return n;const m=new TextEncoder;for(const[_,x]of Object.entries({"events.js":`'use strict'
|
|
32450
|
+
`):"…"}),Z!==null&&O.jsx(cs,{variant:"primary",size:"lg",onClick:()=>kHe(Z.path,Z.line),children:"Open the code"}),m!==null&&O.jsx(cs,{variant:"secondary",size:"lg",onClick:()=>void(n==null?void 0:n.openProject(t.project)),children:"Try again"}),O.jsx(cs,{variant:"ghost",size:"lg",onClick:ZSe,children:Hie()})]})})}function uvr(){const t=na(()=>jA.project),n=na(()=>jA.opens);return t===null?null:O.jsx(lvr,{project:t},`${t}#${n}`)}const NBe=262144,qCt=174,czt=85,fvr=112,GCt="abcdefghijklmnopqrstuvwxyz234567";function dvr(t){let n="",r=0,a=0;for(const s of t)for(a=a<<8|s,r+=8;r>=5;)n+=GCt[a>>>r-5&31],r-=5;return r>0&&(n+=GCt[a<<5-r&31]),n}async function ZVe(t,n){const r=new Uint8Array(await crypto.subtle.digest("SHA-256",n)),a=new Uint8Array(36);return a.set([1,t,18,32]),a.set(r,4),a}function bne(t){const n=[];for(;t>=128;)n.push(t%128|128),t=Math.floor(t/128);return n.push(t),n}function pvr(t){const n=[],r=[8,2,24,...bne(t.reduce((a,s)=>a+s.fileSize,0))];for(const a of t){const s=[10,a.cid.length,...a.cid,18,0,24,...bne(a.tsize)];n.push(18,...bne(s.length),...s),r.push(32,...bne(a.fileSize))}return n.push(10,...bne(r.length),...r),Uint8Array.from(n)}function lzt(t){return`b${dvr(t)}`}async function mvr(t){return lzt(await ZVe(czt,t))}async function bxe(t){if(t.length<=NBe)return mvr(t);let n=[];for(let r=0;r<t.length;r+=NBe){const a=t.subarray(r,r+NBe);n.push({cid:await ZVe(czt,a),tsize:a.length,fileSize:a.length})}do{const r=[];for(let a=0;a<n.length;a+=qCt){const s=n.slice(a,a+qCt),l=pvr(s);r.push({cid:await ZVe(fvr,l),tsize:l.length+s.reduce((d,m)=>d+m.tsize,0),fileSize:s.reduce((d,m)=>d+m.fileSize,0)})}n=r}while(n.length>1);return lzt(n[0].cid)}const DBe="/scene";function uzt(t){const n=[];for(const r of t.split("/"))r===".."?n.pop():r!==""&&r!=="."&&n.push(r);return"/"+n.join("/")}const cI=(t,n)=>uzt(t+"/"+n);function j7(t){const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function hvr(t){const n=t.slice(t.lastIndexOf("/")+1),r=n.lastIndexOf(".");return r<=0?"":n.slice(r)}const _vr=new TextDecoder;class gvr{constructor(){this.files=new Map,this.dirs=new Set,this.parsed=new Map}set(n,r){this.files.set(n,r),this.parsed.delete(n);for(let a=j7(n);!this.dirs.has(a)&&(this.dirs.add(a),a!=="/");a=j7(a));}has(n){return this.files.has(n)}isDir(n){return this.dirs.has(n)}read(n){return this.files.get(n)}text(n){const r=this.files.get(n);return r===void 0||typeof r=="string"?r:_vr.decode(r)}json(n){if(this.parsed.has(n))return this.parsed.get(n);let r;const a=this.text(n);if(a!==void 0)try{r=JSON.parse(a)}catch{r=void 0}return this.parsed.set(n,r),r}}const y_=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),aTe=".dcl-package.json",JCt=t=>Array.isArray(t)?t.filter(n=>typeof n=="string"):[];async function fzt(t,n){if(!await t.has(n))return;const r=await t.read(n,aTe);if(r!==void 0)try{const a=JSON.parse(new TextDecoder().decode(r));return!y_(a)||typeof a.integrity!="string"?void 0:{integrity:a.integrity,files:Number(a.files)||0,bytes:Number(a.bytes)||0,installScripts:JCt(a.installScripts),native:a.native===!0,nodeBuiltins:JCt(a.nodeBuiltins)}}catch{return}}const yvr=async(t,n,r)=>t.write(n,aTe,new TextEncoder().encode(JSON.stringify(r)));async function sTe(t,n,r){let a;try{a=await fetch(t,n===void 0?{}:{integrity:n,mode:"cors"})}catch(s){if(n===void 0)throw s;const l=await fetch(t).then(d=>d.ok,()=>!1);throw new Error(l?`${r} does not match the hash this editor was published with. The editor will not run it: reload the page, and if this persists the files you were served were altered.`:`${r} could not be loaded (${t}). Check the connection and reload the page.`)}if(!a.ok)throw new Error(`${r} could not be loaded: ${a.status} ${t}`);return a}const HCt=/\.(tsx?|mts|cts|jsx?|mjs|cjs|json|composite|css|txt)$/,vvr=/\.d\.[mc]?ts$/;function bvr(t){const n=t.get("scene.json");if(n!==void 0)try{const r=JSON.parse(new TextDecoder().decode(n)).main;return typeof r=="string"?r:void 0}catch{return}}async function xvr(t){const{integrity:n}=t;if(n===void 0)return new Worker(t.workerUrl);const r=new URL(t.workerUrl,location.href).href,a=await(await sTe(r,n.worker,"scene-compiler/worker.js")).text(),s=URL.createObjectURL(new Blob([a],{type:"text/javascript"})),l=new Worker(s);return setTimeout(()=>URL.revokeObjectURL(s),6e4),l}function wvr(t){const n=xvr(t),r=F=>void n.then(B=>B.postMessage(F),()=>{}),a=new Map;let s=1;const l=new Map;let d=1,m=()=>{},_=()=>{};const x=new Promise((F,B)=>{m=F,_=B}),T=F=>{var B;_(new Error(F));for(const[H,ee]of a){const Z={type:"failed",buildId:H,message:F};(B=t.onEvent)==null||B.call(t,Z),ee.resolve({buildId:H,ok:!1,outputs:new Map,diagnostics:[],events:[...ee.events,Z],ms:0})}a.clear();for(const H of l.values())H.reject(new Error(F));l.clear()},A=F=>{var H,ee;const B=F.data;if(B.type==="ready")m({sdkVersion:B.sdkVersion,esbuildVersion:B.esbuildVersion,snapshot:{sdkVersion:B.sdkVersion,provided:B.provided}});else if(B.type==="packagesSet"){const Z=l.get(B.requestId);l.delete(B.requestId),B.error===void 0?Z==null||Z.resolve(B.shadowed):Z==null||Z.reject(new Error(B.error))}else if(B.type==="initFailed")T(B.message);else if(B.type==="event")(H=a.get(B.event.buildId))==null||H.events.push(B.event),(ee=t.onEvent)==null||ee.call(t,B.event);else{const Z=a.get(B.buildId);if(Z===void 0)return;a.delete(B.buildId),Z.resolve({buildId:B.buildId,ok:Z.events.some(K=>K.type==="bundleSaved"),outputs:new Map(B.outputs),diagnostics:Z.events.flatMap(K=>K.type==="diagnostics"?K.diagnostics:[]),events:Z.events,ms:B.ms})}};n.then(F=>{F.onerror=B=>T(B.message||"The build worker failed to start"),F.onmessage=A},F=>T(F instanceof Error?F.message:String(F)));const{integrity:M}=t;return r({type:"init",wasmUrl:new URL(t.wasmUrl,location.href).href,snapshotUrl:new URL(t.snapshotUrl,location.href).href,integrity:M===void 0?void 0:{wasm:M.wasm,snapshot:M.snapshot}}),x.catch(()=>{}),{ready:x,build(F,B={}){const H=s++,ee=bvr(F),Z=[...F].filter(([K])=>HCt.test(K)&&K!==ee);return new Promise(K=>{a.set(H,{events:[],resolve:K}),r({type:"build",buildId:H,files:Z,options:B})})},async setPackages(F,B){const H=[];let ee=0;for(const[_e,he]of Object.entries((F==null?void 0:F.packages)??{})){const te=B===void 0?void 0:await fzt(B,_e);if(B===void 0||(te==null?void 0:te.integrity)!==he.integrity)throw new Error(`${_e} is not in the package store`);for(const de of await B.list(_e)){if(!HCt.test(de)||vvr.test(de)||de===aTe)continue;const Ee=await B.read(_e,de);if(Ee===void 0)throw new Error(`${_e} is incomplete in the package store: ${de}`);H.push([_e,de,Ee]),ee+=Ee.length}}const Z=d++,K=await new Promise((_e,he)=>{l.set(Z,{resolve:_e,reject:he}),r({type:"packages",requestId:Z,lock:F,files:H})});return{packages:Object.keys((F==null?void 0:F.packages)??{}).length-K.length,files:H.length,bytes:ee,shadowed:K}},dispose(){n.then(F=>F.terminate(),()=>{}),T("The scene builder was disposed")}}}const QCt=[".tsx",".ts",".jsx",".js",".css",".json"],YCt=[".jsx",".js",".css",".json",".tsx",".ts"],Svr={".js":[".ts",".tsx"],".jsx":[".ts",".tsx"],".mjs":[".mts"],".cjs":[".cts"]},XCt=t=>!/^\.{0,2}\//.test(t)&&t!=="."&&t!=="..",Tvr=t=>t.split("/",t.startsWith("@")?2:1).join("/"),RBe=t=>(t+"/").includes("/node_modules/");function kvr(t){const n=t.replace(/^\.\//,""),r=(n.includes("/")?n:"**/"+n).replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\/|\*\*|\*|\?/g,a=>a==="**/"?"(?:.*/)?":a==="**"?".*":a==="*"?"[^/]*":"[^/]");return new RegExp("^"+r+"$")}class Evr{constructor(n){this.config=n,this.packages=new Map}resolve(n,r,a){const s=this.locate(n,r,a);return s===void 0?{kind:"missing"}:s.disabled?{kind:"disabled",path:s.path}:{kind:"file",path:s.path,sideEffects:this.hasSideEffects(s.path)}}locate(n,r,a){if(!XCt(n))return this.loadPath(n.startsWith("/")?uzt(n):cI(r,n),a);for(const[d,m]of Object.entries(this.config.aliases??{}))if(n===d||n.startsWith(d+"/"))return this.loadPath(m+n.slice(d.length),a);const s=this.enclosingPackage(r);if(n.startsWith("#"))return s===null?void 0:this.packageImports(s,n,a);if(s!==null&&y_(s.json.browser)){const d=s.json.browser[n];if(d===!1)return{path:n,disabled:!0};if(typeof d=="string")return XCt(d)?this.loadPackage(d,s.dir,a):this.loadPath(cI(s.dir,d),a)}const{tsconfig:l}=this.config;if(l!==void 0&&!RBe(r)){const d=this.loadTsconfigPath(l,n,a);if(d!==void 0)return d}return this.loadPackage(n,r,a)}loadTsconfigPath(n,r,a){let s;for(const[l,d]of Object.entries(n.paths??{})){const m=l.indexOf("*");if(m===-1){if(l===r){s={star:"",prefix:1/0,targets:d};break}continue}const _=l.slice(0,m),x=l.slice(m+1);r.length<_.length+x.length||!r.startsWith(_)||!r.endsWith(x)||(s===void 0||_.length>s.prefix)&&(s={star:r.slice(_.length,r.length-x.length),prefix:_.length,targets:d})}if(s!==void 0)for(const l of s.targets){const d=this.loadPath(cI(n.pathsBase,l.replace("*",s.star)),a);if(d!==void 0)return d}return n.baseUrl===void 0?void 0:this.loadPath(cI(n.baseUrl,r),a)}loadPackage(n,r,a){var d,m;const s=Tvr(n),l=n.slice(s.length);for(let _=r;;_=j7(_)){if(!_.endsWith("/node_modules")){let x=cI(_,"node_modules/"+s);const T=(d=this.config.links)==null?void 0:d[s];if(!this.config.vfs.isDir(x)&&T!==void 0&&_===this.config.linkRoot&&(x=T),this.config.vfs.isDir(x)){const A=(m=this.packageAt(x))==null?void 0:m.json.exports;if(A!=null){const F=this.matchExports(x,A,"."+l,a);return F===void 0?void 0:this.applyBrowserMap(F,a)}const M=this.loadPath(x+l,a);if(M!==void 0)return M}}if(_==="/")return}}packageImports(n,r,a){const{imports:s}=n.json;return y_(s)?this.matchSubpath(s,r,a,d=>d.startsWith("./")?this.loadPath(cI(n.dir,d),a):this.loadPackage(d,n.dir,a)):void 0}matchExports(n,r,a,s){const l=y_(r)&&Object.keys(r).some(m=>m.startsWith("."))?r:{".":r},d=this.matchSubpath(l,a,s,m=>{if(!m.startsWith("./"))return;const _=cI(n,m);return this.config.vfs.has(_)?{path:_}:void 0});return d==null?void 0:d.path}matchSubpath(n,r,a,s){const l=new Set(["browser","default","module",a]),d=(x,T)=>{if(typeof x=="string")return s(T===null?x:x.split("*").join(T));if(Array.isArray(x)){for(const A of x){const M=d(A,T);if(M!==void 0)return M}return}if(y_(x)){for(const[A,M]of Object.entries(x)){if(!l.has(A))continue;const F=d(M,T);if(F!==void 0)return F}return}return x===null?null:void 0};if(Object.prototype.hasOwnProperty.call(n,r)&&!r.includes("*"))return d(n[r],null)??void 0;let m;for(const x of Object.keys(n)){const T=x.indexOf("*"),A=T===-1?x:x.slice(0,T),M=T===-1?"":x.slice(T+1);T===-1&&!x.endsWith("/")||r.length<A.length+M.length||!r.startsWith(A)||!r.endsWith(M)||(m===void 0||x.length>m.key.length)&&(m={key:x,star:r.slice(A.length,r.length-M.length)})}if(m===void 0)return;const _=n[m.key];return m.key.endsWith("/")&&typeof _=="string"?s(_+m.star):d(_,m.star)??void 0}loadPath(n,r){const a=this.loadAsFile(n)??this.loadAsDirectory(n,r);return a===void 0?void 0:this.applyBrowserMap(a,r)}applyBrowserMap(n,r){const a=this.enclosingPackage(j7(n));if(a===null||!y_(a.json.browser))return{path:n};const s="./"+n.slice(a.dir.length+1),l=s.replace(/\.(js|json)$/,"");for(const d of[s,l,s.slice(2),l.slice(2)]){const m=a.json.browser[d];if(m===!1)return{path:n,disabled:!0};if(typeof m=="string"){const _=cI(a.dir,m),x=this.loadAsFile(_)??this.loadAsDirectory(_,r);return x===void 0?void 0:{path:x}}}return{path:n}}loadAsFile(n){const{vfs:r}=this.config;if(r.has(n))return n;for(const s of RBe(n)?YCt:QCt)if(r.has(n+s))return n+s;const a=hvr(n);for(const s of Svr[a]??[]){const l=n.slice(0,-a.length)+s;if(r.has(l))return l}}loadAsIndex(n){for(const r of RBe(n)?YCt:QCt){const a=n+"/index"+r;if(this.config.vfs.has(a))return a}}loadAsDirectory(n,r){if(!this.config.vfs.isDir(n))return;const a=this.packageAt(n);return(a===null?void 0:this.loadMainField(a,r))??this.loadAsIndex(n)}loadMainField(n,r){const a=m=>{if(typeof m!="string")return;const _=cI(n.dir,m);return this.loadAsFile(_)??this.loadAsIndex(_)},s=a(n.json.browser);if(s!==void 0)return s;const l=a(n.json.module);if(l===void 0)return a(n.json.main);const d=n.json.main===void 0?this.loadAsIndex(n.dir):a(n.json.main);return r==="require"&&d!==void 0?d:l}packageAt(n){const r=this.packages.get(n);if(r!==void 0)return r;const a=this.config.vfs.json(n+"/package.json"),s=y_(a)?{dir:n,json:a}:null;return this.packages.set(n,s),s}enclosingPackage(n){for(let r=n;;r=j7(r)){const a=this.packageAt(r);if(a!==null)return a;if(r==="/")return null}}hasSideEffects(n){const r=this.enclosingPackage(j7(n)),a=r==null?void 0:r.json.sideEffects;if(r===null||a===void 0||a===!0)return!0;if(!Array.isArray(a))return a!==!1;const s=n.slice(r.dir.length+1);return a.some(l=>typeof l=="string"&&kvr(l).test(s))}}const ZCt="@dcl/asset-packs";function KCt(t,n){const r=t.get(n);if(r!==void 0)try{const a=JSON.parse(new TextDecoder().decode(r));return y_(a)?a:void 0}catch{return}}function Cvr(t){const n=new Map,r=KCt(t,"package.json"),a=y_(r==null?void 0:r.dependencies)?r.dependencies[ZCt]:void 0;if(typeof a!="string"||!a.startsWith("file:"))return n;const s=cI(DBe,a.slice(5));if(!s.startsWith(`${DBe}/`))return n;const l=s.slice(DBe.length+1),d=KCt(t,`${l}/package.json`);if((d==null?void 0:d.name)!==ZCt||d.version!=="0.0.1-stub"||!t.has(`${l}/dist/index.js`))return n;const m=new TextEncoder;for(const[_,x]of Object.entries({"events.js":`'use strict'
|
|
32451
32451
|
module.exports = require('./index')
|
|
32452
32452
|
`,"events.d.ts":`export { getActionEvents, getTriggerEvents } from './index'
|
|
32453
32453
|
`})){const T=`${l}/dist/${_}`;t.has(T)||n.set(T,m.encode(x))}return n}const k0e="0|[1-9]\\d*",dzt="(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z.-]+)?",Avr=new RegExp(`^[v=\\s]*(${k0e})\\.(${k0e})\\.(${k0e})${dzt}$`),MBe=`${k0e}|[xX*]`,Ovr=new RegExp(`^[v=\\s]*(${MBe})(?:\\.(${MBe})(?:\\.(${MBe})${dzt})?)?$`),Pvr=/^(<=|>=|<|>|=|\^|~>|~)?\s*(.*)$/,pzt=256;function dG(t){if(t.length>pzt)return;const n=Avr.exec(t.trim());if(n===null)return;const[r,a,s]=[Number(n[1]),Number(n[2]),Number(n[3])];if([r,a,s].every(Number.isSafeInteger))return{major:r,minor:a,patch:s,prerelease:mzt(n[4])}}const mzt=t=>t===void 0?[]:t.split(".").map(n=>/^\d+$/.test(n)?Number(n):n);function pXe(t,n){const r=t.major-n.major||t.minor-n.minor||t.patch-n.patch;if(r!==0)return Math.sign(r);if(t.prerelease.length===0||n.prerelease.length===0)return Math.sign(n.prerelease.length-t.prerelease.length);for(let a=0;;a++){const[s,l]=[t.prerelease[a],n.prerelease[a]];if(s===void 0&&l===void 0)return 0;if(s===void 0)return-1;if(l===void 0)return 1;if(s!==l)return typeof s!=typeof l?typeof s=="number"?-1:1:s<l?-1:1}}const cve=(t,n=0,r=0,a=[])=>({major:t,minor:n,patch:r,prerelease:a}),LBe=t=>t===void 0||/^[xX*]$/.test(t);function KVe(t,n){const[,r="",a=""]=Pvr.exec(t)??[],s=Ovr.exec(a);if(s===null)return;const[l,d,m]=[LBe(s[1]),LBe(s[2]),LBe(s[3])],_=l?0:Number(s[1]),x=l||d?0:Number(s[2]),T=l||d||m?0:Number(s[3]),A=!l&&!d&&!m,M=n?[0]:[],F=cve(_,x,T,A?mzt(s[4]):M),B=K=>({op:"<",version:{...K,prerelease:[0]}}),H=cve(_+1),ee=cve(_,x+1);if(r==="^"){if(l)return[];let K=cve(_,x,T+1);return _>0||d?K=H:(x>0||m)&&(K=ee),[{op:">=",version:F},B(K)]}if(r==="~"||r==="~>")return l?[]:[{op:">=",version:F},B(d?H:ee)];if(A)return[{op:r===""?"=":r,version:F}];if(r===""||r==="=")return l?[]:[{op:">=",version:F},B(d?H:ee)];if(l)return r==="<"||r===">"?null:[];const Z=d?H:ee;return r===">"?[{op:">=",version:{...Z,prerelease:M}}]:r==="<="?[B(Z)]:r==="<"?[B(F)]:[{op:">=",version:F}]}function Ivr(t,n,r){const a=KVe(">="+t,r),s=KVe("<="+n,r);if(a===void 0||s===void 0||a===null||s===null)return;const[l]=a;return r&&l!==void 0&&l.version.prerelease.length===0&&(l.version.prerelease=[0]),[...a,...s]}function hzt(t,n=!1){if(t.length>pzt)return;const r=[];for(const a of t.split("||")){const s=a.trim(),l=/^(\S+)\s+-\s+(\S+)$/.exec(s);if(l!==null){const _=Ivr(l[1],l[2],n);if(_===void 0)return;r.push(_);continue}const d=[];let m=!1;for(const _ of s.replace(/(<=|>=|<|>|=|\^|~>|~)\s+/g,"$1").split(/\s+/)){if(_==="")continue;const x=KVe(_,n);if(x===void 0)return;x===null?m=!0:d.push(...x)}m||r.push(d)}return r}const lve=t=>hzt(t)!==void 0;function Nvr(t,{op:n,version:r}){const a=pXe(t,r);switch(n){case"=":return a===0;case"<":return a<0;case"<=":return a<=0;case">":return a>0;case">=":return a>=0}}function WW(t,n,r={}){const a=typeof t=="string"?dG(t):t,s=hzt(n,r.includePrerelease===!0);return a===void 0||s===void 0?!1:s.some(l=>l.every(d=>Nvr(a,d))?a.prerelease.length===0||r.includePrerelease===!0?!0:l.some(({version:d})=>d.prerelease.length>0&&d.major===a.major&&d.minor===a.minor&&d.patch===a.patch):!1)}function eAt(t,n){let r;for(const a of t){const s=dG(a);s===void 0||!WW(s,n)||(r===void 0||pXe(s,r.version)>0)&&(r={text:a,version:s})}return r==null?void 0:r.text}const E3="dcl-editor.lock.json",Dvr=/^(?:@[A-Za-z0-9-~][A-Za-z0-9-._~]*\/)?[A-Za-z0-9-~][A-Za-z0-9-._~]*$/,Rvr=/^sha512-[A-Za-z0-9+/]{86}==$/,Qie=t=>t.length<=214&&Dvr.test(t);function Eq(t){const n=t.lastIndexOf("@");if(n<=0)return;const[r,a]=[t.slice(0,n),t.slice(n+1)];return Qie(r)&&dG(a)!==void 0?{name:r,version:a}:void 0}const B7=(t,n)=>n.startsWith("npm:")?n.slice(4):`${t}@${n}`,tAt=(t,n)=>n.startsWith(t+"@")&&n.lastIndexOf("@")===t.length?n.slice(t.length+1):"npm:"+n;function nAt(t){if(t===void 0)return{};if(!y_(t))return;const n={};for(const[r,a]of Object.entries(t)){if(typeof a!="string"||!Qie(r)||Eq(B7(r,a))===void 0)return;n[r]=a}return n}function _zt(t){if(t===void 0)return;let n;try{n=JSON.parse(typeof t=="string"?t:new TextDecoder().decode(t))}catch{return}if(!y_(n)||n.lockfileVersion!==1||typeof n.registry!="string"||!y_(n.packages))return;const r=nAt(n.dependencies);if(r===void 0)return;const a={};for(const[s,l]of Object.entries(n.packages)){if(Eq(s)===void 0||!y_(l))return;const d=nAt(l.dependencies);if(typeof l.resolved!="string"||typeof l.integrity!="string"||!Rvr.test(l.integrity)||d===void 0)return;a[s]={resolved:l.resolved,integrity:l.integrity,...Object.keys(d).length>0?{dependencies:d}:{}}}return{lockfileVersion:1,registry:n.registry,dependencies:r,packages:a}}const gzt=t=>JSON.stringify(t,null,2)+`
|
|
32454
32454
|
`,yzt="web",mXe=/^[a-z0-9][a-z0-9-]{0,63}$/,Mvr=/^[A-Za-z0-9_.]{1,64}$/,Lvr="\0";function vzt(t){let n="";for(const r of new TextEncoder().encode(t))n+=String.fromCharCode(r);return btoa(n)}function bzt(t){if(!mXe.test(t))throw new Error(`Invalid preview project id "${t}"`);return`/preview/${t}`}function xzt(t){if(!Mvr.test(t))throw new Error(`Invalid preview machine id "${t}"`);return"-"+t}const wzt=(t,n=yzt)=>"b64-"+vzt(bzt(t)+xzt(n)),Fvr=(t,n,r,a=yzt)=>"b64-"+vzt(`${bzt(t)}/${n}${Lvr}${r}${xzt(a)}`),oTe=t=>t;async function jvr(t){const n=new Uint8Array(await crypto.subtle.digest("SHA-256",oTe(t)));return String(n.slice(0,6).reduce((r,a)=>r*256+a,0))}const Bvr="https://registry.npmjs.org",eWe=1024*1024,$vr={packages:200,unpackedBytes:100*eWe,tarballBytes:20*eWe};class jh extends Error{constructor(n,r,a){super(r),this.code=n,this.pkg=a,this.name="PackageResolveError"}}const FBe=t=>t instanceof Error?t.message:String(t);function E0e(t){const n={};if(y_(t))for(const[r,a]of Object.entries(t))typeof a=="string"&&(n[r]=a);return n}function tWe(t,n){return t<n?-1:t>n?1:0}const uve=t=>Object.entries(t).sort(([n],[r])=>tWe(n,r));function xne(t){try{return new URL(t).origin}catch{throw new jh("invalid",`"${t}" is not a url`)}}function jBe(t,n){let r=t,a=n.trim();if(a.startsWith("npm:")){const s=a.lastIndexOf("@");r=s>4?a.slice(4,s):a.slice(4),a=s>4?a.slice(s+1):"latest"}return/^(file|link|portal):/.test(a)?{kind:"local"}:/^[a-z+]+:/.test(a)||a.startsWith("git@")||a.includes("/")||!Qie(r)?{kind:"unsupported"}:{kind:"registry",name:r,range:a===""?"*":a}}function rAt(t,n){const r=y_(n)&&y_(n.dist)?n.dist:void 0;if(!y_(n)||r===void 0||typeof r.tarball!="string")throw new jh("invalid",`the registry has no tarball for ${t}`,t);const a=E0e(n.optionalDependencies),s=E0e(n.dependencies);for(const x of Object.keys(a))delete s[x];const l=y_(n.peerDependenciesMeta)?n.peerDependenciesMeta:{},d={};for(const[x,T]of Object.entries(E0e(n.peerDependencies))){const A=l[x];!(y_(A)&&A.optional===!0)&&s[x]===void 0&&a[x]===void 0&&(d[x]=T)}const m=n.bundleDependencies??n.bundledDependencies,_=typeof r.integrity=="string"?r.integrity.split(/\s+/).find(x=>x.startsWith("sha512-")):void 0;return{tarball:r.tarball,integrity:_==null?void 0:_.split("?")[0],shasum:typeof r.shasum=="string"?r.shasum.toLowerCase():void 0,dependencies:s,optional:a,peers:d,bundled:m===!0?"all":new Set(Array.isArray(m)?m.filter(x=>typeof x=="string"):[]),platform:n.os!==void 0||n.cpu!==void 0||n.libc!==void 0}}async function iAt(t,n){return new Uint8Array(await crypto.subtle.digest(t,oTe(n)))}function Uvr(t){let n="";for(const r of t)n+=String.fromCharCode(r);return btoa(n)}const zvr=t=>Array.from(t,n=>n.toString(16).padStart(2,"0")).join("");function Vvr(t){const n=t.url.replace(/\/+$/,""),r=xne(n),a=new Map;let s=0;async function l(_,x){s++;let T;try{T=await t.fetch(_,{headers:x===void 0?void 0:{Accept:x},credentials:"omit",signal:t.signal})}catch(A){throw new jh("network",`${_}: ${FBe(A)}`)}if(T.url!==""&&xne(T.url)!==r)throw new jh("registry-origin",`${_} was answered by ${xne(T.url)}, not by ${r}`);return T}async function d(_){if(t.frozen)throw new jh("frozen",`${_} is not pinned by the lock, and the project is frozen`,_);const x=await l(`${n}/${_.replace("/","%2f")}`,"application/vnd.npm.install-v1+json");if(x.status===404)throw new jh("not-found",`${_} is not in the registry`,_);if(!x.ok)throw new jh("network",`${_}: the registry answered ${x.status}`,_);let T;try{T=await x.json()}catch(A){throw new jh("network",`${_}: ${FBe(A)}`,_)}if(!y_(T)||!y_(T.versions))throw new jh("invalid",`${_}: the registry sent no versions`,_);return{tags:E0e(T["dist-tags"]),versions:T.versions}}async function m(_,x,T){var M;const A=new jh("limit",`${x}: the tarball is larger than ${T} bytes`,x);if(Number(_.headers.get("content-length"))>T)throw A;try{const F=(M=_.body)==null?void 0:M.getReader();if(F===void 0){const K=new Uint8Array(await _.arrayBuffer());if(K.length>T)throw A;return K}const B=[];let H=0;for(;;){const{done:K,value:_e}=await F.read();if(K)break;if(H+=_e.length,H>T)throw await F.cancel(),A;B.push(_e)}const ee=new Uint8Array(H);let Z=0;for(const K of B)ee.set(K,Z),Z+=K.length;return ee}catch(F){throw F instanceof jh?F:new jh("network",`${x}: ${FBe(F)}`,x)}}return{url:n,requests:()=>s,packument(_){let x=a.get(_);return x===void 0&&a.set(_,x=d(_)),x},async tarball(_,x,T){if(t.frozen)throw new jh("frozen",`${_} is not in the package store, and the project is frozen`,_);if(xne(x)!==r)throw new jh("registry-origin",`${_}: its tarball is on ${xne(x)}, not on ${r}`,_);const A=await l(x);if(!A.ok)throw new jh("network",`${_}: the registry answered ${A.status}`,_);return m(A,_,T)}}}const Wvr=new Set("assert async_hooks buffer child_process cluster console constants crypto dgram diagnostics_channel dns domain events fs http http2 https inspector module net os path perf_hooks process punycode querystring readline repl stream string_decoder sys timers tls trace_events tty url util v8 vm wasi worker_threads zlib".split(" ")),qvr=t=>t.startsWith("node:")||Wvr.has(t.split("/",1)[0]),Gvr=new RegExp(`(?<![.\\w$])require\\(\\s*['"]([^'"\\n]+)['"]\\s*\\)|\\b(?:import|export)\\b[^'"\\n;]*?\\bfrom\\s*['"]([^'"\\n]+)['"]|\\bimport\\s*\\(?\\s*['"]([^'"\\n]+)['"]`,"g"),Jvr=/\.(js|mjs|cjs|json)$/,Hvr=2e3,Qvr=1024*1024;function Yvr(t){const n=t.get("package.json");if(n===void 0)return{};try{const r=JSON.parse(new TextDecoder().decode(n));return y_(r)?r:{}}catch{return{}}}function Xvr(t,n){const r=new gvr,a="/node_modules/"+t;for(const[x,T]of n)Jvr.test(x)&&T.length<=Qvr&&r.set(`${a}/${x}`,T);const s=new Evr({vfs:r}),l=s.resolve(t,"/","import"),d=new Set,m=new Set,_=l.kind==="file"?[l.path]:[];for(let x=_.pop();x!==void 0&&m.size<Hvr;x=_.pop())if(!(m.has(x)||x.endsWith(".json"))){m.add(x);for(const T of(r.text(x)??"").matchAll(Gvr)){const A=T[1]??T[2]??T[3],M=s.resolve(A,j7(x),T[1]===void 0?"import":"require");M.kind==="file"?_.push(M.path):M.kind==="missing"&&qvr(A)&&d.add(A.replace(/^node:/,"").split("/",1)[0])}}return[...d].sort()}function Zvr(t,n){const r=Yvr(n),a=y_(r.scripts)?r.scripts:{},s=n.has("binding.gyp")||r.gypfile===!0,l=["preinstall","install","postinstall"].filter(d=>typeof a[d]=="string");return s&&!l.includes("install")&&l.push("install"),{installScripts:l,native:s||[...n.keys()].some(d=>d.endsWith(".node")),nodeBuiltins:Xvr(t,n)}}class RA extends Error{constructor(n,r){super(r),this.reason=n}}const qW=512,xxe=new TextDecoder;async function Kvr(t,n){const a=new Blob([oTe(t)]).stream().pipeThrough(new DecompressionStream("gzip")).getReader(),s=[];let l=0;try{for(;;){const{done:_,value:x}=await a.read();if(_)break;if(l+=x.length,l>n)throw await a.cancel(),new RA("too-large",`unpacks to more than ${n} bytes`);s.push(x)}}catch(_){throw _ instanceof RA?_:new RA("malformed","is not a gzip archive")}const d=new Uint8Array(l);let m=0;for(const _ of s)d.set(_,m),m+=_.length;return d}function Fre(t,n,r){let a=n;for(;a<n+r&&t[a]!==0;)a++;return xxe.decode(t.subarray(n,a))}function e0r(t){if(t[124]&128)throw new RA("too-large","holds an entry larger than 8 GB");const n=parseInt(Fre(t,124,12).trim()||"0",8);if(!Number.isSafeInteger(n)||n<0)throw new RA("malformed","has an entry with no valid size");return n}function t0r(t){let n=0;for(let r=0;r<qW;r++)n+=r>=148&&r<156?32:t[r];return n===parseInt(Fre(t,148,8).trim(),8)}function n0r(t){const n={};for(let r=0;r<t.length;){let a=r;for(;a<t.length&&t[a]!==32;)a++;const s=Number(xxe.decode(t.subarray(r,a)));if(!Number.isSafeInteger(s)||s<=0)break;const l=xxe.decode(t.subarray(a+1,r+s-1)),d=l.indexOf("=");d>0&&(n[l.slice(0,d)]=l.slice(d+1)),r+=s}return n}function r0r(t){if(t.includes("\0"))throw new RA("unsafe-path","has an entry with a NUL in its path");const n=t.split(/[\\/]/);if(t.startsWith("/")||t.startsWith("\\")||/^[A-Za-z]:/.test(t))throw new RA("unsafe-path",`has an entry with an absolute path: ${t}`);if(n.includes(".."))throw new RA("unsafe-path",`has an entry that leaves the package: ${t}`);const r=n.filter(a=>a!==""&&a!==".").slice(1);return r.length===0?void 0:r.join("/")}function i0r(t){const n=new Map,r=[];let a,s={};for(let l=0;l+qW<=t.length;){const d=t.subarray(l,l+qW);if(d.every(B=>B===0))break;if(!t0r(d))throw new RA("malformed","is not a tar archive");const m=String.fromCharCode(d[156]||48),_=s.size===void 0?e0r(d):Number(s.size),x=l+qW;if(!Number.isSafeInteger(_)||x+_>t.length)throw new RA("malformed","is cut short");const T=t.subarray(x,x+_);if(l=x+Math.ceil(_/qW)*qW,m==="x"){s=n0r(T);continue}if(m==="g")continue;if(m==="L"){a=xxe.decode(T).replace(/\0+$/,"");continue}if(m==="K")continue;const A=Fre(d,257,5)==="ustar"?Fre(d,345,155):"",M=s.path??a??(A===""?"":A+"/")+Fre(d,0,100);a=void 0,s={};const F=r0r(M);if(!(m==="5"||F===void 0)){if(m!=="0"&&m!=="7"){r.push(F);continue}n.set(F,T.slice())}}return{files:n,skipped:r}}const a0r=4;async function s0r(t){var Qt;const n=Vvr({url:t.registry??Bvr,fetch:t.fetch??((We,Fe)=>fetch(We,Fe)),frozen:t.frozen===!0,signal:t.signal}),r={...$vr,...t.limits},a=((Qt=t.snapshot)==null?void 0:Qt.provided)??{},s=t.lock!==void 0&&t.lock.registry===n.url?t.lock:void 0,l={packages:0,downloaded:0,reused:0,requests:0,tarballBytes:0,unpackedBytes:0},d=[],m=(We,Fe,zt)=>{d.some(ft=>ft.code===We&&ft.message===Fe)||d.push({code:We,message:Fe,...zt===void 0?{}:{package:zt}})},_=new Map,x=new Map,T=new Map,A=[],M={};async function F(We){if(_.has(We)||x.has(We)||(s==null?void 0:s.packages[We])!==void 0)return;const Fe=Eq(We);if(Fe===void 0)throw new jh("invalid",`"${We}" is not a package version`);const zt=(await n.packument(Fe.name)).versions[Fe.version];if(zt===void 0)throw new jh("no-version",`${We} is not in the registry`,We);x.set(We,rAt(We,zt))}async function B(We,Fe,zt){const ft=!lve(Fe),xt=Ze=>{const ot=Eq(Ze);return ot!==void 0&&ot.name===We&&(ft||WW(ot.version,Fe))},ht=Ze=>_.has(Ze)||(s==null?void 0:s.packages[Ze])!==void 0;if(zt!==void 0&&xt(zt)&&ht(zt))return zt;if(!ft){const Ze=nn=>{const On=eAt([...nn].filter(xt).map(fn=>fn.slice(We.length+1)),Fe);return On===void 0?void 0:`${We}@${On}`},ot=Ze(_.keys())??Ze(Object.keys((s==null?void 0:s.packages)??{}));if(ot!==void 0)return ot}const Rt=await n.packument(We),qt=Rt.tags.latest,Wt=ft?Rt.tags[Fe]:qt!==void 0&&WW(qt,Fe)?qt:eAt(Object.keys(Rt.versions),Fe);if(Wt===void 0||dG(Wt)===void 0||Rt.versions[Wt]===void 0)throw new jh("no-version",`no version of ${We} matches "${Fe}"`,We);const Le=`${We}@${Wt}`;return!_.has(Le)&&!x.has(Le)&&x.set(Le,rAt(Le,Rt.versions[Wt])),Le}function H(We,Fe){var xt;if(_.has(We))return;if(_.size>=r.packages)throw new jh("limit",`the project needs more than ${r.packages} packages`);const zt=x.get(We),ft=s==null?void 0:s.packages[We];if(zt!==void 0)_.set(We,{resolved:zt.tarball,integrity:zt.integrity??"",dependencies:{}});else if(ft!==void 0)_.set(We,{resolved:ft.resolved,integrity:ft.integrity,dependencies:{...ft.dependencies}});else throw new jh("invalid",`${We} was never resolved`,We);T.set(We,Fe),A.push(We),(xt=t.onProgress)==null||xt.call(t,{type:"resolved",package:We})}function ee(We,Fe){const zt=jBe(We,Fe);if(t.frozen===!0||a[We]!==void 0||zt.kind!=="registry")return;const ft=xt=>xt.startsWith(zt.name+"@")&&lve(zt.range)&&WW(xt.slice(zt.name.length+1),zt.range);[..._.keys(),...Object.keys((s==null?void 0:s.packages)??{})].some(ft)||n.packument(zt.name).catch(()=>{})}function Z(We,Fe,zt){const ft=a[We];if(ft===void 0)return!1;const xt=Fe.trim();return ft!==""&&lve(xt)&&!WW(ft,xt,{includePrerelease:!0})&&(We==="@dcl/sdk"&&zt===void 0?m("sdk-version",`This project pins @dcl/sdk ${xt}; it is built here with ${ft}.`,We):m("snapshot-version",`${zt??"This project"} asks for ${We} ${xt}; it gets the ${ft} the SDK ships.`,zt??We)),!0}function K(We,Fe){var xt,ht;const zt=T.get(Fe),ft=(zt===void 0||(ht=(xt=_.get(zt))==null?void 0:xt.dependencies)==null?void 0:ht[We])??M[We];return ft===void 0?void 0:B7(We,ft)}async function _e(We){var qt;const Fe=_.get(We);if(Fe===void 0)return;const zt=Fe.dependencies??(Fe.dependencies={}),ft=x.get(We);if(ft===void 0){for(const[Wt,Le]of uve({...zt})){if(a[Wt]!==void 0){delete zt[Wt];continue}const Ze=B7(Wt,Le);await F(Ze),H(Ze,We)}return}const xt=[];for(const[Wt,Le]of Object.entries(ft.dependencies))xt.push([Wt,Le,"required"]);for(const[Wt,Le]of Object.entries(ft.optional))xt.push([Wt,Le,"optional"]);for(const[Wt,Le]of Object.entries(ft.peers))xt.push([Wt,Le,"peer"]);xt.sort(([Wt],[Le])=>tWe(Wt,Le));const ht=Wt=>ft.bundled==="all"||ft.bundled.has(Wt);for(const[Wt,Le,Ze]of xt)Ze!=="peer"&&!ht(Wt)&&ee(Wt,Le);let Rt=0;for(const[Wt,Le,Ze]of xt){if(Ze!=="peer"&&ht(Wt)||Z(Wt,Le,We))continue;const ot=jBe(Wt,Le);if(ot.kind!=="registry"){m("unsupported-spec",`${We} depends on ${Wt} as "${Le}", which is not a registry version; it was left out.`,We);continue}try{let nn=Ze==="peer"?K(Wt,We):void 0;if(nn===void 0?nn=await B(ot.name,ot.range,void 0):lve(ot.range)&&!WW(nn.slice(nn.lastIndexOf("@")+1),ot.range)&&m("peer-unmet",`${We} expects ${Wt} ${ot.range}; the project uses ${nn}.`,We),Ze==="optional"&&((qt=x.get(nn))==null?void 0:qt.platform)===!0&&!_.has(nn)){Rt++;continue}H(nn,We),zt[Wt]=tAt(Wt,nn)}catch(nn){if(!(nn instanceof jh)||nn.code==="limit"||nn.code==="frozen"||Ze==="required")throw nn;m(Ze==="peer"?"peer-unmet":"optional-skipped",`${We}: ${Wt} was left out (${nn.message}).`,We)}}Rt>0&&m("optional-skipped",`${We}: ${Rt} optional packages built for one platform were left out.`,We)}for(const[We,Fe]of Object.entries(t.dependencies))typeof Fe=="string"&&Qie(We)&&(s==null?void 0:s.dependencies[We])===void 0&&ee(We,Fe);for(const[We,Fe]of uve(t.dependencies)){if(typeof Fe!="string"||Z(We,Fe,void 0))continue;const zt=jBe(We,Fe);if(zt.kind==="local")continue;if(zt.kind==="unsupported"||!Qie(We)){m("unsupported-spec",`${We}: "${Fe}" is not a registry version; it was left out.`,We);continue}const ft=s==null?void 0:s.dependencies[We],xt=await B(zt.name,zt.range,ft===void 0?void 0:B7(We,ft));H(xt,void 0),M[We]=tAt(We,xt)}for(const[We,Fe]of Object.entries(t.devDependencies??{}))typeof Fe=="string"&&Z(We,Fe,void 0);for(let We=A.shift();We!==void 0;We=A.shift())await _e(We);const he=(We,Fe)=>{if(l.unpackedBytes+=Fe,l.unpackedBytes>r.unpackedBytes)throw new jh("limit",`the packages unpack to more than ${r.unpackedBytes} bytes (at ${We})`,We)};async function te(We,Fe){var Wt,Le;const zt=await n.tarball(We,Fe.resolved,r.tarballBytes),ft="sha512-"+Uvr(await iAt("SHA-512",zt));if(Fe.integrity===""){const Ze=(Wt=x.get(We))==null?void 0:Wt.shasum;if(Ze===void 0||zvr(await iAt("SHA-1",zt))!==Ze)throw new jh("integrity",`${We}: the tarball does not match the checksum the registry lists`,We);Fe.integrity=ft,m("weak-integrity",`${We} was published with a SHA-1 checksum only; the lock pins what was downloaded.`,We)}else if(ft!==Fe.integrity)throw new jh("integrity",`${We}: the tarball does not match its integrity (${Fe.integrity})`,We);(Le=t.onProgress)==null||Le.call(t,{type:"downloaded",package:We,bytes:zt.length});let xt;try{xt=i0r(await Kvr(zt,2*r.unpackedBytes+eWe))}catch(Ze){throw Ze instanceof RA?new jh(Ze.reason==="too-large"?"limit":"unsafe-tarball",`${We} ${Ze.message}`,We):Ze}const{files:ht}=xt;ht.delete(aTe);let Rt=0;for(const Ze of ht.values())Rt+=Ze.length;he(We,Rt);const qt={integrity:Fe.integrity,files:ht.size,bytes:Rt,...Zvr(We.slice(0,We.lastIndexOf("@")),ht)};await t.store.remove(We);for(const[Ze,ot]of ht)await t.store.write(We,Ze,ot);return await yvr(t.store,We,qt),xt.skipped.length>0&&m("links-skipped",`${We}: ${xt.skipped.length} links in the tarball were left out.`,We),l.downloaded++,l.tarballBytes+=zt.length,qt}const de=[..._.keys()],Ee=new Map;let lt=0,Et=!1;const _t=async()=>{var We;for(;lt<de.length&&!Et;){const Fe=de[lt++],zt=_.get(Fe);if(zt!==void 0)try{const ft=await fzt(t.store,Fe),xt=ft!==void 0&&ft.integrity===zt.integrity;xt&&(he(Fe,ft.bytes),l.reused++),Ee.set(Fe,xt?ft:await te(Fe,zt)),(We=t.onProgress)==null||We.call(t,{type:"stored",package:Fe,reused:xt,done:Ee.size,total:de.length})}catch(ft){throw Et=!0,ft}}};await Promise.all(Array.from({length:Math.min(a0r,de.length)},_t));const At=new Set(Object.entries(M).map(([We,Fe])=>B7(We,Fe)));for(const We of de){const Fe=Ee.get(We);Fe!==void 0&&(Fe.installScripts.length>0&&m("install-script",`${We} declares ${Fe.installScripts.join(", ")} scripts; they are not run here.`,We),Fe.native&&m("native",`${We} ships native code, which a scene cannot load.`,We),Fe.nodeBuiltins.length>0&&At.has(We)&&m("node-builtins",`${We} uses Node built-ins a scene does not have: ${Fe.nodeBuiltins.join(", ")}.`,We))}const vt=(We,Fe)=>{const[zt,ft]=[Eq(We),Eq(Fe)];if(zt===void 0||ft===void 0||zt.name!==ft.name)return tWe(We,Fe);const[xt,ht]=[dG(zt.version),dG(ft.version)];return xt===void 0||ht===void 0?0:pXe(xt,ht)},Ve={};for(const We of[...de].sort(vt)){const Fe=_.get(We);if(Fe===void 0)continue;const zt=Object.fromEntries(uve(Fe.dependencies??{}));Ve[We]={resolved:Fe.resolved,integrity:Fe.integrity,...Object.keys(zt).length>0?{dependencies:zt}:{}}}return l.packages=de.length,l.requests=n.requests(),{lock:{lockfileVersion:1,registry:n.url,dependencies:Object.fromEntries(uve(M)),packages:Ve},warnings:d,stats:l}}var aAt={};function sAt(t){return Array.isArray(t)?t:[t]}const nWe="",oAt=" ",BBe="\\",o0r=/^\s+$/,c0r=/(?:[^\\]|^)\\$/,l0r=/^\\!/,u0r=/^\\#/,f0r=/\r?\n/g,d0r=/^\.*\/|^\.+$/,$Be="/";let Szt="node-ignore";typeof Symbol<"u"&&(Szt=Symbol.for("node-ignore"));const cAt=Szt,p0r=(t,n,r)=>Object.defineProperty(t,n,{value:r}),m0r=/([0-z])-([0-z])/g,Tzt=()=>!1,h0r=t=>t.replace(m0r,(n,r,a)=>r.charCodeAt(0)<=a.charCodeAt(0)?n:nWe),_0r=t=>{const{length:n}=t;return t.slice(0,n-n%2)},g0r=[[/^\uFEFF/,()=>nWe],[/((?:\\\\)*?)(\\?\s+)$/,(t,n,r)=>n+(r.indexOf("\\")===0?oAt:nWe)],[/(\\+?)\s/g,(t,n)=>{const{length:r}=n;return n.slice(0,r-r%2)+oAt}],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,n,r)=>n+6<r.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(t,n,r)=>{const a=r.replace(/\\\*/g,"[^\\/]*");return n+a}],[/\\\\\\(?=[$.|*+(){^])/g,()=>BBe],[/\\\\/g,()=>BBe],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,n,r,a,s)=>n===BBe?`\\[${r}${_0r(a)}${s}`:s==="]"&&a.length%2===0?`[${h0r(r)}${a}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,n)=>`${n?`${n}[^/]+`:"[^/]*"}(?=$|\\/$)`]],lAt=Object.create(null),y0r=(t,n)=>{let r=lAt[t];return r||(r=g0r.reduce((a,[s,l])=>a.replace(s,l.bind(t)),t),lAt[t]=r),n?new RegExp(r,"i"):new RegExp(r)},hXe=t=>typeof t=="string",v0r=t=>t&&hXe(t)&&!o0r.test(t)&&!c0r.test(t)&&t.indexOf("#")!==0,b0r=t=>t.split(f0r);class x0r{constructor(n,r,a,s){this.origin=n,this.pattern=r,this.negative=a,this.regex=s}}const w0r=(t,n)=>{const r=t;let a=!1;t.indexOf("!")===0&&(a=!0,t=t.substr(1)),t=t.replace(l0r,"!").replace(u0r,"#");const s=y0r(t,n);return new x0r(r,t,a,s)},S0r=(t,n)=>{throw new n(t)},tR=(t,n,r)=>hXe(t)?t?tR.isNotRelative(t)?r(`path should be a \`path.relative()\`d string, but got "${n}"`,RangeError):!0:r("path must not be empty",TypeError):r(`path must be a string, but got \`${n}\``,TypeError),kzt=t=>d0r.test(t);tR.isNotRelative=kzt;tR.convert=t=>t;class T0r{constructor({ignorecase:n=!0,ignoreCase:r=n,allowRelativePaths:a=!1}={}){p0r(this,cAt,!0),this._rules=[],this._ignoreCase=r,this._allowRelativePaths=a,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(n){if(n&&n[cAt]){this._rules=this._rules.concat(n._rules),this._added=!0;return}if(v0r(n)){const r=w0r(n,this._ignoreCase);this._added=!0,this._rules.push(r)}}add(n){return this._added=!1,sAt(hXe(n)?b0r(n):n).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(n){return this.add(n)}_testOne(n,r){let a=!1,s=!1;return this._rules.forEach(l=>{const{negative:d}=l;if(s===d&&a!==s||d&&!a&&!s&&!r)return;l.regex.test(n)&&(a=!d,s=d)}),{ignored:a,unignored:s}}_test(n,r,a,s){const l=n&&tR.convert(n);return tR(l,n,this._allowRelativePaths?Tzt:S0r),this._t(l,r,a,s)}_t(n,r,a,s){if(n in r)return r[n];if(s||(s=n.split($Be)),s.pop(),!s.length)return r[n]=this._testOne(n,a);const l=this._t(s.join($Be)+$Be,r,a,s);return r[n]=l.ignored?l:this._testOne(n,a)}ignores(n){return this._test(n,this._ignoreCache,!1).ignored}createFilter(){return n=>!this.ignores(n)}filter(n){return sAt(n).filter(this.createFilter())}test(n){return this._test(n,this._testCache,!0)}}const wxe=t=>new T0r(t),k0r=t=>tR(t&&tR.convert(t),t,Tzt);wxe.isPathValid=k0r;wxe.default=wxe;var E0r=wxe;if(typeof process<"u"&&(aAt&&aAt.IGNORE_TEST_WIN32||process.platform==="win32")){const t=r=>/^\\\\\?\\/.test(r)||/["<>|\u0000-\u001F]+/u.test(r)?r:r.replace(/\\/g,"/");tR.convert=t;const n=/^[a-z]:\//i;tR.isNotRelative=r=>n.test(r)||kzt(r)}const C0r=Axe(E0r),A0r=[".*","package.json","package-lock.json","yarn-lock.json","build.json","export","tsconfig.json","tslint.json","node_modules","dclcontext","**/*.ts","**/*.tsx","Dockerfile","thumbnails","dist","README.md","*.blend","*.fbx","*.zip","*.rar","*.map","node_modules/**","*.md"];function _Xe(t,n){const r=C0r().add([...(n==null?void 0:n.split(`
|
|
32455
|
-
`))??[],...A0r].filter(Boolean)),a=[...t].filter(s=>!s.split("/").some(l=>l.startsWith(".")));return r.filter(a)}function O0r(t){const n=t.scene;if(!y_(n))throw new Error('scene.json has no "scene" section');const{base:r,parcels:a}=n;if(typeof r!="string"||!Array.isArray(a))throw new Error("scene.json needs scene.base and scene.parcels");return[...new Set([r,...a.filter(s=>typeof s=="string")])]}function P0r(t){const n=new Set,r=t.files.map(({path:a,version:s})=>{const l=a.toLowerCase();if(n.has(l))throw new Error(`Two files deploy as "${l}"; scene file names are case-insensitive`);return n.add(l),{file:l,hash:Fvr(t.projectId,a,s,t.machineId)}});return{version:"v3",type:"scene",id:wzt(t.projectId,t.machineId),pointers:O0r(t.sceneJson),timestamp:t.timestamp,content:r,metadata:t.sdkVersion===void 0?t.sceneJson:{sdkVersion:t.sdkVersion,...t.sceneJson}}}const Sxe="dcl-editor-preview-v1",I0r="dcl-editor-storage-v1";function rWe(t,n){if(!mXe.test(n))throw new Error(`Invalid preview project id "${n}"`);return new URL(`preview/${n}/`,t).href}const iWe=t=>t+"__manifest",uAt=(t,n)=>`${t}content/contents/${n}`;async function N0r(t){const n=new URL(t.realmUrl).href;if(n!==rWe(new URL("../../",n),t.projectId))throw new Error(`"${t.realmUrl}" is not the preview realm of project "${t.projectId}"`);const r=new Map([...t.files,...t.buildOutputs]),a=r.get(".dclignore"),s=_Xe(r.keys(),a===void 0?void 0:new TextDecoder().decode(a)),l=await Promise.all(s.map(async B=>{const H=r.get(B)??new Uint8Array;return{path:B,bytes:H,version:await jvr(H)}})),d=await caches.open(Sxe),m=await d.match(iWe(n)),_=await(m==null?void 0:m.json().catch(()=>{})),x=y_(_)&&typeof _.version=="number"?_.version:0,T=P0r({projectId:t.projectId,sceneJson:t.sceneJson,files:l,timestamp:Date.now(),sdkVersion:t.sdkVersion,machineId:t.machineId}),A=new Set;await Promise.all(T.content.map(async({hash:B},H)=>{const ee=uAt(n,B);A.add(new URL(ee).href),await d.match(ee)===void 0&&await d.put(ee,new Response(oTe(l[H].bytes),{headers:{"Content-Type":"application/octet-stream"}}))}));const M={version:x+1,entity:T};await d.put(iWe(n),new Response(JSON.stringify(M),{headers:{"Content-Type":"application/json"}}));const F=uAt(n,"");for(const B of await d.keys())B.url.startsWith(F)&&!A.has(B.url)&&await d.delete(B);return{realmUrl:n,entityId:T.id}}const D0r="0.1.0",R0r=new TextEncoder,M0r=new TextDecoder("utf-8",{fatal:!0});function L0r(t,n){return t===void 0?n===null:n!==null&&t.length===n.length&&t.every((r,a)=>r===n[a])}function F0r(t){try{return JSON.parse(t)}catch{throw new Error("Invalid scene request.")}}function fAt(t){if(typeof t!="object"||t===null)return null;const{x:n,y:r,z:a}=t;return[n,r,a].every(s=>typeof s=="number"&&Number.isFinite(s))?{x:n,y:r,z:a}:null}function j0r(t){const n=new Map;return async(r,a)=>{var F;a.throwIfAborted();const{tool:s,args:l}=r;if(s==="playtest"){if(t.playtest===void 0)throw new Error("Playtesting requires an updated editor.");return JSON.stringify(await t.playtest(l,a))}if(s==="asset_request"){if(t.assets===void 0)throw new Error("Asset tools require an updated editor.");return JSON.stringify(await t.assets(l,a))}if(s==="list_files"){const B=typeof l.kind=="string"&&WIt.includes(l.kind)?l.kind:null,H=typeof l.match=="string"?l.match.toLowerCase():"";return JSON.stringify([...t.files().keys()].filter(ee=>{const Z=qIt(ee);return Z===null||Z==="code"&&!wbe(ee)?!1:(B===null||Z===B)&&ee.toLowerCase().includes(H)}).sort().slice(0,2e3))}if(s==="build")return JSON.stringify(await t.build(a));if(s==="view")return JSON.stringify(await t.view({entity:typeof l.entity=="string"&&l.entity.trim()!==""?l.entity:null,from:fAt(l.from),lookAt:fAt(l.lookAt)},a));if(s==="scene_request")return JSON.stringify(await t.scene(typeof l.request=="string"?F0r(l.request):l.request,a));const d=l.path;if(typeof d!="string"||!wbe(d))throw new Error("This path is not an assistant-readable project file.");const m=t.files().get(d);if(s==="read_file"){if(m===void 0)return JSON.stringify({path:d,content:null,revision:null});if(m.byteLength>hxt)throw new Error("This file is too large for the assistant.");const B=M0r.decode(m),H=crypto.randomUUID();return n.set(d,{revision:H,bytes:m.slice()}),JSON.stringify({path:d,content:B,revision:H})}if(s!=="write_file"||!JOn(d))throw new Error("The assistant can write source files; scene data is changed through editor actions.");if(typeof l.content!="string")throw new Error("Missing file content.");const _=R0r.encode(l.content);if(_.byteLength>hxt)throw new Error("This file is too large for the assistant.");const x=n.get(d),T=l.revision===null?null:x==null?void 0:x.bytes;if(T===void 0||l.revision!==null&&l.revision!==(x==null?void 0:x.revision))throw new Error("Read this file before changing it.");await t.write(d,_,T,a),a.throwIfAborted();const A=crypto.randomUUID();n.set(d,{revision:A,bytes:_});const M=await((F=t.written)==null?void 0:F.call(t,d,l.content,T===null))??null;return JSON.stringify({path:d,revision:A,created:T===null,...M===null?{}:{attached:M}})}}function B0r(t){const n=new Set;let r=null,a=null,s=0,l=null,d=Promise.resolve(),m=null;const _=te=>{for(const de of n)de(te)},x=te=>[{id:"claude",label:"Claude",available:!1,models:[],defaultModel:"",transport:"service",reason:te}],T=te=>{(r==null?void 0:r.readyState)===WebSocket.OPEN&&r.send(JSON.stringify(te))};function A(te,de){const Ee=l;Ee!==null&&(l=null,Ee.controller.abort(),de!==void 0&&_({kind:"error",turnId:Ee.id,message:de}),_({kind:"done",turnId:Ee.id,ok:te}))}function M(te){const de=Xl(te.args.request)?te.args.request:{};switch(te.tool){case"write_file":return null;case"read_file":return{tool:"Read",detail:typeof te.args.path=="string"?te.args.path:""};case"asset_request":return{tool:"Assets",detail:String(te.args.action??"")};case"build":return{tool:"Build",detail:"Scene"};case"playtest":return{tool:"Playtest",detail:String(te.args.action??"")};case"scene_request":if(de.type==="batch"&&Array.isArray(de.requests))return{tool:"Scene",detail:`${de.requests.length} changes`};if(de.type==="sceneSettings")return{tool:"Scene",detail:"Settings"};if(de.type==="attachScript")return null}return{tool:"Inspect",detail:"Project"}}function F(te,de,Ee,lt){const Et=de.label===void 0?{}:{label:de.label},_t=M(de);if(_t!==null){lt||_({kind:"tool",turnId:te,..._t,...Et});return}if(de.tool==="write_file"){const vt=typeof de.args.path=="string"?de.args.path:"";_({kind:"tool",turnId:te,tool:de.args.revision===null?"Write":"Edit",detail:vt,...Et});const Ve=JSON.parse(Ee);Xl(Ve)&&Xl(Ve.attached)&&typeof Ve.attached.name=="string"&&_({kind:"tool",turnId:te,tool:"Attached",detail:`${vt.split("/").pop()??vt} to ${Ve.attached.name}`,...Et});return}const At=JSON.parse(Ee);if(Xl(At)&&Array.isArray(At.attached))for(const vt of At.attached)typeof vt=="string"&&_({kind:"tool",turnId:te,tool:"AttachScript",detail:vt,...Et})}async function B(te){const de=l;if(de===null||de.id!==te.turnId||de.controller.signal.aborted)return;let Ee=!1,lt="",Et=!1;try{if(t.wallet()!==de.wallet||t.project().id!==de.projectId)throw new Error("The open project or account changed.");if(te.label!==void 0){const _t=M(te);_t!==null&&(_({kind:"tool",turnId:de.id,..._t,label:te.label}),Et=!0)}if(lt=await de.execute(te,de.controller.signal),lt.length>5e5)throw new Error("The tool result is too large. Ask for a smaller part of the project.");de.controller.signal.throwIfAborted(),Ee=!0,F(de.id,te,lt,Et)}catch(_t){lt=_t instanceof Error?_t.message:typeof _t=="string"&&_t!==""?_t:"The browser tool failed."}l===de&&!de.controller.signal.aborted&&T({kind:"result",turnId:de.id,callId:te.callId,ok:Ee,text:lt})}function H(te){let de;try{de=JSON.parse(te)}catch{A(!1,"Invalid assistant response.");return}if(!Xl(de))return;if(de.kind==="failure"&&typeof de.message=="string"){A(!1,de.message);return}if(de.kind==="call"&&typeof de.turnId=="string"&&typeof de.callId=="string"&&VOn.test(de.callId)&&["list_files","read_file","write_file","scene_request","asset_request","build","view","playtest"].includes(String(de.tool))&&Xl(de.args)){const{label:lt,...Et}=de,_t=typeof lt=="string"?{...Et,label:lt}:Et;if(l===null||l.id!==_t.turnId||l.calls.has(_t.callId))return;l.calls.add(_t.callId);const At=GOn(_t.tool,_t.args),vt=(At?Promise.resolve():d).then(()=>B(_t)).catch(Ve=>{console.error("[assistant] browser tool failed",_t.tool,Ve),(l==null?void 0:l.id)===_t.turnId&&A(!1,"The browser tool failed.")});At||(d=vt);return}if(de.kind!=="event"||!Xl(de.event))return;const Ee=de.event;if(!(l===null||Ee.turnId!==l.id)){if(Ee.kind==="text"&&typeof Ee.text=="string"&&_({kind:"text",turnId:l.id,text:Ee.text}),Ee.kind==="error"&&typeof Ee.message=="string"){const lt=Ee.resumable===!0;lt&&(m=r),_({kind:"error",turnId:l.id,message:Ee.message,...lt?{resumable:lt}:{}})}Ee.kind==="done"&&typeof Ee.ok=="boolean"&&A(Ee.ok)}}async function ee(){if((r==null?void 0:r.readyState)===WebSocket.OPEN)return r;if(a!==null)return a;const te=s,de=(async()=>{if(t.service===null)throw new Error("The assistant service is not configured.");const Ee=await t.fetch(`${t.service}/assistant/connect`,{method:"POST"});if(!Ee.ok)throw new Error("The assistant service is unavailable. Sign in and recheck.");const lt=await Ee.json();if(!Xl(lt)||typeof lt.token!="string")throw new Error("Invalid assistant connection.");if(te!==s)throw new Error("Connection cancelled.");const Et=new URL(`${t.service}/assistant/socket`,location.href);Et.protocol=Et.protocol==="https:"?"wss:":"ws:";const _t=new WebSocket(Et,[WOn,qOn+lt.token]);return r=_t,new Promise((At,vt)=>{let Ve=!1;const Qt=setTimeout(()=>{_t.close(),vt(new Error("Assistant connection timed out."))},1e4);_t.onmessage=({data:We})=>{if(r===_t&&typeof We=="string")if(Ve)H(We);else{let Fe;try{Fe=JSON.parse(We)}catch{_t.close();return}if(!Xl(Fe)||Fe.kind!=="ready")return;Ve=!0,clearTimeout(Qt),At(_t)}},_t.onerror=()=>{_t.close(),vt(new Error("Could not connect to the assistant service."))},_t.onclose=()=>{clearTimeout(Qt),r===_t&&(r=null,A(!1,"Assistant connection closed. Your edits are saved; the next message starts a new conversation.")),vt(new Error("Assistant connection closed."))}})})();a=de;try{return await de}finally{a===de&&(a=null)}}function Z(){try{return t.project().id}catch{return null}}async function K(te,de){try{const Ee=await t.memory.read(te,de);if(Ee!==null)return Ee;const lt={id:$0r(crypto.getRandomValues(new Uint8Array(16))),key:U0r(crypto.getRandomValues(new Uint8Array(32)))};return await t.memory.write(te,de,lt),lt}catch{return}}function _e(){s++,T({kind:"reset"}),A(!1);const te=r;return r=null,a=null,te==null||te.close(),d}return{shell:{async aiProviders(){if(t.wallet()===null)return x("Sign in to Decentraland to use the assistant.");if(t.service===null)return x("The assistant service is not configured.");try{const te=await t.fetch(`${t.service}/assistant/providers`);if(!te.ok)return x("The assistant service is unavailable. Recheck when it is running.");const de=await te.json();return Array.isArray(de)?de.filter(Ee=>Xl(Ee)&&(Ee.id==="claude"||Ee.id==="codex")&&typeof Ee.label=="string"&&typeof Ee.available=="boolean"&&typeof Ee.defaultModel=="string"&&Array.isArray(Ee.models)&&Ee.models.every(lt=>typeof lt=="string")).map(Ee=>({...Ee,transport:"service"})):x("The assistant service returned an invalid provider list.")}catch{return x("Could not reach the assistant service. Recheck your connection.")}},async aiSend(te){if(l!==null)throw new Error("A turn is already running.");const de=t.wallet();if(de===null)throw new Error("Sign in to use the assistant.");m=null;const Ee=t.project(),lt={id:crypto.randomUUID(),wallet:de,projectId:Ee.id,controller:new AbortController,calls:new Set,execute:j0r(Ee.tools)};l=lt,_({kind:"started",turnId:lt.id});try{if(await ee(),lt.controller.signal.throwIfAborted(),t.wallet()!==de||t.project().id!==Ee.id)throw new Error("The open project or account changed.");const Et=await K(Ee.id,de);lt.controller.signal.throwIfAborted(),T({kind:"prompt",turnId:lt.id,projectId:Ee.id,params:te,memory:Et})}catch(Et){l===lt&&A(!1,Et instanceof Error?Et.message:"Could not start the assistant.")}return{turnId:lt.id}},async aiStop(){l!==null&&T({kind:"stop",turnId:l.id}),await _e()},async aiReset(){await _e()},async aiForget(){const te=t.wallet(),de=(l==null?void 0:l.projectId)??Z();l!==null&&T({kind:"stop",turnId:l.id}),A(!1);const Ee=te===null||de===null?null:await t.memory.read(de,te).catch(()=>null);Ee!==null&&te!==null&&de!==null&&(T({kind:"forget",id:Ee.id}),await t.memory.write(de,te,null).catch(()=>{})),await _e()},aiCanResume:()=>m!==null&&m===r&&r.readyState===WebSocket.OPEN,onAiEvent(te){return n.add(te),()=>{n.delete(te)}}},reset:_e,dispose(){_e(),n.clear()}}}function $0r(t){return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}function U0r(t){return btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function z0r(){const t=tt.activeEntity;return async(n,r,a)=>{if(oGe(n)!==n)return null;try{return a?t===null||NS(t)||tt.snapshot[t]===void 0||nR(tt.snapshot,t)||!await zYe(t,n,r)?null:{id:t,name:Zf(tt.snapshot,t)??`#${t}`}:(await lur(n,r),null)}catch(s){return console.error("could not attach the new script:",n,s),null}}}const Ezt=["stone-blocks","red-brick","old-brick","cobblestone","rock","mossy-rock","planks","wood","bark","roof-tiles","concrete","marble","floor-tiles","metal","rusty-metal","metal-plate","grass","sand","gravel","snow","ice"],V0r=["color","normal"],W0r=t=>t.split(/[^A-Za-z0-9]+/).filter(Boolean).map(n=>n[0].toUpperCase()+n.slice(1)).join(""),Czt=(t,n)=>`materials/T_${W0r(t)}_${n==="color"?"D":"N"}.jpg`;function q0r(t){return typeof t=="string"&&Ezt.includes(t)}const G0r=20*1024*1024;function J0r(t){const{glb:n,clips:r,library:a,warnings:s}=t;if(!(n instanceof ArrayBuffer)||n.byteLength===0||n.byteLength>G0r)throw new Error("The model is missing or over 20 MB.");if(!Array.isArray(a)||a.length>Ezt.length)throw new Error("The model names too many shared materials.");const l=[...new Set(a)].map(_=>{if(!q0r(_))throw new Error("The model names an unknown shared material.");return _}),d=Array.isArray(r)?r.filter(_=>typeof _=="string").slice(0,32).map(_=>_.slice(0,64)):[],m=Array.isArray(s)?s.filter(_=>typeof _=="string").slice(0,8).map(_=>_.slice(0,300)):[];return{bytes:new Uint8Array(n),clips:d,library:l,warnings:m}}const C0e={triangles:8e3,materials:6,textures:4,largestTexture:512},dAt=2e4;function H0r(t,n=[]){return[...Object.keys(C0e).filter(r=>t[r]>C0e[r]).map(r=>`${r} ${t[r]} > ${C0e[r]}`),...n.map(r=>`${r}; use 64/128/256/512`)]}async function Q0r(t,n,r){r.throwIfAborted();const a=v$t("build"),s=await new Promise((m,_)=>{const x=()=>{_(new Error("Stopped.")),a.then(T=>T.terminate(),()=>{})};r.addEventListener("abort",x,{once:!0}),a.then(m,_).finally(()=>r.removeEventListener("abort",x))});let l,d=()=>{};try{const m=await new Promise((_,x)=>{l=setTimeout(()=>x(new Error(`The model script stopped answering after ${dAt/1e3} s: it loops forever or ran out of memory. Make it simpler.`)),dAt),d=()=>x(new Error("Stopped.")),r.addEventListener("abort",d,{once:!0}),r.aborted&&d(),s.onmessage=T=>_(T.data),s.postMessage({kind:"build",code:t,name:n})});if(m.kind!=="built")throw new Error(`The model script failed: ${m.kind==="failed"?String(m.error).slice(0,2e3):"no model"}`);return J0r(m)}finally{clearTimeout(l),r.removeEventListener("abort",d),s.terminate()}}const Y0r={description:"bright rising blip: coin or collectible picked up",durationSeconds:.39,loop:!1},X0r={description:"glassy chime: gem, crystal or rare item picked up",durationSeconds:.26,loop:!1},Z0r={description:"short confirm blip: point scored, checkpoint, correct",durationSeconds:.31,loop:!1},K0r={description:"three rising tones: go, round start",durationSeconds:.6,loop:!1},ebr={description:"rising 8-bit fanfare: win, level complete",durationSeconds:.81,loop:!1},tbr={description:"falling 8-bit jingle: lose, game over",durationSeconds:.81,loop:!1},nbr={description:"soft click: button press",durationSeconds:.05,loop:!1},rbr={description:"short rise: panel or menu opens",durationSeconds:.18,loop:!1},ibr={description:"short fall: panel or menu closes",durationSeconds:.18,loop:!1},abr={description:"low buzz: wrong, denied, locked",durationSeconds:.24,loop:!1},sbr={description:"springy rising zip: jump, bounce pad",durationSeconds:.39,loop:!1},obr={description:"soft heavy thud: landing, something dropped",durationSeconds:.55,loop:!1},cbr={description:"punch impact: hit, damage taken",durationSeconds:.26,loop:!1},lbr={description:"wet squelch: slime, goo, closest to a splash",durationSeconds:.52,loop:!1},ubr={description:"rising phaser sweep: teleport, portal, respawn",durationSeconds:.42,loop:!1},fbr={description:"metal latch clack: lever, switch, lock",durationSeconds:.21,loop:!1},dbr={description:"deep boom: explosion, cannon, big impact",durationSeconds:2.04,loop:!1},pbr={coin:Y0r,gem:X0r,"power-up":{description:"rising synth sweep: power-up or boost",durationSeconds:.89,loop:!1},point:Z0r,"countdown-tick":{description:"single beep: each second of a countdown",durationSeconds:.13,loop:!1},start:K0r,win:ebr,lose:tbr,"time-up":{description:"falling buzz: time up, round over",durationSeconds:1.28,loop:!1},click:nbr,open:rbr,close:ibr,error:abr,jump:sbr,land:obr,hit:cbr,splat:lbr,teleport:ubr,"door-open":{description:"wooden door creaking open",durationSeconds:.91,loop:!1},"door-close":{description:"wooden door shutting",durationSeconds:.65,loop:!1},lever:fbr,explosion:dbr,"fire-loop":{description:"roaring flame: fire, lava, furnace, jet",durationSeconds:4.78,loop:!0},"rumble-loop":{description:"low engine rumble: machinery, cave, earthquake",durationSeconds:4.78,loop:!0},"machine-loop":{description:"busy electronic chatter: computer room, lab, generator, machine",durationSeconds:4.55,loop:!0}},Azt=["coin","gem","power-up","point","countdown-tick","start","win","lose","time-up","click","open","close","error","jump","land","hit","splat","teleport","door-open","door-close","lever","explosion","fire-loop","rumble-loop","machine-loop"],mbr=t=>`sounds/${t}.mp3`,hbr=t=>`assets/audio/library/${t}.mp3`,_br=t=>pbr[t];function gbr(t){return typeof t=="string"&&Azt.includes(t)}function pB(t){const n={"web-build/worker.js":"sha384-iQPkltF76057GZFlcTeV7A6xfFcgEvuL3iarlW5DXKsXV7+xBoddZsKsPtuwDBU0","web-build/esbuild.wasm":"sha384-V8Ml7eHSlgGTb/TR1IYB6LtWwAW1NXLDPRjL2FjxwIfqDkSZ/hp+zmfvXDHqu8NV","web-build/sdk-snapshot.json":"sha384-cEzJvvCGlmHpD/zVbHX2vzG5qWftYtZjN4jN2tic6qusNfMDx6/GUXhdgU13Ct+A","three/worker.js":"sha384-fpaxQE7sJmPgdwwsCLEkPRmp3A++vppj0bqkpV7a8egKEfBEEP4o/pD2eYfsXZTp","prefabs/catalog.json":"sha384-ZI9912I5wPBiOnsPxkaYKS+jUHzka6SDVH04Zb1Wvwn/AybJWtfSKBUqEKSuzv1L","materials/T_Bark_D.jpg":"sha384-FtUe6G243wHZ8C0kbR+2lFVHp/atYXEPodY4A1qDQquYeu27euNDRDqEyFoQJ29L","materials/T_Bark_N.jpg":"sha384-EhhyT3HTQ3sy1CVvKMTX+ueIGq2+FgDntZ6lKFZW6sHOrCTCMbxnDhthwQIanVOr","materials/T_Cobblestone_D.jpg":"sha384-lSuwYcPhIyqVZvG0NuB93ESZIEqL0ffEmD7gh6iG3qN4elINxt7KQS8CN4Ay2CQ0","materials/T_Cobblestone_N.jpg":"sha384-A+Xe7cTTQGB4hwE6WPsWgD76xwIZ2/FFlxqeWZnyFk5AWaK6hDEKCEZVeVinJ3uw","materials/T_Concrete_D.jpg":"sha384-1dPzQGKxZAw2NloRUM+KhE0X9XeTLUxBrvkw4Uaa4Gm/ID65iDv+yPWUHYi59gYn","materials/T_Concrete_N.jpg":"sha384-8+TiM45B8TCGHYOHh5/510IpXfo1WgyaS5q/T1B3GOEdQrXHV+x9yXmyjkN9mWsh","materials/T_FloorTiles_D.jpg":"sha384-PwDH1P94cY4VXHyrbTQSpvDh89A5jMf+xG62xUDT9TRbItuR6uI1lXB9onxu4gaX","materials/T_FloorTiles_N.jpg":"sha384-opjmq0wL8b+pxHcujr8IGFCOQt8+pDX7EjcnmzmcKGy7F8H3dv9IgG7gxQXgkQJu","materials/T_Grass_D.jpg":"sha384-GGodYBboPnhEcv7JVlR1mSjLWux7q4qJcOxqdl7a/6bN6IWkel4A1BeHV4sieS25","materials/T_Grass_N.jpg":"sha384-zu3ig6Su3u2I3e3LX2zeaS9LtqJYl8V3siVjWBQ2Xea6iMAcMCXHp2HQyctvaEY2","materials/T_Gravel_D.jpg":"sha384-Y2EZTiFeTQbZlduNmz1Y74fZIvkmh8c2grqr6B1GqejChZbNnRb5ejC8SCqyPY77","materials/T_Gravel_N.jpg":"sha384-VWUAPWQZqvuFDmiZZvhAgqQ24DmSrByuu7ETrD2igGikpZS+U7E81hAJ3Iiv88iT","materials/T_Ice_D.jpg":"sha384-qNSYRVYvzZ6NP5Ny/MDMNajmplmSXf9036CidUKqte1DUUDzMm28FZvWcAMSnyux","materials/T_Ice_N.jpg":"sha384-LYz8XTf6DXyxCy6Jtci0y6E0/ER4b73sdH6lhCbagK8nuYPpD8ChpB8PZUTLMLkF","materials/T_Marble_D.jpg":"sha384-MfvwmuTcZs+OB9BLKNAFU849wj27KcdPxxvF3WAY9OrZGtQORoHXjDWh2YWBukWk","materials/T_Marble_N.jpg":"sha384-SU6JhDtveHoi5d1AUiQV8oVfO1uEChNA7ACvMv1OIKESECfG1lCMw6MG7TZrGhnf","materials/T_MetalPlate_D.jpg":"sha384-Qe4yIHUfUVMwOEDZTsY0u7d19xhUE/GiSyz0s3P9297mx+XXGvDCR8gKdU9hLhbo","materials/T_MetalPlate_N.jpg":"sha384-RpCdFzgg7xIUz1G+nDJEon1H0MHwsk4RHOTfi2Er2hC56AXU2TXcToTY12aqz+4R","materials/T_Metal_D.jpg":"sha384-h2Fs2s1/WPYJwUY3a6vpMqrd0rb7GDWViOvw8SlsSocO/sBqcqzzbjOwYR9uooVE","materials/T_Metal_N.jpg":"sha384-iVL98sXzJCK2z/YuoBw0pwbZyes0ZprTHsvQdFQ6tXhKP5004tHMWJnr5icUVwKp","materials/T_MossyRock_D.jpg":"sha384-5sB1xTHnLgeGIiY5kqc5kr78xBvR17BBrWJZD1IyyEuFO8mcgJ7DaAKH9ZcrV0Oj","materials/T_MossyRock_N.jpg":"sha384-z+02Z5HZoLwVk/i0R/YRm/MW/KQr3Y5h4cB0iH837QsKMrvzrO6iFMuBWXER8ZLk","materials/T_OldBrick_D.jpg":"sha384-1h+VtTgiyyfZ9N5h15snvPP5bjvvI5Mzq958DaMi0BTJKxFbtKoYjnWp9mkhDBTZ","materials/T_OldBrick_N.jpg":"sha384-mORhqcYtb2adL11dYPIpTKvrTVqiz1mqHVW/abZaSerjsKMEvRa5uxoe65nfUmzF","materials/T_Planks_D.jpg":"sha384-olCbQDlaUR5rNCiEPsJt3Z6XYD2L1McfZNZOBdCDsIo4dyKa9Y41H3mCbdY1BMqL","materials/T_Planks_N.jpg":"sha384-Qe2LOHGe2f/b8RdZmZRSrZl0KMgxMT28Q0yj/Ewr0TRsmSe4L1N9TxQscZ7jXIpz","materials/T_RedBrick_D.jpg":"sha384-z5Omhin/SbXfu6KqUuKYyVFQN5GIkfCtva/SIM3g8C09Dy/ajUgaCrQYUQv0Wi6s","materials/T_RedBrick_N.jpg":"sha384-N5Zlk1HLC7ECYSYp9JAlKc9UZk3lFIytrdyYTNCyrRAD6IMQMGM178Ns5ICXoBcY","materials/T_Rock_D.jpg":"sha384-JPbUh7M8Yt82J9u9P3cMPWNBNNDN2MOkMhb4BpWOQ1MUacVygOKoKHOAspiyAaDI","materials/T_Rock_N.jpg":"sha384-d2AXOT8FPWfSBdhZGN2U85WRbKq02qgDIFhEcp9/ZrTfzPPpb3x+1tM3pRfflGWG","materials/T_RoofTiles_D.jpg":"sha384-XyFas+mKIHi1ZJxhOpjcJ3aE7SZjOUukcY1wZqJ0kcwMjYE2SD5mv/Ft1babZiRk","materials/T_RoofTiles_N.jpg":"sha384-OtknIACV+BRu+g5+hVLWILG4Qli4fIDdqqrf3rFTuGr/VxhZIGgxC61tMM7Tr5pt","materials/T_RustyMetal_D.jpg":"sha384-vN18ZCLm3ijlv9l30lI/rUbcUpcJH0ut4hF8GueDNYPZO4WDiqxJH9EX70DGsEsh","materials/T_RustyMetal_N.jpg":"sha384-+rdn3/f1t/jU65sT0kq03mG9HtAIA3a1+bezGQmXOV9FiCM2KUCIugsOUhQAzmjO","materials/T_Sand_D.jpg":"sha384-i3zMj/gXeIpnlll08lxRRvQ9BA+j/3bLnzru+M3LzjvyhwMKgz6bmnLjhe1rPZrz","materials/T_Sand_N.jpg":"sha384-eBZtZpK8wZnUmtNfV5iCt/l4WWvoppG0bFkFeULvqw5gNkT+emO5u8AVtpRTFjxM","materials/T_Snow_D.jpg":"sha384-kOAg+1SQpFtFg/XpbSTT+Boo6hGe/+BXR3fI2pgrTyl0VJTrc2W1pUKlT38nSP6k","materials/T_Snow_N.jpg":"sha384-8ryXPS0Yprm5vNZCUadJRhKh4MQ+8gkD0q1GbjlPLez7GSjsV7QmAyM63PiIn0cK","materials/T_StoneBlocks_D.jpg":"sha384-o2TlIP/+m+uvEmypAk3zXE+9huFaU3K+VTD18p8vPEb9I3SVB1n2ez1jqZTXZNQF","materials/T_StoneBlocks_N.jpg":"sha384-eR/UR9FC3v3Pw4oBlWlOyQNmtgvb5a1mSRwSBMrQhDyXk4neOjmVlTyjBjhOTYOU","materials/T_Wood_D.jpg":"sha384-Tk9jMT15vysCDRdd22J2mFUHCBSHVMhGNa71sYFf7yqvZQkmMGdrIhiIsmi/fAm2","materials/T_Wood_N.jpg":"sha384-b1SWrWCwyf+89JAlVNPCwmwkUTrcGXUqRANI3x+grecaCQblZGLsSaJx/5CNPnPC","sounds/click.mp3":"sha384-5Nn2A2LWwXVAhOJKiwTncPtBTCtmrqOVQVAuz+xHRrAuMnScsTQ06gM0dU14yxa1","sounds/close.mp3":"sha384-JBoxn91EXhKXI4EJZ1nlDO3U735Nz6Nn1UuzpPhRjjpMaEOafABEqQL8GgfV7XTi","sounds/coin.mp3":"sha384-2RR7dy+f4rzUKdiGeSdApfQmbsENC4FzT8o4y3JXs5IX6a2udQbwU3iLhCUZ+z1a","sounds/countdown-tick.mp3":"sha384-I1gWiwXYWkrQ3dmkVDqolRCU+O/OkVqH625gdQZ8i3mntGSNBKJN1u2yPzmiPOio","sounds/door-close.mp3":"sha384-V/WOG/jNZMVo2EK2wosamkz0F/OjilfprwqVR0JwxFuLjzaIGOG6LFUxp1RB2NF6","sounds/door-open.mp3":"sha384-toZQ6Li9ckUBKJ2Ct9j0VihbOL/1cckuyURTQZoeGWNs9O37cudKQDiQZwGpY7zq","sounds/error.mp3":"sha384-/1dEHJ1qoAxzjSucYUOOSu2v1iZYjiVyKIKHvXI6YgbdXR9ekFvFcoeyGSvpOClG","sounds/explosion.mp3":"sha384-ltgcuLllD+21WOWShc9fHRcMCHja6CjvrriwZ6q+svIzA6sjbOzL7as5pD7F6cZg","sounds/fire-loop.mp3":"sha384-961Bvf7i+Y4Ij2823D68797moLbDjrru/1gSbAn3s9G5acVoQbcwrE1hqd94K/XV","sounds/gem.mp3":"sha384-R3zEhJWNA8xL6l1SGy4l81c6sRAsYweKJr1LzwbB/te+hd1PRu6vtm+z1pV8JHV/","sounds/hit.mp3":"sha384-gNRf3+uQRBdPYgenEiKF7x4nZTu0+MSc3k6g4Mzj9pERNfyzmB0eluHrvUSXIQxf","sounds/jump.mp3":"sha384-5Fq5FzFq3J7aaa65LLaRIQ2rDWdBrj6kX1YuIxizC+N5DKmz6yVrZvhOEcdHETZa","sounds/land.mp3":"sha384-FzP8V/7gNObRoNTgDtomIrCIaLPQwp45q2AoqEEmxTVHzgf2Tqs56rqNcasWD/Df","sounds/lever.mp3":"sha384-/l81+1qFlkY+VOiv9vSv80lS2V6FUoHnNNw1CHWNHkxaWbE7qXXIn5byS/0tNnwQ","sounds/lose.mp3":"sha384-Fko/fFGTQf6WOcJz9iDlgfYtldodfjcUgH0hgNGU72c+OntJLlAYQ0i8ZcRFBuoA","sounds/machine-loop.mp3":"sha384-HK+6s/ohv0LmgMNH4XCP8gYdyYNsUQ7MiBgCJSvnznGhXaviNkvZHMZZTo2+Nvkl","sounds/open.mp3":"sha384-r8PUU3VxFOwpVcmIhwYOg6BYUhYrOQnJT4CgVz4V9ooVpM0NeaAhGMPURavBdanE","sounds/point.mp3":"sha384-98vZ+QorY3iw1bm7sRNIm54Mq0LroKWsCNFrPt6aAQ3ZhHN7+I4ibwsu+TxgWf3a","sounds/power-up.mp3":"sha384-URbVyheAkb87lZdDT3iWJQAIJfyUzk8ieEwX2Hv/PFNSqnO098E9mqdhy0KeQM9m","sounds/rumble-loop.mp3":"sha384-1KsyvSyAN9bm4ZrCRF/3+bHDDVvnC560HXk48Zjr+26capvQS0IvtmvFqrdcFgs/","sounds/splat.mp3":"sha384-2aZ/C6hYBRqXPnSZq2TB9M5u3EFDOVxQjeMGOswRv43CzuL0ZAysUhX/nnHr07Hi","sounds/start.mp3":"sha384-zw5mXd2OL6pbHLz5xdyjQn9nc7AVDgLqx1MSiPYehc6yI0Odt5qTh1TyJNpqxJVC","sounds/teleport.mp3":"sha384-pkpm8x8Aknup+URiIAhz9whdPkPLRoJlhdGYRM/2FJyzzaemjIZoIveJ339G3eFU","sounds/time-up.mp3":"sha384-UeQg6KkMKoeiiRIft0T5z3MU8NM9hLZbx3Smhsz7voAqGb/u7Ndag6lpHOaxqhVY","sounds/win.mp3":"sha384-I8Pyt8U4kbyk9xAoxcimTKSgF9BTr4Nf1t63E/Olnahu2FKJ0G6oLPIVD7CotGiH","editor.css":"sha384-UtVv2Sy+fO5029No4SyC1iW7hUXbIfy4nqF1QP2S8A7M1rUOv5qoJPnxdiNzAF60"}[t];if(n===void 0)throw new Error(`${t} is not one of the editor's published files`);return n}function ybr(t){const n=r=>new URL(`web-build/${r}`,t).href;return{workerUrl:n("worker.js"),wasmUrl:n("esbuild.wasm"),snapshotUrl:n("sdk-snapshot.json"),integrity:{worker:pB("web-build/worker.js"),wasm:pB("web-build/esbuild.wasm"),snapshot:pB("web-build/sdk-snapshot.json")}}}function vbr(t){let n=null;return async()=>(n??(n=sTe(new URL("three/worker.js",t).href,pB("three/worker.js"),"three/worker.js").then(r=>r.text())),n.catch(()=>{n=null}),await n)}let aWe=null;function bbr(t){aWe=t}async function Ozt(t){if(aWe===null)throw new Error("The shared library is not available here.");const n=await sTe(new URL(t,aWe).href,pB(t),t);return new Uint8Array(await n.arrayBuffer())}const xbr=(t,n)=>Ozt(Czt(t,n)),wbr=t=>Ozt(mbr(t)),Sbr=new Set(["a","an","the","of","with","for","and","or","to","in","on","some","model","models"]),Pzt=new Set(["flat","picture","photo","poster","print","painting","frame","sign","banner","billboard","logo","nft","flag","decal","sticker","skybox"]);function Tbr(t){return t.length>4&&t.endsWith("ies")?`${t.slice(0,-3)}y`:t.length>4&&/(x|ch|sh)es$/.test(t)?t.slice(0,-2):t.length>3&&t.endsWith("s")&&!t.endsWith("ss")?t.slice(0,-1):t}const GW=t=>{var n;return((n=(t??"").toLowerCase().match(/[a-z]+|[0-9]+/g))==null?void 0:n.map(Tbr))??[]},pAt=new WeakMap;function Izt(t){let n=pAt.get(t);if(n===void 0){const r=t.tags.flatMap(GW),a=[[GW(t.name),3],[GW(t.subcategory),4],[r,2],[GW(t.category),2],[GW(t.description),1]];n={fields:a,flat:kbr(t,a[1][0])},pAt.set(t,n)}return n}function kbr(t,n){if(n.some(a=>Pzt.has(a)))return!(n.includes("3")&&n.includes("d"));const r=[t.width,t.height,t.depth].filter(a=>a!==void 0);return t.category!=="ground"&&r.length===3&&Math.min(...r)<.03&&Math.max(...r)>.3}function Ebr(t,n,r){const a=[...new Set(GW(n).filter(d=>d.length>1&&!Sbr.has(d)))];if(a.length===0)return[];const s=a.some(d=>Pzt.has(d)),l=t.map(d=>{const{fields:m,flat:_}=Izt(d);let x=0,T=0;for(const A of a){const M=m.reduce((F,[B,H])=>F+(B.includes(A)?H:0),0);M>0&&x++,T+=M}return{a:d,matched:x,score:T,sinks:!s&&_}}).filter(d=>d.matched>0);return l.sort((d,m)=>m.matched-d.matched||Number(d.sinks)-Number(m.sinks)||m.score-d.score||(d.a.triangles??0)-(m.a.triangles??0)),l.slice(0,r).map(d=>d.a)}const Cbr=t=>Izt(t).flat;function w7(t){if(typeof t!="string")throw new Error("An entity id or unique name is required.");const n=QSe(tt.snapshot,t);if(n===null||NS(n)||nR(tt.snapshot,n))throw new Error("No editable entity matches that reference.");return n}function A0e(t){return Array.isArray(t)?t.map(A0e):Xl(t)?typeof t.$case=="string"?{[t.$case]:A0e(t[t.$case])}:Object.fromEntries(Object.entries(t).map(([n,r])=>[n,A0e(r)])):t}const mAt=new Map;function Abr(t){const n=GB(t);if(n!==void 0)return Promise.resolve(n);let r=mAt.get(t);return r===void 0&&(r=rv.componentSchema(t).then(a=>JSON.parse(a),()=>null),mAt.set(t,r)),r}function Nzt(t,n){if(!Xl(t)||!Xl(n))return n;const r={...t};for(const[a,s]of Object.entries(n))r[a]=Nzt(t[a],s);return r}async function Cq(t,n,r,a,s=!1){var T;if(typeof n!="string"||!lJ(n)||!Xl(r))throw new Error("Invalid component update.");const l=((T=tt.snapshot[t])==null?void 0:T[n])??null;if(!s&&JSON.stringify(l)!==JSON.stringify(a))throw new Error("This component changed. Inspect the scene and retry.");const d=FS(t,n);let m=A0e(s?Nzt(l,r):r);n==="Transform"&&Xl(m)&&Xl(l)&&(m={...l,...m});const _=await Abr(n),x=_===null?null:UIt(d,_,m);if(await FI(d,t,n,(x==null?void 0:x.ok)===!0?x.json:JSON.stringify(m)),tt.editStatus.get(d)!=="✓ set")throw new Error("The editor could not apply that component.")}const Obr=20,UBe=t=>Math.round((t??0)*10)/10,Dzt=t=>({x:UBe(t.width),y:UBe(t.height),z:UBe(t.depth)}),Pbr=t=>{var n;return{id:t.id,name:t.name,category:t.subcategory===void 0?t.category:`${t.category}/${t.subcategory}`,size:Dzt(t),triangles:t.triangles??null,kb:Math.round((t.fileSize??0)/1024),tags:t.tags.slice(0,6),...(((n=t.animations)==null?void 0:n.length)??0)>0?{animations:t.animations}:{},...Cbr(t)?{flat:!0}:{}}},hAt=200;function Ibr(t){if(!Xl(t))return t;const{components:n,value:r,...a}=t;return a}async function gXe(t,n,r){var a,s,l,d,m;if(n.throwIfAborted(),!Xl(t))throw new Error("Invalid scene request.");if(t.type==="batch"){if(!Array.isArray(t.requests)||t.requests.length===0||t.requests.length>hAt)throw new Error(`A batch needs 1–${hAt} requests.`);const _=[];for(const x of t.requests){if(Xl(x)&&x.type==="batch")throw new Error("Batches do not nest.");try{_.push({ok:!0,result:Ibr(await gXe(x,n,r))})}catch(T){n.throwIfAborted(),_.push({ok:!1,error:T instanceof Error?T.message:String(T)})}}return{results:_}}if(t.type==="sceneSettings"){if(r===void 0)throw new Error("Scene settings cannot be changed here.");return r({permissions:t.permissions,spawnPoints:t.spawnPoints,parcels:t.parcels,base:t.base})}if(t.type==="outline")return Sur(tt.snapshot,{match:typeof t.match=="string"?t.match:void 0,offset:typeof t.offset=="number"?t.offset:void 0});if(t.type==="check"){const _=await szt(),x=RE(),T=Object.entries(tt.snapshot).filter(([M])=>!NS(M)&&!FA(M,x)),A=T.filter(([,M])=>Xl(M.GltfContainer)&&typeof M.GltfContainer.src=="string");return{visuals:{modelEntities:A.length,modelPaths:[...new Set(A.map(([,M])=>M.GltfContainer.src))],primitiveEntities:T.filter(([,M])=>M.MeshRenderer!==void 0).length},liveParcels:((a=tt.scene)==null?void 0:a.parcels)??[],budget:await jVe(),findings:_.map(M=>({level:M.level,title:M.title,detail:M.detail,...M.entityId===void 0?{}:{entity:Zf(tt.snapshot,M.entityId)??M.entityId}}))}}if(t.type==="inspect"){const _=typeof t.match=="string"?t.match.toLowerCase():"",x=typeof t.offset=="number"&&t.offset>0?Math.floor(t.offset):0,T=Object.entries(tt.snapshot).filter(([A])=>!NS(A)&&!nR(tt.snapshot,A)&&(Zf(tt.snapshot,A)??"").toLowerCase().includes(_));return{selected:[...tt.selected],editMode:tt.frozen,total:T.length,offset:x,entities:T.slice(x,x+150).map(([A,M])=>({id:A,name:Zf(tt.snapshot,A),components:Object.fromEntries(Object.entries(M).filter(([F])=>lJ(F)))}))}}if(t.type==="findModels"){if(typeof t.query!="string")throw new Error("findModels needs query: a few words.");const _=Math.min(Obr,Math.max(1,Number(t.limit??8)||8)),x=await rxe();return{models:Ebr(x,t.query,_).map(Pbr),total:x.length}}if(!tt.frozen)throw new Error("Stop Play before changing the scene.");if(t.type==="addSound"){if(!gbr(t.name))throw new Error(`addSound needs name, one of: ${Azt.join(", ")}.`);const _=hbr(t.name);(await iv()).includes(_)||await Qx(_,await wbr(t.name)),await sG(_);const{durationSeconds:x,loop:T}=_br(t.name);return{path:_,durationSeconds:x,loop:T}}if(t.type==="placeModel"){if(typeof t.id!="string")throw new Error("placeModel needs the id of a findModels result.");await rxe();const _=VSe(t.id);if(_===void 0)throw new Error("No catalog model has that id. Use findModels.");const x=await vYe(_),T=await Nbr(x);return{...await _At(t,x,_.name,n,r),size:Dzt(_),...T}}if(t.type==="buildModel"){const _=typeof t.name=="string"&&t.name.trim()!==""?t.name:t.into===void 0?"":Zf(tt.snapshot,w7(t.into))??String(t.into),x=_.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(x===""||x.length>60)throw new Error("buildModel needs name (or into): 1–60 letters or digits.");if(typeof t.code!="string"||t.code.length>6e4)throw new Error("buildModel needs code: the model script, under 60,000 characters.");const{bytes:T,clips:A,library:M,warnings:F}=await Q0r(t.code,_,n),B=kH(T),H=new Map(M.flatMap(lt=>V0r.map(Et=>[Czt(lt,Et),{name:lt,map:Et}]))),ee=B.sharedImages.filter(lt=>!H.has(lt));if(B.externalResources.some(lt=>!B.sharedImages.includes(lt))||ee.length>0)throw new Error("The model refers to files outside the shared materials.");const Z={triangles:B.triangles,materials:B.materials.length,textures:B.textures-B.sharedImages.length,largestTexture:B.largestImage},K=H0r(Z,B.textureProblems);if(K.length>0)throw new Error(`The model is over budget (${K.join(", ")}); simplify it and build again.`);const _e=await lUt(),he=Z.textures+B.sharedImages.filter(lt=>!_e.shared.has(`models/${lt}`)).length;if(_e.used+he>_e.limit)throw new Error(`The scene has ${Math.max(0,_e.limit-_e.used)} of its ${_e.limit} textures left and this model would add ${he}. Reuse materials the scene already has, give parts seen from afar relief:false, use fewer materials, or grow the parcels.`);const te=new Uint8Array(await crypto.subtle.digest("SHA-256",T)),de=`models/${x}-${[...te.slice(0,4)].map(lt=>lt.toString(16).padStart(2,"0")).join("")}.glb`;await Dbr(),await Qx(`models/src/${x}.js`,new TextEncoder().encode(t.code));for(const lt of B.sharedImages){const{name:Et,map:_t}=H.get(lt),At=`models/${lt}`;await DS(At).then(()=>!0,()=>!1)||await Qx(At,await xbr(Et,_t)),await sG(At)}await Qx(de,T),await sG(de);const Ee=await _At({...t,name:t.into===void 0?_:void 0},de,_,n,r);return OJn({name:_,path:de,triangles:Z.triangles}),{...Ee,script:`models/src/${x}.js`,stats:Z,clips:A,materials:M,...F.length>0?{warnings:F}:{},budget:C0e,kb:Math.round(T.length/1024),scene:await jVe()}}if(t.type==="createEntity"){if(typeof t.name!="string"||!t.name.trim()||t.name.length>100)throw new Error("Choose an entity name of 1–100 characters.");const _=t.parent===void 0||t.parent==="0"?0:Number(w7(t.parent)),x=new Set(Object.keys(tt.snapshot));if(t.components!==void 0&&!Xl(t.components))throw new Error("components must map component names to values.");await SYe(t.name,_);const T=tt.activeEntity;if(T===null||x.has(T))throw new Error("The entity could not be created.");const A=[];for(const[M,F]of Object.entries(t.components??{}))try{await Cq(T,M,F,((s=tt.snapshot[T])==null?void 0:s[M])??null)}catch(B){A.push(`${M}: ${B instanceof Error?B.message:String(B)}`)}return{id:T,components:tt.snapshot[T],...A.length>0?{failed:A}:{}}}if(t.type==="move"){const _=w7(t.to),x=t.by;if(!Xl(x)||!["x","y","z"].some(F=>typeof x[F]=="number"))throw new Error("move needs by: {x, y, z} in metres.");const T=(l=tt.snapshot[_])==null?void 0:l.Transform,A=Xl(T)&&Xl(T.position)?T.position:{x:0,y:0,z:0},M=Object.fromEntries(["x","y","z"].map(F=>[F,Number(A[F]??0)+(typeof x[F]=="number"?x[F]:0)]));return await Cq(_,"Transform",{position:M},null,!0),{id:_,position:M}}if(t.type==="setComponent"){const _=w7(t.to);if("patch"in t)await Cq(_,t.component,t.patch,null,!0);else{if(!("expected"in t))throw new Error("Invalid component update.");await Cq(_,t.component,t.value,t.expected)}return{id:_,component:t.component,value:(d=tt.snapshot[_])==null?void 0:d[String(t.component)]}}if(t.type==="removeComponent"){const _=w7(t.to),x=t.component;if(typeof x!="string"||!lJ(x)||x==="Transform"||x===yf)throw new Error("That component cannot be removed.");return((m=tt.snapshot[_])==null?void 0:m[x])===void 0?{id:_,component:x,removed:!1}:(UYe(_,x),{id:_,component:x,components:tt.snapshot[_]})}if(!["attachScript","setParams","placePrefab"].includes(String(t.type)))throw new Error("Unsupported scene request.");return t.type!=="placePrefab"&&w7(t.to),Q$t(JSON.stringify({version:1,requests:[t]}),tt.activeEntity)}async function Nbr(t){let n;try{n=kH(await DS(t))}catch{return{warning:"Its textures could not be counted; run check to see the scene budget."}}const r=await lUt(),s=Object.values(tt.snapshot).some(d=>Xl(d.GltfContainer)&&d.GltfContainer.src===t)?0:n.textures-n.sharedImages.length+n.sharedImages.filter(d=>!r.shared.has(oUt(t,d))).length,l=r.limit-r.used-s;return{textures:n.textures,materials:n.materials.length,sceneTexturesLeft:l,...l<0?{warning:`The scene now uses ${r.used+s} of its ${r.limit} textures; explorers warn above that. Swap it for a model with fewer textures, or grow the parcels.`}:{}}}async function _At(t,n,r,a,s){var m;const l={src:n,visibleMeshesCollisionMask:3},d=Object.fromEntries(["position","rotation","scale"].filter(_=>Xl(t[_])).map(_=>[_,t[_]]));try{if(t.into!==void 0){const x=w7(t.into);await Cq(x,"GltfContainer",l,null,!0);for(const T of["MeshRenderer","Material","MeshCollider"])((m=tt.snapshot[x])==null?void 0:m[T])!==void 0&&UYe(x,T);return await Cq(x,"Transform",{scale:{x:1,y:1,z:1},...d},null,!0),{id:x,model:n,components:tt.snapshot[x]}}const _=await gXe({type:"createEntity",name:t.name??r,parent:t.parent,components:{Transform:{position:{x:8,y:0,z:8},...d},GltfContainer:l}},a,s);return{...Xl(_)?_:{},model:n}}finally{Xf({type:"resync"})}}const gAt="models/src/";async function Dbr(){const t=await Zm(".dclignore").catch(async n=>{if((await iv()).includes(".dclignore"))throw n;return""});t.split(`
|
|
32455
|
+
`))??[],...A0r].filter(Boolean)),a=[...t].filter(s=>!s.split("/").some(l=>l.startsWith(".")));return r.filter(a)}function O0r(t){const n=t.scene;if(!y_(n))throw new Error('scene.json has no "scene" section');const{base:r,parcels:a}=n;if(typeof r!="string"||!Array.isArray(a))throw new Error("scene.json needs scene.base and scene.parcels");return[...new Set([r,...a.filter(s=>typeof s=="string")])]}function P0r(t){const n=new Set,r=t.files.map(({path:a,version:s})=>{const l=a.toLowerCase();if(n.has(l))throw new Error(`Two files deploy as "${l}"; scene file names are case-insensitive`);return n.add(l),{file:l,hash:Fvr(t.projectId,a,s,t.machineId)}});return{version:"v3",type:"scene",id:wzt(t.projectId,t.machineId),pointers:O0r(t.sceneJson),timestamp:t.timestamp,content:r,metadata:t.sdkVersion===void 0?t.sceneJson:{sdkVersion:t.sdkVersion,...t.sceneJson}}}const Sxe="dcl-editor-preview-v1",I0r="dcl-editor-storage-v1";function rWe(t,n){if(!mXe.test(n))throw new Error(`Invalid preview project id "${n}"`);return new URL(`preview/${n}/`,t).href}const iWe=t=>t+"__manifest",uAt=(t,n)=>`${t}content/contents/${n}`;async function N0r(t){const n=new URL(t.realmUrl).href;if(n!==rWe(new URL("../../",n),t.projectId))throw new Error(`"${t.realmUrl}" is not the preview realm of project "${t.projectId}"`);const r=new Map([...t.files,...t.buildOutputs]),a=r.get(".dclignore"),s=_Xe(r.keys(),a===void 0?void 0:new TextDecoder().decode(a)),l=await Promise.all(s.map(async B=>{const H=r.get(B)??new Uint8Array;return{path:B,bytes:H,version:await jvr(H)}})),d=await caches.open(Sxe),m=await d.match(iWe(n)),_=await(m==null?void 0:m.json().catch(()=>{})),x=y_(_)&&typeof _.version=="number"?_.version:0,T=P0r({projectId:t.projectId,sceneJson:t.sceneJson,files:l,timestamp:Date.now(),sdkVersion:t.sdkVersion,machineId:t.machineId}),A=new Set;await Promise.all(T.content.map(async({hash:B},H)=>{const ee=uAt(n,B);A.add(new URL(ee).href),await d.match(ee)===void 0&&await d.put(ee,new Response(oTe(l[H].bytes),{headers:{"Content-Type":"application/octet-stream"}}))}));const M={version:x+1,entity:T};await d.put(iWe(n),new Response(JSON.stringify(M),{headers:{"Content-Type":"application/json"}}));const F=uAt(n,"");for(const B of await d.keys())B.url.startsWith(F)&&!A.has(B.url)&&await d.delete(B);return{realmUrl:n,entityId:T.id}}const D0r="0.1.0",R0r=new TextEncoder,M0r=new TextDecoder("utf-8",{fatal:!0});function L0r(t,n){return t===void 0?n===null:n!==null&&t.length===n.length&&t.every((r,a)=>r===n[a])}function F0r(t){try{return JSON.parse(t)}catch{throw new Error("Invalid scene request.")}}function fAt(t){if(typeof t!="object"||t===null)return null;const{x:n,y:r,z:a}=t;return[n,r,a].every(s=>typeof s=="number"&&Number.isFinite(s))?{x:n,y:r,z:a}:null}function j0r(t){const n=new Map;return async(r,a)=>{var F;a.throwIfAborted();const{tool:s,args:l}=r;if(s==="playtest"){if(t.playtest===void 0)throw new Error("Playtesting requires an updated editor.");return JSON.stringify(await t.playtest(l,a))}if(s==="asset_request"){if(t.assets===void 0)throw new Error("Asset tools require an updated editor.");return JSON.stringify(await t.assets(l,a))}if(s==="list_files"){const B=typeof l.kind=="string"&&WIt.includes(l.kind)?l.kind:null,H=typeof l.match=="string"?l.match.toLowerCase():"";return JSON.stringify([...t.files().keys()].filter(ee=>{const Z=qIt(ee);return Z===null||Z==="code"&&!wbe(ee)?!1:(B===null||Z===B)&&ee.toLowerCase().includes(H)}).sort().slice(0,2e3))}if(s==="build")return JSON.stringify(await t.build(a));if(s==="view")return JSON.stringify(await t.view({entity:typeof l.entity=="string"&&l.entity.trim()!==""?l.entity:null,from:fAt(l.from),lookAt:fAt(l.lookAt)},a));if(s==="scene_request")return JSON.stringify(await t.scene(typeof l.request=="string"?F0r(l.request):l.request,a));const d=l.path;if(typeof d!="string"||!wbe(d))throw new Error("This path is not an assistant-readable project file.");const m=t.files().get(d);if(s==="read_file"){if(m===void 0)return JSON.stringify({path:d,content:null,revision:null});if(m.byteLength>hxt)throw new Error("This file is too large for the assistant.");const B=M0r.decode(m),H=crypto.randomUUID();return n.set(d,{revision:H,bytes:m.slice()}),JSON.stringify({path:d,content:B,revision:H})}if(s!=="write_file"||!JOn(d))throw new Error("The assistant can write source files; scene data is changed through editor actions.");if(typeof l.content!="string")throw new Error("Missing file content.");const _=R0r.encode(l.content);if(_.byteLength>hxt)throw new Error("This file is too large for the assistant.");const x=n.get(d),T=l.revision===null?null:x==null?void 0:x.bytes;if(T===void 0||l.revision!==null&&l.revision!==(x==null?void 0:x.revision))throw new Error("Read this file before changing it.");await t.write(d,_,T,a),a.throwIfAborted();const A=crypto.randomUUID();n.set(d,{revision:A,bytes:_});const M=await((F=t.written)==null?void 0:F.call(t,d,l.content,T===null))??null;return JSON.stringify({path:d,revision:A,created:T===null,...M===null?{}:{attached:M}})}}function B0r(t){const n=new Set;let r=null,a=null,s=0,l=null,d=Promise.resolve(),m=null;const _=te=>{for(const de of n)de(te)},x=te=>[{id:"claude",label:"Claude",available:!1,models:[],defaultModel:"",transport:"service",reason:te}],T=te=>{(r==null?void 0:r.readyState)===WebSocket.OPEN&&r.send(JSON.stringify(te))};function A(te,de){const Ee=l;Ee!==null&&(l=null,Ee.controller.abort(),de!==void 0&&_({kind:"error",turnId:Ee.id,message:de}),_({kind:"done",turnId:Ee.id,ok:te}))}function M(te){const de=Xl(te.args.request)?te.args.request:{};switch(te.tool){case"write_file":return null;case"read_file":return{tool:"Read",detail:typeof te.args.path=="string"?te.args.path:""};case"asset_request":return{tool:"Assets",detail:String(te.args.action??"")};case"build":return{tool:"Build",detail:"Scene"};case"playtest":return{tool:"Playtest",detail:String(te.args.action??"")};case"scene_request":if(de.type==="batch"&&Array.isArray(de.requests))return{tool:"Scene",detail:`${de.requests.length} changes`};if(de.type==="sceneSettings")return{tool:"Scene",detail:"Settings"};if(de.type==="attachScript")return null}return{tool:"Inspect",detail:"Project"}}function F(te,de,Ee,lt){const Et=de.label===void 0?{}:{label:de.label},_t=M(de);if(_t!==null){lt||_({kind:"tool",turnId:te,..._t,...Et});return}if(de.tool==="write_file"){const vt=typeof de.args.path=="string"?de.args.path:"";_({kind:"tool",turnId:te,tool:de.args.revision===null?"Write":"Edit",detail:vt,...Et});const Ve=JSON.parse(Ee);Xl(Ve)&&Xl(Ve.attached)&&typeof Ve.attached.name=="string"&&_({kind:"tool",turnId:te,tool:"Attached",detail:`${vt.split("/").pop()??vt} to ${Ve.attached.name}`,...Et});return}const At=JSON.parse(Ee);if(Xl(At)&&Array.isArray(At.attached))for(const vt of At.attached)typeof vt=="string"&&_({kind:"tool",turnId:te,tool:"AttachScript",detail:vt,...Et})}async function B(te){const de=l;if(de===null||de.id!==te.turnId||de.controller.signal.aborted)return;let Ee=!1,lt="",Et=!1;try{if(t.wallet()!==de.wallet||t.project().id!==de.projectId)throw new Error("The open project or account changed.");if(te.label!==void 0){const _t=M(te);_t!==null&&(_({kind:"tool",turnId:de.id,..._t,label:te.label}),Et=!0)}if(lt=await de.execute(te,de.controller.signal),lt.length>5e5)throw new Error("The tool result is too large. Ask for a smaller part of the project.");de.controller.signal.throwIfAborted(),Ee=!0,F(de.id,te,lt,Et)}catch(_t){lt=_t instanceof Error?_t.message:typeof _t=="string"&&_t!==""?_t:"The browser tool failed."}l===de&&!de.controller.signal.aborted&&T({kind:"result",turnId:de.id,callId:te.callId,ok:Ee,text:lt})}function H(te){let de;try{de=JSON.parse(te)}catch{A(!1,"Invalid assistant response.");return}if(!Xl(de))return;if(de.kind==="failure"&&typeof de.message=="string"){A(!1,de.message);return}if(de.kind==="call"&&typeof de.turnId=="string"&&typeof de.callId=="string"&&VOn.test(de.callId)&&["list_files","read_file","write_file","scene_request","asset_request","build","view","playtest"].includes(String(de.tool))&&Xl(de.args)){const{label:lt,...Et}=de,_t=typeof lt=="string"?{...Et,label:lt}:Et;if(l===null||l.id!==_t.turnId||l.calls.has(_t.callId))return;l.calls.add(_t.callId);const At=GOn(_t.tool,_t.args),vt=(At?Promise.resolve():d).then(()=>B(_t)).catch(Ve=>{console.error("[assistant] browser tool failed",_t.tool,Ve),(l==null?void 0:l.id)===_t.turnId&&A(!1,"The browser tool failed.")});At||(d=vt);return}if(de.kind!=="event"||!Xl(de.event))return;const Ee=de.event;if(!(l===null||Ee.turnId!==l.id)){if(Ee.kind==="text"&&typeof Ee.text=="string"&&_({kind:"text",turnId:l.id,text:Ee.text}),Ee.kind==="error"&&typeof Ee.message=="string"){const lt=Ee.resumable===!0;lt&&(m=r),_({kind:"error",turnId:l.id,message:Ee.message,...lt?{resumable:lt}:{}})}Ee.kind==="done"&&typeof Ee.ok=="boolean"&&A(Ee.ok)}}async function ee(){if((r==null?void 0:r.readyState)===WebSocket.OPEN)return r;if(a!==null)return a;const te=s,de=(async()=>{if(t.service===null)throw new Error("The assistant service is not configured.");const Ee=await t.fetch(`${t.service}/assistant/connect`,{method:"POST"});if(!Ee.ok)throw new Error("The assistant service is unavailable. Sign in and recheck.");const lt=await Ee.json();if(!Xl(lt)||typeof lt.token!="string")throw new Error("Invalid assistant connection.");if(te!==s)throw new Error("Connection cancelled.");const Et=new URL(`${t.service}/assistant/socket`,location.href);Et.protocol=Et.protocol==="https:"?"wss:":"ws:";const _t=new WebSocket(Et,[WOn,qOn+lt.token]);return r=_t,new Promise((At,vt)=>{let Ve=!1;const Qt=setTimeout(()=>{_t.close(),vt(new Error("Assistant connection timed out."))},1e4);_t.onmessage=({data:We})=>{if(r===_t&&typeof We=="string")if(Ve)H(We);else{let Fe;try{Fe=JSON.parse(We)}catch{_t.close();return}if(!Xl(Fe)||Fe.kind!=="ready")return;Ve=!0,clearTimeout(Qt),At(_t)}},_t.onerror=()=>{_t.close(),vt(new Error("Could not connect to the assistant service."))},_t.onclose=()=>{clearTimeout(Qt),r===_t&&(r=null,A(!1,"Assistant connection closed. Your edits are saved; the next message starts a new conversation.")),vt(new Error("Assistant connection closed."))}})})();a=de;try{return await de}finally{a===de&&(a=null)}}function Z(){try{return t.project().id}catch{return null}}async function K(te,de){try{const Ee=await t.memory.read(te,de);if(Ee!==null)return Ee;const lt={id:$0r(crypto.getRandomValues(new Uint8Array(16))),key:U0r(crypto.getRandomValues(new Uint8Array(32)))};return await t.memory.write(te,de,lt),lt}catch{return}}function _e(){s++,T({kind:"reset"}),A(!1);const te=r;return r=null,a=null,te==null||te.close(),d}return{shell:{async aiProviders(){if(t.wallet()===null)return x("Sign in to Decentraland to use the assistant.");if(t.service===null)return x("The assistant service is not configured.");try{const te=await t.fetch(`${t.service}/assistant/providers`);if(!te.ok)return x("The assistant service is unavailable. Recheck when it is running.");const de=await te.json();return Array.isArray(de)?de.filter(Ee=>Xl(Ee)&&(Ee.id==="claude"||Ee.id==="codex")&&typeof Ee.label=="string"&&typeof Ee.available=="boolean"&&typeof Ee.defaultModel=="string"&&Array.isArray(Ee.models)&&Ee.models.every(lt=>typeof lt=="string")).map(Ee=>({...Ee,transport:"service"})):x("The assistant service returned an invalid provider list.")}catch{return x("Could not reach the assistant service. Recheck your connection.")}},async aiSend(te){if(l!==null)throw new Error("A turn is already running.");const de=t.wallet();if(de===null)throw new Error("Sign in to use the assistant.");m=null;const Ee=t.project(),lt={id:crypto.randomUUID(),wallet:de,projectId:Ee.id,controller:new AbortController,calls:new Set,execute:j0r(Ee.tools)};l=lt,_({kind:"started",turnId:lt.id});try{if(await ee(),lt.controller.signal.throwIfAborted(),t.wallet()!==de||t.project().id!==Ee.id)throw new Error("The open project or account changed.");const Et=await K(Ee.id,de);lt.controller.signal.throwIfAborted(),T({kind:"prompt",turnId:lt.id,projectId:Ee.id,params:te,memory:Et})}catch(Et){l===lt&&A(!1,Et instanceof Error?Et.message:"Could not start the assistant.")}return{turnId:lt.id}},async aiStop(){l!==null&&T({kind:"stop",turnId:l.id}),await _e()},async aiReset(){await _e()},async aiForget(){const te=t.wallet(),de=(l==null?void 0:l.projectId)??Z();l!==null&&T({kind:"stop",turnId:l.id}),A(!1);const Ee=te===null||de===null?null:await t.memory.read(de,te).catch(()=>null);Ee!==null&&te!==null&&de!==null&&(T({kind:"forget",id:Ee.id}),await t.memory.write(de,te,null).catch(()=>{})),await _e()},aiCanResume:()=>m!==null&&m===r&&r.readyState===WebSocket.OPEN,onAiEvent(te){return n.add(te),()=>{n.delete(te)}}},reset:_e,dispose(){_e(),n.clear()}}}function $0r(t){return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}function U0r(t){return btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function z0r(){const t=tt.activeEntity;return async(n,r,a)=>{if(oGe(n)!==n)return null;try{return a?t===null||NS(t)||tt.snapshot[t]===void 0||nR(tt.snapshot,t)||!await zYe(t,n,r)?null:{id:t,name:Zf(tt.snapshot,t)??`#${t}`}:(await lur(n,r),null)}catch(s){return console.error("could not attach the new script:",n,s),null}}}const Ezt=["stone-blocks","red-brick","old-brick","cobblestone","rock","mossy-rock","planks","wood","bark","roof-tiles","concrete","marble","floor-tiles","metal","rusty-metal","metal-plate","grass","sand","gravel","snow","ice"],V0r=["color","normal"],W0r=t=>t.split(/[^A-Za-z0-9]+/).filter(Boolean).map(n=>n[0].toUpperCase()+n.slice(1)).join(""),Czt=(t,n)=>`materials/T_${W0r(t)}_${n==="color"?"D":"N"}.jpg`;function q0r(t){return typeof t=="string"&&Ezt.includes(t)}const G0r=20*1024*1024;function J0r(t){const{glb:n,clips:r,library:a,warnings:s}=t;if(!(n instanceof ArrayBuffer)||n.byteLength===0||n.byteLength>G0r)throw new Error("The model is missing or over 20 MB.");if(!Array.isArray(a)||a.length>Ezt.length)throw new Error("The model names too many shared materials.");const l=[...new Set(a)].map(_=>{if(!q0r(_))throw new Error("The model names an unknown shared material.");return _}),d=Array.isArray(r)?r.filter(_=>typeof _=="string").slice(0,32).map(_=>_.slice(0,64)):[],m=Array.isArray(s)?s.filter(_=>typeof _=="string").slice(0,8).map(_=>_.slice(0,300)):[];return{bytes:new Uint8Array(n),clips:d,library:l,warnings:m}}const C0e={triangles:8e3,materials:6,textures:4,largestTexture:512},dAt=2e4;function H0r(t,n=[]){return[...Object.keys(C0e).filter(r=>t[r]>C0e[r]).map(r=>`${r} ${t[r]} > ${C0e[r]}`),...n.map(r=>`${r}; use 64/128/256/512`)]}async function Q0r(t,n,r){r.throwIfAborted();const a=v$t("build"),s=await new Promise((m,_)=>{const x=()=>{_(new Error("Stopped.")),a.then(T=>T.terminate(),()=>{})};r.addEventListener("abort",x,{once:!0}),a.then(m,_).finally(()=>r.removeEventListener("abort",x))});let l,d=()=>{};try{const m=await new Promise((_,x)=>{l=setTimeout(()=>x(new Error(`The model script stopped answering after ${dAt/1e3} s: it loops forever or ran out of memory. Make it simpler.`)),dAt),d=()=>x(new Error("Stopped.")),r.addEventListener("abort",d,{once:!0}),r.aborted&&d(),s.onmessage=T=>_(T.data),s.postMessage({kind:"build",code:t,name:n})});if(m.kind!=="built")throw new Error(`The model script failed: ${m.kind==="failed"?String(m.error).slice(0,2e3):"no model"}`);return J0r(m)}finally{clearTimeout(l),r.removeEventListener("abort",d),s.terminate()}}const Y0r={description:"bright rising blip: coin or collectible picked up",durationSeconds:.39,loop:!1},X0r={description:"glassy chime: gem, crystal or rare item picked up",durationSeconds:.26,loop:!1},Z0r={description:"short confirm blip: point scored, checkpoint, correct",durationSeconds:.31,loop:!1},K0r={description:"three rising tones: go, round start",durationSeconds:.6,loop:!1},ebr={description:"rising 8-bit fanfare: win, level complete",durationSeconds:.81,loop:!1},tbr={description:"falling 8-bit jingle: lose, game over",durationSeconds:.81,loop:!1},nbr={description:"soft click: button press",durationSeconds:.05,loop:!1},rbr={description:"short rise: panel or menu opens",durationSeconds:.18,loop:!1},ibr={description:"short fall: panel or menu closes",durationSeconds:.18,loop:!1},abr={description:"low buzz: wrong, denied, locked",durationSeconds:.24,loop:!1},sbr={description:"springy rising zip: jump, bounce pad",durationSeconds:.39,loop:!1},obr={description:"soft heavy thud: landing, something dropped",durationSeconds:.55,loop:!1},cbr={description:"punch impact: hit, damage taken",durationSeconds:.26,loop:!1},lbr={description:"wet squelch: slime, goo, closest to a splash",durationSeconds:.52,loop:!1},ubr={description:"rising phaser sweep: teleport, portal, respawn",durationSeconds:.42,loop:!1},fbr={description:"metal latch clack: lever, switch, lock",durationSeconds:.21,loop:!1},dbr={description:"deep boom: explosion, cannon, big impact",durationSeconds:2.04,loop:!1},pbr={coin:Y0r,gem:X0r,"power-up":{description:"rising synth sweep: power-up or boost",durationSeconds:.89,loop:!1},point:Z0r,"countdown-tick":{description:"single beep: each second of a countdown",durationSeconds:.13,loop:!1},start:K0r,win:ebr,lose:tbr,"time-up":{description:"falling buzz: time up, round over",durationSeconds:1.28,loop:!1},click:nbr,open:rbr,close:ibr,error:abr,jump:sbr,land:obr,hit:cbr,splat:lbr,teleport:ubr,"door-open":{description:"wooden door creaking open",durationSeconds:.91,loop:!1},"door-close":{description:"wooden door shutting",durationSeconds:.65,loop:!1},lever:fbr,explosion:dbr,"fire-loop":{description:"roaring flame: fire, lava, furnace, jet",durationSeconds:4.78,loop:!0},"rumble-loop":{description:"low engine rumble: machinery, cave, earthquake",durationSeconds:4.78,loop:!0},"machine-loop":{description:"busy electronic chatter: computer room, lab, generator, machine",durationSeconds:4.55,loop:!0}},Azt=["coin","gem","power-up","point","countdown-tick","start","win","lose","time-up","click","open","close","error","jump","land","hit","splat","teleport","door-open","door-close","lever","explosion","fire-loop","rumble-loop","machine-loop"],mbr=t=>`sounds/${t}.mp3`,hbr=t=>`assets/audio/library/${t}.mp3`,_br=t=>pbr[t];function gbr(t){return typeof t=="string"&&Azt.includes(t)}function pB(t){const n={"scene-compiler/worker.js":"sha384-zg+9cNTeS1cZbdghFiI8Pjzyr0RTlPYqVurB8j+3edouJsxrpkzYEVB7ljeTa+F8","scene-compiler/esbuild.wasm":"sha384-V8Ml7eHSlgGTb/TR1IYB6LtWwAW1NXLDPRjL2FjxwIfqDkSZ/hp+zmfvXDHqu8NV","scene-compiler/sdk-snapshot.json":"sha384-cEzJvvCGlmHpD/zVbHX2vzG5qWftYtZjN4jN2tic6qusNfMDx6/GUXhdgU13Ct+A","three/worker.js":"sha384-fpaxQE7sJmPgdwwsCLEkPRmp3A++vppj0bqkpV7a8egKEfBEEP4o/pD2eYfsXZTp","prefabs/catalog.json":"sha384-ZI9912I5wPBiOnsPxkaYKS+jUHzka6SDVH04Zb1Wvwn/AybJWtfSKBUqEKSuzv1L","materials/T_Bark_D.jpg":"sha384-FtUe6G243wHZ8C0kbR+2lFVHp/atYXEPodY4A1qDQquYeu27euNDRDqEyFoQJ29L","materials/T_Bark_N.jpg":"sha384-EhhyT3HTQ3sy1CVvKMTX+ueIGq2+FgDntZ6lKFZW6sHOrCTCMbxnDhthwQIanVOr","materials/T_Cobblestone_D.jpg":"sha384-lSuwYcPhIyqVZvG0NuB93ESZIEqL0ffEmD7gh6iG3qN4elINxt7KQS8CN4Ay2CQ0","materials/T_Cobblestone_N.jpg":"sha384-A+Xe7cTTQGB4hwE6WPsWgD76xwIZ2/FFlxqeWZnyFk5AWaK6hDEKCEZVeVinJ3uw","materials/T_Concrete_D.jpg":"sha384-1dPzQGKxZAw2NloRUM+KhE0X9XeTLUxBrvkw4Uaa4Gm/ID65iDv+yPWUHYi59gYn","materials/T_Concrete_N.jpg":"sha384-8+TiM45B8TCGHYOHh5/510IpXfo1WgyaS5q/T1B3GOEdQrXHV+x9yXmyjkN9mWsh","materials/T_FloorTiles_D.jpg":"sha384-PwDH1P94cY4VXHyrbTQSpvDh89A5jMf+xG62xUDT9TRbItuR6uI1lXB9onxu4gaX","materials/T_FloorTiles_N.jpg":"sha384-opjmq0wL8b+pxHcujr8IGFCOQt8+pDX7EjcnmzmcKGy7F8H3dv9IgG7gxQXgkQJu","materials/T_Grass_D.jpg":"sha384-GGodYBboPnhEcv7JVlR1mSjLWux7q4qJcOxqdl7a/6bN6IWkel4A1BeHV4sieS25","materials/T_Grass_N.jpg":"sha384-zu3ig6Su3u2I3e3LX2zeaS9LtqJYl8V3siVjWBQ2Xea6iMAcMCXHp2HQyctvaEY2","materials/T_Gravel_D.jpg":"sha384-Y2EZTiFeTQbZlduNmz1Y74fZIvkmh8c2grqr6B1GqejChZbNnRb5ejC8SCqyPY77","materials/T_Gravel_N.jpg":"sha384-VWUAPWQZqvuFDmiZZvhAgqQ24DmSrByuu7ETrD2igGikpZS+U7E81hAJ3Iiv88iT","materials/T_Ice_D.jpg":"sha384-qNSYRVYvzZ6NP5Ny/MDMNajmplmSXf9036CidUKqte1DUUDzMm28FZvWcAMSnyux","materials/T_Ice_N.jpg":"sha384-LYz8XTf6DXyxCy6Jtci0y6E0/ER4b73sdH6lhCbagK8nuYPpD8ChpB8PZUTLMLkF","materials/T_Marble_D.jpg":"sha384-MfvwmuTcZs+OB9BLKNAFU849wj27KcdPxxvF3WAY9OrZGtQORoHXjDWh2YWBukWk","materials/T_Marble_N.jpg":"sha384-SU6JhDtveHoi5d1AUiQV8oVfO1uEChNA7ACvMv1OIKESECfG1lCMw6MG7TZrGhnf","materials/T_MetalPlate_D.jpg":"sha384-Qe4yIHUfUVMwOEDZTsY0u7d19xhUE/GiSyz0s3P9297mx+XXGvDCR8gKdU9hLhbo","materials/T_MetalPlate_N.jpg":"sha384-RpCdFzgg7xIUz1G+nDJEon1H0MHwsk4RHOTfi2Er2hC56AXU2TXcToTY12aqz+4R","materials/T_Metal_D.jpg":"sha384-h2Fs2s1/WPYJwUY3a6vpMqrd0rb7GDWViOvw8SlsSocO/sBqcqzzbjOwYR9uooVE","materials/T_Metal_N.jpg":"sha384-iVL98sXzJCK2z/YuoBw0pwbZyes0ZprTHsvQdFQ6tXhKP5004tHMWJnr5icUVwKp","materials/T_MossyRock_D.jpg":"sha384-5sB1xTHnLgeGIiY5kqc5kr78xBvR17BBrWJZD1IyyEuFO8mcgJ7DaAKH9ZcrV0Oj","materials/T_MossyRock_N.jpg":"sha384-z+02Z5HZoLwVk/i0R/YRm/MW/KQr3Y5h4cB0iH837QsKMrvzrO6iFMuBWXER8ZLk","materials/T_OldBrick_D.jpg":"sha384-1h+VtTgiyyfZ9N5h15snvPP5bjvvI5Mzq958DaMi0BTJKxFbtKoYjnWp9mkhDBTZ","materials/T_OldBrick_N.jpg":"sha384-mORhqcYtb2adL11dYPIpTKvrTVqiz1mqHVW/abZaSerjsKMEvRa5uxoe65nfUmzF","materials/T_Planks_D.jpg":"sha384-olCbQDlaUR5rNCiEPsJt3Z6XYD2L1McfZNZOBdCDsIo4dyKa9Y41H3mCbdY1BMqL","materials/T_Planks_N.jpg":"sha384-Qe2LOHGe2f/b8RdZmZRSrZl0KMgxMT28Q0yj/Ewr0TRsmSe4L1N9TxQscZ7jXIpz","materials/T_RedBrick_D.jpg":"sha384-z5Omhin/SbXfu6KqUuKYyVFQN5GIkfCtva/SIM3g8C09Dy/ajUgaCrQYUQv0Wi6s","materials/T_RedBrick_N.jpg":"sha384-N5Zlk1HLC7ECYSYp9JAlKc9UZk3lFIytrdyYTNCyrRAD6IMQMGM178Ns5ICXoBcY","materials/T_Rock_D.jpg":"sha384-JPbUh7M8Yt82J9u9P3cMPWNBNNDN2MOkMhb4BpWOQ1MUacVygOKoKHOAspiyAaDI","materials/T_Rock_N.jpg":"sha384-d2AXOT8FPWfSBdhZGN2U85WRbKq02qgDIFhEcp9/ZrTfzPPpb3x+1tM3pRfflGWG","materials/T_RoofTiles_D.jpg":"sha384-XyFas+mKIHi1ZJxhOpjcJ3aE7SZjOUukcY1wZqJ0kcwMjYE2SD5mv/Ft1babZiRk","materials/T_RoofTiles_N.jpg":"sha384-OtknIACV+BRu+g5+hVLWILG4Qli4fIDdqqrf3rFTuGr/VxhZIGgxC61tMM7Tr5pt","materials/T_RustyMetal_D.jpg":"sha384-vN18ZCLm3ijlv9l30lI/rUbcUpcJH0ut4hF8GueDNYPZO4WDiqxJH9EX70DGsEsh","materials/T_RustyMetal_N.jpg":"sha384-+rdn3/f1t/jU65sT0kq03mG9HtAIA3a1+bezGQmXOV9FiCM2KUCIugsOUhQAzmjO","materials/T_Sand_D.jpg":"sha384-i3zMj/gXeIpnlll08lxRRvQ9BA+j/3bLnzru+M3LzjvyhwMKgz6bmnLjhe1rPZrz","materials/T_Sand_N.jpg":"sha384-eBZtZpK8wZnUmtNfV5iCt/l4WWvoppG0bFkFeULvqw5gNkT+emO5u8AVtpRTFjxM","materials/T_Snow_D.jpg":"sha384-kOAg+1SQpFtFg/XpbSTT+Boo6hGe/+BXR3fI2pgrTyl0VJTrc2W1pUKlT38nSP6k","materials/T_Snow_N.jpg":"sha384-8ryXPS0Yprm5vNZCUadJRhKh4MQ+8gkD0q1GbjlPLez7GSjsV7QmAyM63PiIn0cK","materials/T_StoneBlocks_D.jpg":"sha384-o2TlIP/+m+uvEmypAk3zXE+9huFaU3K+VTD18p8vPEb9I3SVB1n2ez1jqZTXZNQF","materials/T_StoneBlocks_N.jpg":"sha384-eR/UR9FC3v3Pw4oBlWlOyQNmtgvb5a1mSRwSBMrQhDyXk4neOjmVlTyjBjhOTYOU","materials/T_Wood_D.jpg":"sha384-Tk9jMT15vysCDRdd22J2mFUHCBSHVMhGNa71sYFf7yqvZQkmMGdrIhiIsmi/fAm2","materials/T_Wood_N.jpg":"sha384-b1SWrWCwyf+89JAlVNPCwmwkUTrcGXUqRANI3x+grecaCQblZGLsSaJx/5CNPnPC","sounds/click.mp3":"sha384-5Nn2A2LWwXVAhOJKiwTncPtBTCtmrqOVQVAuz+xHRrAuMnScsTQ06gM0dU14yxa1","sounds/close.mp3":"sha384-JBoxn91EXhKXI4EJZ1nlDO3U735Nz6Nn1UuzpPhRjjpMaEOafABEqQL8GgfV7XTi","sounds/coin.mp3":"sha384-2RR7dy+f4rzUKdiGeSdApfQmbsENC4FzT8o4y3JXs5IX6a2udQbwU3iLhCUZ+z1a","sounds/countdown-tick.mp3":"sha384-I1gWiwXYWkrQ3dmkVDqolRCU+O/OkVqH625gdQZ8i3mntGSNBKJN1u2yPzmiPOio","sounds/door-close.mp3":"sha384-V/WOG/jNZMVo2EK2wosamkz0F/OjilfprwqVR0JwxFuLjzaIGOG6LFUxp1RB2NF6","sounds/door-open.mp3":"sha384-toZQ6Li9ckUBKJ2Ct9j0VihbOL/1cckuyURTQZoeGWNs9O37cudKQDiQZwGpY7zq","sounds/error.mp3":"sha384-/1dEHJ1qoAxzjSucYUOOSu2v1iZYjiVyKIKHvXI6YgbdXR9ekFvFcoeyGSvpOClG","sounds/explosion.mp3":"sha384-ltgcuLllD+21WOWShc9fHRcMCHja6CjvrriwZ6q+svIzA6sjbOzL7as5pD7F6cZg","sounds/fire-loop.mp3":"sha384-961Bvf7i+Y4Ij2823D68797moLbDjrru/1gSbAn3s9G5acVoQbcwrE1hqd94K/XV","sounds/gem.mp3":"sha384-R3zEhJWNA8xL6l1SGy4l81c6sRAsYweKJr1LzwbB/te+hd1PRu6vtm+z1pV8JHV/","sounds/hit.mp3":"sha384-gNRf3+uQRBdPYgenEiKF7x4nZTu0+MSc3k6g4Mzj9pERNfyzmB0eluHrvUSXIQxf","sounds/jump.mp3":"sha384-5Fq5FzFq3J7aaa65LLaRIQ2rDWdBrj6kX1YuIxizC+N5DKmz6yVrZvhOEcdHETZa","sounds/land.mp3":"sha384-FzP8V/7gNObRoNTgDtomIrCIaLPQwp45q2AoqEEmxTVHzgf2Tqs56rqNcasWD/Df","sounds/lever.mp3":"sha384-/l81+1qFlkY+VOiv9vSv80lS2V6FUoHnNNw1CHWNHkxaWbE7qXXIn5byS/0tNnwQ","sounds/lose.mp3":"sha384-Fko/fFGTQf6WOcJz9iDlgfYtldodfjcUgH0hgNGU72c+OntJLlAYQ0i8ZcRFBuoA","sounds/machine-loop.mp3":"sha384-HK+6s/ohv0LmgMNH4XCP8gYdyYNsUQ7MiBgCJSvnznGhXaviNkvZHMZZTo2+Nvkl","sounds/open.mp3":"sha384-r8PUU3VxFOwpVcmIhwYOg6BYUhYrOQnJT4CgVz4V9ooVpM0NeaAhGMPURavBdanE","sounds/point.mp3":"sha384-98vZ+QorY3iw1bm7sRNIm54Mq0LroKWsCNFrPt6aAQ3ZhHN7+I4ibwsu+TxgWf3a","sounds/power-up.mp3":"sha384-URbVyheAkb87lZdDT3iWJQAIJfyUzk8ieEwX2Hv/PFNSqnO098E9mqdhy0KeQM9m","sounds/rumble-loop.mp3":"sha384-1KsyvSyAN9bm4ZrCRF/3+bHDDVvnC560HXk48Zjr+26capvQS0IvtmvFqrdcFgs/","sounds/splat.mp3":"sha384-2aZ/C6hYBRqXPnSZq2TB9M5u3EFDOVxQjeMGOswRv43CzuL0ZAysUhX/nnHr07Hi","sounds/start.mp3":"sha384-zw5mXd2OL6pbHLz5xdyjQn9nc7AVDgLqx1MSiPYehc6yI0Odt5qTh1TyJNpqxJVC","sounds/teleport.mp3":"sha384-pkpm8x8Aknup+URiIAhz9whdPkPLRoJlhdGYRM/2FJyzzaemjIZoIveJ339G3eFU","sounds/time-up.mp3":"sha384-UeQg6KkMKoeiiRIft0T5z3MU8NM9hLZbx3Smhsz7voAqGb/u7Ndag6lpHOaxqhVY","sounds/win.mp3":"sha384-I8Pyt8U4kbyk9xAoxcimTKSgF9BTr4Nf1t63E/Olnahu2FKJ0G6oLPIVD7CotGiH","editor.css":"sha384-UtVv2Sy+fO5029No4SyC1iW7hUXbIfy4nqF1QP2S8A7M1rUOv5qoJPnxdiNzAF60"}[t];if(n===void 0)throw new Error(`${t} is not one of the editor's published files`);return n}function ybr(t){const n=r=>new URL(`scene-compiler/${r}`,t).href;return{workerUrl:n("worker.js"),wasmUrl:n("esbuild.wasm"),snapshotUrl:n("sdk-snapshot.json"),integrity:{worker:pB("scene-compiler/worker.js"),wasm:pB("scene-compiler/esbuild.wasm"),snapshot:pB("scene-compiler/sdk-snapshot.json")}}}function vbr(t){let n=null;return async()=>(n??(n=sTe(new URL("three/worker.js",t).href,pB("three/worker.js"),"three/worker.js").then(r=>r.text())),n.catch(()=>{n=null}),await n)}let aWe=null;function bbr(t){aWe=t}async function Ozt(t){if(aWe===null)throw new Error("The shared library is not available here.");const n=await sTe(new URL(t,aWe).href,pB(t),t);return new Uint8Array(await n.arrayBuffer())}const xbr=(t,n)=>Ozt(Czt(t,n)),wbr=t=>Ozt(mbr(t)),Sbr=new Set(["a","an","the","of","with","for","and","or","to","in","on","some","model","models"]),Pzt=new Set(["flat","picture","photo","poster","print","painting","frame","sign","banner","billboard","logo","nft","flag","decal","sticker","skybox"]);function Tbr(t){return t.length>4&&t.endsWith("ies")?`${t.slice(0,-3)}y`:t.length>4&&/(x|ch|sh)es$/.test(t)?t.slice(0,-2):t.length>3&&t.endsWith("s")&&!t.endsWith("ss")?t.slice(0,-1):t}const GW=t=>{var n;return((n=(t??"").toLowerCase().match(/[a-z]+|[0-9]+/g))==null?void 0:n.map(Tbr))??[]},pAt=new WeakMap;function Izt(t){let n=pAt.get(t);if(n===void 0){const r=t.tags.flatMap(GW),a=[[GW(t.name),3],[GW(t.subcategory),4],[r,2],[GW(t.category),2],[GW(t.description),1]];n={fields:a,flat:kbr(t,a[1][0])},pAt.set(t,n)}return n}function kbr(t,n){if(n.some(a=>Pzt.has(a)))return!(n.includes("3")&&n.includes("d"));const r=[t.width,t.height,t.depth].filter(a=>a!==void 0);return t.category!=="ground"&&r.length===3&&Math.min(...r)<.03&&Math.max(...r)>.3}function Ebr(t,n,r){const a=[...new Set(GW(n).filter(d=>d.length>1&&!Sbr.has(d)))];if(a.length===0)return[];const s=a.some(d=>Pzt.has(d)),l=t.map(d=>{const{fields:m,flat:_}=Izt(d);let x=0,T=0;for(const A of a){const M=m.reduce((F,[B,H])=>F+(B.includes(A)?H:0),0);M>0&&x++,T+=M}return{a:d,matched:x,score:T,sinks:!s&&_}}).filter(d=>d.matched>0);return l.sort((d,m)=>m.matched-d.matched||Number(d.sinks)-Number(m.sinks)||m.score-d.score||(d.a.triangles??0)-(m.a.triangles??0)),l.slice(0,r).map(d=>d.a)}const Cbr=t=>Izt(t).flat;function w7(t){if(typeof t!="string")throw new Error("An entity id or unique name is required.");const n=QSe(tt.snapshot,t);if(n===null||NS(n)||nR(tt.snapshot,n))throw new Error("No editable entity matches that reference.");return n}function A0e(t){return Array.isArray(t)?t.map(A0e):Xl(t)?typeof t.$case=="string"?{[t.$case]:A0e(t[t.$case])}:Object.fromEntries(Object.entries(t).map(([n,r])=>[n,A0e(r)])):t}const mAt=new Map;function Abr(t){const n=GB(t);if(n!==void 0)return Promise.resolve(n);let r=mAt.get(t);return r===void 0&&(r=rv.componentSchema(t).then(a=>JSON.parse(a),()=>null),mAt.set(t,r)),r}function Nzt(t,n){if(!Xl(t)||!Xl(n))return n;const r={...t};for(const[a,s]of Object.entries(n))r[a]=Nzt(t[a],s);return r}async function Cq(t,n,r,a,s=!1){var T;if(typeof n!="string"||!lJ(n)||!Xl(r))throw new Error("Invalid component update.");const l=((T=tt.snapshot[t])==null?void 0:T[n])??null;if(!s&&JSON.stringify(l)!==JSON.stringify(a))throw new Error("This component changed. Inspect the scene and retry.");const d=FS(t,n);let m=A0e(s?Nzt(l,r):r);n==="Transform"&&Xl(m)&&Xl(l)&&(m={...l,...m});const _=await Abr(n),x=_===null?null:UIt(d,_,m);if(await FI(d,t,n,(x==null?void 0:x.ok)===!0?x.json:JSON.stringify(m)),tt.editStatus.get(d)!=="✓ set")throw new Error("The editor could not apply that component.")}const Obr=20,UBe=t=>Math.round((t??0)*10)/10,Dzt=t=>({x:UBe(t.width),y:UBe(t.height),z:UBe(t.depth)}),Pbr=t=>{var n;return{id:t.id,name:t.name,category:t.subcategory===void 0?t.category:`${t.category}/${t.subcategory}`,size:Dzt(t),triangles:t.triangles??null,kb:Math.round((t.fileSize??0)/1024),tags:t.tags.slice(0,6),...(((n=t.animations)==null?void 0:n.length)??0)>0?{animations:t.animations}:{},...Cbr(t)?{flat:!0}:{}}},hAt=200;function Ibr(t){if(!Xl(t))return t;const{components:n,value:r,...a}=t;return a}async function gXe(t,n,r){var a,s,l,d,m;if(n.throwIfAborted(),!Xl(t))throw new Error("Invalid scene request.");if(t.type==="batch"){if(!Array.isArray(t.requests)||t.requests.length===0||t.requests.length>hAt)throw new Error(`A batch needs 1–${hAt} requests.`);const _=[];for(const x of t.requests){if(Xl(x)&&x.type==="batch")throw new Error("Batches do not nest.");try{_.push({ok:!0,result:Ibr(await gXe(x,n,r))})}catch(T){n.throwIfAborted(),_.push({ok:!1,error:T instanceof Error?T.message:String(T)})}}return{results:_}}if(t.type==="sceneSettings"){if(r===void 0)throw new Error("Scene settings cannot be changed here.");return r({permissions:t.permissions,spawnPoints:t.spawnPoints,parcels:t.parcels,base:t.base})}if(t.type==="outline")return Sur(tt.snapshot,{match:typeof t.match=="string"?t.match:void 0,offset:typeof t.offset=="number"?t.offset:void 0});if(t.type==="check"){const _=await szt(),x=RE(),T=Object.entries(tt.snapshot).filter(([M])=>!NS(M)&&!FA(M,x)),A=T.filter(([,M])=>Xl(M.GltfContainer)&&typeof M.GltfContainer.src=="string");return{visuals:{modelEntities:A.length,modelPaths:[...new Set(A.map(([,M])=>M.GltfContainer.src))],primitiveEntities:T.filter(([,M])=>M.MeshRenderer!==void 0).length},liveParcels:((a=tt.scene)==null?void 0:a.parcels)??[],budget:await jVe(),findings:_.map(M=>({level:M.level,title:M.title,detail:M.detail,...M.entityId===void 0?{}:{entity:Zf(tt.snapshot,M.entityId)??M.entityId}}))}}if(t.type==="inspect"){const _=typeof t.match=="string"?t.match.toLowerCase():"",x=typeof t.offset=="number"&&t.offset>0?Math.floor(t.offset):0,T=Object.entries(tt.snapshot).filter(([A])=>!NS(A)&&!nR(tt.snapshot,A)&&(Zf(tt.snapshot,A)??"").toLowerCase().includes(_));return{selected:[...tt.selected],editMode:tt.frozen,total:T.length,offset:x,entities:T.slice(x,x+150).map(([A,M])=>({id:A,name:Zf(tt.snapshot,A),components:Object.fromEntries(Object.entries(M).filter(([F])=>lJ(F)))}))}}if(t.type==="findModels"){if(typeof t.query!="string")throw new Error("findModels needs query: a few words.");const _=Math.min(Obr,Math.max(1,Number(t.limit??8)||8)),x=await rxe();return{models:Ebr(x,t.query,_).map(Pbr),total:x.length}}if(!tt.frozen)throw new Error("Stop Play before changing the scene.");if(t.type==="addSound"){if(!gbr(t.name))throw new Error(`addSound needs name, one of: ${Azt.join(", ")}.`);const _=hbr(t.name);(await iv()).includes(_)||await Qx(_,await wbr(t.name)),await sG(_);const{durationSeconds:x,loop:T}=_br(t.name);return{path:_,durationSeconds:x,loop:T}}if(t.type==="placeModel"){if(typeof t.id!="string")throw new Error("placeModel needs the id of a findModels result.");await rxe();const _=VSe(t.id);if(_===void 0)throw new Error("No catalog model has that id. Use findModels.");const x=await vYe(_),T=await Nbr(x);return{...await _At(t,x,_.name,n,r),size:Dzt(_),...T}}if(t.type==="buildModel"){const _=typeof t.name=="string"&&t.name.trim()!==""?t.name:t.into===void 0?"":Zf(tt.snapshot,w7(t.into))??String(t.into),x=_.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(x===""||x.length>60)throw new Error("buildModel needs name (or into): 1–60 letters or digits.");if(typeof t.code!="string"||t.code.length>6e4)throw new Error("buildModel needs code: the model script, under 60,000 characters.");const{bytes:T,clips:A,library:M,warnings:F}=await Q0r(t.code,_,n),B=kH(T),H=new Map(M.flatMap(lt=>V0r.map(Et=>[Czt(lt,Et),{name:lt,map:Et}]))),ee=B.sharedImages.filter(lt=>!H.has(lt));if(B.externalResources.some(lt=>!B.sharedImages.includes(lt))||ee.length>0)throw new Error("The model refers to files outside the shared materials.");const Z={triangles:B.triangles,materials:B.materials.length,textures:B.textures-B.sharedImages.length,largestTexture:B.largestImage},K=H0r(Z,B.textureProblems);if(K.length>0)throw new Error(`The model is over budget (${K.join(", ")}); simplify it and build again.`);const _e=await lUt(),he=Z.textures+B.sharedImages.filter(lt=>!_e.shared.has(`models/${lt}`)).length;if(_e.used+he>_e.limit)throw new Error(`The scene has ${Math.max(0,_e.limit-_e.used)} of its ${_e.limit} textures left and this model would add ${he}. Reuse materials the scene already has, give parts seen from afar relief:false, use fewer materials, or grow the parcels.`);const te=new Uint8Array(await crypto.subtle.digest("SHA-256",T)),de=`models/${x}-${[...te.slice(0,4)].map(lt=>lt.toString(16).padStart(2,"0")).join("")}.glb`;await Dbr(),await Qx(`models/src/${x}.js`,new TextEncoder().encode(t.code));for(const lt of B.sharedImages){const{name:Et,map:_t}=H.get(lt),At=`models/${lt}`;await DS(At).then(()=>!0,()=>!1)||await Qx(At,await xbr(Et,_t)),await sG(At)}await Qx(de,T),await sG(de);const Ee=await _At({...t,name:t.into===void 0?_:void 0},de,_,n,r);return OJn({name:_,path:de,triangles:Z.triangles}),{...Ee,script:`models/src/${x}.js`,stats:Z,clips:A,materials:M,...F.length>0?{warnings:F}:{},budget:C0e,kb:Math.round(T.length/1024),scene:await jVe()}}if(t.type==="createEntity"){if(typeof t.name!="string"||!t.name.trim()||t.name.length>100)throw new Error("Choose an entity name of 1–100 characters.");const _=t.parent===void 0||t.parent==="0"?0:Number(w7(t.parent)),x=new Set(Object.keys(tt.snapshot));if(t.components!==void 0&&!Xl(t.components))throw new Error("components must map component names to values.");await SYe(t.name,_);const T=tt.activeEntity;if(T===null||x.has(T))throw new Error("The entity could not be created.");const A=[];for(const[M,F]of Object.entries(t.components??{}))try{await Cq(T,M,F,((s=tt.snapshot[T])==null?void 0:s[M])??null)}catch(B){A.push(`${M}: ${B instanceof Error?B.message:String(B)}`)}return{id:T,components:tt.snapshot[T],...A.length>0?{failed:A}:{}}}if(t.type==="move"){const _=w7(t.to),x=t.by;if(!Xl(x)||!["x","y","z"].some(F=>typeof x[F]=="number"))throw new Error("move needs by: {x, y, z} in metres.");const T=(l=tt.snapshot[_])==null?void 0:l.Transform,A=Xl(T)&&Xl(T.position)?T.position:{x:0,y:0,z:0},M=Object.fromEntries(["x","y","z"].map(F=>[F,Number(A[F]??0)+(typeof x[F]=="number"?x[F]:0)]));return await Cq(_,"Transform",{position:M},null,!0),{id:_,position:M}}if(t.type==="setComponent"){const _=w7(t.to);if("patch"in t)await Cq(_,t.component,t.patch,null,!0);else{if(!("expected"in t))throw new Error("Invalid component update.");await Cq(_,t.component,t.value,t.expected)}return{id:_,component:t.component,value:(d=tt.snapshot[_])==null?void 0:d[String(t.component)]}}if(t.type==="removeComponent"){const _=w7(t.to),x=t.component;if(typeof x!="string"||!lJ(x)||x==="Transform"||x===yf)throw new Error("That component cannot be removed.");return((m=tt.snapshot[_])==null?void 0:m[x])===void 0?{id:_,component:x,removed:!1}:(UYe(_,x),{id:_,component:x,components:tt.snapshot[_]})}if(!["attachScript","setParams","placePrefab"].includes(String(t.type)))throw new Error("Unsupported scene request.");return t.type!=="placePrefab"&&w7(t.to),Q$t(JSON.stringify({version:1,requests:[t]}),tt.activeEntity)}async function Nbr(t){let n;try{n=kH(await DS(t))}catch{return{warning:"Its textures could not be counted; run check to see the scene budget."}}const r=await lUt(),s=Object.values(tt.snapshot).some(d=>Xl(d.GltfContainer)&&d.GltfContainer.src===t)?0:n.textures-n.sharedImages.length+n.sharedImages.filter(d=>!r.shared.has(oUt(t,d))).length,l=r.limit-r.used-s;return{textures:n.textures,materials:n.materials.length,sceneTexturesLeft:l,...l<0?{warning:`The scene now uses ${r.used+s} of its ${r.limit} textures; explorers warn above that. Swap it for a model with fewer textures, or grow the parcels.`}:{}}}async function _At(t,n,r,a,s){var m;const l={src:n,visibleMeshesCollisionMask:3},d=Object.fromEntries(["position","rotation","scale"].filter(_=>Xl(t[_])).map(_=>[_,t[_]]));try{if(t.into!==void 0){const x=w7(t.into);await Cq(x,"GltfContainer",l,null,!0);for(const T of["MeshRenderer","Material","MeshCollider"])((m=tt.snapshot[x])==null?void 0:m[T])!==void 0&&UYe(x,T);return await Cq(x,"Transform",{scale:{x:1,y:1,z:1},...d},null,!0),{id:x,model:n,components:tt.snapshot[x]}}const _=await gXe({type:"createEntity",name:t.name??r,parent:t.parent,components:{Transform:{position:{x:8,y:0,z:8},...d},GltfContainer:l}},a,s);return{...Xl(_)?_:{},model:n}}finally{Xf({type:"resync"})}}const gAt="models/src/";async function Dbr(){const t=await Zm(".dclignore").catch(async n=>{if((await iv()).includes(".dclignore"))throw n;return""});t.split(`
|
|
32456
32456
|
`).some(n=>n.trim()===gAt)||await nw(".dclignore",`${t}${t===""||t.endsWith(`
|
|
32457
32457
|
`)?"":`
|
|
32458
32458
|
`}${gAt}
|
|
@@ -34664,4 +34664,4 @@ ${n}
|
|
|
34664
34664
|
${r}`));return"w"+Array.from(new Uint8Array(a).slice(0,16),s=>s.toString(16).padStart(2,"0")).join("")}function Hxr(t){return`${t.file===void 0?"":`${t.file}:${t.line??1}:${t.column??0}: `}${t.severity==="error"?"ERROR":"WARNING"}: ${t.message}`}function Qxr(t){return t.length<=3?t.join(", "):`${t.slice(0,3).join(", ")} and ${t.length-3} more`}function Yxr(t,n){const r=N1(t.get("package.json"));for(const a of[r==null?void 0:r.devDependencies,r==null?void 0:r.dependencies]){const s=typeof a=="object"&&a!==null?a["@dcl/sdk"]:void 0;if(typeof s=="string"&&s!==n)return`⚠ This project asks for @dcl/sdk ${s}; the editor builds it with ${n}.`}return null}function Xxr(t){const{emit:n,log:r}=t;let a=null,s=!1,l=null,d=Promise.resolve();const m=A=>{const M=d.then(A,A);return d=M.catch(()=>{}),M};async function _(){if(s)throw new Error("The editor was closed");a===null&&(l=null);const A=a??wvr(t.urls);a=A;try{const M=await A.ready;return{builder:A,sdkVersion:M.sdkVersion,info:M}}catch(M){throw A.dispose(),a===A&&(a=null),M}}async function x(A,M,F){const{builder:B,info:H}=await _();let ee=!1;const Z=await Wxr(M,t.packages,H.snapshot,_e=>{t.onPackages(A,_e),F&&!ee&&r("Downloading packages from npm…"),ee=!0});Z.lockFile!==void 0&&(M.set(E3,Z.lockFile),await t.saveLock(A,Z.lockFile));const K=Z.lock===null?"":gzt(Z.lock);if(K!==l)try{await B.setPackages(Z.lock,t.packages),l=K}catch(_e){F&&r(`⚠ ${XAt(_e)}`),await B.setPackages(null),l=""}if(t.onPackages(A,Z.status),!(!F||Z.status===null)){if(Z.status.state==="error")r(`✖ ${Z.status.message??"The packages could not be installed"}`);else if(Z.downloaded>0){const _e=Object.entries(Z.status.installed).map(([he,te])=>`${he} ${te}`);r(`✔ Packages frozen into the scene: ${_e.join(", ")} (${Z.status.total} in all)`)}for(const _e of Z.status.warnings)r(`⚠ ${_e}`)}}function T(A,M,F=A){const B=rWe(t.pageDir,F),H=new Set;let ee=null,Z=null,K=!0,_e=!1,he=!1,te=null;const de=Et=>(n({type:"failed",message:Et}),r(`✖ Build failed: ${Et.split(`
|
|
34665
34665
|
`)[0]}`),!1);async function Ee(Et){const _t=performance.now();n({type:"buildStarted",changed:Et}),r(Et.length===0?"Building the scene…":`Rebuilding: ${Qxr(Et)}`);try{const{builder:At,sdkVersion:vt}=await _(),Ve=Et.length===0?Yxr(M,vt):null;Ve!==null&&r(Ve);const Qt=Et.length===0||Et.includes("package.json")||Et.includes(E3),{snapshot:We,result:Fe}=await m(async()=>{(Qt||l!==te)&&(await x(A,M,!0),te=l);const xt=new Map(M);return{snapshot:xt,result:await At.build(xt)}});if(he)return!1;const zt=Fe.diagnostics.filter(xt=>xt.severity==="error"||xt.file===void 0||We.has(xt.file));n({type:"diagnostics",diagnostics:zt.map(({severity:xt,message:ht,file:Rt,line:qt,column:Wt})=>({severity:xt,message:ht,file:Rt,line:qt,column:Wt}))});for(const xt of zt)r(Hxr(xt));if(!Fe.ok){const xt=Fe.events.find(ht=>ht.type==="failed");return de((xt==null?void 0:xt.type)==="failed"?xt.message:"The build produced no bundle")}const ft=N1(We.get("scene.json"));return ft===null?de("scene.json is missing or is not valid JSON"):(await N0r({realmUrl:B,projectId:F,files:We,buildOutputs:Fe.outputs,sceneJson:ft,sdkVersion:vt,machineId:await t.machineId(F)}),he?!1:(n({type:"bundleSaved"}),r(`✔ Built in ${Math.round(performance.now()-_t)} ms`),!0))}catch(At){return he?!1:de(XAt(At))}}function lt(){return he?Promise.resolve(!1):(Z!==null||(Z=(async()=>{for(;(K||H.size>0)&&!he;){const Et=K?[]:[...H];K=!1,H.clear(),_e=await Ee(Et)}return _e&&!he})().finally(()=>{Z=null})),Z)}return{id:A,files:M,start:lt,flush(){return ee!==null&&clearTimeout(ee),ee=null,lt()},async published(){const Et=await(await caches.open(Sxe)).match(iWe(B)),_t=await(Et==null?void 0:Et.json().catch(()=>{})),At=_t==null?void 0:_t.entity;return(At==null?void 0:At.id)===wzt(F,await t.machineId(F))},changed(Et){he||(H.add(Et),ee!==null&&clearTimeout(ee),ee=setTimeout(()=>{ee=null,lt()},qxr))},stop(){he=!0,ee!==null&&clearTimeout(ee)}}}return{realmUrl:A=>rWe(t.pageDir,A),open:T,async build(A,M,F){const{builder:B,sdkVersion:H}=await _();return m(async()=>(await x(A,M,!1),{...await B.build(M,F),sdkVersion:H}))},install:(A,M)=>m(()=>x(A,M,!1)),dispose(){s=!0,a==null||a.dispose(),a=null}}}const Zxr=200,Kxr=2e3,ewr=/^\((?:no logs|\+\d+ older entries not retained)\)$/;function twr(t,n){for(let r=Math.min(t.length,n.length);r>0;r--){const a=t.length-r;if(n.slice(0,r).every((s,l)=>s===t[a+l]))return n.slice(r)}return[...n]}function nwr(t,n){let r=[],a=!1,s;const l=async()=>{try{const d=await t(`scene_logs ${Zxr} --server`);if(a)return;const m=d.split(`
|
|
34666
34666
|
`).filter(_=>_.trim()!==""&&!ewr.test(_.trim()));for(const _ of twr(r,m))n(_);r=m}catch{}a||(s=setTimeout(()=>void l(),Kxr))};return l(),()=>{a=!0,clearTimeout(s)}}function rwr(t,n,r){r.throwIfAborted();const a=tt.scene,s=[...t].sort().join(";");return new Promise((l,d)=>{const m=()=>{clearTimeout(M),T(),r.removeEventListener("abort",A)},_=F=>{m(),d(F)},x=()=>{var B;tt.scene===a||tt.status!=="ready"||!tt.frozen||((B=tt.scene)==null?void 0:B.parcels.map(H=>`${H.x},${H.y}`).sort().join(";"))!==s||(m(),l())},T=fqe(x),A=()=>_(r.reason),M=setTimeout(()=>_(new Error("The preview has not loaded the new parcels. Retry sceneSettings before building outside the current layout.")),9e4);r.addEventListener("abort",A,{once:!0});try{n(),x()}catch(F){_(F)}})}const iwr=new Set(["node_modules",".git","bin","dist"]),awr=300*1024,swr=56,owr=5;function cwr(t){const n=t.origin,r=typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null;return r!==null&&(r.source==="import"||r.source==="github")?r:{...r??{},source:"user"}}function lwr(t,n){const r=new Map;let a=new Map;function s(m,_){if(_.size>awr)return t.blob(m,_.hash);let x=r.get(_.hash);return x===void 0&&(x=t.blob(m,_.hash),r.set(_.hash,x),x.catch(()=>r.delete(_.hash))),x}const l={async folders(){const m=await t.list();return a=new Map(m.map(x=>[x.name,x])),(await Promise.all(m.map(async x=>{const T=x.files["data.json"];if(T===void 0)return null;const A=await s(x.name,T).then(F=>new TextDecoder().decode(F),()=>null);if(A===null)return null;const M=Object.fromEntries(Object.entries(x.files).map(([F,B])=>[F,B.size]));return{name:x.name,data:A,files:M}}))).filter(x=>x!==null)},async read(m,_){var T;const x=(T=a.get(m.name))==null?void 0:T.files[_];if(x===void 0)throw new Error(`${m.name}/${_} is not in your library`);return s(m.name,x)}};async function d(m,_){const x={},T=new Map;for(const[M,F]of _){const B=await n(F);x[M]={hash:B,size:F.length},T.set(B,F)}const A=[...T].map(([M,F])=>({hash:M,size:F.length}));for(const M of await t.uploads(m,A)){const F=T.get(M.hash);F!==void 0&&await t.putBlob(M,F)}await t.put(m,x)}return{tree:l,async copyOut(m,_){const[x,T,A]=_.split("/");if(x!=="custom"||T===void 0||A!==void 0||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(T))throw new Error(`not a prefab folder: ${_}`);const M=`${_}/`,F=new Map;for(const[te,de]of m.files()){const Ee=te.slice(M.length);te.startsWith(M)&&!Ee.split("/").some(lt=>iwr.has(lt))&&F.set(Ee,de)}const B=F.get("data.json"),H=B===void 0?null:Oq(new TextDecoder().decode(B));if(H===null)throw new Error(`${_} has no readable data.json`);const ee={...H,id:typeof H.id=="string"?H.id:crypto.randomUUID(),origin:cwr(H)},Z=`${JSON.stringify(ee,null,2)}
|
|
34667
|
-
`;F.set("data.json",new TextEncoder().encode(Z));const K=hWe(tVt(H,T)).slice(0,swr).replace(/_+$/,"")||"prefab",_e=new Set((await t.list()).map(te=>te.name));let he=1;for(let te=0;te<owr;te++){let de=K;for(;_e.has(de);)de=`${K}_${++he}`;try{return await d(de,F),{ref:`user:${de}`,scope:"user",data:Z}}catch(Ee){if(!(Ee instanceof Vzt))throw Ee;_e.add(de)}}throw new Error("could not find a free name in your library — try again")},remove:m=>t.remove(m)}}const ZAt=new WeakMap;function uwr(t){let n=ZAt.get(t);return n===void 0&&(n=crypto.subtle.digest("SHA-256",new Uint8Array(t)).then(r=>[...new Uint8Array(r)].map(a=>a.toString(16).padStart(2,"0")).join("")),ZAt.set(t,n)),n}async function fwr(t){const n=t.get(".dclignore"),r=_Xe(t.keys(),n===void 0?void 0:new TextDecoder().decode(n)).filter(l=>l!==E3),a=new Map;let s=0;for(const l of r){const d=t.get(l);d!==void 0&&(a.set(await uwr(d),d.byteLength),s++)}return{bytes:[...a.values()].reduce((l,d)=>l+d,0),files:s}}const KAt=4e3,dwr=4e6,pwr=VIt*24*60*60*1e3,mwr="assets/images",hwr=3e3,_wr=100,gwr="Sign in to keep prefabs in your own library. The built-in prefabs work without it.",ywr=t=>t instanceof Error?t.message:String(t);function qBe(t,n){var r,a,s;return{realm:n.replace(/\/$/,""),systemScene:"",position:((r=t.scene)==null?void 0:r.base)??((s=(a=t.scene)==null?void 0:a.parcels)==null?void 0:s[0])??"0,0",spawn:Kbr(t),spawnPoints:JSON.stringify(Array.isArray(t.spawnPoints)?t.spawnPoints:[])}}const vwr=({host:t,webBuild:n})=>{const r=new N1r(E1r()),a=JA(t),s=a===null||a.services.projects===null?null:zzt(a.services.projects,(Hn,Rr)=>a.signedFetch(Hn,Rr)),l=()=>{const{address:Hn,isGuest:Rr}=t.identity();return Rr||Hn===null?null:Hn.toLowerCase()},d=[],m=[],_=[],x=[],T=[],A=Hn=>{d.push(Hn),d.length>KAt&&d.splice(0,d.length-KAt);for(const Rr of m)Rr(Hn)},M=Hn=>{for(const Rr of _)Rr(Hn)},F=new Map,B=new Set,H=a3t.then(Gxr),ee=Xxr({pageDir:t.pageDir,urls:n,machineId:async Hn=>Jxr(await H,l()??"guest",Hn),emit:M,log:A,packages:r.packages,saveLock:async(Hn,Rr)=>{await r.write(Hn,E3,Rr),ft.touched(Hn,E3),(K==null?void 0:K.id)===Hn&&K.files.set(E3,Rr)},onPackages:(Hn,Rr)=>{if(Rr===null){F.delete(Hn);return}F.set(Hn,Rr);for(const Fi of B)Fi(Hn,Rr)}});let Z=null,K=null,_e=null,he=null;async function te(Hn){var ta;const Rr=(ta=(await r.list()).find(xs=>xs.id===Hn))==null?void 0:ta.previewId;if(Rr!==void 0)return Rr;const Fi="p"+Array.from(crypto.getRandomValues(new Uint8Array(16)),xs=>xs.toString(16).padStart(2,"0")).join("");return await r.patch(Hn,{previewId:Fi}),Fi}async function de(Hn){const Rr=new URL("preview/",t.pageDir).href,Fi=await caches.open(Sxe);for(const ta of await Fi.keys())ta.url.startsWith(Rr)&&(Hn===null||!ta.url.startsWith(Hn))&&await Fi.delete(ta)}let Ee=0,lt=Promise.resolve(),Et=Promise.resolve();const _t=B0r({service:(a==null?void 0:a.services.projects)??null,fetch:(Hn,Rr)=>a===null?Promise.reject(new Error("The assistant service is not configured.")):a.signedFetch(Hn,Rr),wallet:l,memory:{read:async(Hn,Rr)=>{const Fi=await r.assistantMemory(Hn,Rr);return Xl(Fi)&&typeof Fi.id=="string"&&typeof Fi.key=="string"?{id:Fi.id,key:Fi.key}:null},write:(Hn,Rr,Fi)=>r.setAssistantMemory(Hn,Rr,Fi)},project:()=>{const Hn=si();return{id:Hn.id,tools:{files:()=>Hn.files,write:(Rr,Fi,ta,xs)=>Ve(Hn.id,Rr,Fi,{expected:ta,signal:xs}),assets:zbr({files:()=>Hn.files,write:(Rr,Fi,ta,xs)=>Ve(Hn.id,Rr,Fi,{expected:ta,signal:xs})}),scene:(Rr,Fi)=>gXe(Rr,Fi,async ta=>{var uf,di,Cl;const xs=gl=>{var Jg,_u;return JSON.stringify([(Jg=gl==null?void 0:gl.scene)==null?void 0:Jg.parcels,(_u=gl==null?void 0:gl.scene)==null?void 0:_u.base])};await YA();const Lo=xs(N1(await vt(Hn.id,"scene.json")));await ot(Hn.id,gl=>r1r(gl,ta));const fl=N1(await vt(Hn.id,"scene.json")),Hd=xs(fl)!==Lo,cr=((uf=fl==null?void 0:fl.scene)==null?void 0:uf.parcels)??[],Jl=(di=tt.scene)==null?void 0:di.parcels.map(gl=>`${gl.x},${gl.y}`).sort().join(";");if(Hd||Jl!==[...cr].sort().join(";")){if(!await Hn.flush())throw new Error("The scene did not build. Fix the code and retry sceneSettings to load the new parcels.");Fi.throwIfAborted();const gl=await te(Hn.id);Z=qBe(fl??{},ee.realmUrl(gl)),await rwr(cr,()=>{for(const Jg of x)Jg(Z)},Fi)}else if(Z!==null){const gl=qBe(fl??{},Z.realm);(gl.spawn!==Z.spawn||gl.spawnPoints!==Z.spawnPoints)&&(Z={...Z,spawn:gl.spawn,spawnPoints:gl.spawnPoints},jcr(gl.spawn,gl.spawnPoints))}return{requiredPermissions:(fl==null?void 0:fl.requiredPermissions)??[],spawnPoints:(fl==null?void 0:fl.spawnPoints)??[],parcels:cr,base:((Cl=fl==null?void 0:fl.scene)==null?void 0:Cl.base)??null,previewReady:!0}}),written:z0r(),view:(Rr,Fi)=>jbr(Rr,Fi),playtest:Qbr,build:async Rr=>{Rr.throwIfAborted(),await Et;const Fi=await ee.build(Hn.id,new Map(Hn.files));if(Rr.throwIfAborted(),!Fi.ok)return{ok:!1,diagnostics:Fi.diagnostics};const ta=await qbr();return Rr.throwIfAborted(),{ok:!0,diagnostics:Fi.diagnostics,run:ta}}}}}});function At(){_t.reset(),he==null||he(),he=null,K!==null&&(K.stop(),r.close(K.id),ft.flush(K.id),K=null,_e=null)}async function vt(Hn,Rr){return(K==null?void 0:K.id)===Hn?K.files.get(Rr):r.read(Hn,Rr).catch(Fi=>{if(!uI(Fi))throw Fi})}function Ve(Hn,Rr,Fi,ta){const xs=Et.then(async()=>{if(ta==null||ta.signal.throwIfAborted(),ta!==void 0&&((K==null?void 0:K.id)!==Hn||!L0r(K.files.get(Rr),ta.expected)))throw new Error("This file changed. Read it again before writing.");await r.write(Hn,Rr,Fi),ft.touched(Hn,Rr),(K==null?void 0:K.id)===Hn&&(K.files.set(Rr,Fi),K.changed(Rr))});return Et=xs.catch(Lo=>console.error("[editor] file write failed",Lo)),xs}function Qt(Hn,Rr){const Fi=Et.then(async()=>{const ta=await r.remove(Hn,Rr);return ta&&ft.touched(Hn,Rr),ta&&(K==null?void 0:K.id)===Hn&&K.files.delete(Rr)&&K.changed(Rr),ta});return Et=Fi.catch(ta=>console.error("[editor] file removal failed",ta)),Fi}function We(Hn){const Rr=si();if(Rr.id!==Hn)throw new Error("that scene is not the one open");return{files:()=>Rr.files,write:(Fi,ta)=>Ve(Hn,Fi,ta),remove:async Fi=>{await Qt(Hn,Fi)}}}async function Fe(Hn){var ta;const Rr=N1(await vt(Hn,"scene.json").catch(()=>{})),Fi=(((ta=Rr==null?void 0:Rr.display)==null?void 0:ta.title)??"").replace(/[\x00-\x1f\x7f]/g,"").replace(new RegExp(Uzt.source,"g"),"").trim().slice(0,_wr);return Fi===""?Hn:Fi}async function zt(Hn,Rr){const Fi=(await r.list()).find(xs=>xs.id===Hn);if(Fi===void 0)return null;const ta=await r.duplicate(Hn,`${Fi.name} ${Rr}`,ft.remoteIds());return await ot(ta.id,xs=>{var Lo;return{...xs,display:{...xs.display??{},title:`${((Lo=xs.display)==null?void 0:Lo.title)||Fi.name} ${Rr}`}}}),ta.id}const ft=B1r({store:r,session:()=>{const Hn=l();return s===null||Hn===null?null:{api:s,wallet:Hn}},account:()=>s===null?"unavailable":l()===null?"guest":"on",hash:bxe,title:Fe,duplicate:async Hn=>{const Rr=await zt(Hn,zIt(new Date));if(Rr===null)throw new Error("The scene is no longer on this device");return Rr}});let xt=!1,ht=0;async function Rt(){const Hn=++ht,Rr=l()!==null&&(await _t.shell.aiProviders()).some(Fi=>Fi.available);Hn!==ht||Rr===xt||(xt=Rr,W0())}Rt();let qt=l();const Wt=setInterval(()=>{const Hn=l();Hn!==qt&&(qt=Hn,_t.reset(),W0(),Rt(),ft.refresh(!0),de(_e).catch(Rr=>console.warn("[editor] could not clear the previews",Rr)))},hwr),Le=()=>{document.visibilityState==="hidden"&&ft.flush()};document.addEventListener("visibilitychange",Le);const Ze=new Set;async function ot(Hn,Rr){const Fi=N1(await vt(Hn,"scene.json"));if(Fi===null)throw new Error("scene.json is missing or is not valid JSON");await Ve(Hn,"scene.json",wAt(Rr(Fi)))}async function nn(Hn,Rr){if(Rr==null||Rr==="")return null;const Fi=await vt(Hn,Rr).catch(()=>{});return Fi===void 0||Fi.length>dwr?null:SAt(Rr,Fi)}async function On(Hn,Rr=ft.status().projects){var ta,xs,Lo,fl;const Fi=N1(await vt(Hn.id,"scene.json").catch(()=>{}));return{sync:Rr[Hn.id],path:Hn.id,name:Hn.name,title:((ta=Fi==null?void 0:Fi.display)==null?void 0:ta.title)||Hn.name,world:((xs=Fi==null?void 0:Fi.worldConfiguration)==null?void 0:xs.name)||null,parcels:Array.isArray((Lo=Fi==null?void 0:Fi.scene)==null?void 0:Lo.parcels)?Fi.scene.parcels.length:0,thumbnail:await nn(Hn.id,(fl=Fi==null?void 0:Fi.display)==null?void 0:fl.navmapThumbnail),favourite:Hn.favourite,lastOpened:Hn.lastOpened,published:Hn.published,deletedAt:Hn.deletedAt??void 0}}async function fn(Hn,Rr){var ta,xs;At(),d.length=0,M({type:"sessionStarted"});const Fi=Lo=>{if(At(),Rr===Ee){A(`✖ ${Lo}`);for(const fl of T)fl(Lo)}};try{if(await ft.prepareOpen(Hn,(uf,di)=>A(`Downloading from your account… ${uf}/${di}`)),Rr!==Ee)return;if(!await r.open(Hn)){Fi("This scene is open in another tab. Close it there to edit it here.");return}const Lo=await r.readAll(Hn).then(async uf=>{for(const[di,Cl]of Cvr(uf))await Ve(Hn,di,Cl),uf.set(di,Cl);return uf}).catch(uf=>{throw r.close(Hn),uf});if(Rr!==Ee){r.close(Hn);return}const fl=await te(Hn);if(Rr!==Ee){r.close(Hn);return}const Hd=ee.open(Hn,Lo,fl);K=Hd;const cr=ee.realmUrl(fl);if(_e=cr,A(`▶ Opening ${((xs=(ta=N1(Hd.files.get("scene.json")))==null?void 0:ta.display)==null?void 0:xs.title)||Hn}`),!await Hd.start()&&!await Hd.published()){if(Rr!==Ee)return;A("✖ The scene did not build.");for(const uf of T)uf("The scene did not build.");return}if(await r.patch(Hn,{lastOpened:Date.now()}),Rr!==Ee){At();return}const Jl=N1(Hd.files.get("scene.json"))??{};Z=qBe(Jl,cr),he=nwr(uf=>t.engineConsole(uf),A);for(const uf of x)uf(Z)}catch(Lo){Fi(ywr(Lo))}}function kn(Hn){Z=null;const Rr=++Ee,Fi=_t.reset(),ta=lt.then(async()=>{await Fi,await Et,Rr===Ee&&await Hn(Rr)});return lt=ta.catch(xs=>console.error("[editor] project transition failed",xs)),ta}function si(){if(K===null)throw new Error("no project is open");return K}const St={saveFile:async({path:Hn,content:Rr})=>Ve(si().id,Hn,Rr),getFile:async({path:Hn})=>{const Rr=si().files.get(Hn)??Nxr(Hn);if(Rr===void 0)throw new Error(`no such file: ${Hn}`);return{content:Rr}},removeFiles:async({filePaths:Hn})=>{const Rr=si(),Fi=[],ta=[];for(const xs of Hn)(await Qt(Rr.id,xs).catch(()=>!1)?Fi:ta).push(xs);return{success:Fi,failed:ta}},getFilesSizes:async({path:Hn,ignore:Rr})=>{const Fi=Hn===""?"":`${Hn.replace(/\/+$/,"")}/`;return{files:[...si().files.keys()].filter(xs=>xs.startsWith(Fi)&&!xs.split("/").some(Lo=>Rr.includes(Lo))).sort().map(xs=>({path:xs}))}}},Mi={async find(Hn){return(await r.list()).some(Rr=>Rr.id===Hn)?!0:(await ft.refresh(!0),ft.remoteOnly().some(Rr=>Rr.id===Hn))},files:async Hn=>(K==null?void 0:K.id)===Hn?new Map(K.files):r.readAll(Hn),manifest:Hn=>ft.manifest(Hn),build:async(Hn,Rr)=>ee.build(Hn,await Mi.files(Hn),Rr),dependencies:async Hn=>Fzt(await vt(Hn,"package.json")),onImported:Hn=>(Ze.add(Hn),()=>Ze.delete(Hn))},Br=a===null?null:k1r({host:a,setWorld:async(Hn,Rr)=>{var ta,xs;((xs=(ta=N1(await vt(Hn,"scene.json")))==null?void 0:ta.worldConfiguration)==null?void 0:xs.name)!==Rr&&await ot(Hn,Lo=>({...Lo,worldConfiguration:{...Lo.worldConfiguration??{},name:Rr}}))},files:Hn=>Mi.files(Hn),build:(Hn,Rr)=>ee.build(Hn,Rr,{production:!0}),published:(Hn,Rr)=>r.patch(Hn,{published:Rr})}),go=(a==null?void 0:a.services.projects)==null?null:lwr(M1r(a.services.projects,(Hn,Rr)=>a.signedFetch(Hn,Rr)),bxe);qlr(vbr(t.editorBase)),bbr(t.editorBase),adr(async()=>fwr(await Mi.files(si().id)));const _a=Uxr({builtin:exr(t.editorBase,pB("prefabs/catalog.json"),sTe),user:()=>go!==null&&l()!==null?go.tree:null}),uc={...(a==null?void 0:a.services.projects)==null?{}:{..._t.shell,aiOffered:()=>xt,aiTranscript:()=>{const Hn=qt;if(Hn===null||K===null)return null;const Rr=K.id;return{owner:`${Rr}@${Hn.toLowerCase()}`,load:()=>r.transcript(Rr,Hn),save:Fi=>r.setTranscript(Rr,Hn,Fi)}}},pickProject:async()=>{},openProject:Hn=>kn(Rr=>fn(Hn,Rr)),relaunchProject:Hn=>kn(Rr=>fn(Hn,Rr)),closeProject:()=>kn(async()=>{At(),M({type:"sessionStarted"}),A("■ Scene closed"),await de(null).catch(Hn=>console.warn("[editor] could not clear the previews",Hn))}),getState:async()=>{const Hn=await r.list(),Rr=ft.status().projects,Fi=ft.remoteOnly().map(ta=>({path:ta.id,name:ta.name,title:ta.name,world:null,parcels:0,thumbnail:null,remoteOnly:!0}));return{recentProjects:[...Hn].sort((ta,xs)=>xs.lastOpened-ta.lastOpened).map(ta=>ta.id),projects:[...await Promise.all(Hn.map(ta=>On(ta,Rr))),...Fi],logs:[...d],bevyWebDir:"",editorSceneDir:"",webPort:0,scenePort:0,editorScenePort:0,favourites:Hn.filter(ta=>ta.favourite).map(ta=>ta.id)}},onStackLog:Hn=>{m.push(Hn)},onBuildEvent:Hn=>{_.push(Hn)},onServersReady:Hn=>{x.push(Hn)},requestReady:async()=>Z,onServersError:Hn=>{T.push(Hn)},toggleFavourite:async Hn=>{const Rr=(await r.list()).find(Fi=>Fi.id===Hn);Rr!==void 0&&await r.patch(Hn,{favourite:!Rr.favourite})},deleteProject:async Hn=>{const Rr=await r.trash(Hn);return Rr&&ft.trashed(Hn),Rr},trashedProjects:async()=>Promise.all((await r.trashed()).map(Hn=>On(Hn))),restoreProject:async Hn=>{const Rr=await r.restore(Hn);return Rr&&ft.restored(Hn),Rr},syncStatus:async()=>(ft.refresh(),ft.status()),onSyncStatus:Hn=>ft.subscribe(Hn),resolveSyncConflict:(Hn,Rr)=>ft.resolve(Hn,Rr),exportProject:async Hn=>X1r(await Fe(Hn),await Mi.files(Hn)),importProject:async Hn=>{const Rr=await K1r(Hn,async(Fi,ta)=>{const xs=await r.create(Fi,ta,{taken:ft.remoteIds()});return ft.touched(xs.id,"scene.json"),xs.id});if((Rr==null?void 0:Rr.ok)===!0){const{id:Fi,needsPackages:ta}=Rr.report;Object.keys(ta).length>0&&r.readAll(Fi).then(xs=>ee.install(Fi,xs)).catch(xs=>console.warn("[editor] could not install the packages of",Fi,xs));for(const xs of Ze)xs(Rr.report)}return Rr},projectPackages:async Hn=>F.get(Hn)??null,onProjectPackages:Hn=>(B.add(Hn),()=>B.delete(Hn)),...Br===null||a===null?{}:{publishScene:(Hn,Rr,Fi)=>Br.publish(Hn,Rr,Fi),publishStop:async()=>Br.stop(),publishWorlds:async()=>{const Hn=l();return Hn===null?[]:S1r(Hn,a.services.worldsContent.replace(/\/+$/,""))}},canImportFolder:Y1r(),renameProject:(Hn,Rr)=>ot(Hn,Fi=>({...Fi,display:{...Fi.display??{},title:Rr.trim()}})),duplicateProject:Hn=>zt(Hn,"copy"),sceneTemplates:async()=>Oxr(),createScene:async(Hn,Rr,Fi)=>{const ta=Kzt(Fi),xs=N1(ta.get("scene.json"));if(xs===null)throw new Error(`template not found: ${Fi}`);ta.set("scene.json",wAt({...xs,display:{...xs.display??{},title:Rr.trim()}}));const Lo=await r.create(Rr,ta,{taken:ft.remoteIds()});return ft.touched(Lo.id,"scene.json"),Lo.id},openExternal:async Hn=>{/^https?:$/.test(new URL(Hn).protocol)&&window.open(Hn,"_blank","noopener,noreferrer")},compositeEntityIds:async Hn=>{for(const Rr of e1r){const Fi=await vt(Hn,Rr);if(Fi!==void 0)return t1r(new TextDecoder().decode(Fi))}return[]},sceneSettings:async Hn=>{const Rr=N1(await vt(Hn,"scene.json"));if(Rr===null)throw new Error("scene.json is missing or is not valid JSON");const Fi=Ybr(Rr);return{...Fi,thumbnail:await nn(Hn,Fi.thumbnailPath)}},saveSceneSettings:async(Hn,Rr)=>{const Fi=Xbr(Rr);return Fi!==null?Fi:(await ot(Hn,ta=>Zbr(ta,Rr)),null)},pickSceneThumbnail:async Hn=>{const Rr=await Zzt(Object.values(sWe).join(","));if(Rr===null)return null;const Fi=Mzt(Rr.name);if(sWe[Fi]===void 0)throw new Error("not a supported image (png, jpg, gif, webp)");const ta=`${mwr}/scene-thumbnail${Fi}`,xs=new Uint8Array(await Rr.arrayBuffer());return await Ve(Hn,ta,xs),{path:ta,dataUrl:SAt(ta,xs)}},appVersion:async()=>D0r,prefabLibraryList:()=>_a.list(),prefabLibraryCopyIn:async(Hn,Rr)=>_a.copyIn(Hn,We(Rr)),prefabLibraryUpdateCopy:async(Hn,Rr)=>_a.updateCopy(Hn,We(Rr)),prefabUserLibrary:()=>go===null?"unavailable":l()===null?"guest":"on",...go===null?{}:{prefabLibraryCopyOut:async(Hn,Rr)=>{if(l()===null)throw new Error(gwr);return go.copyOut(We(Hn),Rr)},prefabLibraryDelete:async Hn=>{const Rr=eVt(Hn);return(Rr==null?void 0:Rr.scope)==="user"&&l()!==null?go.remove(Rr.name):!1}}};async function Kc(){const Hn=new Set;for(const Rr of[...await r.list(),...await r.trashed()]){const Fi=_zt(await vt(Rr.id,E3).catch(()=>{}));for(const ta of Object.keys((Fi==null?void 0:Fi.packages)??{}))Hn.add(ta);for(const[ta,xs]of Object.entries((Fi==null?void 0:Fi.dependencies)??{}))Hn.add(B7(ta,xs))}for(const Rr of await r.packages.keys())Hn.has(Rr)||await r.packages.remove(Rr)}return r.purge(Date.now()-pwr).then(async Hn=>{const Rr=await caches.open(Sxe),Fi=Hn.map(({id:xs,previewId:Lo})=>ee.realmUrl(Lo??xs));for(const xs of await Rr.keys())Fi.some(Lo=>xs.url.startsWith(Lo))&&await Rr.delete(xs);const ta=await caches.open(I0r);for(const xs of Fi)await ta.delete(`${xs}__storage`);Hn.length>0&&await Kc()}).catch(Hn=>console.warn("[editor] could not empty the trash",Hn)),{shell:uc,projects:Mi,dataLayer:St,dispose:()=>{_t.dispose(),Ee++,At(),ee.dispose(),clearInterval(Wt),document.removeEventListener("visibilitychange",Le),ft.flush().finally(()=>ft.dispose())}}};let $7=null,pG=null,Yne=null,eOt=!1;function bwr(){if($7!==null)return $7;const t=window.__dclEditorHost;if(t===void 0||t.version!==0&&t.version!==1)return console.error("[editor] window.__dclEditorHost (contract v0 or v1) is missing: nothing to mount into"),null;console.log("[editor] web build 2026-10-13T23:54:29.142Z"),nIt(t),XPt(a=>t.engineConsole(a)),p3t(()=>t.identity()),nqn.needed=!1;const n=vwr({host:t,webBuild:ybr(t.editorBase)});window.editorShell=xwr(n.shell,t),NNt(n.dataLayer??null),dGe();const r=document.createElement("link");return r.rel="stylesheet",r.href=new URL("editor.css",t.editorBase).href,r.integrity=pB("editor.css"),r.crossOrigin="anonymous",r.onerror=()=>console.error("[editor] editor.css did not load or does not match the hash this editor was published with: its fonts are not applied"),document.head.appendChild(r),jA.project=null,jA.notice=null,$7={host:t,web:n,fonts:r},$7}function Cxe(){const t=pG;pG=null,t==null||t.unmount()}function xwr(t,n){return{...t,openProject:async r=>{const a=pG;Cxe(),a==null||a.api.close(),Yne??(Yne=rFt(n.container,O.jsx(uvr,{}))),n.setMode("edit"),jA.project=r,jA.opens++,await t.openProject(r)}}}function wwr(t,n){var m;const r=bwr();if(r===null)return()=>{};Cxe();const a=document.createElement("div");a.style.cssText="position:relative;width:100%;height:100%",LWn(a),t.appendChild(a);const s=rFt(a,O.jsx(BWn,{}),"eui-create-root"),l={api:n,unmount:()=>{s(),a.remove()}};pG=l;const d=eOt?null:((m=JA(r.host))==null?void 0:m.openProject)??null;return eOt=!0,d!==null&&r.web.projects.find(d).catch(()=>!1).then(_=>{var x;pG===l&&(_?(x=window.editorShell)==null||x.openProject(d):jA.notice=`“${d}” is not on this device or on your account. Here are your scenes.`)}),()=>{pG===l&&Cxe()}}function Swr(){Cxe();const t=$7;if(t===null)return;$7=null;const n=YA();Yne==null||Yne(),Yne=null,t.fonts.remove(),jA.project=null,delete window.editorShell,p3t(null),XPt(null),nIt(null),t.host.setMode("off"),n.finally(()=>{var r,a;(a=(r=t.web).dispose)==null||a.call(r),$7===null&&NNt(null)})}window.__dclEditor={mountHome:wwr,unmount:Swr};
|
|
34667
|
+
`;F.set("data.json",new TextEncoder().encode(Z));const K=hWe(tVt(H,T)).slice(0,swr).replace(/_+$/,"")||"prefab",_e=new Set((await t.list()).map(te=>te.name));let he=1;for(let te=0;te<owr;te++){let de=K;for(;_e.has(de);)de=`${K}_${++he}`;try{return await d(de,F),{ref:`user:${de}`,scope:"user",data:Z}}catch(Ee){if(!(Ee instanceof Vzt))throw Ee;_e.add(de)}}throw new Error("could not find a free name in your library — try again")},remove:m=>t.remove(m)}}const ZAt=new WeakMap;function uwr(t){let n=ZAt.get(t);return n===void 0&&(n=crypto.subtle.digest("SHA-256",new Uint8Array(t)).then(r=>[...new Uint8Array(r)].map(a=>a.toString(16).padStart(2,"0")).join("")),ZAt.set(t,n)),n}async function fwr(t){const n=t.get(".dclignore"),r=_Xe(t.keys(),n===void 0?void 0:new TextDecoder().decode(n)).filter(l=>l!==E3),a=new Map;let s=0;for(const l of r){const d=t.get(l);d!==void 0&&(a.set(await uwr(d),d.byteLength),s++)}return{bytes:[...a.values()].reduce((l,d)=>l+d,0),files:s}}const KAt=4e3,dwr=4e6,pwr=VIt*24*60*60*1e3,mwr="assets/images",hwr=3e3,_wr=100,gwr="Sign in to keep prefabs in your own library. The built-in prefabs work without it.",ywr=t=>t instanceof Error?t.message:String(t);function qBe(t,n){var r,a,s;return{realm:n.replace(/\/$/,""),systemScene:"",position:((r=t.scene)==null?void 0:r.base)??((s=(a=t.scene)==null?void 0:a.parcels)==null?void 0:s[0])??"0,0",spawn:Kbr(t),spawnPoints:JSON.stringify(Array.isArray(t.spawnPoints)?t.spawnPoints:[])}}const vwr=({host:t,sceneCompiler:n})=>{const r=new N1r(E1r()),a=JA(t),s=a===null||a.services.projects===null?null:zzt(a.services.projects,(Hn,Rr)=>a.signedFetch(Hn,Rr)),l=()=>{const{address:Hn,isGuest:Rr}=t.identity();return Rr||Hn===null?null:Hn.toLowerCase()},d=[],m=[],_=[],x=[],T=[],A=Hn=>{d.push(Hn),d.length>KAt&&d.splice(0,d.length-KAt);for(const Rr of m)Rr(Hn)},M=Hn=>{for(const Rr of _)Rr(Hn)},F=new Map,B=new Set,H=a3t.then(Gxr),ee=Xxr({pageDir:t.pageDir,urls:n,machineId:async Hn=>Jxr(await H,l()??"guest",Hn),emit:M,log:A,packages:r.packages,saveLock:async(Hn,Rr)=>{await r.write(Hn,E3,Rr),ft.touched(Hn,E3),(K==null?void 0:K.id)===Hn&&K.files.set(E3,Rr)},onPackages:(Hn,Rr)=>{if(Rr===null){F.delete(Hn);return}F.set(Hn,Rr);for(const Fi of B)Fi(Hn,Rr)}});let Z=null,K=null,_e=null,he=null;async function te(Hn){var ta;const Rr=(ta=(await r.list()).find(xs=>xs.id===Hn))==null?void 0:ta.previewId;if(Rr!==void 0)return Rr;const Fi="p"+Array.from(crypto.getRandomValues(new Uint8Array(16)),xs=>xs.toString(16).padStart(2,"0")).join("");return await r.patch(Hn,{previewId:Fi}),Fi}async function de(Hn){const Rr=new URL("preview/",t.pageDir).href,Fi=await caches.open(Sxe);for(const ta of await Fi.keys())ta.url.startsWith(Rr)&&(Hn===null||!ta.url.startsWith(Hn))&&await Fi.delete(ta)}let Ee=0,lt=Promise.resolve(),Et=Promise.resolve();const _t=B0r({service:(a==null?void 0:a.services.projects)??null,fetch:(Hn,Rr)=>a===null?Promise.reject(new Error("The assistant service is not configured.")):a.signedFetch(Hn,Rr),wallet:l,memory:{read:async(Hn,Rr)=>{const Fi=await r.assistantMemory(Hn,Rr);return Xl(Fi)&&typeof Fi.id=="string"&&typeof Fi.key=="string"?{id:Fi.id,key:Fi.key}:null},write:(Hn,Rr,Fi)=>r.setAssistantMemory(Hn,Rr,Fi)},project:()=>{const Hn=si();return{id:Hn.id,tools:{files:()=>Hn.files,write:(Rr,Fi,ta,xs)=>Ve(Hn.id,Rr,Fi,{expected:ta,signal:xs}),assets:zbr({files:()=>Hn.files,write:(Rr,Fi,ta,xs)=>Ve(Hn.id,Rr,Fi,{expected:ta,signal:xs})}),scene:(Rr,Fi)=>gXe(Rr,Fi,async ta=>{var uf,di,Cl;const xs=gl=>{var Jg,_u;return JSON.stringify([(Jg=gl==null?void 0:gl.scene)==null?void 0:Jg.parcels,(_u=gl==null?void 0:gl.scene)==null?void 0:_u.base])};await YA();const Lo=xs(N1(await vt(Hn.id,"scene.json")));await ot(Hn.id,gl=>r1r(gl,ta));const fl=N1(await vt(Hn.id,"scene.json")),Hd=xs(fl)!==Lo,cr=((uf=fl==null?void 0:fl.scene)==null?void 0:uf.parcels)??[],Jl=(di=tt.scene)==null?void 0:di.parcels.map(gl=>`${gl.x},${gl.y}`).sort().join(";");if(Hd||Jl!==[...cr].sort().join(";")){if(!await Hn.flush())throw new Error("The scene did not build. Fix the code and retry sceneSettings to load the new parcels.");Fi.throwIfAborted();const gl=await te(Hn.id);Z=qBe(fl??{},ee.realmUrl(gl)),await rwr(cr,()=>{for(const Jg of x)Jg(Z)},Fi)}else if(Z!==null){const gl=qBe(fl??{},Z.realm);(gl.spawn!==Z.spawn||gl.spawnPoints!==Z.spawnPoints)&&(Z={...Z,spawn:gl.spawn,spawnPoints:gl.spawnPoints},jcr(gl.spawn,gl.spawnPoints))}return{requiredPermissions:(fl==null?void 0:fl.requiredPermissions)??[],spawnPoints:(fl==null?void 0:fl.spawnPoints)??[],parcels:cr,base:((Cl=fl==null?void 0:fl.scene)==null?void 0:Cl.base)??null,previewReady:!0}}),written:z0r(),view:(Rr,Fi)=>jbr(Rr,Fi),playtest:Qbr,build:async Rr=>{Rr.throwIfAborted(),await Et;const Fi=await ee.build(Hn.id,new Map(Hn.files));if(Rr.throwIfAborted(),!Fi.ok)return{ok:!1,diagnostics:Fi.diagnostics};const ta=await qbr();return Rr.throwIfAborted(),{ok:!0,diagnostics:Fi.diagnostics,run:ta}}}}}});function At(){_t.reset(),he==null||he(),he=null,K!==null&&(K.stop(),r.close(K.id),ft.flush(K.id),K=null,_e=null)}async function vt(Hn,Rr){return(K==null?void 0:K.id)===Hn?K.files.get(Rr):r.read(Hn,Rr).catch(Fi=>{if(!uI(Fi))throw Fi})}function Ve(Hn,Rr,Fi,ta){const xs=Et.then(async()=>{if(ta==null||ta.signal.throwIfAborted(),ta!==void 0&&((K==null?void 0:K.id)!==Hn||!L0r(K.files.get(Rr),ta.expected)))throw new Error("This file changed. Read it again before writing.");await r.write(Hn,Rr,Fi),ft.touched(Hn,Rr),(K==null?void 0:K.id)===Hn&&(K.files.set(Rr,Fi),K.changed(Rr))});return Et=xs.catch(Lo=>console.error("[editor] file write failed",Lo)),xs}function Qt(Hn,Rr){const Fi=Et.then(async()=>{const ta=await r.remove(Hn,Rr);return ta&&ft.touched(Hn,Rr),ta&&(K==null?void 0:K.id)===Hn&&K.files.delete(Rr)&&K.changed(Rr),ta});return Et=Fi.catch(ta=>console.error("[editor] file removal failed",ta)),Fi}function We(Hn){const Rr=si();if(Rr.id!==Hn)throw new Error("that scene is not the one open");return{files:()=>Rr.files,write:(Fi,ta)=>Ve(Hn,Fi,ta),remove:async Fi=>{await Qt(Hn,Fi)}}}async function Fe(Hn){var ta;const Rr=N1(await vt(Hn,"scene.json").catch(()=>{})),Fi=(((ta=Rr==null?void 0:Rr.display)==null?void 0:ta.title)??"").replace(/[\x00-\x1f\x7f]/g,"").replace(new RegExp(Uzt.source,"g"),"").trim().slice(0,_wr);return Fi===""?Hn:Fi}async function zt(Hn,Rr){const Fi=(await r.list()).find(xs=>xs.id===Hn);if(Fi===void 0)return null;const ta=await r.duplicate(Hn,`${Fi.name} ${Rr}`,ft.remoteIds());return await ot(ta.id,xs=>{var Lo;return{...xs,display:{...xs.display??{},title:`${((Lo=xs.display)==null?void 0:Lo.title)||Fi.name} ${Rr}`}}}),ta.id}const ft=B1r({store:r,session:()=>{const Hn=l();return s===null||Hn===null?null:{api:s,wallet:Hn}},account:()=>s===null?"unavailable":l()===null?"guest":"on",hash:bxe,title:Fe,duplicate:async Hn=>{const Rr=await zt(Hn,zIt(new Date));if(Rr===null)throw new Error("The scene is no longer on this device");return Rr}});let xt=!1,ht=0;async function Rt(){const Hn=++ht,Rr=l()!==null&&(await _t.shell.aiProviders()).some(Fi=>Fi.available);Hn!==ht||Rr===xt||(xt=Rr,W0())}Rt();let qt=l();const Wt=setInterval(()=>{const Hn=l();Hn!==qt&&(qt=Hn,_t.reset(),W0(),Rt(),ft.refresh(!0),de(_e).catch(Rr=>console.warn("[editor] could not clear the previews",Rr)))},hwr),Le=()=>{document.visibilityState==="hidden"&&ft.flush()};document.addEventListener("visibilitychange",Le);const Ze=new Set;async function ot(Hn,Rr){const Fi=N1(await vt(Hn,"scene.json"));if(Fi===null)throw new Error("scene.json is missing or is not valid JSON");await Ve(Hn,"scene.json",wAt(Rr(Fi)))}async function nn(Hn,Rr){if(Rr==null||Rr==="")return null;const Fi=await vt(Hn,Rr).catch(()=>{});return Fi===void 0||Fi.length>dwr?null:SAt(Rr,Fi)}async function On(Hn,Rr=ft.status().projects){var ta,xs,Lo,fl;const Fi=N1(await vt(Hn.id,"scene.json").catch(()=>{}));return{sync:Rr[Hn.id],path:Hn.id,name:Hn.name,title:((ta=Fi==null?void 0:Fi.display)==null?void 0:ta.title)||Hn.name,world:((xs=Fi==null?void 0:Fi.worldConfiguration)==null?void 0:xs.name)||null,parcels:Array.isArray((Lo=Fi==null?void 0:Fi.scene)==null?void 0:Lo.parcels)?Fi.scene.parcels.length:0,thumbnail:await nn(Hn.id,(fl=Fi==null?void 0:Fi.display)==null?void 0:fl.navmapThumbnail),favourite:Hn.favourite,lastOpened:Hn.lastOpened,published:Hn.published,deletedAt:Hn.deletedAt??void 0}}async function fn(Hn,Rr){var ta,xs;At(),d.length=0,M({type:"sessionStarted"});const Fi=Lo=>{if(At(),Rr===Ee){A(`✖ ${Lo}`);for(const fl of T)fl(Lo)}};try{if(await ft.prepareOpen(Hn,(uf,di)=>A(`Downloading from your account… ${uf}/${di}`)),Rr!==Ee)return;if(!await r.open(Hn)){Fi("This scene is open in another tab. Close it there to edit it here.");return}const Lo=await r.readAll(Hn).then(async uf=>{for(const[di,Cl]of Cvr(uf))await Ve(Hn,di,Cl),uf.set(di,Cl);return uf}).catch(uf=>{throw r.close(Hn),uf});if(Rr!==Ee){r.close(Hn);return}const fl=await te(Hn);if(Rr!==Ee){r.close(Hn);return}const Hd=ee.open(Hn,Lo,fl);K=Hd;const cr=ee.realmUrl(fl);if(_e=cr,A(`▶ Opening ${((xs=(ta=N1(Hd.files.get("scene.json")))==null?void 0:ta.display)==null?void 0:xs.title)||Hn}`),!await Hd.start()&&!await Hd.published()){if(Rr!==Ee)return;A("✖ The scene did not build.");for(const uf of T)uf("The scene did not build.");return}if(await r.patch(Hn,{lastOpened:Date.now()}),Rr!==Ee){At();return}const Jl=N1(Hd.files.get("scene.json"))??{};Z=qBe(Jl,cr),he=nwr(uf=>t.engineConsole(uf),A);for(const uf of x)uf(Z)}catch(Lo){Fi(ywr(Lo))}}function kn(Hn){Z=null;const Rr=++Ee,Fi=_t.reset(),ta=lt.then(async()=>{await Fi,await Et,Rr===Ee&&await Hn(Rr)});return lt=ta.catch(xs=>console.error("[editor] project transition failed",xs)),ta}function si(){if(K===null)throw new Error("no project is open");return K}const St={saveFile:async({path:Hn,content:Rr})=>Ve(si().id,Hn,Rr),getFile:async({path:Hn})=>{const Rr=si().files.get(Hn)??Nxr(Hn);if(Rr===void 0)throw new Error(`no such file: ${Hn}`);return{content:Rr}},removeFiles:async({filePaths:Hn})=>{const Rr=si(),Fi=[],ta=[];for(const xs of Hn)(await Qt(Rr.id,xs).catch(()=>!1)?Fi:ta).push(xs);return{success:Fi,failed:ta}},getFilesSizes:async({path:Hn,ignore:Rr})=>{const Fi=Hn===""?"":`${Hn.replace(/\/+$/,"")}/`;return{files:[...si().files.keys()].filter(xs=>xs.startsWith(Fi)&&!xs.split("/").some(Lo=>Rr.includes(Lo))).sort().map(xs=>({path:xs}))}}},Mi={async find(Hn){return(await r.list()).some(Rr=>Rr.id===Hn)?!0:(await ft.refresh(!0),ft.remoteOnly().some(Rr=>Rr.id===Hn))},files:async Hn=>(K==null?void 0:K.id)===Hn?new Map(K.files):r.readAll(Hn),manifest:Hn=>ft.manifest(Hn),build:async(Hn,Rr)=>ee.build(Hn,await Mi.files(Hn),Rr),dependencies:async Hn=>Fzt(await vt(Hn,"package.json")),onImported:Hn=>(Ze.add(Hn),()=>Ze.delete(Hn))},Br=a===null?null:k1r({host:a,setWorld:async(Hn,Rr)=>{var ta,xs;((xs=(ta=N1(await vt(Hn,"scene.json")))==null?void 0:ta.worldConfiguration)==null?void 0:xs.name)!==Rr&&await ot(Hn,Lo=>({...Lo,worldConfiguration:{...Lo.worldConfiguration??{},name:Rr}}))},files:Hn=>Mi.files(Hn),build:(Hn,Rr)=>ee.build(Hn,Rr,{production:!0}),published:(Hn,Rr)=>r.patch(Hn,{published:Rr})}),go=(a==null?void 0:a.services.projects)==null?null:lwr(M1r(a.services.projects,(Hn,Rr)=>a.signedFetch(Hn,Rr)),bxe);qlr(vbr(t.editorBase)),bbr(t.editorBase),adr(async()=>fwr(await Mi.files(si().id)));const _a=Uxr({builtin:exr(t.editorBase,pB("prefabs/catalog.json"),sTe),user:()=>go!==null&&l()!==null?go.tree:null}),uc={...(a==null?void 0:a.services.projects)==null?{}:{..._t.shell,aiOffered:()=>xt,aiTranscript:()=>{const Hn=qt;if(Hn===null||K===null)return null;const Rr=K.id;return{owner:`${Rr}@${Hn.toLowerCase()}`,load:()=>r.transcript(Rr,Hn),save:Fi=>r.setTranscript(Rr,Hn,Fi)}}},pickProject:async()=>{},openProject:Hn=>kn(Rr=>fn(Hn,Rr)),relaunchProject:Hn=>kn(Rr=>fn(Hn,Rr)),closeProject:()=>kn(async()=>{At(),M({type:"sessionStarted"}),A("■ Scene closed"),await de(null).catch(Hn=>console.warn("[editor] could not clear the previews",Hn))}),getState:async()=>{const Hn=await r.list(),Rr=ft.status().projects,Fi=ft.remoteOnly().map(ta=>({path:ta.id,name:ta.name,title:ta.name,world:null,parcels:0,thumbnail:null,remoteOnly:!0}));return{recentProjects:[...Hn].sort((ta,xs)=>xs.lastOpened-ta.lastOpened).map(ta=>ta.id),projects:[...await Promise.all(Hn.map(ta=>On(ta,Rr))),...Fi],logs:[...d],bevyWebDir:"",editorSceneDir:"",webPort:0,scenePort:0,editorScenePort:0,favourites:Hn.filter(ta=>ta.favourite).map(ta=>ta.id)}},onStackLog:Hn=>{m.push(Hn)},onBuildEvent:Hn=>{_.push(Hn)},onServersReady:Hn=>{x.push(Hn)},requestReady:async()=>Z,onServersError:Hn=>{T.push(Hn)},toggleFavourite:async Hn=>{const Rr=(await r.list()).find(Fi=>Fi.id===Hn);Rr!==void 0&&await r.patch(Hn,{favourite:!Rr.favourite})},deleteProject:async Hn=>{const Rr=await r.trash(Hn);return Rr&&ft.trashed(Hn),Rr},trashedProjects:async()=>Promise.all((await r.trashed()).map(Hn=>On(Hn))),restoreProject:async Hn=>{const Rr=await r.restore(Hn);return Rr&&ft.restored(Hn),Rr},syncStatus:async()=>(ft.refresh(),ft.status()),onSyncStatus:Hn=>ft.subscribe(Hn),resolveSyncConflict:(Hn,Rr)=>ft.resolve(Hn,Rr),exportProject:async Hn=>X1r(await Fe(Hn),await Mi.files(Hn)),importProject:async Hn=>{const Rr=await K1r(Hn,async(Fi,ta)=>{const xs=await r.create(Fi,ta,{taken:ft.remoteIds()});return ft.touched(xs.id,"scene.json"),xs.id});if((Rr==null?void 0:Rr.ok)===!0){const{id:Fi,needsPackages:ta}=Rr.report;Object.keys(ta).length>0&&r.readAll(Fi).then(xs=>ee.install(Fi,xs)).catch(xs=>console.warn("[editor] could not install the packages of",Fi,xs));for(const xs of Ze)xs(Rr.report)}return Rr},projectPackages:async Hn=>F.get(Hn)??null,onProjectPackages:Hn=>(B.add(Hn),()=>B.delete(Hn)),...Br===null||a===null?{}:{publishScene:(Hn,Rr,Fi)=>Br.publish(Hn,Rr,Fi),publishStop:async()=>Br.stop(),publishWorlds:async()=>{const Hn=l();return Hn===null?[]:S1r(Hn,a.services.worldsContent.replace(/\/+$/,""))}},canImportFolder:Y1r(),renameProject:(Hn,Rr)=>ot(Hn,Fi=>({...Fi,display:{...Fi.display??{},title:Rr.trim()}})),duplicateProject:Hn=>zt(Hn,"copy"),sceneTemplates:async()=>Oxr(),createScene:async(Hn,Rr,Fi)=>{const ta=Kzt(Fi),xs=N1(ta.get("scene.json"));if(xs===null)throw new Error(`template not found: ${Fi}`);ta.set("scene.json",wAt({...xs,display:{...xs.display??{},title:Rr.trim()}}));const Lo=await r.create(Rr,ta,{taken:ft.remoteIds()});return ft.touched(Lo.id,"scene.json"),Lo.id},openExternal:async Hn=>{/^https?:$/.test(new URL(Hn).protocol)&&window.open(Hn,"_blank","noopener,noreferrer")},compositeEntityIds:async Hn=>{for(const Rr of e1r){const Fi=await vt(Hn,Rr);if(Fi!==void 0)return t1r(new TextDecoder().decode(Fi))}return[]},sceneSettings:async Hn=>{const Rr=N1(await vt(Hn,"scene.json"));if(Rr===null)throw new Error("scene.json is missing or is not valid JSON");const Fi=Ybr(Rr);return{...Fi,thumbnail:await nn(Hn,Fi.thumbnailPath)}},saveSceneSettings:async(Hn,Rr)=>{const Fi=Xbr(Rr);return Fi!==null?Fi:(await ot(Hn,ta=>Zbr(ta,Rr)),null)},pickSceneThumbnail:async Hn=>{const Rr=await Zzt(Object.values(sWe).join(","));if(Rr===null)return null;const Fi=Mzt(Rr.name);if(sWe[Fi]===void 0)throw new Error("not a supported image (png, jpg, gif, webp)");const ta=`${mwr}/scene-thumbnail${Fi}`,xs=new Uint8Array(await Rr.arrayBuffer());return await Ve(Hn,ta,xs),{path:ta,dataUrl:SAt(ta,xs)}},appVersion:async()=>D0r,prefabLibraryList:()=>_a.list(),prefabLibraryCopyIn:async(Hn,Rr)=>_a.copyIn(Hn,We(Rr)),prefabLibraryUpdateCopy:async(Hn,Rr)=>_a.updateCopy(Hn,We(Rr)),prefabUserLibrary:()=>go===null?"unavailable":l()===null?"guest":"on",...go===null?{}:{prefabLibraryCopyOut:async(Hn,Rr)=>{if(l()===null)throw new Error(gwr);return go.copyOut(We(Hn),Rr)},prefabLibraryDelete:async Hn=>{const Rr=eVt(Hn);return(Rr==null?void 0:Rr.scope)==="user"&&l()!==null?go.remove(Rr.name):!1}}};async function Kc(){const Hn=new Set;for(const Rr of[...await r.list(),...await r.trashed()]){const Fi=_zt(await vt(Rr.id,E3).catch(()=>{}));for(const ta of Object.keys((Fi==null?void 0:Fi.packages)??{}))Hn.add(ta);for(const[ta,xs]of Object.entries((Fi==null?void 0:Fi.dependencies)??{}))Hn.add(B7(ta,xs))}for(const Rr of await r.packages.keys())Hn.has(Rr)||await r.packages.remove(Rr)}return r.purge(Date.now()-pwr).then(async Hn=>{const Rr=await caches.open(Sxe),Fi=Hn.map(({id:xs,previewId:Lo})=>ee.realmUrl(Lo??xs));for(const xs of await Rr.keys())Fi.some(Lo=>xs.url.startsWith(Lo))&&await Rr.delete(xs);const ta=await caches.open(I0r);for(const xs of Fi)await ta.delete(`${xs}__storage`);Hn.length>0&&await Kc()}).catch(Hn=>console.warn("[editor] could not empty the trash",Hn)),{shell:uc,projects:Mi,dataLayer:St,dispose:()=>{_t.dispose(),Ee++,At(),ee.dispose(),clearInterval(Wt),document.removeEventListener("visibilitychange",Le),ft.flush().finally(()=>ft.dispose())}}};let $7=null,pG=null,Yne=null,eOt=!1;function bwr(){if($7!==null)return $7;const t=window.__dclEditorHost;if(t===void 0||t.version!==0&&t.version!==1)return console.error("[editor] window.__dclEditorHost (contract v0 or v1) is missing: nothing to mount into"),null;console.log("[editor] web build 2026-10-14T14:24:55.767Z"),nIt(t),XPt(a=>t.engineConsole(a)),p3t(()=>t.identity()),nqn.needed=!1;const n=vwr({host:t,sceneCompiler:ybr(t.editorBase)});window.editorShell=xwr(n.shell,t),NNt(n.dataLayer??null),dGe();const r=document.createElement("link");return r.rel="stylesheet",r.href=new URL("editor.css",t.editorBase).href,r.integrity=pB("editor.css"),r.crossOrigin="anonymous",r.onerror=()=>console.error("[editor] editor.css did not load or does not match the hash this editor was published with: its fonts are not applied"),document.head.appendChild(r),jA.project=null,jA.notice=null,$7={host:t,web:n,fonts:r},$7}function Cxe(){const t=pG;pG=null,t==null||t.unmount()}function xwr(t,n){return{...t,openProject:async r=>{const a=pG;Cxe(),a==null||a.api.close(),Yne??(Yne=rFt(n.container,O.jsx(uvr,{}))),n.setMode("edit"),jA.project=r,jA.opens++,await t.openProject(r)}}}function wwr(t,n){var m;const r=bwr();if(r===null)return()=>{};Cxe();const a=document.createElement("div");a.style.cssText="position:relative;width:100%;height:100%",LWn(a),t.appendChild(a);const s=rFt(a,O.jsx(BWn,{}),"eui-create-root"),l={api:n,unmount:()=>{s(),a.remove()}};pG=l;const d=eOt?null:((m=JA(r.host))==null?void 0:m.openProject)??null;return eOt=!0,d!==null&&r.web.projects.find(d).catch(()=>!1).then(_=>{var x;pG===l&&(_?(x=window.editorShell)==null||x.openProject(d):jA.notice=`“${d}” is not on this device or on your account. Here are your scenes.`)}),()=>{pG===l&&Cxe()}}function Swr(){Cxe();const t=$7;if(t===null)return;$7=null;const n=YA();Yne==null||Yne(),Yne=null,t.fonts.remove(),jA.project=null,delete window.editorShell,p3t(null),XPt(null),nIt(null),t.host.setMode("off"),n.finally(()=>{var r,a;(a=(r=t.web).dispose)==null||a.call(r),$7===null&&NNt(null)})}window.__dclEditor={mountHome:wwr,unmount:Swr};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl-regenesislabs/web-editor",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "The Decentraland scene editor for the web explorer: editor.js plus the files it loads beside it. Served by version, not installed.",
|
|
6
6
|
"repository": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ct=Object.create;var Je=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames;var Bt=Object.getPrototypeOf,Vt=Object.prototype.hasOwnProperty;var Wt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Dt=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Nt(e))!Vt.call(t,s)&&s!==n&&Je(t,s,{get:()=>e[s],enumerable:!(r=Mt(e,s))||r.enumerable});return t};var Ft=(t,e,n)=>(n=t!=null?Ct(Bt(t)):{},Dt(e||!t||!t.__esModule?Je(n,"default",{value:t,enumerable:!0}):n,t));var $t=Wt((Wr,At)=>{function kt(t){return Array.isArray(t)?t:[t]}var Ue="",vt=" ",Oe="\\",jn=/^\s+$/,In=/(?:[^\\]|^)\\$/,Sn=/^\\!/,_n=/^\\#/,On=/\r?\n/g,Tn=/^\.*\/|^\.+$/,Te="/",xt="node-ignore";typeof Symbol<"u"&&(xt=Symbol.for("node-ignore"));var bt=xt,Un=(t,e,n)=>Object.defineProperty(t,e,{value:n}),Ln=/([0-z])-([0-z])/g,Rt=()=>!1,Cn=t=>t.replace(Ln,(e,n,r)=>n.charCodeAt(0)<=r.charCodeAt(0)?e:Ue),Mn=t=>{let{length:e}=t;return t.slice(0,e-e%2)},Nn=[[/^\uFEFF/,()=>Ue],[/((?:\\\\)*?)(\\?\s+)$/,(t,e,n)=>e+(n.indexOf("\\")===0?vt:Ue)],[/(\\+?)\s/g,(t,e)=>{let{length:n}=e;return e.slice(0,n-n%2)+vt}],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,n)=>e+6<n.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(t,e,n)=>{let r=n.replace(/\\\*/g,"[^\\/]*");return e+r}],[/\\\\\\(?=[$.|*+(){^])/g,()=>Oe],[/\\\\/g,()=>Oe],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,n,r,s)=>e===Oe?`\\[${n}${Mn(r)}${s}`:s==="]"&&r.length%2===0?`[${Cn(n)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],Pt=Object.create(null),Bn=(t,e)=>{let n=Pt[t];return n||(n=Nn.reduce((r,[s,i])=>r.replace(s,i.bind(t)),t),Pt[t]=n),e?new RegExp(n,"i"):new RegExp(n)},Me=t=>typeof t=="string",Vn=t=>t&&Me(t)&&!jn.test(t)&&!In.test(t)&&t.indexOf("#")!==0,Wn=t=>t.split(On),Le=class{constructor(e,n,r,s){this.origin=e,this.pattern=n,this.negative=r,this.regex=s}},Dn=(t,e)=>{let n=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(Sn,"!").replace(_n,"#");let s=Bn(t,e);return new Le(n,t,r,s)},Fn=(t,e)=>{throw new e(t)},B=(t,e,n)=>Me(t)?t?B.isNotRelative(t)?n(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:n("path must not be empty",TypeError):n(`path must be a string, but got \`${e}\``,TypeError),Et=t=>Tn.test(t);B.isNotRelative=Et;B.convert=t=>t;var Ce=class{constructor({ignorecase:e=!0,ignoreCase:n=e,allowRelativePaths:r=!1}={}){Un(this,bt,!0),this._rules=[],this._ignoreCase=n,this._allowRelativePaths=r,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(e){if(e&&e[bt]){this._rules=this._rules.concat(e._rules),this._added=!0;return}if(Vn(e)){let n=Dn(e,this._ignoreCase);this._added=!0,this._rules.push(n)}}add(e){return this._added=!1,kt(Me(e)?Wn(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(e){return this.add(e)}_testOne(e,n){let r=!1,s=!1;return this._rules.forEach(i=>{let{negative:c}=i;if(s===c&&r!==s||c&&!r&&!s&&!n)return;i.regex.test(e)&&(r=!c,s=c)}),{ignored:r,unignored:s}}_test(e,n,r,s){let i=e&&B.convert(e);return B(i,e,this._allowRelativePaths?Rt:Fn),this._t(i,n,r,s)}_t(e,n,r,s){if(e in n)return n[e];if(s||(s=e.split(Te)),s.pop(),!s.length)return n[e]=this._testOne(e,r);let i=this._t(s.join(Te)+Te,n,r,s);return n[e]=i.ignored?i:this._testOne(e,r)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return kt(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},le=t=>new Ce(t),zn=t=>B(t&&B.convert(t),t,Rt);le.isPathValid=zn;le.default=le;At.exports=le;if(typeof process<"u"&&(process.env&&process.env.IGNORE_TEST_WIN32||process.platform==="win32")){let t=n=>/^\\\\\?\\/.test(n)||/["<>|\u0000-\u001F]+/u.test(n)?n:n.replace(/\\/g,"/");B.convert=t;let e=/^[a-z]:\//i;B.isNotRelative=n=>e.test(n)||Et(n)}});var re="/scene";function ge(t){let e=[];for(let n of t.split("/"))n===".."?e.pop():n!==""&&n!=="."&&e.push(n);return"/"+e.join("/")}var L=(t,e)=>ge(t+"/"+e);function M(t){let e=t.lastIndexOf("/");return e<=0?"/":t.slice(0,e)}function Ge(t){let e=t.slice(t.lastIndexOf("/")+1),n=e.lastIndexOf(".");return n<=0?"":e.slice(n)}var zt=new TextDecoder,X=class{constructor(){this.files=new Map;this.dirs=new Set;this.parsed=new Map}set(e,n){this.files.set(e,n),this.parsed.delete(e);for(let r=M(e);!this.dirs.has(r)&&(this.dirs.add(r),r!=="/");r=M(r));}has(e){return this.files.has(e)}isDir(e){return this.dirs.has(e)}read(e){return this.files.get(e)}text(e){let n=this.files.get(e);return n===void 0||typeof n=="string"?n:zt.decode(n)}json(e){if(this.parsed.has(e))return this.parsed.get(e);let n,r=this.text(e);if(r!==void 0)try{n=JSON.parse(r)}catch{n=void 0}return this.parsed.set(e,n),n}},v=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);var F=".dcl-package.json",pe=class{constructor(){this.packages=new Map}has(e){return this.packages.has(e)}list(e){return[...this.packages.get(e)?.keys()??[]]}read(e,n){return this.packages.get(e)?.get(n)}write(e,n,r){let s=this.packages.get(e);s===void 0&&this.packages.set(e,s=new Map),s.set(n,r)}remove(e){this.packages.delete(e)}},He=t=>Array.isArray(t)?t.filter(e=>typeof e=="string"):[];async function Z(t,e){if(!await t.has(e))return;let n=await t.read(e,F);if(n!==void 0)try{let r=JSON.parse(new TextDecoder().decode(n));return!v(r)||typeof r.integrity!="string"?void 0:{integrity:r.integrity,files:Number(r.files)||0,bytes:Number(r.bytes)||0,installScripts:He(r.installScripts),native:r.native===!0,nodeBuiltins:He(r.nodeBuiltins)}}catch{return}}var Xe=async(t,e,n)=>t.write(e,F,new TextEncoder().encode(JSON.stringify(n)));async function he(t,e,n){let r;try{r=await fetch(t,e===void 0?{}:{integrity:e,mode:"cors"})}catch(s){if(e===void 0)throw s;let i=await fetch(t).then(c=>c.ok,()=>!1);throw new Error(i?`${n} does not match the hash this editor was published with. The editor will not run it: reload the page, and if this persists the files you were served were altered.`:`${n} could not be loaded (${t}). Check the connection and reload the page.`)}if(!r.ok)throw new Error(`${n} could not be loaded: ${r.status} ${t}`);return r}var Ze=/\.(tsx?|mts|cts|jsx?|mjs|cjs|json|composite|css|txt)$/,Kt=/\.d\.[mc]?ts$/;function qt(t){let e=t.get("scene.json");if(e!==void 0)try{let n=JSON.parse(new TextDecoder().decode(e)).main;return typeof n=="string"?n:void 0}catch{return}}async function Jt(t){let{integrity:e}=t;if(e===void 0)return new Worker(t.workerUrl);let n=new URL(t.workerUrl,location.href).href,r=await(await he(n,e.worker,"web-build/worker.js")).text(),s=URL.createObjectURL(new Blob([r],{type:"text/javascript"})),i=new Worker(s);return setTimeout(()=>URL.revokeObjectURL(s),6e4),i}function Gt(t){let e=Jt(t),n=m=>void e.then(g=>g.postMessage(m),()=>{}),r=new Map,s=1,i=new Map,c=1,f=()=>{},a=()=>{},d=new Promise((m,g)=>{f=m,a=g}),l=m=>{a(new Error(m));for(let[g,k]of r){let E={type:"failed",buildId:g,message:m};t.onEvent?.(E),k.resolve({buildId:g,ok:!1,outputs:new Map,diagnostics:[],events:[...k.events,E],ms:0})}r.clear();for(let g of i.values())g.reject(new Error(m));i.clear()},h=m=>{let g=m.data;if(g.type==="ready")f({sdkVersion:g.sdkVersion,esbuildVersion:g.esbuildVersion,snapshot:{sdkVersion:g.sdkVersion,provided:g.provided}});else if(g.type==="packagesSet"){let k=i.get(g.requestId);i.delete(g.requestId),g.error===void 0?k?.resolve(g.shadowed):k?.reject(new Error(g.error))}else if(g.type==="initFailed")l(g.message);else if(g.type==="event")r.get(g.event.buildId)?.events.push(g.event),t.onEvent?.(g.event);else{let k=r.get(g.buildId);if(k===void 0)return;r.delete(g.buildId),k.resolve({buildId:g.buildId,ok:k.events.some(E=>E.type==="bundleSaved"),outputs:new Map(g.outputs),diagnostics:k.events.flatMap(E=>E.type==="diagnostics"?E.diagnostics:[]),events:k.events,ms:g.ms})}};e.then(m=>{m.onerror=g=>l(g.message||"The build worker failed to start"),m.onmessage=h},m=>l(m instanceof Error?m.message:String(m)));let{integrity:y}=t;return n({type:"init",wasmUrl:new URL(t.wasmUrl,location.href).href,snapshotUrl:new URL(t.snapshotUrl,location.href).href,integrity:y===void 0?void 0:{wasm:y.wasm,snapshot:y.snapshot}}),d.catch(()=>{}),{ready:d,build(m,g={}){let k=s++,E=qt(m),$=[...m].filter(([j])=>Ze.test(j)&&j!==E);return new Promise(j=>{r.set(k,{events:[],resolve:j}),n({type:"build",buildId:k,files:$,options:g})})},async setPackages(m,g){let k=[],E=0;for(let[C,G]of Object.entries(m?.packages??{})){let ue=g===void 0?void 0:await Z(g,C);if(g===void 0||ue?.integrity!==G.integrity)throw new Error(`${C} is not in the package store`);for(let S of await g.list(C)){if(!Ze.test(S)||Kt.test(S)||S===F)continue;let D=await g.read(C,S);if(D===void 0)throw new Error(`${C} is incomplete in the package store: ${S}`);k.push([C,S,D]),E+=D.length}}let $=c++,j=await new Promise((C,G)=>{i.set($,{resolve:C,reject:G}),n({type:"packages",requestId:$,lock:m,files:k})});return{packages:Object.keys(m?.packages??{}).length-j.length,files:k.length,bytes:E,shadowed:j}},dispose(){e.then(m=>m.terminate(),()=>{}),l("The scene builder was disposed")}}}var Ye=[".tsx",".ts",".jsx",".js",".css",".json"],Qe=[".jsx",".js",".css",".json",".tsx",".ts"],Ht={".js":[".ts",".tsx"],".jsx":[".ts",".tsx"],".mjs":[".mts"],".cjs":[".cts"]},et=t=>!/^\.{0,2}\//.test(t)&&t!=="."&&t!=="..",Xt=t=>t.split("/",t.startsWith("@")?2:1).join("/"),me=t=>(t+"/").includes("/node_modules/");function Zt(t){let e=t.replace(/^\.\//,""),n=(e.includes("/")?e:"**/"+e).replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\/|\*\*|\*|\?/g,r=>r==="**/"?"(?:.*/)?":r==="**"?".*":r==="*"?"[^/]*":"[^/]");return new RegExp("^"+n+"$")}var Y=class{constructor(e){this.config=e;this.packages=new Map}resolve(e,n,r){let s=this.locate(e,n,r);return s===void 0?{kind:"missing"}:s.disabled?{kind:"disabled",path:s.path}:{kind:"file",path:s.path,sideEffects:this.hasSideEffects(s.path)}}locate(e,n,r){if(!et(e))return this.loadPath(e.startsWith("/")?ge(e):L(n,e),r);for(let[c,f]of Object.entries(this.config.aliases??{}))if(e===c||e.startsWith(c+"/"))return this.loadPath(f+e.slice(c.length),r);let s=this.enclosingPackage(n);if(e.startsWith("#"))return s===null?void 0:this.packageImports(s,e,r);if(s!==null&&v(s.json.browser)){let c=s.json.browser[e];if(c===!1)return{path:e,disabled:!0};if(typeof c=="string")return et(c)?this.loadPackage(c,s.dir,r):this.loadPath(L(s.dir,c),r)}let{tsconfig:i}=this.config;if(i!==void 0&&!me(n)){let c=this.loadTsconfigPath(i,e,r);if(c!==void 0)return c}return this.loadPackage(e,n,r)}loadTsconfigPath(e,n,r){let s;for(let[i,c]of Object.entries(e.paths??{})){let f=i.indexOf("*");if(f===-1){if(i===n){s={star:"",prefix:1/0,targets:c};break}continue}let a=i.slice(0,f),d=i.slice(f+1);n.length<a.length+d.length||!n.startsWith(a)||!n.endsWith(d)||(s===void 0||a.length>s.prefix)&&(s={star:n.slice(a.length,n.length-d.length),prefix:a.length,targets:c})}if(s!==void 0)for(let i of s.targets){let c=this.loadPath(L(e.pathsBase,i.replace("*",s.star)),r);if(c!==void 0)return c}return e.baseUrl===void 0?void 0:this.loadPath(L(e.baseUrl,n),r)}loadPackage(e,n,r){let s=Xt(e),i=e.slice(s.length);for(let c=n;;c=M(c)){if(!c.endsWith("/node_modules")){let f=L(c,"node_modules/"+s),a=this.config.links?.[s];if(!this.config.vfs.isDir(f)&&a!==void 0&&c===this.config.linkRoot&&(f=a),this.config.vfs.isDir(f)){let d=this.packageAt(f)?.json.exports;if(d!=null){let h=this.matchExports(f,d,"."+i,r);return h===void 0?void 0:this.applyBrowserMap(h,r)}let l=this.loadPath(f+i,r);if(l!==void 0)return l}}if(c==="/")return}}packageImports(e,n,r){let{imports:s}=e.json;return v(s)?this.matchSubpath(s,n,r,c=>c.startsWith("./")?this.loadPath(L(e.dir,c),r):this.loadPackage(c,e.dir,r)):void 0}matchExports(e,n,r,s){let i=v(n)&&Object.keys(n).some(f=>f.startsWith("."))?n:{".":n};return this.matchSubpath(i,r,s,f=>{if(!f.startsWith("./"))return;let a=L(e,f);return this.config.vfs.has(a)?{path:a}:void 0})?.path}matchSubpath(e,n,r,s){let i=new Set(["browser","default","module",r]),c=(d,l)=>{if(typeof d=="string")return s(l===null?d:d.split("*").join(l));if(Array.isArray(d)){for(let h of d){let y=c(h,l);if(y!==void 0)return y}return}if(v(d)){for(let[h,y]of Object.entries(d)){if(!i.has(h))continue;let m=c(y,l);if(m!==void 0)return m}return}return d===null?null:void 0};if(Object.prototype.hasOwnProperty.call(e,n)&&!n.includes("*"))return c(e[n],null)??void 0;let f;for(let d of Object.keys(e)){let l=d.indexOf("*"),h=l===-1?d:d.slice(0,l),y=l===-1?"":d.slice(l+1);l===-1&&!d.endsWith("/")||n.length<h.length+y.length||!n.startsWith(h)||!n.endsWith(y)||(f===void 0||d.length>f.key.length)&&(f={key:d,star:n.slice(h.length,n.length-y.length)})}if(f===void 0)return;let a=e[f.key];return f.key.endsWith("/")&&typeof a=="string"?s(a+f.star):c(a,f.star)??void 0}loadPath(e,n){let r=this.loadAsFile(e)??this.loadAsDirectory(e,n);return r===void 0?void 0:this.applyBrowserMap(r,n)}applyBrowserMap(e,n){let r=this.enclosingPackage(M(e));if(r===null||!v(r.json.browser))return{path:e};let s="./"+e.slice(r.dir.length+1),i=s.replace(/\.(js|json)$/,"");for(let c of[s,i,s.slice(2),i.slice(2)]){let f=r.json.browser[c];if(f===!1)return{path:e,disabled:!0};if(typeof f=="string"){let a=L(r.dir,f),d=this.loadAsFile(a)??this.loadAsDirectory(a,n);return d===void 0?void 0:{path:d}}}return{path:e}}loadAsFile(e){let{vfs:n}=this.config;if(n.has(e))return e;for(let s of me(e)?Qe:Ye)if(n.has(e+s))return e+s;let r=Ge(e);for(let s of Ht[r]??[]){let i=e.slice(0,-r.length)+s;if(n.has(i))return i}}loadAsIndex(e){for(let n of me(e)?Qe:Ye){let r=e+"/index"+n;if(this.config.vfs.has(r))return r}}loadAsDirectory(e,n){if(!this.config.vfs.isDir(e))return;let r=this.packageAt(e);return(r===null?void 0:this.loadMainField(r,n))??this.loadAsIndex(e)}loadMainField(e,n){let r=f=>{if(typeof f!="string")return;let a=L(e.dir,f);return this.loadAsFile(a)??this.loadAsIndex(a)},s=r(e.json.browser);if(s!==void 0)return s;let i=r(e.json.module);if(i===void 0)return r(e.json.main);let c=e.json.main===void 0?this.loadAsIndex(e.dir):r(e.json.main);return n==="require"&&c!==void 0?c:i}packageAt(e){let n=this.packages.get(e);if(n!==void 0)return n;let r=this.config.vfs.json(e+"/package.json"),s=v(r)?{dir:e,json:r}:null;return this.packages.set(e,s),s}enclosingPackage(e){for(let n=e;;n=M(n)){let r=this.packageAt(n);if(r!==null)return r;if(n==="/")return null}}hasSideEffects(e){let n=this.enclosingPackage(M(e)),r=n?.json.sideEffects;if(n===null||r===void 0||r===!0)return!0;if(!Array.isArray(r))return r!==!1;let s=e.slice(n.dir.length+1);return r.some(i=>typeof i=="string"&&Zt(i).test(s))}};var tt="@dcl/asset-packs";function nt(t,e){let n=t.get(e);if(n!==void 0)try{let r=JSON.parse(new TextDecoder().decode(n));return v(r)?r:void 0}catch{return}}function Yt(t){let e=new Map,n=nt(t,"package.json"),r=v(n?.dependencies)?n.dependencies[tt]:void 0;if(typeof r!="string"||!r.startsWith("file:"))return e;let s=L(re,r.slice(5));if(!s.startsWith(`${re}/`))return e;let i=s.slice(re.length+1),c=nt(t,`${i}/package.json`);if(c?.name!==tt||c.version!=="0.0.1-stub"||!t.has(`${i}/dist/index.js`))return e;let f=new TextEncoder;for(let[a,d]of Object.entries({"events.js":`'use strict'
|
|
1
|
+
var Ct=Object.create;var Je=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames;var Bt=Object.getPrototypeOf,Vt=Object.prototype.hasOwnProperty;var Wt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Dt=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Nt(e))!Vt.call(t,s)&&s!==n&&Je(t,s,{get:()=>e[s],enumerable:!(r=Mt(e,s))||r.enumerable});return t};var Ft=(t,e,n)=>(n=t!=null?Ct(Bt(t)):{},Dt(e||!t||!t.__esModule?Je(n,"default",{value:t,enumerable:!0}):n,t));var $t=Wt((Wr,At)=>{function kt(t){return Array.isArray(t)?t:[t]}var Ue="",vt=" ",Oe="\\",jn=/^\s+$/,In=/(?:[^\\]|^)\\$/,Sn=/^\\!/,_n=/^\\#/,On=/\r?\n/g,Tn=/^\.*\/|^\.+$/,Te="/",xt="node-ignore";typeof Symbol<"u"&&(xt=Symbol.for("node-ignore"));var bt=xt,Un=(t,e,n)=>Object.defineProperty(t,e,{value:n}),Ln=/([0-z])-([0-z])/g,Rt=()=>!1,Cn=t=>t.replace(Ln,(e,n,r)=>n.charCodeAt(0)<=r.charCodeAt(0)?e:Ue),Mn=t=>{let{length:e}=t;return t.slice(0,e-e%2)},Nn=[[/^\uFEFF/,()=>Ue],[/((?:\\\\)*?)(\\?\s+)$/,(t,e,n)=>e+(n.indexOf("\\")===0?vt:Ue)],[/(\\+?)\s/g,(t,e)=>{let{length:n}=e;return e.slice(0,n-n%2)+vt}],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,n)=>e+6<n.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(t,e,n)=>{let r=n.replace(/\\\*/g,"[^\\/]*");return e+r}],[/\\\\\\(?=[$.|*+(){^])/g,()=>Oe],[/\\\\/g,()=>Oe],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,n,r,s)=>e===Oe?`\\[${n}${Mn(r)}${s}`:s==="]"&&r.length%2===0?`[${Cn(n)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],Pt=Object.create(null),Bn=(t,e)=>{let n=Pt[t];return n||(n=Nn.reduce((r,[s,i])=>r.replace(s,i.bind(t)),t),Pt[t]=n),e?new RegExp(n,"i"):new RegExp(n)},Me=t=>typeof t=="string",Vn=t=>t&&Me(t)&&!jn.test(t)&&!In.test(t)&&t.indexOf("#")!==0,Wn=t=>t.split(On),Le=class{constructor(e,n,r,s){this.origin=e,this.pattern=n,this.negative=r,this.regex=s}},Dn=(t,e)=>{let n=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(Sn,"!").replace(_n,"#");let s=Bn(t,e);return new Le(n,t,r,s)},Fn=(t,e)=>{throw new e(t)},B=(t,e,n)=>Me(t)?t?B.isNotRelative(t)?n(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:n("path must not be empty",TypeError):n(`path must be a string, but got \`${e}\``,TypeError),Et=t=>Tn.test(t);B.isNotRelative=Et;B.convert=t=>t;var Ce=class{constructor({ignorecase:e=!0,ignoreCase:n=e,allowRelativePaths:r=!1}={}){Un(this,bt,!0),this._rules=[],this._ignoreCase=n,this._allowRelativePaths=r,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(e){if(e&&e[bt]){this._rules=this._rules.concat(e._rules),this._added=!0;return}if(Vn(e)){let n=Dn(e,this._ignoreCase);this._added=!0,this._rules.push(n)}}add(e){return this._added=!1,kt(Me(e)?Wn(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(e){return this.add(e)}_testOne(e,n){let r=!1,s=!1;return this._rules.forEach(i=>{let{negative:c}=i;if(s===c&&r!==s||c&&!r&&!s&&!n)return;i.regex.test(e)&&(r=!c,s=c)}),{ignored:r,unignored:s}}_test(e,n,r,s){let i=e&&B.convert(e);return B(i,e,this._allowRelativePaths?Rt:Fn),this._t(i,n,r,s)}_t(e,n,r,s){if(e in n)return n[e];if(s||(s=e.split(Te)),s.pop(),!s.length)return n[e]=this._testOne(e,r);let i=this._t(s.join(Te)+Te,n,r,s);return n[e]=i.ignored?i:this._testOne(e,r)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return kt(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},le=t=>new Ce(t),zn=t=>B(t&&B.convert(t),t,Rt);le.isPathValid=zn;le.default=le;At.exports=le;if(typeof process<"u"&&(process.env&&process.env.IGNORE_TEST_WIN32||process.platform==="win32")){let t=n=>/^\\\\\?\\/.test(n)||/["<>|\u0000-\u001F]+/u.test(n)?n:n.replace(/\\/g,"/");B.convert=t;let e=/^[a-z]:\//i;B.isNotRelative=n=>e.test(n)||Et(n)}});var re="/scene";function ge(t){let e=[];for(let n of t.split("/"))n===".."?e.pop():n!==""&&n!=="."&&e.push(n);return"/"+e.join("/")}var L=(t,e)=>ge(t+"/"+e);function M(t){let e=t.lastIndexOf("/");return e<=0?"/":t.slice(0,e)}function Ge(t){let e=t.slice(t.lastIndexOf("/")+1),n=e.lastIndexOf(".");return n<=0?"":e.slice(n)}var zt=new TextDecoder,X=class{constructor(){this.files=new Map;this.dirs=new Set;this.parsed=new Map}set(e,n){this.files.set(e,n),this.parsed.delete(e);for(let r=M(e);!this.dirs.has(r)&&(this.dirs.add(r),r!=="/");r=M(r));}has(e){return this.files.has(e)}isDir(e){return this.dirs.has(e)}read(e){return this.files.get(e)}text(e){let n=this.files.get(e);return n===void 0||typeof n=="string"?n:zt.decode(n)}json(e){if(this.parsed.has(e))return this.parsed.get(e);let n,r=this.text(e);if(r!==void 0)try{n=JSON.parse(r)}catch{n=void 0}return this.parsed.set(e,n),n}},v=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);var F=".dcl-package.json",pe=class{constructor(){this.packages=new Map}has(e){return this.packages.has(e)}list(e){return[...this.packages.get(e)?.keys()??[]]}read(e,n){return this.packages.get(e)?.get(n)}write(e,n,r){let s=this.packages.get(e);s===void 0&&this.packages.set(e,s=new Map),s.set(n,r)}remove(e){this.packages.delete(e)}},He=t=>Array.isArray(t)?t.filter(e=>typeof e=="string"):[];async function Z(t,e){if(!await t.has(e))return;let n=await t.read(e,F);if(n!==void 0)try{let r=JSON.parse(new TextDecoder().decode(n));return!v(r)||typeof r.integrity!="string"?void 0:{integrity:r.integrity,files:Number(r.files)||0,bytes:Number(r.bytes)||0,installScripts:He(r.installScripts),native:r.native===!0,nodeBuiltins:He(r.nodeBuiltins)}}catch{return}}var Xe=async(t,e,n)=>t.write(e,F,new TextEncoder().encode(JSON.stringify(n)));async function he(t,e,n){let r;try{r=await fetch(t,e===void 0?{}:{integrity:e,mode:"cors"})}catch(s){if(e===void 0)throw s;let i=await fetch(t).then(c=>c.ok,()=>!1);throw new Error(i?`${n} does not match the hash this editor was published with. The editor will not run it: reload the page, and if this persists the files you were served were altered.`:`${n} could not be loaded (${t}). Check the connection and reload the page.`)}if(!r.ok)throw new Error(`${n} could not be loaded: ${r.status} ${t}`);return r}var Ze=/\.(tsx?|mts|cts|jsx?|mjs|cjs|json|composite|css|txt)$/,Kt=/\.d\.[mc]?ts$/;function qt(t){let e=t.get("scene.json");if(e!==void 0)try{let n=JSON.parse(new TextDecoder().decode(e)).main;return typeof n=="string"?n:void 0}catch{return}}async function Jt(t){let{integrity:e}=t;if(e===void 0)return new Worker(t.workerUrl);let n=new URL(t.workerUrl,location.href).href,r=await(await he(n,e.worker,"scene-compiler/worker.js")).text(),s=URL.createObjectURL(new Blob([r],{type:"text/javascript"})),i=new Worker(s);return setTimeout(()=>URL.revokeObjectURL(s),6e4),i}function Gt(t){let e=Jt(t),n=m=>void e.then(g=>g.postMessage(m),()=>{}),r=new Map,s=1,i=new Map,c=1,f=()=>{},a=()=>{},d=new Promise((m,g)=>{f=m,a=g}),l=m=>{a(new Error(m));for(let[g,k]of r){let E={type:"failed",buildId:g,message:m};t.onEvent?.(E),k.resolve({buildId:g,ok:!1,outputs:new Map,diagnostics:[],events:[...k.events,E],ms:0})}r.clear();for(let g of i.values())g.reject(new Error(m));i.clear()},h=m=>{let g=m.data;if(g.type==="ready")f({sdkVersion:g.sdkVersion,esbuildVersion:g.esbuildVersion,snapshot:{sdkVersion:g.sdkVersion,provided:g.provided}});else if(g.type==="packagesSet"){let k=i.get(g.requestId);i.delete(g.requestId),g.error===void 0?k?.resolve(g.shadowed):k?.reject(new Error(g.error))}else if(g.type==="initFailed")l(g.message);else if(g.type==="event")r.get(g.event.buildId)?.events.push(g.event),t.onEvent?.(g.event);else{let k=r.get(g.buildId);if(k===void 0)return;r.delete(g.buildId),k.resolve({buildId:g.buildId,ok:k.events.some(E=>E.type==="bundleSaved"),outputs:new Map(g.outputs),diagnostics:k.events.flatMap(E=>E.type==="diagnostics"?E.diagnostics:[]),events:k.events,ms:g.ms})}};e.then(m=>{m.onerror=g=>l(g.message||"The build worker failed to start"),m.onmessage=h},m=>l(m instanceof Error?m.message:String(m)));let{integrity:y}=t;return n({type:"init",wasmUrl:new URL(t.wasmUrl,location.href).href,snapshotUrl:new URL(t.snapshotUrl,location.href).href,integrity:y===void 0?void 0:{wasm:y.wasm,snapshot:y.snapshot}}),d.catch(()=>{}),{ready:d,build(m,g={}){let k=s++,E=qt(m),$=[...m].filter(([j])=>Ze.test(j)&&j!==E);return new Promise(j=>{r.set(k,{events:[],resolve:j}),n({type:"build",buildId:k,files:$,options:g})})},async setPackages(m,g){let k=[],E=0;for(let[C,G]of Object.entries(m?.packages??{})){let ue=g===void 0?void 0:await Z(g,C);if(g===void 0||ue?.integrity!==G.integrity)throw new Error(`${C} is not in the package store`);for(let S of await g.list(C)){if(!Ze.test(S)||Kt.test(S)||S===F)continue;let D=await g.read(C,S);if(D===void 0)throw new Error(`${C} is incomplete in the package store: ${S}`);k.push([C,S,D]),E+=D.length}}let $=c++,j=await new Promise((C,G)=>{i.set($,{resolve:C,reject:G}),n({type:"packages",requestId:$,lock:m,files:k})});return{packages:Object.keys(m?.packages??{}).length-j.length,files:k.length,bytes:E,shadowed:j}},dispose(){e.then(m=>m.terminate(),()=>{}),l("The scene builder was disposed")}}}var Ye=[".tsx",".ts",".jsx",".js",".css",".json"],Qe=[".jsx",".js",".css",".json",".tsx",".ts"],Ht={".js":[".ts",".tsx"],".jsx":[".ts",".tsx"],".mjs":[".mts"],".cjs":[".cts"]},et=t=>!/^\.{0,2}\//.test(t)&&t!=="."&&t!=="..",Xt=t=>t.split("/",t.startsWith("@")?2:1).join("/"),me=t=>(t+"/").includes("/node_modules/");function Zt(t){let e=t.replace(/^\.\//,""),n=(e.includes("/")?e:"**/"+e).replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\/|\*\*|\*|\?/g,r=>r==="**/"?"(?:.*/)?":r==="**"?".*":r==="*"?"[^/]*":"[^/]");return new RegExp("^"+n+"$")}var Y=class{constructor(e){this.config=e;this.packages=new Map}resolve(e,n,r){let s=this.locate(e,n,r);return s===void 0?{kind:"missing"}:s.disabled?{kind:"disabled",path:s.path}:{kind:"file",path:s.path,sideEffects:this.hasSideEffects(s.path)}}locate(e,n,r){if(!et(e))return this.loadPath(e.startsWith("/")?ge(e):L(n,e),r);for(let[c,f]of Object.entries(this.config.aliases??{}))if(e===c||e.startsWith(c+"/"))return this.loadPath(f+e.slice(c.length),r);let s=this.enclosingPackage(n);if(e.startsWith("#"))return s===null?void 0:this.packageImports(s,e,r);if(s!==null&&v(s.json.browser)){let c=s.json.browser[e];if(c===!1)return{path:e,disabled:!0};if(typeof c=="string")return et(c)?this.loadPackage(c,s.dir,r):this.loadPath(L(s.dir,c),r)}let{tsconfig:i}=this.config;if(i!==void 0&&!me(n)){let c=this.loadTsconfigPath(i,e,r);if(c!==void 0)return c}return this.loadPackage(e,n,r)}loadTsconfigPath(e,n,r){let s;for(let[i,c]of Object.entries(e.paths??{})){let f=i.indexOf("*");if(f===-1){if(i===n){s={star:"",prefix:1/0,targets:c};break}continue}let a=i.slice(0,f),d=i.slice(f+1);n.length<a.length+d.length||!n.startsWith(a)||!n.endsWith(d)||(s===void 0||a.length>s.prefix)&&(s={star:n.slice(a.length,n.length-d.length),prefix:a.length,targets:c})}if(s!==void 0)for(let i of s.targets){let c=this.loadPath(L(e.pathsBase,i.replace("*",s.star)),r);if(c!==void 0)return c}return e.baseUrl===void 0?void 0:this.loadPath(L(e.baseUrl,n),r)}loadPackage(e,n,r){let s=Xt(e),i=e.slice(s.length);for(let c=n;;c=M(c)){if(!c.endsWith("/node_modules")){let f=L(c,"node_modules/"+s),a=this.config.links?.[s];if(!this.config.vfs.isDir(f)&&a!==void 0&&c===this.config.linkRoot&&(f=a),this.config.vfs.isDir(f)){let d=this.packageAt(f)?.json.exports;if(d!=null){let h=this.matchExports(f,d,"."+i,r);return h===void 0?void 0:this.applyBrowserMap(h,r)}let l=this.loadPath(f+i,r);if(l!==void 0)return l}}if(c==="/")return}}packageImports(e,n,r){let{imports:s}=e.json;return v(s)?this.matchSubpath(s,n,r,c=>c.startsWith("./")?this.loadPath(L(e.dir,c),r):this.loadPackage(c,e.dir,r)):void 0}matchExports(e,n,r,s){let i=v(n)&&Object.keys(n).some(f=>f.startsWith("."))?n:{".":n};return this.matchSubpath(i,r,s,f=>{if(!f.startsWith("./"))return;let a=L(e,f);return this.config.vfs.has(a)?{path:a}:void 0})?.path}matchSubpath(e,n,r,s){let i=new Set(["browser","default","module",r]),c=(d,l)=>{if(typeof d=="string")return s(l===null?d:d.split("*").join(l));if(Array.isArray(d)){for(let h of d){let y=c(h,l);if(y!==void 0)return y}return}if(v(d)){for(let[h,y]of Object.entries(d)){if(!i.has(h))continue;let m=c(y,l);if(m!==void 0)return m}return}return d===null?null:void 0};if(Object.prototype.hasOwnProperty.call(e,n)&&!n.includes("*"))return c(e[n],null)??void 0;let f;for(let d of Object.keys(e)){let l=d.indexOf("*"),h=l===-1?d:d.slice(0,l),y=l===-1?"":d.slice(l+1);l===-1&&!d.endsWith("/")||n.length<h.length+y.length||!n.startsWith(h)||!n.endsWith(y)||(f===void 0||d.length>f.key.length)&&(f={key:d,star:n.slice(h.length,n.length-y.length)})}if(f===void 0)return;let a=e[f.key];return f.key.endsWith("/")&&typeof a=="string"?s(a+f.star):c(a,f.star)??void 0}loadPath(e,n){let r=this.loadAsFile(e)??this.loadAsDirectory(e,n);return r===void 0?void 0:this.applyBrowserMap(r,n)}applyBrowserMap(e,n){let r=this.enclosingPackage(M(e));if(r===null||!v(r.json.browser))return{path:e};let s="./"+e.slice(r.dir.length+1),i=s.replace(/\.(js|json)$/,"");for(let c of[s,i,s.slice(2),i.slice(2)]){let f=r.json.browser[c];if(f===!1)return{path:e,disabled:!0};if(typeof f=="string"){let a=L(r.dir,f),d=this.loadAsFile(a)??this.loadAsDirectory(a,n);return d===void 0?void 0:{path:d}}}return{path:e}}loadAsFile(e){let{vfs:n}=this.config;if(n.has(e))return e;for(let s of me(e)?Qe:Ye)if(n.has(e+s))return e+s;let r=Ge(e);for(let s of Ht[r]??[]){let i=e.slice(0,-r.length)+s;if(n.has(i))return i}}loadAsIndex(e){for(let n of me(e)?Qe:Ye){let r=e+"/index"+n;if(this.config.vfs.has(r))return r}}loadAsDirectory(e,n){if(!this.config.vfs.isDir(e))return;let r=this.packageAt(e);return(r===null?void 0:this.loadMainField(r,n))??this.loadAsIndex(e)}loadMainField(e,n){let r=f=>{if(typeof f!="string")return;let a=L(e.dir,f);return this.loadAsFile(a)??this.loadAsIndex(a)},s=r(e.json.browser);if(s!==void 0)return s;let i=r(e.json.module);if(i===void 0)return r(e.json.main);let c=e.json.main===void 0?this.loadAsIndex(e.dir):r(e.json.main);return n==="require"&&c!==void 0?c:i}packageAt(e){let n=this.packages.get(e);if(n!==void 0)return n;let r=this.config.vfs.json(e+"/package.json"),s=v(r)?{dir:e,json:r}:null;return this.packages.set(e,s),s}enclosingPackage(e){for(let n=e;;n=M(n)){let r=this.packageAt(n);if(r!==null)return r;if(n==="/")return null}}hasSideEffects(e){let n=this.enclosingPackage(M(e)),r=n?.json.sideEffects;if(n===null||r===void 0||r===!0)return!0;if(!Array.isArray(r))return r!==!1;let s=e.slice(n.dir.length+1);return r.some(i=>typeof i=="string"&&Zt(i).test(s))}};var tt="@dcl/asset-packs";function nt(t,e){let n=t.get(e);if(n!==void 0)try{let r=JSON.parse(new TextDecoder().decode(n));return v(r)?r:void 0}catch{return}}function Yt(t){let e=new Map,n=nt(t,"package.json"),r=v(n?.dependencies)?n.dependencies[tt]:void 0;if(typeof r!="string"||!r.startsWith("file:"))return e;let s=L(re,r.slice(5));if(!s.startsWith(`${re}/`))return e;let i=s.slice(re.length+1),c=nt(t,`${i}/package.json`);if(c?.name!==tt||c.version!=="0.0.1-stub"||!t.has(`${i}/dist/index.js`))return e;let f=new TextEncoder;for(let[a,d]of Object.entries({"events.js":`'use strict'
|
|
2
2
|
module.exports = require('./index')
|
|
3
3
|
`,"events.d.ts":`export { getActionEvents, getTriggerEvents } from './index'
|
|
4
4
|
`})){let l=`${i}/dist/${a}`;t.has(l)||e.set(l,f.encode(d))}return e}var ie="0|[1-9]\\d*",rt="(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z.-]+)?",Qt=new RegExp(`^[v=\\s]*(${ie})\\.(${ie})\\.(${ie})${rt}$`),we=`${ie}|[xX*]`,en=new RegExp(`^[v=\\s]*(${we})(?:\\.(${we})(?:\\.(${we})${rt})?)?$`),tn=/^(<=|>=|<|>|=|\^|~>|~)?\s*(.*)$/,st=256;function V(t){if(t.length>st)return;let e=Qt.exec(t.trim());if(e===null)return;let[n,r,s]=[Number(e[1]),Number(e[2]),Number(e[3])];if([n,r,s].every(Number.isSafeInteger))return{major:n,minor:r,patch:s,prerelease:it(e[4])}}var it=t=>t===void 0?[]:t.split(".").map(e=>/^\d+$/.test(e)?Number(e):e);function oe(t,e){let n=t.major-e.major||t.minor-e.minor||t.patch-e.patch;if(n!==0)return Math.sign(n);if(t.prerelease.length===0||e.prerelease.length===0)return Math.sign(e.prerelease.length-t.prerelease.length);for(let r=0;;r++){let[s,i]=[t.prerelease[r],e.prerelease[r]];if(s===void 0&&i===void 0)return 0;if(s===void 0)return-1;if(i===void 0)return 1;if(s!==i)return typeof s!=typeof i?typeof s=="number"?-1:1:s<i?-1:1}}var se=(t,e=0,n=0,r=[])=>({major:t,minor:e,patch:n,prerelease:r}),ye=t=>t===void 0||/^[xX*]$/.test(t);function ke(t,e){let[,n="",r=""]=tn.exec(t)??[],s=en.exec(r);if(s===null)return;let[i,c,f]=[ye(s[1]),ye(s[2]),ye(s[3])],a=i?0:Number(s[1]),d=i||c?0:Number(s[2]),l=i||c||f?0:Number(s[3]),h=!i&&!c&&!f,y=e?[0]:[],m=se(a,d,l,h?it(s[4]):y),g=j=>({op:"<",version:{...j,prerelease:[0]}}),k=se(a+1),E=se(a,d+1);if(n==="^"){if(i)return[];let j=se(a,d,l+1);return a>0||c?j=k:(d>0||f)&&(j=E),[{op:">=",version:m},g(j)]}if(n==="~"||n==="~>")return i?[]:[{op:">=",version:m},g(c?k:E)];if(h)return[{op:n===""?"=":n,version:m}];if(n===""||n==="=")return i?[]:[{op:">=",version:m},g(c?k:E)];if(i)return n==="<"||n===">"?null:[];let $=c?k:E;return n===">"?[{op:">=",version:{...$,prerelease:y}}]:n==="<="?[g($)]:n==="<"?[g(m)]:[{op:">=",version:m}]}function nn(t,e,n){let r=ke(">="+t,n),s=ke("<="+e,n);if(r===void 0||s===void 0||r===null||s===null)return;let[i]=r;return n&&i!==void 0&&i.version.prerelease.length===0&&(i.version.prerelease=[0]),[...r,...s]}function ot(t,e=!1){if(t.length>st)return;let n=[];for(let r of t.split("||")){let s=r.trim(),i=/^(\S+)\s+-\s+(\S+)$/.exec(s);if(i!==null){let a=nn(i[1],i[2],e);if(a===void 0)return;n.push(a);continue}let c=[],f=!1;for(let a of s.replace(/(<=|>=|<|>|=|\^|~>|~)\s+/g,"$1").split(/\s+/)){if(a==="")continue;let d=ke(a,e);if(d===void 0)return;d===null?f=!0:c.push(...d)}f||n.push(c)}return n}var Q=t=>ot(t)!==void 0;function rn(t,{op:e,version:n}){let r=oe(t,n);switch(e){case"=":return r===0;case"<":return r<0;case"<=":return r<=0;case">":return r>0;case">=":return r>=0}}function z(t,e,n={}){let r=typeof t=="string"?V(t):t,s=ot(e,n.includePrerelease===!0);return r===void 0||s===void 0?!1:s.some(i=>i.every(c=>rn(r,c))?r.prerelease.length===0||n.includePrerelease===!0?!0:i.some(({version:c})=>c.prerelease.length>0&&c.major===r.major&&c.minor===r.minor&&c.patch===r.patch):!1)}function ve(t,e){let n;for(let r of t){let s=V(r);s===void 0||!z(s,e)||(n===void 0||oe(s,n.version)>0)&&(n={text:r,version:s})}return n?.text}var sn="dcl-editor.lock.json",on=/^(?:@[A-Za-z0-9-~][A-Za-z0-9-._~]*\/)?[A-Za-z0-9-~][A-Za-z0-9-._~]*$/,an=/^sha512-[A-Za-z0-9+/]{86}==$/,K=t=>t.length<=214&&on.test(t);function q(t){let e=t.lastIndexOf("@");if(e<=0)return;let[n,r]=[t.slice(0,e),t.slice(e+1)];return K(n)&&V(r)!==void 0?{name:n,version:r}:void 0}var N=(t,e)=>e.startsWith("npm:")?e.slice(4):`${t}@${e}`,be=(t,e)=>e.startsWith(t+"@")&&e.lastIndexOf("@")===t.length?e.slice(t.length+1):"npm:"+e;function at(t){if(t===void 0)return{};if(!v(t))return;let e={};for(let[n,r]of Object.entries(t)){if(typeof r!="string"||!K(n)||q(N(n,r))===void 0)return;e[n]=r}return e}function cn(t){if(t===void 0)return;let e;try{e=JSON.parse(typeof t=="string"?t:new TextDecoder().decode(t))}catch{return}if(!v(e)||e.lockfileVersion!==1||typeof e.registry!="string"||!v(e.packages))return;let n=at(e.dependencies);if(n===void 0)return;let r={};for(let[s,i]of Object.entries(e.packages)){if(q(s)===void 0||!v(i))return;let c=at(i.dependencies);if(typeof i.resolved!="string"||typeof i.integrity!="string"||!an.test(i.integrity)||c===void 0)return;r[s]={resolved:i.resolved,integrity:i.integrity,...Object.keys(c).length>0?{dependencies:c}:{}}}return{lockfileVersion:1,registry:e.registry,dependencies:n,packages:r}}var dn=t=>JSON.stringify(t,null,2)+`
|
|
@@ -701,4 +701,4 @@ module.exports = require('./index')
|
|
|
701
701
|
`)).replace(i.scriptsArray,()=>n.size===0?"[]":`[
|
|
702
702
|
${t.join(`,
|
|
703
703
|
`)}
|
|
704
|
-
]`)}function w3(e,n){return e.map(o=>({severity:n,message:o.text,file:o.location?.file,line:o.location?.line,column:o.location?.column,lineText:o.location?.lineText,...$t(o.detail)&&typeof o.detail.missingPackage=="string"?{missingPackage:o.detail.missingPackage}:{}}))}var Bte=e=>e instanceof Error&&"errors"in e&&Array.isArray(e.errors);function Ute(e,n,o){let t=`Could not resolve "${e}"`;if(!Um(e)||e.startsWith("#"))return{text:t};let i=n.lastIndexOf("/node_modules/"),r=i===-1?"":` (imported by ${Dm(n.slice(i+14))})`;if(uI(e))return{text:`${t}: it is a Node built-in, which a scene does not have${r}`};let c=Dm(e);return o.isDir(ot(kt,"node_modules/"+c))?{text:`${t}: the package "${c}" has no module there${r}`}:{text:`${t}: the package "${c}" is not installed${r}`,detail:{missingPackage:c}}}var $m=class{constructor(n,o){this.esbuild=n;this.snapshot=o;this.contextKey=""}setPackages(n){this.packages=n}async build(n,o){let t=o.production===!0,i=Wl(n,"scene.json");if(i===void 0)return Gl("scene.json is missing or is not valid JSON");let r=i.main;if(typeof r!="string"||r==="")return Gl('scene.json needs a "main" entry, the path of the built bundle');if(i.runtimeVersion!=="7")return Gl('scene.json needs "runtimeVersion": "7"');if(!n.has("tsconfig.json"))return Gl("tsconfig.json is missing");if(!n.has(Lm))return Gl(`${Lm} is missing`);let c=[],{meta:s}=this.snapshot,a=pI(this.snapshot,n,this.packages),u=a.dependencies["@dcl/sdk"];typeof u=="string"&&/^\d/.test(u)&&u!==s.sdkVersion&&c.push({severity:"warning",file:"package.json",message:`This project pins @dcl/sdk ${u}; it is built here with ${s.sdkVersion}.`});let d=sI(n);c.push(...d.diagnostics);let p=cI(n);p&&!a.ownAssetPacks&&c.push({severity:"warning",message:"This scene uses smart items but ships no @dcl/asset-packs; they are built as no-ops."}),this.inputs={vfs:a.vfs,resolver:a.resolver,virtualModules:{"sdk-composite":`export const compositeFromLoader = {${d.compositeLines.join(",")}}`,"sdk-scripts":Ite(this.snapshot,d.scripts)}};let f={bundle:!0,platform:"browser",format:"cjs",write:!1,outfile:ot(kt,r),sourcemap:t?!1:"inline",minify:t,minifyIdentifiers:t,minifySyntax:t,minifyWhitespace:t,treeShaking:!0,absWorkingDir:kt,target:"es2020",sourceRoot:"dcl://"+(t?"/":Fn("/"+r)),define:{document:"undefined",window:"undefined",DEBUG:t?"false":"true","globalThis.DEBUG":t?"false":"true","process.env.NODE_ENV":JSON.stringify(t?"production":"development"),DCL_MAX_COMPOSITE_ENTITY:String(d.maxCompositeEntity)},tsconfigRaw:JSON.stringify({compilerOptions:fI(a.tsconfig.compilerOptions)}),supported:{"import-assertions":!1,"import-meta":!1,"dynamic-import":!1,hashbang:!1},logOverride:{"import-is-undefined":"silent"},logLevel:"silent",stdin:{contents:(p?s.entrypoint.editorScene:s.entrypoint.scene).split(JSON.stringify(s.placeholders.entrypoint)).join(JSON.stringify(ot(kt,Lm))),resolveDir:ot(kt,Fn(Lm)),sourcefile:"index.ts.entry-point.ts",loader:"ts"}};try{let g=await(await this.contextFor(f)).rebuild();c.push(...w3(g.warnings,"warning"));let m=g.outputFiles?.[0];if(m===void 0)return{outputs:new Map,bundleFile:void 0,diagnostics:c,failure:"The bundler produced no output"};let y=new Map([[r,m.contents]]);return d.crdt!==void 0&&y.set("main.crdt",d.crdt),{outputs:y,bundleFile:r,diagnostics:c,failure:void 0}}catch(h){if(!Bte(h))throw h;return c.push(...w3(h.errors,"error"),...w3(h.warnings,"warning")),{outputs:new Map,bundleFile:void 0,diagnostics:c,failure:h.message}}}async contextFor(n){let o=JSON.stringify(n);return this.context!==void 0&&o===this.contextKey?this.context:(await this.context?.dispose(),this.context=await this.esbuild.context({...n,plugins:[this.plugin()]}),this.contextKey=o,this.context)}plugin(){let n=()=>{if(this.inputs===void 0)throw new Error("no build in progress");return this.inputs};return{name:"in-memory-scene",setup:o=>{o.onResolve({filter:/~sdk\/all-composites/},()=>({namespace:"sdk-composite",path:"all-composites"})),o.onResolve({filter:/~sdk\/script-utils/},()=>({namespace:"sdk-scripts",path:"script-utils"})),o.onLoad({filter:/.*/,namespace:"sdk-composite"},()=>({loader:"js",contents:n().virtualModules["sdk-composite"]})),o.onLoad({filter:/.*/,namespace:"sdk-scripts"},()=>({loader:"ts",contents:n().virtualModules["sdk-scripts"],resolveDir:kt})),o.onResolve({filter:/.*/},t=>{if(Mte.test(t.path))return{path:t.path,external:!0};let i=t.kind==="require-call"||t.kind==="require-resolve"?"require":"import",r=n().resolver.resolve(t.path,t.resolveDir||kt,i);return r.kind==="file"?{path:r.path,sideEffects:r.sideEffects}:r.kind==="disabled"?{path:r.path,namespace:"disabled"}:{errors:[Ute(t.path,t.importer,n().vfs)]}}),o.onLoad({filter:/.*/,namespace:"disabled"},()=>({loader:"js",contents:""})),o.onLoad({filter:/.*/,namespace:"file"},t=>{let i=n().vfs.read(t.path),r=Rte[Bc(t.path)];return i===void 0?{errors:[{text:`File not found: ${t.path}`}]}:r===void 0?{errors:[{text:`No loader is configured for "${Bc(t.path)}" files: ${t.path}`}]}:{contents:i,loader:r}})}}}};async function A3(e,n,o){let t;try{t=await fetch(e,n===void 0?{}:{integrity:n,mode:"cors"})}catch(i){if(n===void 0)throw i;let r=await fetch(e).then(c=>c.ok,()=>!1);throw new Error(r?`${o} does not match the hash this editor was published with. The editor will not run it: reload the page, and if this persists the files you were served were altered.`:`${o} could not be loaded (${e}). Check the connection and reload the page.`)}if(!t.ok)throw new Error(`${o} could not be loaded: ${t.status} ${e}`);return t}var Cc=(e,n=[])=>self.postMessage(e,n),Hl=e=>Cc({type:"event",event:e}),k3=e=>e instanceof Error?e.message:String(e);async function xte(e){let n=new Uint8Array(await crypto.subtle.digest("SHA-256",Jm(e)));return Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}function Dte(){let e=self.setTimeout.bind(self),n=[],o=new MessageChannel;o.port1.onmessage=()=>n.shift()?.();let t=(i,r,...c)=>typeof i!="function"||r!==void 0&&r>0?e(i,r,...c):(n.push(()=>i(...c)),o.port2.postMessage(null),0);self.setTimeout=t}async function Lte(e){Dte();let[n,o]=await Promise.all([A3(e.wasmUrl,e.integrity?.wasm,"
|
|
704
|
+
]`)}function w3(e,n){return e.map(o=>({severity:n,message:o.text,file:o.location?.file,line:o.location?.line,column:o.location?.column,lineText:o.location?.lineText,...$t(o.detail)&&typeof o.detail.missingPackage=="string"?{missingPackage:o.detail.missingPackage}:{}}))}var Bte=e=>e instanceof Error&&"errors"in e&&Array.isArray(e.errors);function Ute(e,n,o){let t=`Could not resolve "${e}"`;if(!Um(e)||e.startsWith("#"))return{text:t};let i=n.lastIndexOf("/node_modules/"),r=i===-1?"":` (imported by ${Dm(n.slice(i+14))})`;if(uI(e))return{text:`${t}: it is a Node built-in, which a scene does not have${r}`};let c=Dm(e);return o.isDir(ot(kt,"node_modules/"+c))?{text:`${t}: the package "${c}" has no module there${r}`}:{text:`${t}: the package "${c}" is not installed${r}`,detail:{missingPackage:c}}}var $m=class{constructor(n,o){this.esbuild=n;this.snapshot=o;this.contextKey=""}setPackages(n){this.packages=n}async build(n,o){let t=o.production===!0,i=Wl(n,"scene.json");if(i===void 0)return Gl("scene.json is missing or is not valid JSON");let r=i.main;if(typeof r!="string"||r==="")return Gl('scene.json needs a "main" entry, the path of the built bundle');if(i.runtimeVersion!=="7")return Gl('scene.json needs "runtimeVersion": "7"');if(!n.has("tsconfig.json"))return Gl("tsconfig.json is missing");if(!n.has(Lm))return Gl(`${Lm} is missing`);let c=[],{meta:s}=this.snapshot,a=pI(this.snapshot,n,this.packages),u=a.dependencies["@dcl/sdk"];typeof u=="string"&&/^\d/.test(u)&&u!==s.sdkVersion&&c.push({severity:"warning",file:"package.json",message:`This project pins @dcl/sdk ${u}; it is built here with ${s.sdkVersion}.`});let d=sI(n);c.push(...d.diagnostics);let p=cI(n);p&&!a.ownAssetPacks&&c.push({severity:"warning",message:"This scene uses smart items but ships no @dcl/asset-packs; they are built as no-ops."}),this.inputs={vfs:a.vfs,resolver:a.resolver,virtualModules:{"sdk-composite":`export const compositeFromLoader = {${d.compositeLines.join(",")}}`,"sdk-scripts":Ite(this.snapshot,d.scripts)}};let f={bundle:!0,platform:"browser",format:"cjs",write:!1,outfile:ot(kt,r),sourcemap:t?!1:"inline",minify:t,minifyIdentifiers:t,minifySyntax:t,minifyWhitespace:t,treeShaking:!0,absWorkingDir:kt,target:"es2020",sourceRoot:"dcl://"+(t?"/":Fn("/"+r)),define:{document:"undefined",window:"undefined",DEBUG:t?"false":"true","globalThis.DEBUG":t?"false":"true","process.env.NODE_ENV":JSON.stringify(t?"production":"development"),DCL_MAX_COMPOSITE_ENTITY:String(d.maxCompositeEntity)},tsconfigRaw:JSON.stringify({compilerOptions:fI(a.tsconfig.compilerOptions)}),supported:{"import-assertions":!1,"import-meta":!1,"dynamic-import":!1,hashbang:!1},logOverride:{"import-is-undefined":"silent"},logLevel:"silent",stdin:{contents:(p?s.entrypoint.editorScene:s.entrypoint.scene).split(JSON.stringify(s.placeholders.entrypoint)).join(JSON.stringify(ot(kt,Lm))),resolveDir:ot(kt,Fn(Lm)),sourcefile:"index.ts.entry-point.ts",loader:"ts"}};try{let g=await(await this.contextFor(f)).rebuild();c.push(...w3(g.warnings,"warning"));let m=g.outputFiles?.[0];if(m===void 0)return{outputs:new Map,bundleFile:void 0,diagnostics:c,failure:"The bundler produced no output"};let y=new Map([[r,m.contents]]);return d.crdt!==void 0&&y.set("main.crdt",d.crdt),{outputs:y,bundleFile:r,diagnostics:c,failure:void 0}}catch(h){if(!Bte(h))throw h;return c.push(...w3(h.errors,"error"),...w3(h.warnings,"warning")),{outputs:new Map,bundleFile:void 0,diagnostics:c,failure:h.message}}}async contextFor(n){let o=JSON.stringify(n);return this.context!==void 0&&o===this.contextKey?this.context:(await this.context?.dispose(),this.context=await this.esbuild.context({...n,plugins:[this.plugin()]}),this.contextKey=o,this.context)}plugin(){let n=()=>{if(this.inputs===void 0)throw new Error("no build in progress");return this.inputs};return{name:"in-memory-scene",setup:o=>{o.onResolve({filter:/~sdk\/all-composites/},()=>({namespace:"sdk-composite",path:"all-composites"})),o.onResolve({filter:/~sdk\/script-utils/},()=>({namespace:"sdk-scripts",path:"script-utils"})),o.onLoad({filter:/.*/,namespace:"sdk-composite"},()=>({loader:"js",contents:n().virtualModules["sdk-composite"]})),o.onLoad({filter:/.*/,namespace:"sdk-scripts"},()=>({loader:"ts",contents:n().virtualModules["sdk-scripts"],resolveDir:kt})),o.onResolve({filter:/.*/},t=>{if(Mte.test(t.path))return{path:t.path,external:!0};let i=t.kind==="require-call"||t.kind==="require-resolve"?"require":"import",r=n().resolver.resolve(t.path,t.resolveDir||kt,i);return r.kind==="file"?{path:r.path,sideEffects:r.sideEffects}:r.kind==="disabled"?{path:r.path,namespace:"disabled"}:{errors:[Ute(t.path,t.importer,n().vfs)]}}),o.onLoad({filter:/.*/,namespace:"disabled"},()=>({loader:"js",contents:""})),o.onLoad({filter:/.*/,namespace:"file"},t=>{let i=n().vfs.read(t.path),r=Rte[Bc(t.path)];return i===void 0?{errors:[{text:`File not found: ${t.path}`}]}:r===void 0?{errors:[{text:`No loader is configured for "${Bc(t.path)}" files: ${t.path}`}]}:{contents:i,loader:r}})}}}};async function A3(e,n,o){let t;try{t=await fetch(e,n===void 0?{}:{integrity:n,mode:"cors"})}catch(i){if(n===void 0)throw i;let r=await fetch(e).then(c=>c.ok,()=>!1);throw new Error(r?`${o} does not match the hash this editor was published with. The editor will not run it: reload the page, and if this persists the files you were served were altered.`:`${o} could not be loaded (${e}). Check the connection and reload the page.`)}if(!t.ok)throw new Error(`${o} could not be loaded: ${t.status} ${e}`);return t}var Cc=(e,n=[])=>self.postMessage(e,n),Hl=e=>Cc({type:"event",event:e}),k3=e=>e instanceof Error?e.message:String(e);async function xte(e){let n=new Uint8Array(await crypto.subtle.digest("SHA-256",Jm(e)));return Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}function Dte(){let e=self.setTimeout.bind(self),n=[],o=new MessageChannel;o.port1.onmessage=()=>n.shift()?.();let t=(i,r,...c)=>typeof i!="function"||r!==void 0&&r>0?e(i,r,...c):(n.push(()=>i(...c)),o.port2.postMessage(null),0);self.setTimeout=t}async function Lte(e){Dte();let[n,o]=await Promise.all([A3(e.wasmUrl,e.integrity?.wasm,"scene-compiler/esbuild.wasm"),A3(e.snapshotUrl,e.integrity?.snapshot,"scene-compiler/sdk-snapshot.json")]),t=await WebAssembly.compile(await n.arrayBuffer()),[,i]=await Promise.all([as.initialize({wasmModule:t,worker:!1}),o.json()]);if(as.version!==i.meta.esbuildVersion)throw new Error(`bundler ${as.version} does not match the SDK's ${i.meta.esbuildVersion}`);let r={};for(let[c,{version:s}]of Object.entries(i.meta.provided))r[c]=s;return Cc({type:"ready",sdkVersion:i.meta.sdkVersion,esbuildVersion:as.version,provided:r}),{session:new $m(as,i),snapshotNames:new Set(Object.keys(r))}}var Rc,jm=Promise.resolve();async function $te(e){let{buildId:n}=e,o=performance.now(),t=()=>Math.round(performance.now()-o);Hl({type:"buildStarted",buildId:n});let i=new Map;try{if(Rc===void 0)throw new Error("build requested before init");let c=await(await Rc).session.build(new Map(e.files),e.options);Hl({type:"diagnostics",buildId:n,diagnostics:c.diagnostics});let s=c.bundleFile===void 0?void 0:c.outputs.get(c.bundleFile);c.failure!==void 0||c.bundleFile===void 0||s===void 0?Hl({type:"failed",buildId:n,message:c.failure??"The build produced no bundle"}):(i=c.outputs,Hl({type:"bundleSaved",buildId:n,file:c.bundleFile,hash:await xte(s),bytes:s.length,ms:t()}))}catch(c){Hl({type:"failed",buildId:n,message:k3(c)})}let r=[...i];Cc({type:"result",buildId:n,outputs:r,ms:t()},r.map(([,c])=>c.buffer))}async function jte(e){let{requestId:n}=e;try{if(Rc===void 0)throw new Error("packages sent before init");let{session:o,snapshotNames:t}=await Rc,i=e.lock===null?void 0:x3(e.lock,e.files,t);o.setPackages(i),Cc({type:"packagesSet",requestId:n,packages:i?.count??0,shadowed:i?.shadowed??[]})}catch(o){Cc({type:"packagesSet",requestId:n,error:k3(o),packages:0,shadowed:[]})}}self.onmessage=e=>{let n=e.data;n.type==="init"?(Rc=Lte(n),Rc.catch(o=>Cc({type:"initFailed",message:k3(o)}))):n.type==="packages"?jm=jm.then(()=>jte(n)):jm=jm.then(()=>$te(n))};})();
|
|
File without changes
|
|
File without changes
|